From 88f229cef924fcb45c46b8d6e002c3d8142f60d8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 23 Apr 2020 15:03:55 +0200 Subject: [PATCH 1/5] fifo enhancement --- container/FIFO.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/container/FIFO.h b/container/FIFO.h index 134da9b8..889d2ade 100644 --- a/container/FIFO.h +++ b/container/FIFO.h @@ -3,6 +3,11 @@ #include +/** + * @brief Simple First-In-First-Out data structure + * @tparam T Entry Type + * @tparam capacity Maximum capacity + */ template class FIFO { private: @@ -54,6 +59,26 @@ public: return HasReturnvaluesIF::RETURN_OK; } } + + ReturnValue_t peek(T * value) { + if(empty()) { + return EMPTY; + } else { + *value = data[readIndex]; + return HasReturnvaluesIF::RETURN_OK; + } + } + + ReturnValue_t pop() { + if(empty()) { + return EMPTY; + } else { + readIndex = next(readIndex); + --currentSize; + return HasReturnvaluesIF::RETURN_OK; + } + } + static const uint8_t INTERFACE_ID = CLASS_ID::FIFO_CLASS; static const ReturnValue_t FULL = MAKE_RETURN_CODE(1); static const ReturnValue_t EMPTY = MAKE_RETURN_CODE(2); From df9e66834e5ccb7d7d81a07b199baaebd4f6826c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 5 May 2020 19:07:11 +0200 Subject: [PATCH 2/5] pop() better --- container/FIFO.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/container/FIFO.h b/container/FIFO.h index 889d2ade..f70c78b0 100644 --- a/container/FIFO.h +++ b/container/FIFO.h @@ -70,13 +70,8 @@ public: } ReturnValue_t pop() { - if(empty()) { - return EMPTY; - } else { - readIndex = next(readIndex); - --currentSize; - return HasReturnvaluesIF::RETURN_OK; - } + T value; + return this->retrieve(&value); } static const uint8_t INTERFACE_ID = CLASS_ID::FIFO_CLASS; From f2945f873fd1908f572650913f41a3175bf8c451 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 8 May 2020 14:17:27 +0200 Subject: [PATCH 3/5] additional access function for mode message --- modes/ModeMessage.cpp | 4 ++++ modes/ModeMessage.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/modes/ModeMessage.cpp b/modes/ModeMessage.cpp index 62fea7e4..1d3baad5 100644 --- a/modes/ModeMessage.cpp +++ b/modes/ModeMessage.cpp @@ -16,6 +16,10 @@ ReturnValue_t ModeMessage::setModeMessage(CommandMessage* message, Command_t com return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t ModeMessage::getCantReachModeReason(const CommandMessage* message) { + return message->getParameter(); +} + void ModeMessage::clear(CommandMessage* message) { message->setCommand(CommandMessage::CMD_NONE); } diff --git a/modes/ModeMessage.h b/modes/ModeMessage.h index fad34726..0a72aee0 100644 --- a/modes/ModeMessage.h +++ b/modes/ModeMessage.h @@ -24,6 +24,7 @@ public: static const Command_t REPLY_MODE_INFO = MAKE_COMMAND_ID(0x03); //!> Unrequested info about the current mode (used for composites to inform their container of a changed mode) static const Command_t REPLY_CANT_REACH_MODE = MAKE_COMMAND_ID(0x04); //!> Reply in case a mode command can't be executed. Par1: returnCode, Par2: 0 //SHOULDDO is there a way we can transmit a returnvalue when responding that the mode is wrong, so we can give a nice failure code when commanded by PUS? + // shouldn't that possible with parameter 2 when submode only takes 1 byte? static const Command_t REPLY_WRONG_MODE_REPLY = MAKE_COMMAND_ID(0x05);//!> Reply to a CMD_MODE_COMMAND, indicating that a mode was commanded and a transition started but was aborted; the parameters contain the mode that was reached static const Command_t CMD_MODE_READ = MAKE_COMMAND_ID(0x06);//!> Command to read the current mode and reply with a REPLY_MODE_REPLY static const Command_t CMD_MODE_ANNOUNCE = MAKE_COMMAND_ID(0x07);//!> Command to trigger an ModeInfo Event. This command does NOT have a reply. @@ -34,6 +35,7 @@ public: static ReturnValue_t setModeMessage(CommandMessage* message, Command_t command, Mode_t mode, Submode_t submode); static void cantReachMode(CommandMessage* message, ReturnValue_t reason); + static ReturnValue_t getCantReachModeReason(const CommandMessage* message); static void clear(CommandMessage* message); }; From 26763b7cee17b470a44de92301cfed17fd330b49 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 13 May 2020 11:24:17 +0200 Subject: [PATCH 4/5] added comparison operator --- storagemanager/StorageManagerIF.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storagemanager/StorageManagerIF.h b/storagemanager/StorageManagerIF.h index 575e9caa..a0c2b23d 100644 --- a/storagemanager/StorageManagerIF.h +++ b/storagemanager/StorageManagerIF.h @@ -48,6 +48,10 @@ union store_address_t { * Alternative access to the raw value. */ uint32_t raw; + + bool operator==(const store_address_t& other) const { + return raw == other.raw; + } }; /** From 50fd86edc1a9d35e681eb730f2e838733a24254d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 25 May 2020 15:03:31 +0200 Subject: [PATCH 5/5] removed shoulddo, issue will be created --- modes/ModeMessage.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/modes/ModeMessage.h b/modes/ModeMessage.h index 0a72aee0..f72fdeec 100644 --- a/modes/ModeMessage.h +++ b/modes/ModeMessage.h @@ -23,8 +23,6 @@ public: static const Command_t REPLY_MODE_REPLY = MAKE_COMMAND_ID(0x02);//!> Reply to a CMD_MODE_COMMAND or CMD_MODE_READ static const Command_t REPLY_MODE_INFO = MAKE_COMMAND_ID(0x03); //!> Unrequested info about the current mode (used for composites to inform their container of a changed mode) static const Command_t REPLY_CANT_REACH_MODE = MAKE_COMMAND_ID(0x04); //!> Reply in case a mode command can't be executed. Par1: returnCode, Par2: 0 - //SHOULDDO is there a way we can transmit a returnvalue when responding that the mode is wrong, so we can give a nice failure code when commanded by PUS? - // shouldn't that possible with parameter 2 when submode only takes 1 byte? static const Command_t REPLY_WRONG_MODE_REPLY = MAKE_COMMAND_ID(0x05);//!> Reply to a CMD_MODE_COMMAND, indicating that a mode was commanded and a transition started but was aborted; the parameters contain the mode that was reached static const Command_t CMD_MODE_READ = MAKE_COMMAND_ID(0x06);//!> Command to read the current mode and reply with a REPLY_MODE_REPLY static const Command_t CMD_MODE_ANNOUNCE = MAKE_COMMAND_ID(0x07);//!> Command to trigger an ModeInfo Event. This command does NOT have a reply.