diff --git a/CHANGELOG.md b/CHANGELOG.md index 66e543359..b77888084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- `CService200ModeManagement`: Various bugfixes which lead to now execution complete being generated + on mode announcements, duplicate mode reply generated on announce commands, and the mode read + subservice not working properly. - Memory leak fixes for the TCP/IP TMTC bridge. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/737 - `Service9TimeManagement`: Fix the time dump at the `SET_TIME` subservice: Include clock timeval diff --git a/src/fsfw/modes/ModeMessage.cpp b/src/fsfw/modes/ModeMessage.cpp index ecc52c941..fbfb71aae 100644 --- a/src/fsfw/modes/ModeMessage.cpp +++ b/src/fsfw/modes/ModeMessage.cpp @@ -24,3 +24,19 @@ void ModeMessage::setCantReachMode(CommandMessage* message, ReturnValue_t reason message->setParameter(reason); message->setParameter2(0); } + +void ModeMessage::setModeAnnounceMessage(CommandMessage& message, bool recursive) { + Command_t cmd; + if (recursive) { + cmd = CMD_MODE_ANNOUNCE_RECURSIVELY; + } else { + cmd = CMD_MODE_ANNOUNCE; + } + message.setCommand(cmd); +} + +void ModeMessage::setCmdModeMessage(CommandMessage& message, Mode_t mode, Submode_t submode) { + setModeMessage(&message, CMD_MODE_COMMAND, mode, submode); +} + +void ModeMessage::setModeReadMessage(CommandMessage& message) { message.setCommand(CMD_MODE_READ); } diff --git a/src/fsfw/modes/ModeMessage.h b/src/fsfw/modes/ModeMessage.h index 84429e840..c00e6c9ef 100644 --- a/src/fsfw/modes/ModeMessage.h +++ b/src/fsfw/modes/ModeMessage.h @@ -45,6 +45,9 @@ class ModeMessage { static void setModeMessage(CommandMessage* message, Command_t command, Mode_t mode, Submode_t submode); + static void setCmdModeMessage(CommandMessage& message, Mode_t mode, Submode_t submode); + static void setModeAnnounceMessage(CommandMessage& message, bool recursive); + static void setModeReadMessage(CommandMessage& message); static void setCantReachMode(CommandMessage* message, ReturnValue_t reason); static void clear(CommandMessage* message); }; diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index d28df59b8..15745a373 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -19,7 +19,7 @@ ReturnValue_t CService200ModeCommanding::isValidSubservice(uint8_t subservice) { switch (subservice) { case (Subservice::COMMAND_MODE_COMMAND): case (Subservice::COMMAND_MODE_READ): - case (Subservice::COMMAND_MODE_ANNCOUNCE): + case (Subservice::COMMAND_MODE_ANNOUNCE): return returnvalue::OK; default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; @@ -53,16 +53,32 @@ ReturnValue_t CService200ModeCommanding::checkInterfaceAndAcquireMessageQueue( ReturnValue_t CService200ModeCommanding::prepareCommand(CommandMessage *message, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint32_t *state, object_id_t objectId) { - ModePacket modeCommandPacket; - ReturnValue_t result = - modeCommandPacket.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); - if (result != returnvalue::OK) { - return result; - } + bool recursive = false; + switch (subservice) { + case (Subservice::COMMAND_MODE_COMMAND): { + ModePacket modeCommandPacket; + ReturnValue_t result = + modeCommandPacket.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); + if (result != returnvalue::OK) { + return result; + } - ModeMessage::setModeMessage(message, ModeMessage::CMD_MODE_COMMAND, modeCommandPacket.getMode(), - modeCommandPacket.getSubmode()); - return result; + ModeMessage::setModeMessage(message, ModeMessage::CMD_MODE_COMMAND, + modeCommandPacket.getMode(), modeCommandPacket.getSubmode()); + return returnvalue::OK; + } + case (Subservice::COMMAND_MODE_ANNOUNCE_RECURSIVELY): + recursive = true; + [[fallthrough]]; + case (Subservice::COMMAND_MODE_ANNOUNCE): + ModeMessage::setModeAnnounceMessage(*message, recursive); + return EXECUTION_COMPLETE; + case (Subservice::COMMAND_MODE_READ): + ModeMessage::setModeReadMessage(*message); + return returnvalue::OK; + default: + return CommandingServiceBase::INVALID_SUBSERVICE; + } } ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply, @@ -73,8 +89,10 @@ ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply ReturnValue_t result = returnvalue::FAILED; switch (replyId) { case (ModeMessage::REPLY_MODE_REPLY): { - result = prepareModeReply(reply, objectId); - break; + if (previousCommand != ModeMessage::CMD_MODE_COMMAND) { + return prepareModeReply(reply, objectId); + } + return returnvalue::OK; } case (ModeMessage::REPLY_WRONG_MODE_REPLY): { result = prepareWrongModeReply(reply, objectId); diff --git a/src/fsfw/pus/CService200ModeCommanding.h b/src/fsfw/pus/CService200ModeCommanding.h index 830e5950e..cf2baf7ea 100644 --- a/src/fsfw/pus/CService200ModeCommanding.h +++ b/src/fsfw/pus/CService200ModeCommanding.h @@ -52,7 +52,7 @@ class CService200ModeCommanding : public CommandingServiceBase { COMMAND_MODE_READ = 3, //!< [EXPORT] : [COMMAND] Trigger an ModeInfo Event. //! This command does NOT have a reply - COMMAND_MODE_ANNCOUNCE = 4, + COMMAND_MODE_ANNOUNCE = 4, //!< [EXPORT] : [COMMAND] Trigger a ModeInfo Event and to send this //! command to every child. This command does NOT have a reply. COMMAND_MODE_ANNOUNCE_RECURSIVELY = 5,