From 58a4f4f8a1d9608b671cd6fab087afea5d086dc1 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 1 Aug 2020 16:39:17 +0200 Subject: [PATCH 1/2] command message bugfix, CSB improvement parameter helper diagnostic message --- ipc/CommandMessage.cpp | 1 + parameters/ParameterHelper.cpp | 7 ++++--- parameters/ParameterHelper.h | 6 ++++++ tmtcservices/CommandingServiceBase.cpp | 8 ++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ipc/CommandMessage.cpp b/ipc/CommandMessage.cpp index 8c296abdd..cc1185c7d 100644 --- a/ipc/CommandMessage.cpp +++ b/ipc/CommandMessage.cpp @@ -88,6 +88,7 @@ void CommandMessage::setToUnknownCommand() { void CommandMessage::setReplyRejected(ReturnValue_t reason, Command_t initialCommand) { + setCommand(REPLY_REJECTED); setParameter(reason); setParameter2(initialCommand); } diff --git a/parameters/ParameterHelper.cpp b/parameters/ParameterHelper.cpp index e40ed6756..53f1229ff 100644 --- a/parameters/ParameterHelper.cpp +++ b/parameters/ParameterHelper.cpp @@ -26,7 +26,6 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) { } break; case ParameterMessage::CMD_PARAMETER_LOAD: { - uint8_t domain = HasParametersIF::getDomain( ParameterMessage::getParameterId(message)); uint16_t parameterId = HasParametersIF::getMatrixId( @@ -34,12 +33,14 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) { uint8_t index = HasParametersIF::getIndex( ParameterMessage::getParameterId(message)); - const uint8_t *storedStream; - size_t storedStreamSize; + const uint8_t *storedStream = nullptr; + size_t storedStreamSize = 0; result = storage->getData( ParameterMessage::getStoreId(message), &storedStream, &storedStreamSize); if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "ParameterHelper::handleParameterMessage: Getting" + " store data failed for load command." << std::endl; break; } diff --git a/parameters/ParameterHelper.h b/parameters/ParameterHelper.h index 352cf0a9b..538aaac6f 100644 --- a/parameters/ParameterHelper.h +++ b/parameters/ParameterHelper.h @@ -5,6 +5,12 @@ #include #include +/** + * @brief Helper class to handle parameter messages + * @details + * This class simplfiies handling of parameter messages, which are sent + * to a class which implements ReceivesParameterMessagesIF. + */ class ParameterHelper { public: ParameterHelper(ReceivesParameterMessagesIF *owner); diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index 4c9b5375c..80a280937 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -126,11 +126,11 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { &nextCommand, iter->objectId, &isStep); /* If the child implementation does not implement special handling for - * rejected replies (RETURN_FAILED is returned), a failure verification - * will be generated with the reason as the return code and the initial - * command as failure parameter 1 */ + * rejected replies (RETURN_FAILED or INVALID_REPLY is returned), a + * failure verification will be generated with the reason as the + * return code and the initial command as failure parameter 1 */ if(reply->getCommand() == CommandMessage::REPLY_REJECTED and - result == RETURN_FAILED) { + (result == RETURN_FAILED or result == INVALID_REPLY)) { result = reply->getReplyRejectedReason(); failureParameter1 = iter->command; } From 66eac57e3bb77c73a4030d1320a64b42e5841641 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 1 Aug 2020 16:54:54 +0200 Subject: [PATCH 2/2] csb update --- tmtcservices/CommandingServiceBase.cpp | 6 +++--- tmtcservices/CommandingServiceBase.h | 17 ++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index 80a280937..330fd00f6 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -129,7 +129,7 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { * rejected replies (RETURN_FAILED or INVALID_REPLY is returned), a * failure verification will be generated with the reason as the * return code and the initial command as failure parameter 1 */ - if(reply->getCommand() == CommandMessage::REPLY_REJECTED and + if((reply->getCommand() == CommandMessage::REPLY_REJECTED) and (result == RETURN_FAILED or result == INVALID_REPLY)) { result = reply->getReplyRejectedReason(); failureParameter1 = iter->command; @@ -230,8 +230,8 @@ void CommandingServiceBase::handleRequestQueue() { address = message.getStorageId(); packet.setStoreAddress(address); - if (packet.getSubService() == 0 - or isValidSubservice(packet.getSubService()) != RETURN_OK) { + if ((packet.getSubService() == 0) + or (isValidSubservice(packet.getSubService()) != RETURN_OK)) { rejectPacket(TC_VERIFY::START_FAILURE, &packet, INVALID_SUBSERVICE); continue; } diff --git a/tmtcservices/CommandingServiceBase.h b/tmtcservices/CommandingServiceBase.h index 1bd18571e..b3a15985e 100644 --- a/tmtcservices/CommandingServiceBase.h +++ b/tmtcservices/CommandingServiceBase.h @@ -87,7 +87,7 @@ public: * @param opCode is unused here at the moment * @return RETURN_OK */ - virtual ReturnValue_t performOperation(uint8_t opCode); + virtual ReturnValue_t performOperation(uint8_t opCode) override; virtual uint16_t getIdentifier(); @@ -116,7 +116,7 @@ public: * Used to setup the reference of the task, that executes this component * @param task Pointer to the taskIF of this task */ - virtual void setTaskIF(PeriodicTaskIF* task); + virtual void setTaskIF(PeriodicTaskIF* task) override; protected: /** @@ -173,9 +173,7 @@ protected: * This function is implemented by child services to specify how replies * to a command from another software component are handled. * @param reply - * This is the reply which can be accessed via the command message - * interface. The internal message pointer can be passed to different - * command message implementations (see CommandMessageIF) + * This is the reply in form of a generic read-only command message. * @param previousCommand * Command_t of related command * @param state [out/in] @@ -189,10 +187,11 @@ protected: * - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to * generate TC verification success * - @c INVALID_REPLY Calls handleUnrequestedReply - * - Anything else triggers a TC verification failure. If RETURN_FAILED - * is returned and the command ID is CommandMessage::REPLY_REJECTED, - * a failure verification message with the reason as the error parameter - * and the initial command as failure parameter 1. + * - Anything else triggers a TC verification failure. If RETURN_FAILED or + * INVALID_REPLY is returned and the command ID is + * CommandMessage::REPLY_REJECTED, a failure verification message with + * the reason as the error parameter and the initial command as + * failure parameter 1 is generated. */ virtual ReturnValue_t handleReply(const CommandMessage* reply, Command_t previousCommand, uint32_t *state,