From 25db9bc9ed8bb53b211d1e0ea5b46ed6967888c6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Dec 2020 21:30:39 +0100 Subject: [PATCH 01/12] tmtcservices update --- pus/servicepackets/Service1Packets.h | 8 ++--- tcdistribution/PUSDistributor.cpp | 4 +-- tmtcservices/AcceptsTelecommandsIF.h | 12 +++---- tmtcservices/AcceptsTelemetryIF.h | 9 ++--- tmtcservices/AcceptsVerifyMessageIF.h | 6 ++-- tmtcservices/CommandingServiceBase.cpp | 40 +++++++++++----------- tmtcservices/CommandingServiceBase.h | 10 +++--- tmtcservices/PusServiceBase.cpp | 47 ++++++++++++++------------ tmtcservices/PusServiceBase.h | 13 +++---- tmtcservices/PusVerificationReport.cpp | 2 +- tmtcservices/PusVerificationReport.h | 2 -- tmtcservices/ServiceTypes.h | 8 +---- tmtcservices/SourceSequenceCounter.h | 12 ++----- tmtcservices/TmTcBridge.cpp | 8 ++--- tmtcservices/TmTcBridge.h | 10 +++--- tmtcservices/TmTcMessage.cpp | 11 +++--- tmtcservices/TmTcMessage.h | 16 ++++----- tmtcservices/VerificationCodes.h | 2 +- 18 files changed, 107 insertions(+), 113 deletions(-) diff --git a/pus/servicepackets/Service1Packets.h b/pus/servicepackets/Service1Packets.h index ecb62693..2249b4b0 100644 --- a/pus/servicepackets/Service1Packets.h +++ b/pus/servicepackets/Service1Packets.h @@ -49,7 +49,7 @@ public: if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - if (failureSubtype == TC_VERIFY::PROGRESS_FAILURE) { + if (failureSubtype == tc_verification::PROGRESS_FAILURE) { result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { @@ -77,7 +77,7 @@ public: size_t size = 0; size += SerializeAdapter::getSerializedSize(&packetId); size += sizeof(packetSequenceControl); - if(failureSubtype==TC_VERIFY::PROGRESS_FAILURE){ + if(failureSubtype==tc_verification::PROGRESS_FAILURE){ size += SerializeAdapter::getSerializedSize(&stepNumber); } size += SerializeAdapter::getSerializedSize(&errorCode); @@ -131,7 +131,7 @@ public: if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - if (subtype == TC_VERIFY::PROGRESS_SUCCESS) { + if (subtype == tc_verification::PROGRESS_SUCCESS) { result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { @@ -145,7 +145,7 @@ public: size_t size = 0; size += SerializeAdapter::getSerializedSize(&packetId); size += sizeof(packetSequenceControl); - if(subtype == TC_VERIFY::PROGRESS_SUCCESS){ + if(subtype == tc_verification::PROGRESS_SUCCESS){ size += SerializeAdapter::getSerializedSize(&stepNumber); } return size; diff --git a/tcdistribution/PUSDistributor.cpp b/tcdistribution/PUSDistributor.cpp index d964202f..8e5b94cc 100644 --- a/tcdistribution/PUSDistributor.cpp +++ b/tcdistribution/PUSDistributor.cpp @@ -77,14 +77,14 @@ ReturnValue_t PUSDistributor::callbackAfterSending(ReturnValue_t queueStatus) { tcStatus = queueStatus; } if (tcStatus != RETURN_OK) { - this->verifyChannel.sendFailureReport(TC_VERIFY::ACCEPTANCE_FAILURE, + this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, currentPacket, tcStatus); // A failed packet is deleted immediately after reporting, // otherwise it will block memory. currentPacket->deletePacket(); return RETURN_FAILED; } else { - this->verifyChannel.sendSuccessReport(TC_VERIFY::ACCEPTANCE_SUCCESS, + this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, currentPacket); return RETURN_OK; } diff --git a/tmtcservices/AcceptsTelecommandsIF.h b/tmtcservices/AcceptsTelecommandsIF.h index 76d10a59..bff0e955 100644 --- a/tmtcservices/AcceptsTelecommandsIF.h +++ b/tmtcservices/AcceptsTelecommandsIF.h @@ -1,5 +1,5 @@ -#ifndef ACCEPTSTELECOMMANDSIF_H_ -#define ACCEPTSTELECOMMANDSIF_H_ +#ifndef FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_ +#define FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_ #include "../ipc/MessageQueueSenderIF.h" @@ -12,7 +12,7 @@ class AcceptsTelecommandsIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::ACCEPTS_TELECOMMANDS_IF; - static const ReturnValue_t ACTIVITY_STARTED = MAKE_RETURN_CODE(1); + static const ReturnValue_t ACTIVITY_STARTED = MAKE_RETURN_CODE(1); // is this used anywhere or can it be removed? static const ReturnValue_t INVALID_SUBSERVICE = MAKE_RETURN_CODE(2); static const ReturnValue_t ILLEGAL_APPLICATION_DATA = MAKE_RETURN_CODE(3); static const ReturnValue_t SEND_TM_FAILED = MAKE_RETURN_CODE(4); @@ -26,9 +26,9 @@ public: /** * @brief Getter for the service id. * @details Any receiving service (at least any PUS service) shall have a - * service id. If the receiver can handle Telecommands, but for + * service ID. If the receiver can handle Telecommands, but for * some reason has no service id, it shall return 0. - * @return The service id or 0. + * @return The service ID or 0. */ virtual uint16_t getIdentifier() = 0; /** @@ -40,4 +40,4 @@ public: }; -#endif /* ACCEPTSTELECOMMANDSIF_H_ */ +#endif /* FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_ */ diff --git a/tmtcservices/AcceptsTelemetryIF.h b/tmtcservices/AcceptsTelemetryIF.h index 2325dbe0..43173d89 100644 --- a/tmtcservices/AcceptsTelemetryIF.h +++ b/tmtcservices/AcceptsTelemetryIF.h @@ -1,5 +1,5 @@ -#ifndef ACCEPTSTELEMETRYIF_H_ -#define ACCEPTSTELEMETRYIF_H_ +#ifndef FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ +#define FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ #include "../ipc/MessageQueueSenderIF.h" /** @@ -20,7 +20,8 @@ public: * receiving message queue. * @return The telemetry reception message queue id. */ - virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) = 0; + virtual MessageQueueId_t getReportReceptionQueue( + uint8_t virtualChannel = 0) = 0; }; -#endif /* ACCEPTSTELEMETRYIF_H_ */ +#endif /* FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ */ diff --git a/tmtcservices/AcceptsVerifyMessageIF.h b/tmtcservices/AcceptsVerifyMessageIF.h index c9318ab0..d16def4d 100644 --- a/tmtcservices/AcceptsVerifyMessageIF.h +++ b/tmtcservices/AcceptsVerifyMessageIF.h @@ -1,5 +1,5 @@ -#ifndef ACCEPTSVERIFICATIONMESSAGEIF_H_ -#define ACCEPTSVERIFICATIONMESSAGEIF_H_ +#ifndef FSFW_TMTCSERVICES_ACCEPTSVERIFICATIONMESSAGEIF_H_ +#define FSFW_TMTCSERVICES_ACCEPTSVERIFICATIONMESSAGEIF_H_ #include "../ipc/MessageQueueSenderIF.h" @@ -12,4 +12,4 @@ public: }; -#endif /* ACCEPTSVERIFICATIONMESSAGEIF_H_ */ +#endif /* FSFW_TMTCSERVICES_ACCEPTSVERIFICATIONMESSAGEIF_H_ */ diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index 0ebc3944..ed765ecc 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -1,9 +1,9 @@ -#include "../tcdistribution/PUSDistributorIF.h" #include "AcceptsTelemetryIF.h" -#include "../objectmanager/ObjectManagerIF.h" - #include "CommandingServiceBase.h" #include "TmTcMessage.h" + +#include "../tcdistribution/PUSDistributorIF.h" +#include "../objectmanager/ObjectManagerIF.h" #include "../ipc/QueueFactory.h" #include "../tmtcpacket/pus/TcPacketStored.h" #include "../tmtcpacket/pus/TmPacketStored.h" @@ -149,13 +149,13 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { default: if (isStep) { verificationReporter.sendFailureReport( - TC_VERIFY::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, + tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, result, ++iter->second.step, failureParameter1, failureParameter2); } else { verificationReporter.sendFailureReport( - TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, + tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, result, 0, failureParameter1, failureParameter2); } @@ -184,13 +184,13 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, if (sendResult == RETURN_OK) { if (isStep and result != NO_STEP_MESSAGE) { verificationReporter.sendSuccessReport( - TC_VERIFY::PROGRESS_SUCCESS, + tc_verification::PROGRESS_SUCCESS, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, ++iter->second.step); } else { verificationReporter.sendSuccessReport( - TC_VERIFY::COMPLETION_SUCCESS, + tc_verification::COMPLETION_SUCCESS, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, 0); checkAndExecuteFifo(iter); @@ -200,14 +200,14 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, if (isStep) { nextCommand->clearCommandMessage(); verificationReporter.sendFailureReport( - TC_VERIFY::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, + tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, sendResult, ++iter->second.step, failureParameter1, failureParameter2); } else { nextCommand->clearCommandMessage(); verificationReporter.sendFailureReport( - TC_VERIFY::COMPLETION_FAILURE, + tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, sendResult, 0, failureParameter1, failureParameter2); @@ -232,14 +232,14 @@ void CommandingServiceBase::handleRequestQueue() { if ((packet.getSubService() == 0) or (isValidSubservice(packet.getSubService()) != RETURN_OK)) { - rejectPacket(TC_VERIFY::START_FAILURE, &packet, INVALID_SUBSERVICE); + rejectPacket(tc_verification::START_FAILURE, &packet, INVALID_SUBSERVICE); continue; } result = getMessageQueueAndObject(packet.getSubService(), packet.getApplicationData(), packet.getApplicationDataSize(), &queue, &objectId); if (result != HasReturnvaluesIF::RETURN_OK) { - rejectPacket(TC_VERIFY::START_FAILURE, &packet, result); + rejectPacket(tc_verification::START_FAILURE, &packet, result); continue; } @@ -250,14 +250,14 @@ void CommandingServiceBase::handleRequestQueue() { if (iter != commandMap.end()) { result = iter->second.fifo.insert(address); if (result != RETURN_OK) { - rejectPacket(TC_VERIFY::START_FAILURE, &packet, OBJECT_BUSY); + rejectPacket(tc_verification::START_FAILURE, &packet, OBJECT_BUSY); } } else { CommandInfo newInfo; //Info will be set by startExecution if neccessary newInfo.objectId = objectId; result = commandMap.insert(queue, newInfo, &iter); if (result != RETURN_OK) { - rejectPacket(TC_VERIFY::START_FAILURE, &packet, BUSY); + rejectPacket(tc_verification::START_FAILURE, &packet, BUSY); } else { startExecution(&packet, iter); } @@ -338,10 +338,10 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket, iter->second.tcInfo.tcPacketId = storedPacket->getPacketId(); iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSequenceControl(); - acceptPacket(TC_VERIFY::START_SUCCESS, storedPacket); + acceptPacket(tc_verification::START_SUCCESS, storedPacket); } else { command.clearCommandMessage(); - rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult); + rejectPacket(tc_verification::START_FAILURE, storedPacket, sendResult); checkAndExecuteFifo(iter); } break; @@ -352,18 +352,18 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket, &command); } if (sendResult == RETURN_OK) { - verificationReporter.sendSuccessReport(TC_VERIFY::START_SUCCESS, + verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS, storedPacket); - acceptPacket(TC_VERIFY::COMPLETION_SUCCESS, storedPacket); + acceptPacket(tc_verification::COMPLETION_SUCCESS, storedPacket); checkAndExecuteFifo(iter); } else { command.clearCommandMessage(); - rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult); + rejectPacket(tc_verification::START_FAILURE, storedPacket, sendResult); checkAndExecuteFifo(iter); } break; default: - rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, result); + rejectPacket(tc_verification::START_FAILURE, storedPacket, result); checkAndExecuteFifo(iter); break; } @@ -414,7 +414,7 @@ void CommandingServiceBase::checkTimeout() { for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) { if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) { verificationReporter.sendFailureReport( - TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, + tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, TIMEOUT); checkAndExecuteFifo(iter); diff --git a/tmtcservices/CommandingServiceBase.h b/tmtcservices/CommandingServiceBase.h index 252b6943..3611d7c6 100644 --- a/tmtcservices/CommandingServiceBase.h +++ b/tmtcservices/CommandingServiceBase.h @@ -1,18 +1,20 @@ #ifndef FSFW_TMTCSERVICES_COMMANDINGSERVICEBASE_H_ #define FSFW_TMTCSERVICES_COMMANDINGSERVICEBASE_H_ +#include "AcceptsTelecommandsIF.h" +#include "VerificationReporter.h" + #include "../objectmanager/SystemObject.h" #include "../storagemanager/StorageManagerIF.h" #include "../tasks/ExecutableObjectIF.h" #include "../ipc/MessageQueueIF.h" -#include "AcceptsTelecommandsIF.h" - -#include "VerificationReporter.h" #include "../ipc/CommandMessage.h" #include "../container/FixedMap.h" #include "../container/FIFO.h" #include "../serialize/SerializeIF.h" +#include + class TcPacketStored; namespace Factory{ @@ -40,7 +42,7 @@ class CommandingServiceBase: public SystemObject, friend void (Factory::setStaticFrameworkObjectIds)(); public: // We could make this configurable via preprocessor and the FSFWConfig file. - static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH = 3; + static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH = FSFW_CSB_FIFO_DEPTH; static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE; diff --git a/tmtcservices/PusServiceBase.cpp b/tmtcservices/PusServiceBase.cpp index d35944a4..cb5a1247 100644 --- a/tmtcservices/PusServiceBase.cpp +++ b/tmtcservices/PusServiceBase.cpp @@ -1,9 +1,10 @@ -#include "../serviceinterface/ServiceInterfaceStream.h" -#include "../tcdistribution/PUSDistributorIF.h" -#include "AcceptsTelemetryIF.h" #include "PusServiceBase.h" +#include "AcceptsTelemetryIF.h" #include "PusVerificationReport.h" #include "TmTcMessage.h" + +#include "../serviceinterface/ServiceInterfaceStream.h" +#include "../tcdistribution/PUSDistributorIF.h" #include "../ipc/QueueFactory.h" object_id_t PusServiceBase::packetSource = 0; @@ -41,9 +42,14 @@ void PusServiceBase::handleRequestQueue() { ReturnValue_t result = RETURN_FAILED; for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) { ReturnValue_t status = this->requestQueue->receiveMessage(&message); - // debug << "PusServiceBase::performOperation: Receiving from MQ ID: " - // << std::hex << this->requestQueue.getId() - // << std::dec << " returned: " << status << std::endl; +// if(status != MessageQueueIF::EMPTY) { +// sif::debug << "PusServiceBase::performOperation: Receiving from " +// << "MQ ID: " << std::hex << "0x" << std::setw(8) +// << std::setfill('0') << this->requestQueue->getId() +// << std::dec << " returned: " << status << std::setfill(' ') +// << std::endl; +// } + if (status == RETURN_OK) { this->currentPacket.setStoreAddress(message.getStorageId()); //info << "Service " << (uint16_t) this->serviceId << @@ -55,11 +61,11 @@ void PusServiceBase::handleRequestQueue() { // ": handleRequest returned: " << (int)return_code << std::endl; if (result == RETURN_OK) { this->verifyReporter.sendSuccessReport( - TC_VERIFY::COMPLETION_SUCCESS, &this->currentPacket); + tc_verification::COMPLETION_SUCCESS, &this->currentPacket); } else { this->verifyReporter.sendFailureReport( - TC_VERIFY::COMPLETION_FAILURE, &this->currentPacket, + tc_verification::COMPLETION_FAILURE, &this->currentPacket, result, 0, errorParameter1, errorParameter2); } this->currentPacket.deletePacket(); @@ -74,9 +80,8 @@ void PusServiceBase::handleRequestQueue() { } else { sif::error << "PusServiceBase::performOperation: Service " - << (uint16_t) this->serviceId - << ": Error receiving packet. Code: " << std::hex << status - << std::dec << std::endl; + << this->serviceId << ": Error receiving packet. Code: " + << std::hex << status << std::dec << std::endl; } } } @@ -98,19 +103,17 @@ ReturnValue_t PusServiceBase::initialize() { packetDestination); PUSDistributorIF* distributor = objectManager->get( packetSource); - if ((destService != nullptr) && (distributor != nullptr)) { - this->requestQueue->setDefaultDestination( - destService->getReportReceptionQueue()); - distributor->registerService(this); - return RETURN_OK; - } - else { + if (destService == nullptr or distributor == nullptr) { sif::error << "PusServiceBase::PusServiceBase: Service " - << (uint32_t) this->serviceId << ": Configuration error." - << " Make sure packetSource and packetDestination are defined " - "correctly" << std::endl; - return RETURN_FAILED; + << this->serviceId << ": Configuration error. Make sure " + << "packetSource and packetDestination are defined correctly" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; } + this->requestQueue->setDefaultDestination( + destService->getReportReceptionQueue()); + distributor->registerService(this); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PusServiceBase::initializeAfterTaskCreation() { diff --git a/tmtcservices/PusServiceBase.h b/tmtcservices/PusServiceBase.h index 98d65efb..4d3d99bc 100644 --- a/tmtcservices/PusServiceBase.h +++ b/tmtcservices/PusServiceBase.h @@ -1,14 +1,15 @@ -#ifndef FRAMEWORK_TMTCSERVICES_PUSSERVICEBASE_H_ -#define FRAMEWORK_TMTCSERVICES_PUSSERVICEBASE_H_ +#ifndef FSFW_TMTCSERVICES_PUSSERVICEBASE_H_ +#define FSFW_TMTCSERVICES_PUSSERVICEBASE_H_ + +#include "AcceptsTelecommandsIF.h" +#include "VerificationCodes.h" +#include "VerificationReporter.h" #include "../objectmanager/ObjectManagerIF.h" #include "../objectmanager/SystemObject.h" #include "../returnvalues/HasReturnvaluesIF.h" #include "../tasks/ExecutableObjectIF.h" #include "../tmtcpacket/pus/TcPacketStored.h" -#include "AcceptsTelecommandsIF.h" -#include "VerificationCodes.h" -#include "VerificationReporter.h" #include "../ipc/MessageQueueIF.h" namespace Factory{ @@ -156,4 +157,4 @@ private: void handleRequestQueue(); }; -#endif /* PUSSERVICEBASE_H_ */ +#endif /* FSFW_TMTCSERVICES_PUSSERVICEBASE_H_ */ diff --git a/tmtcservices/PusVerificationReport.cpp b/tmtcservices/PusVerificationReport.cpp index bfad9ec5..c64e5feb 100644 --- a/tmtcservices/PusVerificationReport.cpp +++ b/tmtcservices/PusVerificationReport.cpp @@ -1,5 +1,5 @@ #include "../serialize/SerializeAdapter.h" -#include "PusVerificationReport.h" +#include "../tmtcservices/PusVerificationReport.h" PusVerificationMessage::PusVerificationMessage() { } diff --git a/tmtcservices/PusVerificationReport.h b/tmtcservices/PusVerificationReport.h index 88954cfd..9dce95ac 100644 --- a/tmtcservices/PusVerificationReport.h +++ b/tmtcservices/PusVerificationReport.h @@ -7,8 +7,6 @@ #include "../tmtcpacket/pus/TcPacketBase.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include - class PusVerificationMessage: public MessageQueueMessage { private: struct verifciationMessageContent { diff --git a/tmtcservices/ServiceTypes.h b/tmtcservices/ServiceTypes.h index 1f5bff42..552601f9 100644 --- a/tmtcservices/ServiceTypes.h +++ b/tmtcservices/ServiceTypes.h @@ -1,13 +1,7 @@ -/** - * @file ServiceTypes.h - * @brief This file defines the ServiceTypes class. - * @date 11.04.2013 - * @author baetz - */ - #ifndef SERVICETYPES_H_ #define SERVICETYPES_H_ +// SHOULDDO: This is a duplication of existing configuration structures. Delete it? namespace SERVICE { enum ServiceTypes { TELECOMMAND_VERIFICATION = 1, diff --git a/tmtcservices/SourceSequenceCounter.h b/tmtcservices/SourceSequenceCounter.h index 1cc58758..2b30a53f 100644 --- a/tmtcservices/SourceSequenceCounter.h +++ b/tmtcservices/SourceSequenceCounter.h @@ -1,12 +1,6 @@ -/** - * @file SourceSequenceCounter.h - * @brief This file defines the SourceSequenceCounter class. - * @date 04.02.2013 - * @author baetz - */ +#ifndef FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ +#define FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ -#ifndef SOURCESEQUENCECOUNTER_H_ -#define SOURCESEQUENCECOUNTER_H_ #include "../tmtcpacket/SpacePacketBase.h" class SourceSequenceCounter { @@ -27,4 +21,4 @@ public: }; -#endif /* SOURCESEQUENCECOUNTER_H_ */ +#endif /* FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ */ diff --git a/tmtcservices/TmTcBridge.cpp b/tmtcservices/TmTcBridge.cpp index 8c2f15e5..b4e9967b 100644 --- a/tmtcservices/TmTcBridge.cpp +++ b/tmtcservices/TmTcBridge.cpp @@ -1,7 +1,6 @@ -#include "../tmtcservices/TmTcBridge.h" +#include "TmTcBridge.h" #include "../ipc/QueueFactory.h" -#include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../serviceinterface/ServiceInterfaceStream.h" #include "../globalfunctions/arrayprinter.h" @@ -95,8 +94,9 @@ ReturnValue_t TmTcBridge::handleTm() { ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = handleTmQueue(); if(result != RETURN_OK) { - sif::error << "TmTcBridge::handleTm: Error handling TM queue!" - << std::endl; + sif::error << "TmTcBridge::handleTm: Error handling TM queue with " + << "error code 0x" << std::hex << result << std::dec + << "!" << std::endl; status = result; } diff --git a/tmtcservices/TmTcBridge.h b/tmtcservices/TmTcBridge.h index 62cfdaac..0177648c 100644 --- a/tmtcservices/TmTcBridge.h +++ b/tmtcservices/TmTcBridge.h @@ -1,13 +1,13 @@ -#ifndef FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_ -#define FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_ +#ifndef FSFW_TMTCSERVICES_TMTCBRIDGE_H_ +#define FSFW_TMTCSERVICES_TMTCBRIDGE_H_ +#include "AcceptsTelemetryIF.h" +#include "AcceptsTelecommandsIF.h" #include "../objectmanager/SystemObject.h" -#include "../tmtcservices/AcceptsTelemetryIF.h" #include "../tasks/ExecutableObjectIF.h" #include "../ipc/MessageQueueIF.h" #include "../storagemanager/StorageManagerIF.h" -#include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../container/DynamicFIFO.h" #include "../tmtcservices/TmTcMessage.h" @@ -159,4 +159,4 @@ protected: }; -#endif /* FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_ */ +#endif /* FSFW_TMTCSERVICES_TMTCBRIDGE_H_ */ diff --git a/tmtcservices/TmTcMessage.cpp b/tmtcservices/TmTcMessage.cpp index 987bd232..ae028315 100644 --- a/tmtcservices/TmTcMessage.cpp +++ b/tmtcservices/TmTcMessage.cpp @@ -1,5 +1,6 @@ #include "TmTcMessage.h" -#include + +#include TmTcMessage::TmTcMessage() { @@ -15,15 +16,15 @@ store_address_t TmTcMessage::getStorageId() { return temp_id; } -TmTcMessage::TmTcMessage(store_address_t store_id) { +TmTcMessage::TmTcMessage(store_address_t storeId) { this->messageSize += sizeof(store_address_t); - this->setStorageId(store_id); + this->setStorageId(storeId); } size_t TmTcMessage::getMinimumMessageSize() { return this->HEADER_SIZE + sizeof(store_address_t); } -void TmTcMessage::setStorageId(store_address_t store_id) { - memcpy(this->getData(), &store_id, sizeof(store_address_t) ); +void TmTcMessage::setStorageId(store_address_t storeId) { + memcpy(this->getData(), &storeId, sizeof(store_address_t) ); } diff --git a/tmtcservices/TmTcMessage.h b/tmtcservices/TmTcMessage.h index b5e1ff8d..41fe198a 100644 --- a/tmtcservices/TmTcMessage.h +++ b/tmtcservices/TmTcMessage.h @@ -1,5 +1,5 @@ -#ifndef TMTCMESSAGE_H_ -#define TMTCMESSAGE_H_ +#ifndef FSFW_TMTCSERVICES_TMTCMESSAGE_H_ +#define FSFW_TMTCSERVICES_TMTCMESSAGE_H_ #include "../ipc/MessageQueueMessage.h" #include "../storagemanager/StorageManagerIF.h" @@ -10,13 +10,13 @@ * a packet stored in one of the IPC stores (typically a special TM and * a special TC store). This makes passing commands very simple and * efficient. - * \ingroup message_queue + * @ingroup message_queue */ class TmTcMessage : public MessageQueueMessage { protected: /** * @brief This call always returns the same fixed size of the message. - * @return Returns HEADER_SIZE + \c sizeof(store_address_t). + * @return Returns HEADER_SIZE + @c sizeof(store_address_t). */ size_t getMinimumMessageSize(); public: @@ -29,7 +29,7 @@ public: * into the message. * @param packet_id The packet id to put into the message. */ - TmTcMessage( store_address_t packet_id ); + TmTcMessage( store_address_t packetId ); /** * @brief The class's destructor is empty. */ @@ -42,9 +42,9 @@ public: /** * @brief In some cases it might be useful to have a setter for packet id * as well. - * @param packet_id The packet id to put into the message. + * @param packetId The packet id to put into the message. */ - void setStorageId( store_address_t packet_id ); + void setStorageId( store_address_t packetId ); }; -#endif /* TMTCMESSAGE_H_ */ +#endif /* FSFW_TMTCSERVICES_TMTCMESSAGE_H_ */ diff --git a/tmtcservices/VerificationCodes.h b/tmtcservices/VerificationCodes.h index e3e89b5a..35ad6819 100644 --- a/tmtcservices/VerificationCodes.h +++ b/tmtcservices/VerificationCodes.h @@ -1,7 +1,7 @@ #ifndef VERIFICATIONCODES_H_ #define VERIFICATIONCODES_H_ -namespace TC_VERIFY { +namespace tc_verification { enum verification_flags { NONE = 0b0000, From 703d2590ffbf21603e37a2ecad50e3a7d1a767ec Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Dec 2020 15:20:08 +0100 Subject: [PATCH 02/12] update csb --- CHANGELOG | 4 ++++ tmtcservices/CommandingServiceBase.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7b07db08..2ddd7673 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -60,3 +60,7 @@ that DHB users adapt their polling sequence tables to perform this step. This st allows setting a unique ID. Event.cpp source file removed, functions now defined in header directly. Namespaces renamed. Functions declared `constexpr` now + +### Commanding Service Base + +- CSB uses the diff --git a/tmtcservices/CommandingServiceBase.h b/tmtcservices/CommandingServiceBase.h index 3611d7c6..e10f2ddd 100644 --- a/tmtcservices/CommandingServiceBase.h +++ b/tmtcservices/CommandingServiceBase.h @@ -42,7 +42,8 @@ class CommandingServiceBase: public SystemObject, friend void (Factory::setStaticFrameworkObjectIds)(); public: // We could make this configurable via preprocessor and the FSFWConfig file. - static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH = FSFW_CSB_FIFO_DEPTH; + static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH = + fsfwconfig::FSFW_CSB_FIFO_DEPTH; static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE; From 72c54d59fac16ceaeb3d32458c6de5e28f60c18e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Dec 2020 15:32:56 +0100 Subject: [PATCH 03/12] fsfw config --- defaultcfg/fsfwconfig/FSFWConfig.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/defaultcfg/fsfwconfig/FSFWConfig.h b/defaultcfg/fsfwconfig/FSFWConfig.h index 1386bf66..334f352a 100644 --- a/defaultcfg/fsfwconfig/FSFWConfig.h +++ b/defaultcfg/fsfwconfig/FSFWConfig.h @@ -15,12 +15,6 @@ //! Can be used to enable additional debugging printouts for developing the FSFW #define FSFW_PRINT_VERBOSITY_LEVEL 0 -//! Defines the FIFO depth of each commanding service base which -//! also determines how many commands a CSB service can handle in one cycle -//! simulataneously. This will increase the required RAM for -//! each CSB service ! -#define FSFW_CSB_FIFO_DEPTH 6 - //! If FSFW_OBJ_EVENT_TRANSLATION is set to one, //! additional output which requires the translation files translateObjects //! and translateEvents (and their compiled source files) @@ -52,6 +46,12 @@ static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8; static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; + +//! Defines the FIFO depth of each commanding service base which +//! also determines how many commands a CSB service can handle in one cycle +//! simulataneously. This will increase the required RAM for +//! each CSB service ! +static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6; } #endif /* CONFIG_FSFWCONFIG_H_ */ From 82a83a50ee01613c4227407b846173555015b4b4 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Dec 2020 15:39:33 +0100 Subject: [PATCH 04/12] change log update --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 2ddd7673..68b457f4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -63,4 +63,4 @@ now ### Commanding Service Base -- CSB uses the +- CSB uses the new fsfwconfig::FSFW_CSB_FIFO_DEPTH variable to determine the FIFO depth for each CSB instance. This variable has to be set in the FSFWConfig.h file From b28bf35fc340cf9718af100c7531f15ea6bf1a8f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Dec 2020 12:44:55 +0100 Subject: [PATCH 05/12] devicehandler updates --- devicehandlers/DeviceHandlerBase.cpp | 10 +++- devicehandlers/DeviceHandlerBase.h | 69 ++++++++++++++-------------- devicehandlers/DeviceHandlerIF.h | 2 +- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index f095834e..cb040714 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -928,7 +928,7 @@ void DeviceHandlerBase::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { uint32_t DeviceHandlerBase::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 0; + return 5000; } ReturnValue_t DeviceHandlerBase::getStateOfSwitches(void) { @@ -1459,3 +1459,11 @@ DeviceCommandId_t DeviceHandlerBase::getPendingCommand() const { } return DeviceHandlerIF::NO_COMMAND; } + +void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() { + for(const auto& reply: deviceReplyMap) { + if(reply.second.dataSet != nullptr) { + reply.second.dataSet->setValidity(false, true); + } + } +} diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 9a5287e0..ee4447ed 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -254,9 +254,10 @@ protected: * * @param[out] id the device command id that has been built * @return - * - @c RETURN_OK to send command after setting #rawPacket and #rawPacketLen. - * - @c NOTHING_TO_SEND when no command is to be sent. - * - Anything else triggers an even with the returnvalue as a parameter. + * - @c RETURN_OK to send command after setting #rawPacket and + * #rawPacketLen. + * - @c NOTHING_TO_SEND when no command is to be sent. + * - Anything else triggers an even with the returnvalue as a parameter. */ virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) = 0; @@ -273,7 +274,8 @@ protected: * and filling them in doStartUp(), doShutDown() and doTransition() so no * modes have to be checked here. * - * #rawPacket and #rawPacketLen must be set by this method to the packet to be sent. + * #rawPacket and #rawPacketLen must be set by this method to the + * packet to be sent. * * @param[out] id the device command id built * @return @@ -284,19 +286,23 @@ protected: virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) = 0; /** - * @brief Build a device command packet from data supplied by a direct command. + * @brief Build a device command packet from data supplied by a + * direct command. * * @details - * #rawPacket and #rawPacketLen should be set by this method to the packet to be sent. - * The existence of the command in the command map and the command size check - * against 0 are done by the base class. + * #rawPacket and #rawPacketLen should be set by this method to the packet + * to be sent. The existence of the command in the command map and the + * command size check against 0 are done by the base class. * - * @param deviceCommand the command to build, already checked against deviceCommandMap + * @param deviceCommand the command to build, already checked against + * deviceCommandMap * @param commandData pointer to the data from the direct command * @param commandDataLen length of commandData * @return - * - @c RETURN_OK to send command after #rawPacket and #rawPacketLen have been set. - * - Anything else triggers an event with the returnvalue as a parameter + * - @c RETURN_OK to send command after #rawPacket and #rawPacketLen + * have been set. + * - Anything else triggers an event with the + * returnvalue as a parameter */ virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t * commandData, size_t commandDataLen) = 0; @@ -681,7 +687,7 @@ protected: //! The dataset used to access housekeeping data related to the //! respective device reply. Will point to a dataset held by //! the child handler (if one is specified) - LocalPoolDataSetBase* dataSet; + LocalPoolDataSetBase* dataSet = nullptr; //! The command that expects this reply. DeviceCommandMap::iterator command; }; @@ -743,6 +749,17 @@ protected: //!< Object which may be the root cause of an identified fault. static object_id_t defaultFdirParentId; + /** + * @brief Set all datapool variables that are update periodically in + * normal mode invalid + * @details + * The default implementation will set all datasets which have been added + * in #fillCommandAndReplyMap to invalid. It will also set all pool + * variables inside the dataset to invalid. The user can override this + * method optionally. + */ + virtual void setNormalDatapoolEntriesInvalid(); + /** * Helper function to get pending command. This is useful for devices * like SPI sensors to identify the last sent command. @@ -785,7 +802,6 @@ protected: * * The submode is left unchanged. * - * * @param newMode */ void setMode(Mode_t newMode); @@ -838,8 +854,6 @@ protected: virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom); /** - * Is the combination of mode and submode valid? - * * @param mode * @param submode * @return @@ -850,13 +864,10 @@ protected: Submode_t submode); /** - * Get the Rmap action for the current step. - * + * Get the communication action for the current step. * The step number can be read from #pstStep. - * - * @return The Rmap action to execute in this step + * @return The communication action to execute in this step */ - virtual CommunicationAction getComAction(); /** @@ -898,8 +909,8 @@ protected: * It gets space in the #IPCStore, copies data there, then sends a raw reply * containing the store address. * - * This method is virtual, as the STR has a different channel to send - * raw replies and overwrites it accordingly. + * This method is virtual, as devices can have different channels to send + * raw replies * * @param data data to send * @param len length of @c data @@ -918,7 +929,7 @@ protected: void replyRawReplyIfnotWiretapped(const uint8_t *data, size_t len); /** - * notify child about mode change + * @brief Notify child about mode change. */ virtual void modeChanged(void); @@ -950,8 +961,7 @@ protected: DeviceCommandId_t alternateReplyID = 0); /** - * get the state of the PCDU switches in the datapool - * + * Get the state of the PCDU switches in the local datapool * @return * - @c PowerSwitchIF::SWITCH_ON if all switches specified * by #switches are on @@ -961,15 +971,6 @@ protected: */ ReturnValue_t getStateOfSwitches(void); - /** - * @brief Set all datapool variables that are update periodically in - * normal mode invalid - * @details TODO: Use local pools - * Child classes should provide an implementation which sets all those - * variables invalid which are set periodically during any normal mode. - */ - virtual void setNormalDatapoolEntriesInvalid() = 0; - /** * build a list of sids and pass it to the #hkSwitcher */ diff --git a/devicehandlers/DeviceHandlerIF.h b/devicehandlers/DeviceHandlerIF.h index dba6b228..e5648751 100644 --- a/devicehandlers/DeviceHandlerIF.h +++ b/devicehandlers/DeviceHandlerIF.h @@ -131,7 +131,7 @@ public: // Standard codes used in interpretDeviceReply static const ReturnValue_t DEVICE_DID_NOT_EXECUTE = MAKE_RETURN_CODE(0xC0); //the device reported, that it did not execute the command static const ReturnValue_t DEVICE_REPORTED_ERROR = MAKE_RETURN_CODE(0xC1); - static const ReturnValue_t UNKNOW_DEVICE_REPLY = MAKE_RETURN_CODE(0xC2); //the deviceCommandId reported by scanforReply is unknown + static const ReturnValue_t UNKNOWN_DEVICE_REPLY = MAKE_RETURN_CODE(0xC2); //the deviceCommandId reported by scanforReply is unknown static const ReturnValue_t DEVICE_REPLY_INVALID = MAKE_RETURN_CODE(0xC3); //syntax etc is correct but still not ok, eg parameters where none are expected // Standard codes used in buildCommandFromCommand From 9de2b054ef6155293237cc928ca97bf2a5b0c718 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Dec 2020 12:53:03 +0100 Subject: [PATCH 06/12] updated changelog --- CHANGELOG | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 7b07db08..4e51bc64 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -53,6 +53,12 @@ ID for now. - There is an additional `PERFORM_OPERATION` step for the device handler base. It is important that DHB users adapt their polling sequence tables to perform this step. This steps allows for aclear distinction between operation and communication steps +- setNormalDatapoolEntriesInvalid is not an abstract method and a default implementation was provided +- getTransitionDelayMs now return 5000 ms instead of 0 in default implementation + +### DeviceHandlerIF + +- Typo for UNKNOWN_DEVICE_REPLY ### Events From 820731de7bfa40d88a592a927031793bbc73f873 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Dec 2020 13:23:19 +0100 Subject: [PATCH 07/12] updated docs, added new doc folder --- README.md | 100 ++++++++++++---------------------- doc/README-config.md | 21 +++++++ doc/README-core.md | 50 +++++++++++++++++ doc/README-devicehandlers.txt | 0 4 files changed, 106 insertions(+), 65 deletions(-) create mode 100644 doc/README-config.md create mode 100644 doc/README-core.md create mode 100644 doc/README-devicehandlers.txt diff --git a/README.md b/README.md index 4aabe36a..8552e0c8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ ![FSFW Logo](logo/FSFW_Logo_V3_bw.png) + # Flight Software Framework (FSFW) The Flight Software Framework is a C++ Object Oriented Framework for unmanned, @@ -14,83 +15,54 @@ The framework is designed for systems, which communicate with external devices, Therefore, a mode and health system provides control over the states of the software and the controlled devices. In addition, a simple mechanism of event based fault detection, isolation and recovery is implemented as well. -The recommended hardware is a microprocessor with more than 2 MB of RAM and 1 MB of non-volatile Memory. +The recommended hardware is a microprocessor with more than 1 MB of RAM and 1 MB of non-volatile Memory. For reference, current Applications use a Cobham Gaisler UT699 (LEON3FT), a ISISPACE IOBC or a Zynq-7020 SoC. +The `fsfw` was also tested on the STM32H743ZI-Nucleo board. +## How to Use + +The [FSFW example](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example) provides a good starting point and a demo +to see the FSFW capabilities and build it with the Make or the CMake build system. +Generally, the FSFW is included in a project by compiling the FSFW sources and providing +a configuration folder and adding it to the include path. +A template configuration folder was provided and can be copied into the project root to have +a starting point. The [configuration section](doc/README-config.md#top) provides more specific information about +the possible options. ## Structure -The general structure is driven by the usage of interfaces provided by objects. The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be widely available, even with older compilers. +The general structure is driven by the usage of interfaces provided by objects. +The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be widely available, even with older compilers. The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. This simplifies the instantiation of objects and allows the usage of some standard containers. Dynamic Allocation after initialization is discouraged and different solutions are provided in the FSFW to achieve that. -The fsfw uses Run-time type information. -Exceptions are not allowed. +The fsfw uses run-time type information but exceptions are not allowed. ### Failure Handling -Functions should return a defined ReturnValue_t to signal to the caller that something is gone wrong. +Functions should return a defined ReturnValue_t to signal to the caller that something has gone wrong. Returnvalues must be unique. For this the function HasReturnvaluesIF::makeReturnCode or the Macro MAKE_RETURN can be used. The CLASS_ID is a unique id for that type of object. See returnvalues/FwClassIds. ### OSAL -The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS. A independent OSAL called "host" is currently not finished. This aims to be running on windows as well. -The OSAL provides periodic tasks, message queues, clocks and Semaphores as well as Mutexes. + +The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS. +A independent Host OSAL is in development which will provide abstraction for common type of +host OSes (tested for Linux and Windows, not for MacOS yet). +The OSAL provides periodic tasks, message queues, clocks and semaphores as well as mutexes. ### Core Components -Clock: - * This is a class of static functions that can be used at anytime - * Leap Seconds must be set if any time conversions from UTC to other times is used - -ObjectManager (must be created): - -* The component which handles all references. All SystemObjects register at this component. -* Any SystemObject needs to have a unique ObjectId. Those can be managed like objects::framework_objects. -* A reference to an object can be get by calling the following function. T must be the specific Interface you want to call. -A nullptr check of the returning Pointer must be done. This function is based on Run-time type information. - -``` c++ - template T* ObjectManagerIF::get( object_id_t id ) - -``` -* A typical way to create all objects on startup is a handing a static produce function to the ObjectManager on creation. -By calling objectManager->initialize() the produce function will be called and all SystemObjects will be initialized afterwards. - -Event Manager: - -* Component which allows routing of events -* Other objects can subscribe to specific events, ranges of events or all events of an object. -* Subscriptions can be done during runtime but should be done during initialization -* Amounts of allowed subscriptions must be configured by setting this parameters: - -``` c++ -namespace fsfwconfig { -//! Configure the allocated pool sizes for the event manager. -static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; -static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; -static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; -} -``` - - -Health Table: - -* A component which holds every health state -* Provides a thread safe way to access all health states without the need of message exchanges - -Stores - -* The message based communication can only exchange a few bytes of information inside the message itself. Therefore, additional information can be exchanged with Stores. With this, only the store address must be exchanged in the message. -* Internally, the FSFW uses an IPC Store to exchange data between processes. For incoming TCs a TC Store is used. For outgoing TM a TM store is used. -* All of them should use the Thread Safe Class storagemanager/PoolManager - -Tasks - -There are two different types of tasks: - * The PeriodicTask just executes objects that are of type ExecutableObjectIF in the order of the insertion to the Tasks. - * FixedTimeslotTask executes a list of calls in the order of the given list. This is intended for DeviceHandlers, where polling should be in a defined order. An example can be found in defaultcfg/fsfwconfig/pollingSequence +The FSFW has following core components. More detailed informations can be found in the +[core component section](doc/README-core.md#top): +1. Tasks: Abstraction for different (periodic) task types like periodic tasks or tasks with fixed timeslots +2. ObjectManager: This module stores all `SystemObjects` by mapping a provided unique object ID to the object handles. +3. Static Stores: Different stores are provided to store data of variable size (like telecommands or small telemetry) in a pool structure without + using dynamic memory allocation. These pools are allocated up front. +3. Clock: This module provided common time related functions +4. EventManager: This module allows routing of events generated by `SystemObjects` +5. HealthTable: A component which stores the health states of objects ### Static Ids in the framework @@ -121,13 +93,15 @@ If the communication is based on CCSDS Frames and Space Packets, several classes If Space Packets are used, a timestamper must be created. An example can be found in the timemanager folder, this uses CCSDSTime::CDS_short. -#### DeviceHandling +#### Device Handlers -DeviceHandlers are a core component of the FSFW. +DeviceHandlers are another important component of the FSFW. The idea is, to have a software counterpart of every physical device to provide a simple mode, health and commanding interface. -By separating the underlying Communication Interface with DeviceCommunicationIF, a DH can be tested on different hardware. +By separating the underlying Communication Interface with DeviceCommunicationIF, a device handler (DH) can be tested on different hardware. The DH has mechanisms to monitor the communication with the physical device which allow for FDIR reaction. +Device Handlers can be created by overriding `DeviceHandlerBase`. A standard FDIR component for the DH will be created automatically but can be overwritten by the user. +More information on DeviceHandlers can be found in the related [documentation section](doc/README-devicehandlers.md#top). #### Modes, Health @@ -149,10 +123,6 @@ The health state represents if the component is able to perform its tasks. This can be used to signal the system to avoid using this component instead of a redundant one. The on-board FDIR uses the health state for isolation and recovery. -## Example config - -A example config can be found in defaultcfg/fsfwconfig. - ## Unit Tests Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include catch2 itself. diff --git a/doc/README-config.md b/doc/README-config.md new file mode 100644 index 00000000..036a7d14 --- /dev/null +++ b/doc/README-config.md @@ -0,0 +1,21 @@ + +## Configuring the FSFW + +The FSFW can be configured via the `fsfwconfig` folder. A template folder has +been provided to have a starting point for this. The folder should be added +to the include path. + + +### Configuring the Event Manager + +The number of allowed subscriptions can be modified with the following +parameters: + +``` c++ +namespace fsfwconfig { +//! Configure the allocated pool sizes for the event manager. +static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; +static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; +static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; +} +``` \ No newline at end of file diff --git a/doc/README-core.md b/doc/README-core.md new file mode 100644 index 00000000..c47ae0f2 --- /dev/null +++ b/doc/README-core.md @@ -0,0 +1,50 @@ +## FSFW Core Modules + +These core modules provide the most important functionalities of the +Flight Software Framework + +### Clock + + * This is a class of static functions that can be used at anytime + * Leap Seconds must be set if any time conversions from UTC to other times is used + +### ObjectManager + +* Must be created during program startup +* The component which handles all references. All SystemObjects register at this component. +* Any SystemObject needs to have a unique ObjectId. Those can be managed like objects::framework_objects. +* A reference to an object can be get by calling the following function. T must be the specific Interface you want to call. +A nullptr check of the returning Pointer must be done. This function is based on Run-time type information. + +``` c++ + template T* ObjectManagerIF::get( object_id_t id ) + +``` +* A typical way to create all objects on startup is a handing a static produce function to the ObjectManager on creation. +By calling objectManager->initialize() the produce function will be called and all SystemObjects will be initialized afterwards. + +### Event Manager + +* Component which allows routing of events +* Other objects can subscribe to specific events, ranges of events or all events of an object. +* Subscriptions can be done during runtime but should be done during initialization +* Amounts of allowed subscriptions can be configured in `FSFWConfig.h` + +### Health Table + +* A component which holds every health state +* Provides a thread safe way to access all health states without the need of message exchanges + +### Stores + +* The message based communication can only exchange a few bytes of information inside the message itself. Therefore, additional information can + be exchanged with Stores. With this, only the store address must be exchanged in the message. +* Internally, the FSFW uses an IPC Store to exchange data between processes. For incoming TCs a TC Store is used. For outgoing TM a TM store is used. +* All of them should use the Thread Safe Class storagemanager/PoolManager + +### Tasks + +There are two different types of tasks: + * The PeriodicTask just executes objects that are of type ExecutableObjectIF in the order of the insertion to the Tasks. + * FixedTimeslotTask executes a list of calls in the order of the given list. This is intended for DeviceHandlers, where polling should be in a defined order. An example can be found in defaultcfg/fsfwconfig/pollingSequence + diff --git a/doc/README-devicehandlers.txt b/doc/README-devicehandlers.txt new file mode 100644 index 00000000..e69de29b From 9937842ded66d2ffca374bff275719cbba0fe4c1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Dec 2020 14:11:36 +0100 Subject: [PATCH 08/12] get transiition delay abstract --- devicehandlers/DeviceHandlerBase.cpp | 5 ----- devicehandlers/DeviceHandlerBase.h | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index cb040714..d2d4ecb8 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -926,11 +926,6 @@ void DeviceHandlerBase::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { setMode(getBaseMode(mode)); } -uint32_t DeviceHandlerBase::getTransitionDelayMs(Mode_t modeFrom, - Mode_t modeTo) { - return 5000; -} - ReturnValue_t DeviceHandlerBase::getStateOfSwitches(void) { if(powerSwitcher == nullptr) { return NO_SWITCH; diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index ee4447ed..45450f62 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -490,7 +490,7 @@ protected: * @param modeTo * @return time in ms */ - virtual uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo); + virtual uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) = 0; /** * Return the switches connected to the device. From 3b391d33801ef998d8748364711c0dbb17231664 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Dec 2020 14:15:21 +0100 Subject: [PATCH 09/12] deleted service types header --- tmtcservices/ServiceTypes.h | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 tmtcservices/ServiceTypes.h diff --git a/tmtcservices/ServiceTypes.h b/tmtcservices/ServiceTypes.h deleted file mode 100644 index 552601f9..00000000 --- a/tmtcservices/ServiceTypes.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef SERVICETYPES_H_ -#define SERVICETYPES_H_ - -// SHOULDDO: This is a duplication of existing configuration structures. Delete it? -namespace SERVICE { -enum ServiceTypes { - TELECOMMAND_VERIFICATION = 1, - DEVICE_COMMAND_DISTRIBUTION = 2, - HOUSEKEEPING_AND_DIAGNOSTIC_DATA_REPORTING = 3, - PARAMETER_STATISTICS_REPORTING = 4, - EVENT_REPORTING = 5, - MEMORY_MANAGEMENT = 6, - FUNCTION_MANAGEMENT = 8, - TIME_MANAGEMENT = 9, - ON_BOARD_OPERATIONS_SCHEDULING = 11, - ON_BOARD_MONITORING = 12, - LARGE_DATA_TRANSFER = 13, - PACKET_FORWARDING_CONTROL = 14, - ON_BOARD_STORAGE_AND_RETRIEVAL = 15, - TEST = 17, - ON_BOARD_OPERATIONS_PROCEDURE = 18, - EVENT_ACTION = 19 -}; -} - -#endif /* SERVICETYPES_H_ */ From d607332f8d20477d47624e4562417f279b9ccd85 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Dec 2020 14:19:13 +0100 Subject: [PATCH 10/12] removed comment --- tmtcservices/AcceptsTelecommandsIF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtcservices/AcceptsTelecommandsIF.h b/tmtcservices/AcceptsTelecommandsIF.h index bff0e955..7c871049 100644 --- a/tmtcservices/AcceptsTelecommandsIF.h +++ b/tmtcservices/AcceptsTelecommandsIF.h @@ -12,7 +12,7 @@ class AcceptsTelecommandsIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::ACCEPTS_TELECOMMANDS_IF; - static const ReturnValue_t ACTIVITY_STARTED = MAKE_RETURN_CODE(1); // is this used anywhere or can it be removed? + static const ReturnValue_t ACTIVITY_STARTED = MAKE_RETURN_CODE(1); static const ReturnValue_t INVALID_SUBSERVICE = MAKE_RETURN_CODE(2); static const ReturnValue_t ILLEGAL_APPLICATION_DATA = MAKE_RETURN_CODE(3); static const ReturnValue_t SEND_TM_FAILED = MAKE_RETURN_CODE(4); From 9ac07368da3fab3a60fa0caffe0f10f8c35e2fd9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Dec 2020 14:26:42 +0100 Subject: [PATCH 11/12] changelog update --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4e51bc64..8b13b68d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -54,7 +54,7 @@ ID for now. - There is an additional `PERFORM_OPERATION` step for the device handler base. It is important that DHB users adapt their polling sequence tables to perform this step. This steps allows for aclear distinction between operation and communication steps - setNormalDatapoolEntriesInvalid is not an abstract method and a default implementation was provided -- getTransitionDelayMs now return 5000 ms instead of 0 in default implementation +- getTransitionDelayMs is now an abstract method ### DeviceHandlerIF From 822cc0306c90603bbd66365293670e1163dc36cd Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Tue, 22 Dec 2020 15:35:23 +0100 Subject: [PATCH 12/12] Fixed file ending of devicehanlder remake --- doc/README-devicehandlers.md | 1 + doc/README-devicehandlers.txt | 0 2 files changed, 1 insertion(+) create mode 100644 doc/README-devicehandlers.md delete mode 100644 doc/README-devicehandlers.txt diff --git a/doc/README-devicehandlers.md b/doc/README-devicehandlers.md new file mode 100644 index 00000000..6e737cc5 --- /dev/null +++ b/doc/README-devicehandlers.md @@ -0,0 +1 @@ +## FSFW DeviceHandlers \ No newline at end of file diff --git a/doc/README-devicehandlers.txt b/doc/README-devicehandlers.txt deleted file mode 100644 index e69de29b..00000000