From 2700d4d28c1641431c0ad966ab2924aa6cfc14de Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Wed, 4 Aug 2021 13:20:28 +0200 Subject: [PATCH] ploc updater wip --- fsfw | 2 +- mission/devices/PlocUpdater.cpp | 47 +++++++++++++++------------------ mission/devices/PlocUpdater.h | 11 ++++++-- tmtc | 2 +- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/fsfw b/fsfw index 0ff81294..296c587e 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 0ff81294e7e209bb4a26171b10d80fe522e65bcf +Subproject commit 296c587e3de10c579847e04af3176b3acaa2d701 diff --git a/mission/devices/PlocUpdater.cpp b/mission/devices/PlocUpdater.cpp index d1a44783..c7310298 100644 --- a/mission/devices/PlocUpdater.cpp +++ b/mission/devices/PlocUpdater.cpp @@ -8,52 +8,47 @@ PlocUpdater::~PlocUpdater() { } ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, uint32_t size) { + MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_FAILED; + if (state == BUSY) { - return UPDATER_BUSY; + return IS_BUSY; } - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; - dumpData.address = 0; - receivedDataSize = 0; - timer.resetTimer(); + + if (size > MAX_PLOC_UPDATE_PATH) { + return PATH_TOO_LONG; + } + switch (actionId) { case UPDATE_NVM0_A: + result = prepareNvm0AUpdate(std::string(data, size)); break; case UPDATE_NVM0_B: + result = prepareNvm0BUpdate(); break; case UPDATE_NVM1_A: + result = prepareNvm1AUpdate(); break; case UPDATE_NVM1_B: - break; - dumpData.size = STRHandler::IMAGE_HEADER_SIZE; - dumpData.memoryId = STRHandler::ASC_MID_IMAGE; - result = commandActionHelper.commandAction(objects::STR_HANDLER, - STRHandler::ASC_SEND_IMAGE_TC_ID, &dumpData); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - state = EXPECT_IMAGE_SIZE; - break; - case FETCH_MIRU_DATA: - dumpData.memoryId = STRHandler::ASC_MID_MASSMEMORY; - dumpData.size = chunkSize; - result = commandActionHelper.commandAction(objects::STR_HANDLER, - STRHandler::ASC_MIRU_DUMP_DATA_TC_ID, &dumpData); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - state = MIRU_DATA_REQUESTED; + result = prepareNvm1BUpdate(); break; default: return INVALID_ACTION_ID; } - return EXECUTION_FINISHED; + return result; } MessageQueueId_t PlocUpdater::getCommandQueue() const { return commandQueue.getId(); } +ReturnValue_t PlocUpdater::checkPath(size_t size) { + if (size > MAX_PLOC_UPDATE_PATH) { + return PATH_TOO_LONG; + } + return RETURN_OK; +} + PlocUpdater::prepare getCurrentMountPrefix diff --git a/mission/devices/PlocUpdater.h b/mission/devices/PlocUpdater.h index ae3edf1f..dd37898e 100644 --- a/mission/devices/PlocUpdater.h +++ b/mission/devices/PlocUpdater.h @@ -2,6 +2,7 @@ #define MISSION_DEVICES_PLOCUPDATER_H_ #include "fsfw/action/CommandActionHelper.h" +#include "fsfw/returnvalues/HasReturnValuesIF.h" /** * @brief An object of this class can be used to perform the software updates of the PLOC. The @@ -15,7 +16,8 @@ */ class PlocUpdater : public SystemObject, public HasActionsIF, - public ExecutableObjectIF { + public ExecutableObjectIF, + public HasReturnvaluesIF { public: static const ActionId_t UPDATE_NVM0_A = 0; @@ -36,10 +38,15 @@ private: //! [EXPORT] : [COMMENT] Updater is already performing an update static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Received update command with invalid path string (too long). + static const ReturnValue_t PATH_TOO_LONG = MAKE_RETURN_CODE(0xA0); - static constexpr uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; + static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; + static const size_t MAX_PLOC_UPDATE_PATH = 20; CommandActionHelper commandActionHelper; + + ReturnValue_t checkPath(size_t size); }; #endif /* MISSION_DEVICES_PLOCUPDATER_H_ */ diff --git a/tmtc b/tmtc index 477743f6..4aebf4c0 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 477743f6264689327528beb5344c39247af6c49e +Subproject commit 4aebf4c0d9a4a094e1a18753bca77d6a3b993378