From 98dae18430f6a19ee1047d5c0b47d16cf4ee6bc2 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 13:46:29 +0100 Subject: [PATCH 1/6] update defaultcfg folder --- defaultcfg/{config => fsfwconfig}/FSFWConfig.h | 15 +++++++++------ defaultcfg/{config => fsfwconfig}/OBSWConfig.h | 0 defaultcfg/{config => fsfwconfig}/OBSWVersion.h | 0 .../devices/logicalAddresses.cpp | 0 .../devices/logicalAddresses.h | 2 +- .../devices/powerSwitcherList.cpp | 0 .../devices/powerSwitcherList.h | 0 .../events/subsystemIdRanges.h | 0 .../config.mk => fsfwconfig/fsfwconfig.mk} | 0 .../ipc/missionMessageTypes.cpp | 3 ++- .../ipc/missionMessageTypes.h | 0 .../{config => fsfwconfig}/objects/Factory.cpp | 14 +++++++------- .../{config => fsfwconfig}/objects/Factory.h | 0 .../objects/systemObjectList.h | 0 .../pollingsequence/PollingSequenceFactory.cpp | 0 .../pollingsequence/PollingSequenceFactory.h | 0 .../returnvalues/classIds.h | 0 defaultcfg/{config => fsfwconfig}/tmtc/apid.h | 0 defaultcfg/{config => fsfwconfig}/tmtc/pusIds.h | 0 19 files changed, 19 insertions(+), 15 deletions(-) rename defaultcfg/{config => fsfwconfig}/FSFWConfig.h (81%) rename defaultcfg/{config => fsfwconfig}/OBSWConfig.h (100%) rename defaultcfg/{config => fsfwconfig}/OBSWVersion.h (100%) rename defaultcfg/{config => fsfwconfig}/devices/logicalAddresses.cpp (100%) rename defaultcfg/{config => fsfwconfig}/devices/logicalAddresses.h (89%) rename defaultcfg/{config => fsfwconfig}/devices/powerSwitcherList.cpp (100%) rename defaultcfg/{config => fsfwconfig}/devices/powerSwitcherList.h (100%) rename defaultcfg/{config => fsfwconfig}/events/subsystemIdRanges.h (100%) rename defaultcfg/{config/config.mk => fsfwconfig/fsfwconfig.mk} (100%) rename defaultcfg/{config => fsfwconfig}/ipc/missionMessageTypes.cpp (79%) rename defaultcfg/{config => fsfwconfig}/ipc/missionMessageTypes.h (100%) rename defaultcfg/{config => fsfwconfig}/objects/Factory.cpp (75%) rename defaultcfg/{config => fsfwconfig}/objects/Factory.h (100%) rename defaultcfg/{config => fsfwconfig}/objects/systemObjectList.h (100%) rename defaultcfg/{config => fsfwconfig}/pollingsequence/PollingSequenceFactory.cpp (100%) rename defaultcfg/{config => fsfwconfig}/pollingsequence/PollingSequenceFactory.h (100%) rename defaultcfg/{config => fsfwconfig}/returnvalues/classIds.h (100%) rename defaultcfg/{config => fsfwconfig}/tmtc/apid.h (100%) rename defaultcfg/{config => fsfwconfig}/tmtc/pusIds.h (100%) diff --git a/defaultcfg/config/FSFWConfig.h b/defaultcfg/fsfwconfig/FSFWConfig.h similarity index 81% rename from defaultcfg/config/FSFWConfig.h rename to defaultcfg/fsfwconfig/FSFWConfig.h index ea86152c..1386bf66 100644 --- a/defaultcfg/config/FSFWConfig.h +++ b/defaultcfg/fsfwconfig/FSFWConfig.h @@ -1,19 +1,19 @@ #ifndef CONFIG_FSFWCONFIG_H_ #define CONFIG_FSFWCONFIG_H_ -#include #include +#include //! Used to determine whether C++ ostreams are used //! Those can lead to code bloat. #define FSFW_CPP_OSTREAM_ENABLED 1 -//! Reduced printout to further decrese code size +//! Reduced printout to further decrease code size //! Be careful, this also turns off most diagnostic prinouts! -#define FSFW_REDUCED_PRINTOUT 0 +#define FSFW_ENHANCED_PRINTOUT 0 -//! Can be used to enable debugging printouts for developing the FSFW -#define FSFW_DEBUGGING 0 +//! 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 @@ -38,7 +38,10 @@ //! When using the newlib nano library, C99 support for stdio facilities //! will not be provided. This define should be set to 1 if this is the case. -#define FSFW_NO_C99_IO 1 +#define FSFW_NO_C99_IO 1 + +//! Specify whether a special mode store is used for Subsystem components. +#define FSFW_USE_MODESTORE 0 namespace fsfwconfig { //! Default timestamp size. The default timestamp will be an eight byte CDC diff --git a/defaultcfg/config/OBSWConfig.h b/defaultcfg/fsfwconfig/OBSWConfig.h similarity index 100% rename from defaultcfg/config/OBSWConfig.h rename to defaultcfg/fsfwconfig/OBSWConfig.h diff --git a/defaultcfg/config/OBSWVersion.h b/defaultcfg/fsfwconfig/OBSWVersion.h similarity index 100% rename from defaultcfg/config/OBSWVersion.h rename to defaultcfg/fsfwconfig/OBSWVersion.h diff --git a/defaultcfg/config/devices/logicalAddresses.cpp b/defaultcfg/fsfwconfig/devices/logicalAddresses.cpp similarity index 100% rename from defaultcfg/config/devices/logicalAddresses.cpp rename to defaultcfg/fsfwconfig/devices/logicalAddresses.cpp diff --git a/defaultcfg/config/devices/logicalAddresses.h b/defaultcfg/fsfwconfig/devices/logicalAddresses.h similarity index 89% rename from defaultcfg/config/devices/logicalAddresses.h rename to defaultcfg/fsfwconfig/devices/logicalAddresses.h index 174fa788..e0827ba3 100644 --- a/defaultcfg/config/devices/logicalAddresses.h +++ b/defaultcfg/fsfwconfig/devices/logicalAddresses.h @@ -1,8 +1,8 @@ #ifndef CONFIG_DEVICES_LOGICALADDRESSES_H_ #define CONFIG_DEVICES_LOGICALADDRESSES_H_ -#include #include +#include "../objects/systemObjectList.h" #include /** diff --git a/defaultcfg/config/devices/powerSwitcherList.cpp b/defaultcfg/fsfwconfig/devices/powerSwitcherList.cpp similarity index 100% rename from defaultcfg/config/devices/powerSwitcherList.cpp rename to defaultcfg/fsfwconfig/devices/powerSwitcherList.cpp diff --git a/defaultcfg/config/devices/powerSwitcherList.h b/defaultcfg/fsfwconfig/devices/powerSwitcherList.h similarity index 100% rename from defaultcfg/config/devices/powerSwitcherList.h rename to defaultcfg/fsfwconfig/devices/powerSwitcherList.h diff --git a/defaultcfg/config/events/subsystemIdRanges.h b/defaultcfg/fsfwconfig/events/subsystemIdRanges.h similarity index 100% rename from defaultcfg/config/events/subsystemIdRanges.h rename to defaultcfg/fsfwconfig/events/subsystemIdRanges.h diff --git a/defaultcfg/config/config.mk b/defaultcfg/fsfwconfig/fsfwconfig.mk similarity index 100% rename from defaultcfg/config/config.mk rename to defaultcfg/fsfwconfig/fsfwconfig.mk diff --git a/defaultcfg/config/ipc/missionMessageTypes.cpp b/defaultcfg/fsfwconfig/ipc/missionMessageTypes.cpp similarity index 79% rename from defaultcfg/config/ipc/missionMessageTypes.cpp rename to defaultcfg/fsfwconfig/ipc/missionMessageTypes.cpp index e2edbf9c..b41b87ba 100644 --- a/defaultcfg/config/ipc/missionMessageTypes.cpp +++ b/defaultcfg/fsfwconfig/ipc/missionMessageTypes.cpp @@ -1,4 +1,5 @@ -#include +#include "missionMessageTypes.h" + #include void messagetypes::clearMissionMessage(CommandMessage* message) { diff --git a/defaultcfg/config/ipc/missionMessageTypes.h b/defaultcfg/fsfwconfig/ipc/missionMessageTypes.h similarity index 100% rename from defaultcfg/config/ipc/missionMessageTypes.h rename to defaultcfg/fsfwconfig/ipc/missionMessageTypes.h diff --git a/defaultcfg/config/objects/Factory.cpp b/defaultcfg/fsfwconfig/objects/Factory.cpp similarity index 75% rename from defaultcfg/config/objects/Factory.cpp rename to defaultcfg/fsfwconfig/objects/Factory.cpp index 51dd6130..41333b1c 100644 --- a/defaultcfg/config/objects/Factory.cpp +++ b/defaultcfg/fsfwconfig/objects/Factory.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -31,15 +32,15 @@ void Factory::produce(void) { setStaticFrameworkObjectIds(); new EventManager(objects::EVENT_MANAGER); new HealthTable(objects::HEALTH_TABLE); - //new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); + new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); } void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; + PusServiceBase::packetSource = objects::NO_OBJECT; + PusServiceBase::packetDestination = objects::NO_OBJECT; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; + CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; @@ -48,7 +49,6 @@ void Factory::setStaticFrameworkObjectIds() { DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; - TmPacketStored::timeStamperId = objects::PUS_TIME; - //TmFunnel::downlinkDestination = objects::NO_OBJECT; + TmPacketStored::timeStamperId = objects::NO_OBJECT; } diff --git a/defaultcfg/config/objects/Factory.h b/defaultcfg/fsfwconfig/objects/Factory.h similarity index 100% rename from defaultcfg/config/objects/Factory.h rename to defaultcfg/fsfwconfig/objects/Factory.h diff --git a/defaultcfg/config/objects/systemObjectList.h b/defaultcfg/fsfwconfig/objects/systemObjectList.h similarity index 100% rename from defaultcfg/config/objects/systemObjectList.h rename to defaultcfg/fsfwconfig/objects/systemObjectList.h diff --git a/defaultcfg/config/pollingsequence/PollingSequenceFactory.cpp b/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp similarity index 100% rename from defaultcfg/config/pollingsequence/PollingSequenceFactory.cpp rename to defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp diff --git a/defaultcfg/config/pollingsequence/PollingSequenceFactory.h b/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.h similarity index 100% rename from defaultcfg/config/pollingsequence/PollingSequenceFactory.h rename to defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.h diff --git a/defaultcfg/config/returnvalues/classIds.h b/defaultcfg/fsfwconfig/returnvalues/classIds.h similarity index 100% rename from defaultcfg/config/returnvalues/classIds.h rename to defaultcfg/fsfwconfig/returnvalues/classIds.h diff --git a/defaultcfg/config/tmtc/apid.h b/defaultcfg/fsfwconfig/tmtc/apid.h similarity index 100% rename from defaultcfg/config/tmtc/apid.h rename to defaultcfg/fsfwconfig/tmtc/apid.h diff --git a/defaultcfg/config/tmtc/pusIds.h b/defaultcfg/fsfwconfig/tmtc/pusIds.h similarity index 100% rename from defaultcfg/config/tmtc/pusIds.h rename to defaultcfg/fsfwconfig/tmtc/pusIds.h From 802e24e2933be81eb6f7a35af89692dfff5bc159 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 14:43:36 +0100 Subject: [PATCH 2/6] change log update --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 96f5703c..d5e083dc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -## Changes from ASTP 0.0.1 to 0.0.2 +## Changes from ASTP 1.0.0 to 1.1.0 ### FreeRTOS OSAL From 45df446ab80e1303738889c21e15921c4b807fd6 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 14:44:03 +0100 Subject: [PATCH 3/6] change log update --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d5e083dc..4937b5f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -## Changes from ASTP 1.0.0 to 1.1.0 +## Changes from ASTP 0.0.1 to 1.0.0 ### FreeRTOS OSAL From 3e74c18d88d0fadc82f7b60be926d2582d5ec7f0 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 14:59:35 +0100 Subject: [PATCH 4/6] health servicd --- pus/CService201HealthCommanding.cpp | 102 ++++++++++++++++++++++++++++ pus/CService201HealthCommanding.h | 63 +++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 pus/CService201HealthCommanding.cpp create mode 100644 pus/CService201HealthCommanding.h diff --git a/pus/CService201HealthCommanding.cpp b/pus/CService201HealthCommanding.cpp new file mode 100644 index 00000000..db43db89 --- /dev/null +++ b/pus/CService201HealthCommanding.cpp @@ -0,0 +1,102 @@ +#include "CService201HealthCommanding.h" + +#include "../health/HasHealthIF.h" +#include "../serviceinterface/ServiceInterfaceStream.h" +#include "../health/HealthMessage.h" +#include "servicepackets/Service201Packets.h" + +CService201HealthCommanding::CService201HealthCommanding(object_id_t objectId, + uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands, + uint16_t commandTimeoutSeconds): + CommandingServiceBase(objectId, apid, serviceId, + numParallelCommands, commandTimeoutSeconds) { +} + +CService201HealthCommanding::~CService201HealthCommanding() { +} + +ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) { + switch(subservice) { + case(Subservice::COMMAND_SET_HEALTH): + case(Subservice::COMMAND_ANNOUNCE_HEALTH): + case(Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): + return RETURN_OK; + default: + sif::error << "Invalid Subservice" << std::endl; + return AcceptsTelecommandsIF::INVALID_SUBSERVICE; + } +} + +ReturnValue_t CService201HealthCommanding::getMessageQueueAndObject( + uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, + MessageQueueId_t *id, object_id_t *objectId) { + if(tcDataLen < sizeof(object_id_t)) { + return CommandingServiceBase::INVALID_TC; + } + SerializeAdapter::deSerialize(objectId, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + + return checkInterfaceAndAcquireMessageQueue(id,objectId); +} + +ReturnValue_t CService201HealthCommanding::checkInterfaceAndAcquireMessageQueue( + MessageQueueId_t* messageQueueToSet, object_id_t* objectId) { + HasHealthIF * destination = objectManager->get(*objectId); + if(destination == nullptr) { + return CommandingServiceBase::INVALID_OBJECT; + } + + *messageQueueToSet = destination->getCommandQueue(); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CService201HealthCommanding::prepareCommand( + CommandMessage* message, uint8_t subservice, const uint8_t *tcData, + size_t tcDataLen, uint32_t *state, object_id_t objectId) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + switch(subservice) { + case(Subservice::COMMAND_SET_HEALTH): { + HealthSetCommand healthCommand; + result = healthCommand.deSerialize(&tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + break; + } + HealthMessage::setHealthMessage(message, HealthMessage::HEALTH_SET, + healthCommand.getHealth()); + break; + } + case(Subservice::COMMAND_ANNOUNCE_HEALTH): { + HealthMessage::setHealthMessage(message, + HealthMessage::HEALTH_ANNOUNCE); + break; + } + case(Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): { + HealthMessage::setHealthMessage(message, + HealthMessage::HEALTH_ANNOUNCE_ALL); + break; + } + } + return result; +} + +ReturnValue_t CService201HealthCommanding::handleReply + (const CommandMessage* reply, Command_t previousCommand, + uint32_t *state, CommandMessage* optionalNextCommand, + object_id_t objectId, bool *isStep) { + Command_t replyId = reply->getCommand(); + if (replyId == HealthMessage::REPLY_HEALTH_SET) { + return prepareHealthSetReply(reply); + } + return CommandingServiceBase::INVALID_REPLY; +} + +ReturnValue_t CService201HealthCommanding::prepareHealthSetReply( + const CommandMessage* reply) { + prepareHealthSetReply(reply); + uint8_t health = static_cast(HealthMessage::getHealth(reply)); + uint8_t oldHealth = static_cast(HealthMessage::getOldHealth(reply)); + HealthSetReply healthSetReply(health, oldHealth); + return sendTmPacket(Subservice::REPLY_HEALTH_SET, &healthSetReply); +} + diff --git a/pus/CService201HealthCommanding.h b/pus/CService201HealthCommanding.h new file mode 100644 index 00000000..124e2ac7 --- /dev/null +++ b/pus/CService201HealthCommanding.h @@ -0,0 +1,63 @@ +#ifndef FSFW_PUS_CSERVICE201HEALTHCOMMANDING_H_ +#define FSFW_PUS_CSERVICE201HEALTHCOMMANDING_H_ + +#include "../tmtcservices/CommandingServiceBase.h" + +/** + * @brief Custom PUS service to set health of all objects + * implementing hasHealthIF. + * + * Examples: Device Handlers, Assemblies or Subsystems. + * Full Documentation: ECSS-E-ST-70-41C or ECSS-E-70-41A + * Dissertation Baetz p. 115, 116, 165-167. + * + * This is a gateway service. It relays device commands using the software bus. + * This service is very closely tied to the Commanding Service Base template + * class. There is constant interaction between this Service Base und a + * child class like this service + * + */ +class CService201HealthCommanding: public CommandingServiceBase { +public: + + CService201HealthCommanding(object_id_t objectId, uint16_t apid, + uint8_t serviceId, uint8_t numParallelCommands = 4, + uint16_t commandTimeoutSeconds = 60); + virtual~ CService201HealthCommanding(); +protected: + /* CSB abstract function implementations */ + ReturnValue_t isValidSubservice(uint8_t subservice) override; + ReturnValue_t getMessageQueueAndObject(uint8_t subservice, + const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id, + object_id_t *objectId) override; + /** Prepare health command */ + ReturnValue_t prepareCommand(CommandMessage* message, + uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, + uint32_t *state, object_id_t objectId) override; + /** Handle health reply */ + ReturnValue_t handleReply(const CommandMessage* reply, + Command_t previousCommand, uint32_t *state, + CommandMessage* optionalNextCommand, object_id_t objectId, + bool *isStep) override; + +private: + ReturnValue_t checkAndAcquireTargetID(object_id_t* objectIdToSet, + const uint8_t* tcData, size_t tcDataLen); + ReturnValue_t checkInterfaceAndAcquireMessageQueue( + MessageQueueId_t* MessageQueueToSet, object_id_t* objectId); + + ReturnValue_t prepareHealthSetReply(const CommandMessage *reply); + + enum Subservice { + //! [EXPORT] : [TC] Set health of target object + COMMAND_SET_HEALTH = 1, + //! [EXPORT] : [TM] Reply to health set command which also provides old health + REPLY_HEALTH_SET = 2, + //! [EXPORT] : [TC] Commands object to announce their health as an event + COMMAND_ANNOUNCE_HEALTH = 3, + //! [EXPORT] : [TC] Commands all objects in the health map to announce their health + COMMAND_ANNOUNCE_HEALTH_ALL = 4 + }; +}; + +#endif /* FSFW_PUS_CSERVICE201HEALTHCOMMANDING_H_ */ From 257e3e2db9297afc460b2590111033c3e3b25e32 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 15:03:49 +0100 Subject: [PATCH 5/6] change log update --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 4937b5f8..a4951a41 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,3 +5,5 @@ - vRequestContextSwitchFromISR is declared extern "C" so it can be defined in a C file without issues + +- PUS Health Service added, which allows to command and retrieve health via PUS packets From c72ba92247a2d1d13b5d12291a304c46ac56cfa5 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 15:05:54 +0100 Subject: [PATCH 6/6] health service update --- pus/CService201HealthCommanding.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pus/CService201HealthCommanding.cpp b/pus/CService201HealthCommanding.cpp index db43db89..edacd73a 100644 --- a/pus/CService201HealthCommanding.cpp +++ b/pus/CService201HealthCommanding.cpp @@ -86,11 +86,15 @@ ReturnValue_t CService201HealthCommanding::handleReply object_id_t objectId, bool *isStep) { Command_t replyId = reply->getCommand(); if (replyId == HealthMessage::REPLY_HEALTH_SET) { - return prepareHealthSetReply(reply); + return EXECUTION_COMPLETE; + } + else if(replyId == CommandMessageIF::REPLY_REJECTED) { + return reply->getReplyRejectedReason(); } return CommandingServiceBase::INVALID_REPLY; } +// Not used for now, health state already reported by event ReturnValue_t CService201HealthCommanding::prepareHealthSetReply( const CommandMessage* reply) { prepareHealthSetReply(reply);