eive-obsw/mission/tmtc/Service15TmStorage.cpp

86 lines
3.3 KiB
C++
Raw Normal View History

2022-10-24 10:14:58 +02:00
#include "Service15TmStorage.h"
2022-12-14 13:51:24 +01:00
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/tmstorage/TmStoreFrontendSimpleIF.h>
#include "eive/objects.h"
2022-12-14 15:41:20 +01:00
#include "fsfw/tmstorage/TmStoreMessage.h"
2022-12-14 13:51:24 +01:00
2022-10-24 10:26:00 +02:00
using namespace returnvalue;
2022-10-24 10:14:58 +02:00
2022-10-24 10:26:00 +02:00
Service15TmStorage::Service15TmStorage(object_id_t objectId, uint16_t apid,
uint8_t numParallelCommands, uint16_t commandTimeoutSecs,
size_t queueDepth)
: CommandingServiceBase(objectId, apid, "PUS Service 15", 15, numParallelCommands,
commandTimeoutSecs, queueDepth) {}
2022-12-14 11:29:32 +01:00
ReturnValue_t Service15TmStorage::isValidSubservice(uint8_t subservice) {
switch (subservice) {
2023-02-20 16:12:56 +01:00
case (Subservices::DELETE_UP_TO):
2022-12-14 13:19:14 +01:00
case (Subservices::START_BY_TIME_RANGE_RETRIEVAL): {
return OK;
}
2023-02-20 16:12:56 +01:00
default: {
return FAILED;
2022-12-14 13:19:14 +01:00
}
2022-12-14 11:29:32 +01:00
}
}
2022-10-24 10:26:00 +02:00
ReturnValue_t Service15TmStorage::getMessageQueueAndObject(uint8_t subservice,
const uint8_t *tcData, size_t tcDataLen,
MessageQueueId_t *id,
object_id_t *objectId) {
2023-02-21 20:43:16 +01:00
if (tcDataLen < 4) {
return CommandingServiceBase::INVALID_TC;
2022-12-14 13:51:24 +01:00
}
2023-02-21 20:43:16 +01:00
SerializeAdapter::deSerialize(objectId, &tcData, &tcDataLen, SerializeIF::Endianness::NETWORK);
2022-12-14 13:51:24 +01:00
auto *frontendIF = ObjectManager::instance()->get<TmStoreFrontendSimpleIF>(*objectId);
if (frontendIF == nullptr) {
return FAILED;
}
*id = frontendIF->getCommandQueue();
2022-10-24 10:26:00 +02:00
return OK;
2022-10-24 10:14:58 +02:00
}
2022-10-24 10:26:00 +02:00
ReturnValue_t Service15TmStorage::prepareCommand(CommandMessage *message, uint8_t subservice,
const uint8_t *tcData, size_t tcDataLen,
uint32_t *state, object_id_t objectId) {
2022-12-14 15:41:20 +01:00
if (subservice == Subservices::START_BY_TIME_RANGE_RETRIEVAL) {
2023-02-22 13:27:16 +01:00
// TODO: Hardcoded to UNIX timestamps.. Should allow arbitrary timestamp and let receiver
// to time reading and reply handling
2022-12-14 15:41:20 +01:00
if (tcDataLen != 12) {
return INVALID_TC;
}
store_address_t storeId;
2023-02-22 13:27:16 +01:00
ReturnValue_t result = ipcStore->addData(&storeId, tcData + 4, tcDataLen - 4);
2022-12-14 15:41:20 +01:00
if (result != OK) {
return result;
}
// Store timestamps
TmStoreMessage::setDownlinkContentTimeMessage(message, storeId);
2023-02-22 13:27:16 +01:00
return CommandingServiceBase::EXECUTION_COMPLETE;
2022-12-14 15:41:20 +01:00
} else if (subservice == Subservices::DELETE_UP_TO) {
2023-02-22 13:27:16 +01:00
// TODO: Hardcoded to UNIX timestamps.. Should allow arbitrary timestamp and let receiver
// to time reading and reply handling
2022-12-14 15:41:20 +01:00
if (tcDataLen != 8) {
return INVALID_TC;
}
store_address_t storeId;
2023-02-22 13:27:16 +01:00
ReturnValue_t result = ipcStore->addData(&storeId, tcData + 4, tcDataLen - 4);
2022-12-14 15:41:20 +01:00
if (result != OK) {
return result;
}
// Store timestamps
TmStoreMessage::setDeleteContentTimeMessage(message, storeId);
2023-02-22 13:27:16 +01:00
return CommandingServiceBase::EXECUTION_COMPLETE;
2022-12-14 15:41:20 +01:00
}
2022-10-24 10:26:00 +02:00
return OK;
2022-10-24 10:14:58 +02:00
}
2022-10-24 10:26:00 +02:00
ReturnValue_t Service15TmStorage::handleReply(const CommandMessage *reply,
Command_t previousCommand, uint32_t *state,
CommandMessage *optionalNextCommand,
object_id_t objectId, bool *isStep) {
return OK;
2022-10-24 10:14:58 +02:00
}