Merge branch 'mueller/master' into source/master

This commit is contained in:
Robin Müller 2020-08-01 17:06:12 +02:00
commit 7475e6a9b8
5 changed files with 26 additions and 19 deletions

View File

@ -88,6 +88,7 @@ void CommandMessage::setToUnknownCommand() {
void CommandMessage::setReplyRejected(ReturnValue_t reason, void CommandMessage::setReplyRejected(ReturnValue_t reason,
Command_t initialCommand) { Command_t initialCommand) {
setCommand(REPLY_REJECTED);
setParameter(reason); setParameter(reason);
setParameter2(initialCommand); setParameter2(initialCommand);
} }

View File

@ -26,7 +26,6 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
} }
break; break;
case ParameterMessage::CMD_PARAMETER_LOAD: { case ParameterMessage::CMD_PARAMETER_LOAD: {
uint8_t domain = HasParametersIF::getDomain( uint8_t domain = HasParametersIF::getDomain(
ParameterMessage::getParameterId(message)); ParameterMessage::getParameterId(message));
uint16_t parameterId = HasParametersIF::getMatrixId( uint16_t parameterId = HasParametersIF::getMatrixId(
@ -34,12 +33,14 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
uint8_t index = HasParametersIF::getIndex( uint8_t index = HasParametersIF::getIndex(
ParameterMessage::getParameterId(message)); ParameterMessage::getParameterId(message));
const uint8_t *storedStream; const uint8_t *storedStream = nullptr;
size_t storedStreamSize; size_t storedStreamSize = 0;
result = storage->getData( result = storage->getData(
ParameterMessage::getStoreId(message), &storedStream, ParameterMessage::getStoreId(message), &storedStream,
&storedStreamSize); &storedStreamSize);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "ParameterHelper::handleParameterMessage: Getting"
" store data failed for load command." << std::endl;
break; break;
} }

View File

@ -5,6 +5,12 @@
#include <framework/parameters/ParameterMessage.h> #include <framework/parameters/ParameterMessage.h>
#include <framework/parameters/ReceivesParameterMessagesIF.h> #include <framework/parameters/ReceivesParameterMessagesIF.h>
/**
* @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 { class ParameterHelper {
public: public:
ParameterHelper(ReceivesParameterMessagesIF *owner); ParameterHelper(ReceivesParameterMessagesIF *owner);

View File

@ -126,11 +126,11 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
&nextCommand, iter->objectId, &isStep); &nextCommand, iter->objectId, &isStep);
/* If the child implementation does not implement special handling for /* If the child implementation does not implement special handling for
* rejected replies (RETURN_FAILED is returned), a failure verification * rejected replies (RETURN_FAILED or INVALID_REPLY is returned), a
* will be generated with the reason as the return code and the initial * failure verification will be generated with the reason as the
* command as failure parameter 1 */ * 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) { (result == RETURN_FAILED or result == INVALID_REPLY)) {
result = reply->getReplyRejectedReason(); result = reply->getReplyRejectedReason();
failureParameter1 = iter->command; failureParameter1 = iter->command;
} }
@ -230,8 +230,8 @@ void CommandingServiceBase::handleRequestQueue() {
address = message.getStorageId(); address = message.getStorageId();
packet.setStoreAddress(address); packet.setStoreAddress(address);
if (packet.getSubService() == 0 if ((packet.getSubService() == 0)
or isValidSubservice(packet.getSubService()) != RETURN_OK) { or (isValidSubservice(packet.getSubService()) != RETURN_OK)) {
rejectPacket(TC_VERIFY::START_FAILURE, &packet, INVALID_SUBSERVICE); rejectPacket(TC_VERIFY::START_FAILURE, &packet, INVALID_SUBSERVICE);
continue; continue;
} }

View File

@ -87,7 +87,7 @@ public:
* @param opCode is unused here at the moment * @param opCode is unused here at the moment
* @return RETURN_OK * @return RETURN_OK
*/ */
virtual ReturnValue_t performOperation(uint8_t opCode); virtual ReturnValue_t performOperation(uint8_t opCode) override;
virtual uint16_t getIdentifier(); virtual uint16_t getIdentifier();
@ -116,7 +116,7 @@ public:
* Used to setup the reference of the task, that executes this component * Used to setup the reference of the task, that executes this component
* @param task Pointer to the taskIF of this task * @param task Pointer to the taskIF of this task
*/ */
virtual void setTaskIF(PeriodicTaskIF* task); virtual void setTaskIF(PeriodicTaskIF* task) override;
protected: protected:
/** /**
@ -173,9 +173,7 @@ protected:
* This function is implemented by child services to specify how replies * This function is implemented by child services to specify how replies
* to a command from another software component are handled. * to a command from another software component are handled.
* @param reply * @param reply
* This is the reply which can be accessed via the command message * This is the reply in form of a generic read-only command message.
* interface. The internal message pointer can be passed to different
* command message implementations (see CommandMessageIF)
* @param previousCommand * @param previousCommand
* Command_t of related command * Command_t of related command
* @param state [out/in] * @param state [out/in]
@ -189,10 +187,11 @@ protected:
* - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to * - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to
* generate TC verification success * generate TC verification success
* - @c INVALID_REPLY Calls handleUnrequestedReply * - @c INVALID_REPLY Calls handleUnrequestedReply
* - Anything else triggers a TC verification failure. If RETURN_FAILED * - Anything else triggers a TC verification failure. If RETURN_FAILED or
* is returned and the command ID is CommandMessage::REPLY_REJECTED, * INVALID_REPLY is returned and the command ID is
* a failure verification message with the reason as the error parameter * CommandMessage::REPLY_REJECTED, a failure verification message with
* and the initial command as failure parameter 1. * the reason as the error parameter and the initial command as
* failure parameter 1 is generated.
*/ */
virtual ReturnValue_t handleReply(const CommandMessage* reply, virtual ReturnValue_t handleReply(const CommandMessage* reply,
Command_t previousCommand, uint32_t *state, Command_t previousCommand, uint32_t *state,