switched to new tmtc stack API
This commit is contained in:
parent
9860061fc6
commit
be35bd53a6
@ -34,7 +34,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
|
||||
SerializeElement<T> limitValue;
|
||||
SerializeElement<ReturnValue_t> oldState;
|
||||
SerializeElement<ReturnValue_t> newState;
|
||||
uint8_t rawTimestamp[TimeStamperIF::MISSION_TIMESTAMP_SIZE] = {};
|
||||
uint8_t rawTimestamp[TimeStamperIF::MAXIMUM_TIMESTAMP_LEN] = {};
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> timestampSerializer;
|
||||
TimeStamperIF* timeStamper;
|
||||
MonitoringReportContent()
|
||||
@ -47,7 +47,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
|
||||
oldState(0),
|
||||
newState(0),
|
||||
timestampSerializer(rawTimestamp, sizeof(rawTimestamp)),
|
||||
timeStamper(NULL) {
|
||||
timeStamper(nullptr) {
|
||||
setAllNext();
|
||||
}
|
||||
MonitoringReportContent(gp_id_t globalPoolId, T value, T limitValue, ReturnValue_t oldState,
|
||||
@ -61,7 +61,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
|
||||
oldState(oldState),
|
||||
newState(newState),
|
||||
timestampSerializer(rawTimestamp, sizeof(rawTimestamp)),
|
||||
timeStamper(NULL) {
|
||||
timeStamper(nullptr) {
|
||||
setAllNext();
|
||||
if (checkAndSetStamper()) {
|
||||
timeStamper->addTimeStamp(rawTimestamp, sizeof(rawTimestamp));
|
||||
|
@ -84,7 +84,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
message->getMaximumMessageSize());
|
||||
} else {
|
||||
if (not ignoreFault) {
|
||||
InternalErrorReporterIF* internalErrorReporter =
|
||||
auto* internalErrorReporter =
|
||||
ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
|
||||
if (internalErrorReporter != nullptr) {
|
||||
internalErrorReporter->queueMessageNotSent();
|
||||
|
@ -1,15 +1,14 @@
|
||||
#include "fsfw/pus/Service17Test.h"
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h"
|
||||
#include "fsfw/tmtcservices/sendAndStoreHelper.h"
|
||||
|
||||
Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId,
|
||||
StorageManagerIF* tmStore, StorageManagerIF* ipcStore,
|
||||
InternalErrorReporterIF* errReporter)
|
||||
: PusServiceBase(objectId, apid, serviceId, ipcStore),
|
||||
helper(tmStore, MessageQueueIF::NO_QUEUE, MessageQueueIF::NO_QUEUE, errReporter),
|
||||
Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId)
|
||||
: PusServiceBase(objectId, apid, serviceId),
|
||||
storeHelper(apid, nullptr),
|
||||
sendHelper(nullptr),
|
||||
packetSubCounter(0) {}
|
||||
|
||||
Service17Test::~Service17Test() = default;
|
||||
@ -17,15 +16,13 @@ Service17Test::~Service17Test() = default;
|
||||
ReturnValue_t Service17Test::handleRequest(uint8_t subservice) {
|
||||
switch (subservice) {
|
||||
case Subservice::CONNECTION_TEST: {
|
||||
helper.preparePacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter);
|
||||
helper.sendPacket();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
storeHelper.preparePacket(serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter);
|
||||
return tm::storeAndSendTmPacket(storeHelper, sendHelper);
|
||||
}
|
||||
case Subservice::EVENT_TRIGGER_TEST: {
|
||||
helper.preparePacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
||||
helper.sendPacket();
|
||||
storeHelper.preparePacket(serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
||||
triggerEvent(TEST, 1234, 5678);
|
||||
return RETURN_OK;
|
||||
return tm::storeAndSendTmPacket(storeHelper, sendHelper);
|
||||
}
|
||||
default:
|
||||
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
|
||||
@ -39,6 +36,17 @@ ReturnValue_t Service17Test::initialize() {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
helper.setMsgDestination(requestQueue->getDefaultDestination());
|
||||
helper.setMsgSource(requestQueue->getId());
|
||||
if (tm) }
|
||||
initializeTmHelpers(sendHelper, storeHelper);
|
||||
if (storeHelper.getTmStore() == nullptr) {
|
||||
auto* tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
|
||||
if (tmStore == nullptr) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
storeHelper.setTmStore(tmStore);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Service17Test::setCustomTmStore(StorageManagerIF* tmStore_) {
|
||||
storeHelper.setTmStore(tmStore_);
|
||||
}
|
||||
|
@ -33,16 +33,19 @@ class Service17Test : public PusServiceBase {
|
||||
EVENT_TRIGGER_TEST = 128,
|
||||
};
|
||||
|
||||
Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId,
|
||||
InternalErrorReporterIF* errReporter, StorageManagerIF* tmStore = nullptr,
|
||||
StorageManagerIF* ipcStore = nullptr);
|
||||
Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId);
|
||||
|
||||
void setCustomTmStore(StorageManagerIF* tmStore);
|
||||
|
||||
~Service17Test() override;
|
||||
ReturnValue_t handleRequest(uint8_t subservice) override;
|
||||
ReturnValue_t performService() override;
|
||||
ReturnValue_t initialize() override;
|
||||
|
||||
protected:
|
||||
TmStoreHelper helper;
|
||||
TmStoreHelper storeHelper;
|
||||
TmSendHelper sendHelper;
|
||||
|
||||
uint16_t packetSubCounter = 0;
|
||||
};
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/pus/servicepackets/Service1Packets.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h"
|
||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||
#include "fsfw/tmtcservices/PusVerificationReport.h"
|
||||
#include "fsfw/tmtcservices/sendAndStoreHelper.h"
|
||||
|
||||
Service1TelecommandVerification::Service1TelecommandVerification(object_id_t objectId,
|
||||
uint16_t apid, uint8_t serviceId,
|
||||
@ -15,7 +15,9 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj
|
||||
: SystemObject(objectId),
|
||||
apid(apid),
|
||||
serviceId(serviceId),
|
||||
targetDestination(targetDestination) {
|
||||
targetDestination(targetDestination),
|
||||
sendHelper(nullptr),
|
||||
storeHelper(apid, nullptr) {
|
||||
tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
||||
}
|
||||
|
||||
@ -67,32 +69,23 @@ ReturnValue_t Service1TelecommandVerification::generateFailureReport(
|
||||
FailureReport report(message->getReportId(), message->getTcPacketId(),
|
||||
message->getTcSequenceControl(), message->getStep(), message->getErrorCode(),
|
||||
message->getParameter1(), message->getParameter2());
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report);
|
||||
#else
|
||||
TmPacketStoredPusC tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report);
|
||||
#endif
|
||||
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(), tmQueue->getId());
|
||||
return result;
|
||||
storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++);
|
||||
storeHelper.setSourceDataSerializable(&report);
|
||||
return tm::storeAndSendTmPacket(storeHelper, sendHelper);
|
||||
}
|
||||
|
||||
ReturnValue_t Service1TelecommandVerification::generateSuccessReport(
|
||||
PusVerificationMessage* message) {
|
||||
SuccessReport report(message->getReportId(), message->getTcPacketId(),
|
||||
message->getTcSequenceControl(), message->getStep());
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report);
|
||||
#else
|
||||
TmPacketStoredPusC tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report);
|
||||
#endif
|
||||
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(), tmQueue->getId());
|
||||
return result;
|
||||
storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++);
|
||||
storeHelper.setSourceDataSerializable(&report);
|
||||
return tm::storeAndSendTmPacket(storeHelper, sendHelper);
|
||||
}
|
||||
|
||||
ReturnValue_t Service1TelecommandVerification::initialize() {
|
||||
// Get target object for TC verification messages
|
||||
AcceptsTelemetryIF* funnel =
|
||||
ObjectManager::instance()->get<AcceptsTelemetryIF>(targetDestination);
|
||||
auto* funnel = ObjectManager::instance()->get<AcceptsTelemetryIF>(targetDestination);
|
||||
if (funnel == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Service1TelecommandVerification::initialize: Specified"
|
||||
@ -103,5 +96,12 @@ ReturnValue_t Service1TelecommandVerification::initialize() {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
tmQueue->setDefaultDestination(funnel->getReportReceptionQueue());
|
||||
if (tmStore == nullptr) {
|
||||
tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
|
||||
if (tmStore == nullptr) {
|
||||
return ObjectManager::CHILD_INIT_FAILED;
|
||||
}
|
||||
storeHelper.setTmStore(tmStore);
|
||||
}
|
||||
return SystemObject::initialize();
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h"
|
||||
#include "fsfw/tmtcservices/PusVerificationReport.h"
|
||||
#include "fsfw/tmtcservices/TmSendHelper.h"
|
||||
#include "fsfw/tmtcservices/TmStoreHelper.h"
|
||||
|
||||
/**
|
||||
* @brief Verify TC acceptance, start, progress and execution.
|
||||
@ -45,13 +47,13 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF,
|
||||
|
||||
Service1TelecommandVerification(object_id_t objectId, uint16_t apid, uint8_t serviceId,
|
||||
object_id_t targetDestination, uint16_t messageQueueDepth);
|
||||
virtual ~Service1TelecommandVerification();
|
||||
~Service1TelecommandVerification() override;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return ID of Verification Queue
|
||||
*/
|
||||
virtual MessageQueueId_t getVerificationQueue() override;
|
||||
MessageQueueId_t getVerificationQueue() override;
|
||||
|
||||
/**
|
||||
* Performs the service periodically as specified in init_mission().
|
||||
@ -59,7 +61,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF,
|
||||
* @param operationCode
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
ReturnValue_t performOperation(uint8_t operationCode) override;
|
||||
|
||||
/**
|
||||
* Initializes the destination for TC verification messages and initializes
|
||||
@ -80,6 +82,9 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF,
|
||||
|
||||
uint16_t packetSubCounter = 0;
|
||||
|
||||
TmSendHelper sendHelper;
|
||||
TmStoreHelper storeHelper;
|
||||
StorageManagerIF* tmStore = nullptr;
|
||||
MessageQueueIF* tmQueue = nullptr;
|
||||
|
||||
enum class Subservice : uint8_t {
|
||||
|
@ -137,7 +137,7 @@ ReturnValue_t Service20ParameterManagement::prepareLoadCommand(CommandMessage* m
|
||||
if (parameterDataLen == 0) {
|
||||
return CommandingServiceBase::INVALID_TC;
|
||||
}
|
||||
ReturnValue_t result = IPCStore->getFreeElement(&storeAddress, parameterDataLen, &storePointer);
|
||||
ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, parameterDataLen, &storePointer);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -169,7 +169,7 @@ ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* re
|
||||
|
||||
switch (replyId) {
|
||||
case ParameterMessage::REPLY_PARAMETER_DUMP: {
|
||||
ConstAccessorPair parameterData = IPCStore->getData(ParameterMessage::getStoreId(reply));
|
||||
ConstAccessorPair parameterData = ipcStore->getData(ParameterMessage::getStoreId(reply));
|
||||
if (parameterData.first != HasReturnvaluesIF::RETURN_OK) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ ReturnValue_t Service2DeviceAccess::prepareRawCommand(CommandMessage* messageToS
|
||||
// store command into the Inter Process Communication Store
|
||||
store_address_t storeAddress;
|
||||
ReturnValue_t result =
|
||||
IPCStore->addData(&storeAddress, RawCommand.getCommand(), RawCommand.getCommandSize());
|
||||
ipcStore->addData(&storeAddress, RawCommand.getCommand(), RawCommand.getCommandSize());
|
||||
DeviceHandlerMessage::setDeviceHandlerRawCommandMessage(messageToSet, storeAddress);
|
||||
return result;
|
||||
}
|
||||
@ -135,7 +135,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs
|
||||
store_address_t storeAddress = DeviceHandlerMessage::getStoreAddress(reply);
|
||||
const uint8_t* data = nullptr;
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size);
|
||||
ReturnValue_t result = ipcStore->getData(storeAddress, &data, &size);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in "
|
||||
@ -147,10 +147,8 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs
|
||||
|
||||
// Init our dummy packet and correct endianness of object ID before
|
||||
// sending it back.
|
||||
WiretappingPacket TmPacket(DeviceHandlerMessage::getDeviceObjectId(reply), data);
|
||||
TmPacket.objectId = EndianConverter::convertBigEndian(TmPacket.objectId);
|
||||
sendTmPacket(subservice, TmPacket.data, size, reinterpret_cast<uint8_t*>(&TmPacket.objectId),
|
||||
sizeof(TmPacket.objectId));
|
||||
WiretappingPacket tmPacket(DeviceHandlerMessage::getDeviceObjectId(reply), data);
|
||||
sendTmPacket(subservice, tmPacket.objectId, tmPacket.data, size);
|
||||
}
|
||||
|
||||
MessageQueueId_t Service2DeviceAccess::getDeviceQueue() { return commandQueue->getId(); }
|
||||
|
@ -284,14 +284,13 @@ ReturnValue_t Service3Housekeeping::generateHkReply(const CommandMessage* hkMess
|
||||
store_address_t storeId;
|
||||
|
||||
sid_t sid = HousekeepingMessage::getHkDataReply(hkMessage, &storeId);
|
||||
auto resultPair = IPCStore->getData(storeId);
|
||||
auto resultPair = ipcStore->getData(storeId);
|
||||
if (resultPair.first != HasReturnvaluesIF::RETURN_OK) {
|
||||
return resultPair.first;
|
||||
}
|
||||
|
||||
HkPacket hkPacket(sid, resultPair.second.data(), resultPair.second.size());
|
||||
return sendTmPacket(static_cast<uint8_t>(subserviceId), hkPacket.hkData, hkPacket.hkSize, nullptr,
|
||||
0);
|
||||
return sendTmPacket(static_cast<uint8_t>(subserviceId), hkPacket.hkData, hkPacket.hkSize);
|
||||
}
|
||||
|
||||
sid_t Service3Housekeeping::buildSid(object_id_t objectId, const uint8_t** tcData,
|
||||
|
@ -6,11 +6,14 @@
|
||||
#include "fsfw/pus/servicepackets/Service5Packets.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h"
|
||||
#include "fsfw/tmtcservices/sendAndStoreHelper.h"
|
||||
|
||||
Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t apid,
|
||||
uint8_t serviceId, size_t maxNumberReportsPerCycle,
|
||||
uint32_t messageQueueDepth)
|
||||
: PusServiceBase(objectId, apid, serviceId),
|
||||
sendHelper(nullptr),
|
||||
storeHelper(apid, nullptr),
|
||||
maxNumberReportsPerCycle(maxNumberReportsPerCycle) {
|
||||
eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
||||
}
|
||||
@ -45,15 +48,9 @@ ReturnValue_t Service5EventReporting::performService() {
|
||||
ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) {
|
||||
EventReport report(message.getEventId(), message.getReporter(), message.getParameter1(),
|
||||
message.getParameter2());
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacket(PusServiceBase::apid, PusServiceBase::serviceId,
|
||||
message.getSeverity(), packetSubCounter++, &report);
|
||||
#else
|
||||
TmPacketStoredPusC tmPacket(PusServiceBase::apid, PusServiceBase::serviceId,
|
||||
message.getSeverity(), packetSubCounter++, &report);
|
||||
#endif
|
||||
ReturnValue_t result =
|
||||
tmPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||
storeHelper.preparePacket(serviceId, message.getSeverity(), packetSubCounter);
|
||||
storeHelper.setSourceDataSerializable(&report);
|
||||
ReturnValue_t result = tm::storeAndSendTmPacket(storeHelper, sendHelper);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "Service5EventReporting::generateEventReport: "
|
||||
@ -64,6 +61,8 @@ ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message)
|
||||
"Service5EventReporting::generateEventReport: "
|
||||
"Could not send TM packet\n");
|
||||
#endif
|
||||
} else {
|
||||
packetSubCounter++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -86,14 +85,18 @@ ReturnValue_t Service5EventReporting::handleRequest(uint8_t subservice) {
|
||||
// In addition to the default PUSServiceBase initialization, this service needs
|
||||
// to be registered to the event manager to listen for events.
|
||||
ReturnValue_t Service5EventReporting::initialize() {
|
||||
ReturnValue_t result = PusServiceBase::initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
auto* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
if (manager == nullptr) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
// register Service 5 as listener for events
|
||||
ReturnValue_t result = manager->registerListener(eventQueue->getId(), true);
|
||||
result = manager->registerListener(eventQueue->getId(), true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return PusServiceBase::initialize();
|
||||
initializeTmHelpers(sendHelper, storeHelper);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class Service5EventReporting : public PusServiceBase {
|
||||
public:
|
||||
Service5EventReporting(object_id_t objectId, uint16_t apid, uint8_t serviceId,
|
||||
size_t maxNumberReportsPerCycle = 10, uint32_t messageQueueDepth = 10);
|
||||
virtual ~Service5EventReporting();
|
||||
~Service5EventReporting() override;
|
||||
|
||||
/***
|
||||
* Check for events and generate event reports if required.
|
||||
@ -77,6 +77,8 @@ class Service5EventReporting : public PusServiceBase {
|
||||
uint16_t packetSubCounter = 0;
|
||||
MessageQueueIF* eventQueue = nullptr;
|
||||
bool enableEventReport = true;
|
||||
TmSendHelper sendHelper;
|
||||
TmStoreHelper storeHelper;
|
||||
const uint8_t maxNumberReportsPerCycle;
|
||||
|
||||
ReturnValue_t generateEventReport(EventMessage message);
|
||||
|
@ -78,7 +78,7 @@ ReturnValue_t Service8FunctionManagement::prepareDirectCommand(CommandMessage* m
|
||||
// store additional parameters into the IPC Store
|
||||
store_address_t parameterAddress;
|
||||
ReturnValue_t result =
|
||||
IPCStore->addData(¶meterAddress, command.getParameters(), command.getParametersSize());
|
||||
ipcStore->addData(¶meterAddress, command.getParameters(), command.getParametersSize());
|
||||
|
||||
// setCommand expects a Command Message, an Action ID and a store adress
|
||||
// pointing to additional parameters
|
||||
@ -130,7 +130,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage*
|
||||
store_address_t storeId = ActionMessage::getStoreId(reply);
|
||||
size_t size = 0;
|
||||
const uint8_t* buffer = nullptr;
|
||||
ReturnValue_t result = IPCStore->getData(storeId, &buffer, &size);
|
||||
ReturnValue_t result = ipcStore->getData(storeId, &buffer, &size);
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Service 8: Could not retrieve data for data reply" << std::endl;
|
||||
@ -140,7 +140,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage*
|
||||
DataReply dataReply(objectId, actionId, buffer, size);
|
||||
result = sendTmPacket(static_cast<uint8_t>(Subservice::REPLY_DIRECT_COMMANDING_DATA), &dataReply);
|
||||
|
||||
auto deletionResult = IPCStore->deleteData(storeId);
|
||||
auto deletionResult = ipcStore->deleteData(storeId);
|
||||
if (deletionResult != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "Service8FunctionManagement::handleReply: Deletion"
|
||||
|
@ -9,7 +9,7 @@ Service9TimeManagement::Service9TimeManagement(object_id_t objectId, uint16_t ap
|
||||
uint8_t serviceId)
|
||||
: PusServiceBase(objectId, apid, serviceId) {}
|
||||
|
||||
Service9TimeManagement::~Service9TimeManagement() {}
|
||||
Service9TimeManagement::~Service9TimeManagement() = default;
|
||||
|
||||
ReturnValue_t Service9TimeManagement::performService() { return RETURN_OK; }
|
||||
|
||||
@ -25,7 +25,9 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
|
||||
|
||||
ReturnValue_t Service9TimeManagement::setTime() {
|
||||
Clock::TimeOfDay_t timeToSet;
|
||||
TimePacket timePacket(currentPacket.getUserData(), currentPacket.getUserDataSize());
|
||||
size_t userDataLen = 0;
|
||||
const uint8_t* timeData = currentPacket.getUserData(userDataLen);
|
||||
TimePacket timePacket(timeData, userDataLen);
|
||||
ReturnValue_t result =
|
||||
CCSDSTime::convertFromCcsds(&timeToSet, timePacket.getTime(), timePacket.getTimeSize());
|
||||
if (result != RETURN_OK) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE9PACKETS_H_
|
||||
#define FSFW_PUS_SERVICEPACKETS_SERVICE9PACKETS_H_
|
||||
|
||||
#include "../../serialize/SerialLinkedListAdapter.h"
|
||||
#include "fsfw/serialize/SerialLinkedListAdapter.h"
|
||||
|
||||
/**
|
||||
* @brief Subservice 128
|
||||
@ -11,16 +11,16 @@
|
||||
*/
|
||||
class TimePacket : SerialLinkedListAdapter<SerializeIF> { //!< [EXPORT] : [SUBSERVICE] 128
|
||||
public:
|
||||
TimePacket(const TimePacket& command) = delete;
|
||||
TimePacket(const uint8_t* timeBuffer_, uint32_t timeSize_) {
|
||||
timeBuffer = timeBuffer_;
|
||||
timeSize = timeSize_;
|
||||
}
|
||||
const uint8_t* getTime() { return timeBuffer; }
|
||||
|
||||
uint32_t getTimeSize() const { return timeSize; }
|
||||
[[nodiscard]] uint32_t getTimeSize() const { return timeSize; }
|
||||
|
||||
private:
|
||||
TimePacket(const TimePacket& command);
|
||||
const uint8_t* timeBuffer;
|
||||
uint32_t timeSize; //!< [EXPORT] : [IGNORE]
|
||||
};
|
||||
|
@ -55,7 +55,7 @@ class StorageManagerIF : public HasReturnvaluesIF {
|
||||
/**
|
||||
* @brief This is the empty virtual destructor as required for C++ interfaces.
|
||||
*/
|
||||
virtual ~StorageManagerIF(){};
|
||||
~StorageManagerIF() override = default;
|
||||
/**
|
||||
* @brief With addData, a free storage position is allocated and data
|
||||
* stored there.
|
||||
@ -160,8 +160,8 @@ class StorageManagerIF : public HasReturnvaluesIF {
|
||||
* @li RETURN_FAILED if data could not be added.
|
||||
* storageId is unchanged then.
|
||||
*/
|
||||
virtual ReturnValue_t getFreeElement(store_address_t* storageId, const size_t size,
|
||||
uint8_t** p_data, bool ignoreFault = false) = 0;
|
||||
virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** p_data,
|
||||
bool ignoreFault = false) = 0;
|
||||
|
||||
/**
|
||||
* Clears the whole store.
|
||||
@ -192,7 +192,7 @@ class StorageManagerIF : public HasReturnvaluesIF {
|
||||
* Get number of pools.
|
||||
* @return
|
||||
*/
|
||||
virtual max_subpools_t getNumberOfSubPools() const = 0;
|
||||
[[nodiscard]] virtual max_subpools_t getNumberOfSubPools() const = 0;
|
||||
};
|
||||
|
||||
#endif /* FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_ */
|
||||
|
@ -36,7 +36,7 @@ PusDistributor::TcMqMapIter PusDistributor::selectDestination() {
|
||||
HasReturnvaluesIF::RETURN_OK) {
|
||||
return queueMapIt;
|
||||
}
|
||||
reader.setData(packetPtr, packetLen);
|
||||
reader.setReadOnlyData(packetPtr, packetLen);
|
||||
// this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket);
|
||||
if (reader.getFullData() != nullptr) {
|
||||
tcStatus =
|
||||
|
@ -14,14 +14,15 @@
|
||||
* overriding the #addTimeStamp function.
|
||||
* @ingroup utility
|
||||
*/
|
||||
class TimeStamper : public TimeStamperIF, public SystemObject {
|
||||
class CdsShortTimeStamper : public TimeStamperIF, public SystemObject {
|
||||
public:
|
||||
static constexpr size_t TIMESTAMP_LEN = 7;
|
||||
/**
|
||||
* @brief Default constructor which also registers the time stamper as a
|
||||
* system object so it can be found with the #objectManager.
|
||||
* @param objectId
|
||||
*/
|
||||
TimeStamper(object_id_t objectId);
|
||||
explicit CdsShortTimeStamper(object_id_t objectId);
|
||||
|
||||
/**
|
||||
* Adds a CCSDS CDC short 8 byte timestamp to the given buffer.
|
||||
@ -30,7 +31,13 @@ class TimeStamper : public TimeStamperIF, public SystemObject {
|
||||
* @param maxSize
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer, const uint8_t maxSize);
|
||||
ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override;
|
||||
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const override;
|
||||
size_t getSerializedSize() const override;
|
||||
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override;
|
||||
size_t getTimestampSize() const override;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TIMEMANAGER_TIMESTAMPER_H_ */
|
@ -1,23 +1,35 @@
|
||||
#include "fsfw/timemanager/TimeStamper.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/timemanager/CdsShortTimeStamper.h"
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
|
||||
TimeStamper::TimeStamper(object_id_t objectId) : SystemObject(objectId) {}
|
||||
CdsShortTimeStamper::CdsShortTimeStamper(object_id_t objectId) : SystemObject(objectId) {}
|
||||
|
||||
ReturnValue_t TimeStamper::addTimeStamp(uint8_t* buffer, const uint8_t maxSize) {
|
||||
if (maxSize < TimeStamperIF::MISSION_TIMESTAMP_SIZE) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
ReturnValue_t CdsShortTimeStamper::addTimeStamp(uint8_t *buffer, const uint8_t maxSize) {
|
||||
size_t serLen = 0;
|
||||
return serialize(&buffer, &serLen, maxSize, SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
|
||||
ReturnValue_t CdsShortTimeStamper::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
if (*size + getSerializedSize() > maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
|
||||
timeval now;
|
||||
timeval now{};
|
||||
Clock::getClock_timeval(&now);
|
||||
CCSDSTime::CDS_short cds;
|
||||
CCSDSTime::CDS_short cds{};
|
||||
ReturnValue_t result = CCSDSTime::convertToCcsds(&cds, &now);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(buffer, &cds, sizeof(cds));
|
||||
std::memcpy(*buffer, &cds, sizeof(cds));
|
||||
*buffer += getSerializedSize();
|
||||
*size += getSerializedSize();
|
||||
return result;
|
||||
}
|
||||
size_t CdsShortTimeStamper::getSerializedSize() const { return getTimestampSize(); }
|
||||
ReturnValue_t CdsShortTimeStamper::deSerialize(const uint8_t **buffer, size_t *size,
|
||||
SerializeIF::Endianness streamEndianness) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
size_t CdsShortTimeStamper::getTimestampSize() const { return TIMESTAMP_LEN; }
|
||||
|
@ -1,9 +1,8 @@
|
||||
#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||
#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
||||
/**
|
||||
* A class implementing this IF provides facilities to add a time stamp to the
|
||||
@ -11,17 +10,21 @@
|
||||
* Implementors need to ensure that calling the method is thread-safe, i.e.
|
||||
* addTimeStamp may be called in parallel from a different context.
|
||||
*/
|
||||
class TimeStamperIF {
|
||||
class TimeStamperIF : public SerializeIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::TIME_STAMPER_IF;
|
||||
static const ReturnValue_t BAD_TIMESTAMP = MAKE_RETURN_CODE(1);
|
||||
|
||||
// I am going to assume there are no larger timestamps
|
||||
static constexpr size_t MAXIMUM_TIMESTAMP_LEN = 16;
|
||||
|
||||
//! This is a mission-specific constant and determines the total
|
||||
//! size reserved for timestamps.
|
||||
static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE;
|
||||
// static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE;
|
||||
|
||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer, const uint8_t maxSize) = 0;
|
||||
virtual ~TimeStamperIF() {}
|
||||
[[nodiscard]] virtual size_t getTimestampSize() const = 0;
|
||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0;
|
||||
~TimeStamperIF() override = default;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */
|
||||
|
@ -75,3 +75,7 @@ void SpacePacketCreator::checkFieldValidity() {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SpacePacketCreator::setParams(SpacePacketParams params_) { params = std::move(params_); }
|
||||
|
||||
SpacePacketParams &SpacePacketCreator::getParams() { return params; }
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
||||
struct SpacePacketParams {
|
||||
SpacePacketParams() = default;
|
||||
|
||||
SpacePacketParams(PacketId packetId, PacketSeqCtrl psc, uint16_t dataLen)
|
||||
: packetId(std::move(packetId)), packetSeqCtrl(std::move(psc)), dataLen(dataLen) {}
|
||||
|
||||
@ -20,6 +22,7 @@ struct SpacePacketParams {
|
||||
|
||||
class SpacePacketCreator : public SpacePacketIF, public SerializeIF {
|
||||
public:
|
||||
SpacePacketCreator() = default;
|
||||
explicit SpacePacketCreator(SpacePacketParams params);
|
||||
SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid,
|
||||
ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen,
|
||||
@ -30,6 +33,8 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF {
|
||||
[[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override;
|
||||
[[nodiscard]] uint16_t getPacketDataLen() const override;
|
||||
|
||||
SpacePacketParams &getParams();
|
||||
void setParams(SpacePacketParams params);
|
||||
void setApid(uint16_t apid);
|
||||
void setSeqCount(uint16_t seqCount);
|
||||
void setSeqFlags(ccsds::SequenceFlags flags);
|
||||
@ -45,9 +50,7 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF {
|
||||
|
||||
private:
|
||||
void checkFieldValidity();
|
||||
|
||||
SpacePacketCreator() = default;
|
||||
bool valid{};
|
||||
SpacePacketParams params;
|
||||
SpacePacketParams params{};
|
||||
};
|
||||
#endif // FSFW_TMTCPACKET_SPACEPACKETCREATOR_H
|
||||
|
@ -18,7 +18,7 @@ class SpacePacketIF {
|
||||
/**
|
||||
* This is the minimum size of a SpacePacket.
|
||||
*/
|
||||
static const uint16_t MINIMUM_SIZE = sizeof(ccsds::PrimaryHeader) + CRC_SIZE;
|
||||
static const uint16_t MIN_CCSDS_SIZE = sizeof(ccsds::PrimaryHeader) + CRC_SIZE;
|
||||
|
||||
virtual ~SpacePacketIF() = default;
|
||||
|
||||
|
@ -31,7 +31,7 @@ PacketMatchTree::~PacketMatchTree() = default;
|
||||
|
||||
ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t subtype) {
|
||||
// We assume adding APID is always requested.
|
||||
PusTmMinimal::TmPacketMinimalPointer data{};
|
||||
mintm::MinimalPusTm data{};
|
||||
data.secHeader.service = type;
|
||||
data.secHeader.subservice = subtype;
|
||||
PusTmMinimal testPacket((uint8_t*)&data);
|
||||
@ -122,7 +122,7 @@ ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test,
|
||||
}
|
||||
|
||||
ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type, uint8_t subtype) {
|
||||
PusTmMinimal::TmPacketMinimalPointer data{};
|
||||
mintm::MinimalPusTm data{};
|
||||
data.secHeader.service = type;
|
||||
data.secHeader.subservice = subtype;
|
||||
PusTmMinimal testPacket((uint8_t*)&data);
|
||||
|
10
src/fsfw/tmtcpacket/pus/CreatorDataIF.h
Normal file
10
src/fsfw/tmtcpacket/pus/CreatorDataIF.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef FSFW_TMTCPACKET_CREATORDATAIF_H
|
||||
#define FSFW_TMTCPACKET_CREATORDATAIF_H
|
||||
|
||||
#include "definitions.h"
|
||||
|
||||
class CreatorDataIF {
|
||||
public:
|
||||
virtual ecss::DataWrapper& getDataWrapper() = 0;
|
||||
};
|
||||
#endif // FSFW_TMTCPACKET_CREATORDATAIF_H
|
@ -29,24 +29,6 @@ class PusIF : public SpacePacketIF {
|
||||
* @return The packet's PUS Service Subtype.
|
||||
*/
|
||||
[[nodiscard]] virtual uint8_t getSubService() const = 0;
|
||||
|
||||
/**
|
||||
* This is a getter for a pointer to the packet's Application data.
|
||||
*
|
||||
* These are the bytes that follow after the Data Field Header. They form
|
||||
* the packet's application data.
|
||||
* @return A pointer to the PUS Application Data.
|
||||
*/
|
||||
[[nodiscard]] virtual const uint8_t* getUserData(size_t& appDataLen) const = 0;
|
||||
/**
|
||||
* This method calculates the size of the PUS Application data field.
|
||||
*
|
||||
* It takes the information stored in the CCSDS Packet Data Length field
|
||||
* and subtracts the Data Field Header size and the CRC size.
|
||||
* @return The size of the PUS Application Data (without Error Control
|
||||
* field)
|
||||
*/
|
||||
[[nodiscard]] virtual uint16_t getUserDataSize() const = 0;
|
||||
};
|
||||
|
||||
#endif // FSFW_TMTCPACKET_PUSIF_H
|
||||
|
12
src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h
Normal file
12
src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef FSFW_TMTCPACKET_RAWDATAIF_H
|
||||
#define FSFW_TMTCPACKET_RAWDATAIF_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
class RawUserDataReaderIF {
|
||||
public:
|
||||
virtual const uint8_t* getUserData(size_t& userDataLen) = 0;
|
||||
};
|
||||
|
||||
#endif // FSFW_TMTCPACKET_RAWDATAIF_H
|
@ -3,11 +3,39 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
||||
namespace ecss {
|
||||
|
||||
//! Version numbers according to ECSS-E-ST-70-41C p.439
|
||||
enum PusVersion : uint8_t { PUS_A = 1, PUS_C = 2 };
|
||||
|
||||
struct RawData {
|
||||
const uint8_t* data;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
enum DataTypes { RAW, SERIALIZABLE };
|
||||
|
||||
union DataUnion {
|
||||
RawData raw;
|
||||
SerializeIF* serializable;
|
||||
};
|
||||
|
||||
struct DataWrapper {
|
||||
DataTypes type;
|
||||
DataUnion dataUnion;
|
||||
|
||||
[[nodiscard]] size_t getLength() const {
|
||||
if (type == DataTypes::RAW) {
|
||||
return dataUnion.raw.len;
|
||||
} else if (type == DataTypes::SERIALIZABLE and dataUnion.serializable != nullptr) {
|
||||
return dataUnion.serializable->getSerializedSize();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ecss
|
||||
|
||||
#endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_ */
|
||||
|
@ -1,17 +1,20 @@
|
||||
#include "PusTcCreator.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "PusTcIF.h"
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/serialize/SerializeAdapter.h"
|
||||
|
||||
PusTcCreator::PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams)
|
||||
: spCreator(spParams), pusParams(pusParams) {
|
||||
: spCreator(std::move(spParams)), pusParams(pusParams) {
|
||||
updateSpLengthField();
|
||||
}
|
||||
|
||||
ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
if (*size + PusTcIF::MIN_LEN + pusParams.appDataLen > maxSize) {
|
||||
size_t userDataLen = pusParams.dataWrapper.getLength();
|
||||
if (*size + PusTcIF::MIN_LEN + userDataLen > maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
ReturnValue_t result = spCreator.serialize(buffer, size, maxSize, streamEndianness);
|
||||
@ -33,15 +36,28 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(*buffer, pusParams.appData, pusParams.appDataLen);
|
||||
*buffer += pusParams.appDataLen;
|
||||
*size += pusParams.appDataLen;
|
||||
if (pusParams.dataWrapper.type == ecss::DataTypes::RAW) {
|
||||
const uint8_t *data = pusParams.dataWrapper.dataUnion.raw.data;
|
||||
if (data != nullptr and userDataLen > 0) {
|
||||
std::memcpy(*buffer, data, userDataLen);
|
||||
*buffer += userDataLen;
|
||||
*size += userDataLen;
|
||||
}
|
||||
} else if (pusParams.dataWrapper.type == ecss::DataTypes::SERIALIZABLE and
|
||||
pusParams.dataWrapper.dataUnion.serializable != nullptr) {
|
||||
result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t crc16 = CRC::crc16ccitt(*buffer, getFullPacketLen() - 2);
|
||||
return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
|
||||
void PusTcCreator::updateSpLengthField() {
|
||||
spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_LEN + pusParams.appDataLen + 1);
|
||||
spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_LEN + pusParams.dataWrapper.getLength() + 1);
|
||||
}
|
||||
|
||||
size_t PusTcCreator::getSerializedSize() const { return spCreator.getFullPacketLen(); }
|
||||
@ -66,10 +82,4 @@ uint8_t PusTcCreator::getService() const { return pusParams.service; }
|
||||
uint8_t PusTcCreator::getSubService() const { return pusParams.subservice; }
|
||||
|
||||
uint16_t PusTcCreator::getSourceId() const { return pusParams.sourceId; }
|
||||
|
||||
const uint8_t *PusTcCreator::getUserData(size_t &appDataLen) const {
|
||||
appDataLen = getUserDataSize();
|
||||
return pusParams.appData;
|
||||
}
|
||||
|
||||
uint16_t PusTcCreator::getUserDataSize() const { return pusParams.appDataLen; }
|
||||
ecss::DataWrapper &PusTcCreator::getDataWrapper() { return pusParams.dataWrapper; }
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h"
|
||||
#include "fsfw/tmtcpacket/pus/CreatorDataIF.h"
|
||||
#include "fsfw/tmtcpacket/pus/definitions.h"
|
||||
#include "fsfw/tmtcpacket/pus/tc/PusTcIF.h"
|
||||
|
||||
@ -14,12 +15,11 @@ struct PusTcParams {
|
||||
uint8_t subservice;
|
||||
uint8_t ackFlags = ecss::ACK_ALL;
|
||||
uint16_t sourceId = 0;
|
||||
uint8_t *appData = nullptr;
|
||||
size_t appDataLen = 0;
|
||||
ecss::DataWrapper dataWrapper{};
|
||||
uint8_t pusVersion = ecss::PusVersion::PUS_C;
|
||||
};
|
||||
|
||||
class PusTcCreator : public PusTcIF, public SerializeIF {
|
||||
class PusTcCreator : public PusTcIF, public SerializeIF, public CreatorDataIF {
|
||||
public:
|
||||
PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams);
|
||||
|
||||
@ -37,8 +37,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF {
|
||||
[[nodiscard]] uint8_t getService() const override;
|
||||
[[nodiscard]] uint8_t getSubService() const override;
|
||||
[[nodiscard]] uint16_t getSourceId() const override;
|
||||
const uint8_t *getUserData(size_t &appDataLen) const override;
|
||||
[[nodiscard]] uint16_t getUserDataSize() const override;
|
||||
ecss::DataWrapper &getDataWrapper() override;
|
||||
|
||||
private:
|
||||
SpacePacketCreator spCreator;
|
||||
|
@ -23,7 +23,7 @@ enum AckField {
|
||||
static constexpr uint8_t ACK_ALL = ACK_ACCEPTANCE | ACK_START | ACK_STEP | ACK_COMPLETION;
|
||||
|
||||
/**
|
||||
* This struct defines a byte-wise structured PUS C ata Field Header.
|
||||
* This struct defines a byte-wise structured PUS C data Field Header.
|
||||
* Any optional fields in the header must be added or removed here.
|
||||
* Currently, the Source Id field is present with one byte.
|
||||
* No spare byte support for now.
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "fsfw/serialize.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
PusTcReader::PusTcReader(const uint8_t* data, size_t size) { setData(data, size); }
|
||||
PusTcReader::PusTcReader(const uint8_t* data, size_t size) { setReadOnlyData(data, size); }
|
||||
|
||||
PusTcReader::~PusTcReader() = default;
|
||||
|
||||
@ -39,12 +39,6 @@ uint8_t PusTcReader::getSubService() const { return pointers.secHeaderStart[2];
|
||||
uint16_t PusTcReader::getSourceId() const {
|
||||
return (pointers.secHeaderStart[3] << 8) | pointers.secHeaderStart[4];
|
||||
}
|
||||
const uint8_t* PusTcReader::getUserData(size_t& appDataLen) const {
|
||||
appDataLen = appDataSize;
|
||||
return pointers.userDataStart;
|
||||
}
|
||||
|
||||
uint16_t PusTcReader::getUserDataSize() const { return appDataSize; }
|
||||
|
||||
uint16_t PusTcReader::getErrorControl() const {
|
||||
return pointers.crcStart[0] << 8 | pointers.crcStart[1];
|
||||
@ -62,11 +56,17 @@ ReturnValue_t PusTcReader::setData(uint8_t* pData, size_t size_, void* args) {
|
||||
spReader.setData(pData, size_, args);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
ReturnValue_t PusTcReader::setData(const uint8_t* data, size_t size_) {
|
||||
|
||||
ReturnValue_t PusTcReader::setReadOnlyData(const uint8_t* data, size_t size_) {
|
||||
setData(const_cast<uint8_t*>(data), size_, nullptr);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
const uint8_t* PusTcReader::getUserData(size_t& userDataLen) {
|
||||
userDataLen = appDataSize;
|
||||
return pointers.userDataStart;
|
||||
}
|
||||
|
||||
/*
|
||||
void PusTcReader::print() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "PusTcIF.h"
|
||||
#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
|
||||
#include "fsfw/tmtcpacket/pus/RawUserDataReaderIF.h"
|
||||
|
||||
/**
|
||||
* This class is the basic data handler for any ECSS PUS Telecommand packet.
|
||||
@ -18,7 +19,10 @@
|
||||
* check can be performed by making use of the getWholeData method.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class PusTcReader : public PusTcIF, public ReadablePacketIF, public RedirectableDataPointerIF {
|
||||
class PusTcReader : public PusTcIF,
|
||||
public RawUserDataReaderIF,
|
||||
public ReadablePacketIF,
|
||||
public RedirectableDataPointerIF {
|
||||
public:
|
||||
PusTcReader() = default;
|
||||
/**
|
||||
@ -48,12 +52,11 @@ class PusTcReader : public PusTcIF, public ReadablePacketIF, public Redirectable
|
||||
[[nodiscard]] uint8_t getService() const override;
|
||||
[[nodiscard]] uint8_t getSubService() const override;
|
||||
[[nodiscard]] uint16_t getSourceId() const override;
|
||||
[[nodiscard]] const uint8_t* getUserData(size_t& appDataLen) const override;
|
||||
[[nodiscard]] uint16_t getUserDataSize() const override;
|
||||
[[nodiscard]] uint16_t getErrorControl() const;
|
||||
const uint8_t* getFullData() override;
|
||||
|
||||
ReturnValue_t setData(const uint8_t* data, size_t size);
|
||||
ReturnValue_t setReadOnlyData(const uint8_t* data, size_t size);
|
||||
const uint8_t* getUserData(size_t& userDataLen) override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -1,6 +1,19 @@
|
||||
#include "PusTmCreator.h"
|
||||
|
||||
PusTmCreator::PusTmCreator(PusTmParams& params_) : params(params_){};
|
||||
#include <utility>
|
||||
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/timemanager/TimeStamperIF.h"
|
||||
|
||||
PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams,
|
||||
TimeStamperIF* timeStamper)
|
||||
: pusParams(initPusParams), spCreator(std::move(initSpParams)){};
|
||||
|
||||
PusTmCreator::PusTmCreator(TimeStamperIF* timeStamper_) {
|
||||
pusParams.secHeader.timeStamper = timeStamper_;
|
||||
};
|
||||
|
||||
PusTmCreator::PusTmCreator() = default;
|
||||
|
||||
uint16_t PusTmCreator::getPacketIdRaw() const { return 0; }
|
||||
uint16_t PusTmCreator::getPacketSeqCtrlRaw() const { return 0; }
|
||||
@ -8,5 +21,79 @@ uint16_t PusTmCreator::getPacketDataLen() const { return 0; }
|
||||
uint8_t PusTmCreator::getPusVersion() const { return 0; }
|
||||
uint8_t PusTmCreator::getService() const { return 0; }
|
||||
uint8_t PusTmCreator::getSubService() const { return 0; }
|
||||
const uint8_t* PusTmCreator::getUserData(size_t& appDataLen) const { return nullptr; }
|
||||
uint16_t PusTmCreator::getUserDataSize() const { return 0; }
|
||||
PusTmParams& PusTmCreator::getParams() { return pusParams; }
|
||||
void PusTmCreator::setTimeStamper(TimeStamperIF* timeStamper_) {
|
||||
pusParams.secHeader.timeStamper = timeStamper_;
|
||||
}
|
||||
uint8_t PusTmCreator::getScTimeRefStatus() { return 0; }
|
||||
uint16_t PusTmCreator::getMessageTypeCounter() { return 0; }
|
||||
uint16_t PusTmCreator::getDestId() { return 0; }
|
||||
|
||||
ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
if (*size + getSerializedSize() > maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
ReturnValue_t result = spCreator.serialize(buffer, size, maxSize);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
size_t userDataLen = pusParams.dataWrapper.getLength();
|
||||
**buffer =
|
||||
((pusParams.secHeader.pusVersion << 4) & 0xF0) | (pusParams.secHeader.scTimeRefStatus & 0x0F);
|
||||
*buffer += 1;
|
||||
**buffer = pusParams.secHeader.service;
|
||||
*buffer += 1;
|
||||
**buffer = pusParams.secHeader.subservice;
|
||||
*buffer += 1;
|
||||
*size += 3;
|
||||
result = SerializeAdapter::serialize(&pusParams.secHeader.messageTypeCounter, buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::serialize(&pusParams.secHeader.destId, buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = pusParams.secHeader.timeStamper->serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
if (pusParams.dataWrapper.type == ecss::DataTypes::RAW and
|
||||
pusParams.dataWrapper.dataUnion.raw.data != nullptr) {
|
||||
std::memcpy(*buffer, pusParams.dataWrapper.dataUnion.raw.data, userDataLen);
|
||||
*buffer += userDataLen;
|
||||
*size += userDataLen;
|
||||
} else if (pusParams.dataWrapper.type == ecss::DataTypes::SERIALIZABLE and
|
||||
pusParams.dataWrapper.dataUnion.serializable != nullptr) {
|
||||
result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
uint16_t crc16 = CRC::crc16ccitt(*buffer, getFullPacketLen() - 2);
|
||||
return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
|
||||
size_t PusTmCreator::getSerializedSize() const { return getFullPacketLen(); }
|
||||
ReturnValue_t PusTmCreator::deSerialize(const uint8_t** buffer, size_t* size,
|
||||
SerializeIF::Endianness streamEndianness) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
ecss::DataWrapper& PusTmCreator::getDataWrapper() { return pusParams.dataWrapper; }
|
||||
TimeStamperIF* PusTmCreator::getTimestamper() { return pusParams.secHeader.timeStamper; }
|
||||
SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); }
|
||||
|
||||
void PusTmCreator::updateSpLengthField() {
|
||||
size_t headerLen = PusTmIF::MIN_TM_SIZE;
|
||||
if (pusParams.secHeader.timeStamper != nullptr) {
|
||||
headerLen += pusParams.secHeader.timeStamper->getSerializedSize();
|
||||
}
|
||||
spCreator.setDataLen(headerLen + pusParams.dataWrapper.getLength() + 1);
|
||||
}
|
||||
|
||||
void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); };
|
||||
|
@ -1,33 +1,62 @@
|
||||
#ifndef FSFW_TMTCPACKET_TMPACKETCREATOR_H
|
||||
#define FSFW_TMTCPACKET_TMPACKETCREATOR_H
|
||||
|
||||
#include "fsfw/tmtcpacket/pus/PusIF.h"
|
||||
#include "PusTmIF.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h"
|
||||
#include "fsfw/tmtcpacket/pus/CreatorDataIF.h"
|
||||
|
||||
struct PusTmParams {
|
||||
struct PusTmSecHeader {
|
||||
uint8_t pusVersion;
|
||||
uint8_t scTimeRefStatus;
|
||||
uint8_t service;
|
||||
uint8_t subservice;
|
||||
uint16_t messageTypeCounter;
|
||||
uint16_t destId;
|
||||
uint8_t* timestamp;
|
||||
size_t timestampLen;
|
||||
TimeStamperIF* timeStamper;
|
||||
};
|
||||
class PusTmCreator : public PusIF {
|
||||
public:
|
||||
~PusTmCreator() override = default;
|
||||
explicit PusTmCreator(PusTmParams& params);
|
||||
|
||||
struct PusTmParams {
|
||||
PusTmSecHeader secHeader;
|
||||
ecss::DataWrapper dataWrapper;
|
||||
};
|
||||
|
||||
class TimeStamperIF;
|
||||
|
||||
class PusTmCreator : public SerializeIF, public PusTmIF, public CreatorDataIF {
|
||||
public:
|
||||
PusTmCreator();
|
||||
|
||||
explicit PusTmCreator(TimeStamperIF* timeStamper);
|
||||
PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams,
|
||||
TimeStamperIF* timeStamper);
|
||||
~PusTmCreator() override = default;
|
||||
|
||||
void setTimeStamper(TimeStamperIF* timeStamper);
|
||||