From d95582b81b1258d14da0507825b643f141112507 Mon Sep 17 00:00:00 2001 From: Cleanroom Laptop L590 Date: Thu, 24 Mar 2022 16:54:41 +0100 Subject: [PATCH 1/7] cmake lists update to suppress large warning --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9786d572..7ef11493 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,9 +48,10 @@ add_library(${LIB_FSFW_NAME}) if(FSFW_BUILD_UNITTESTS) message(STATUS "Building the FSFW unittests in addition to the static library") # Check whether the user has already installed Catch2 first - find_package(Catch2 3) + find_package(Catch2 3 QUIET) # Not installed, so use FetchContent to download and provide Catch2 if(NOT Catch2_FOUND) + message(STATUS "Catch2 installation not found. Downloading Catch2 library with FetchContent") include(FetchContent) FetchContent_Declare( From d9d9a28ef84f01b3915865cd5399e9ebe0e104f2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Mar 2022 21:04:46 +0100 Subject: [PATCH 2/7] delete code which is not required anymore --- hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index 69f6311e..52b6dc07 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -1,9 +1,6 @@ #include "MgmLIS3MDLHandler.h" #include "fsfw/datapool/PoolReadGuard.h" -#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 -#include "fsfw/globalfunctions/PeriodicOperationDivider.h" -#endif #include From 916ed3f56ac676f5a411895d4fadbb8665bb550e Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 28 Mar 2022 13:50:42 +0200 Subject: [PATCH 3/7] added function to add component to a periodic task by pointer --- src/fsfw/osal/freertos/PeriodicTask.cpp | 10 +++++++--- src/fsfw/osal/freertos/PeriodicTask.h | 10 ++++++++++ src/fsfw/osal/host/PeriodicTask.cpp | 10 +++++++--- src/fsfw/osal/host/PeriodicTask.h | 10 ++++++++++ src/fsfw/osal/linux/PeriodicPosixTask.cpp | 10 +++++++--- src/fsfw/osal/linux/PeriodicPosixTask.h | 8 ++++++++ src/fsfw/osal/rtems/PeriodicTask.cpp | 10 +++++++--- src/fsfw/osal/rtems/PeriodicTask.h | 9 +++++++++ src/fsfw/tasks/PeriodicTaskIF.h | 20 ++++++++++++-------- 9 files changed, 77 insertions(+), 20 deletions(-) diff --git a/src/fsfw/osal/freertos/PeriodicTask.cpp b/src/fsfw/osal/freertos/PeriodicTask.cpp index 8dfa0290..d2c46ea8 100644 --- a/src/fsfw/osal/freertos/PeriodicTask.cpp +++ b/src/fsfw/osal/freertos/PeriodicTask.cpp @@ -97,7 +97,11 @@ void PeriodicTask::taskFunctionality() { ReturnValue_t PeriodicTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = ObjectManager::instance()->get(object); - if (newObject == nullptr) { + return addComponent(newObject); +} + +ReturnValue_t PeriodicTask::addComponent(ExecutableObjectIF* object) { + if (object == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" "it implement ExecutableObjectIF" @@ -105,8 +109,8 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object) { #endif return HasReturnvaluesIF::RETURN_FAILED; } - objectList.push_back(newObject); - newObject->setTaskIF(this); + objectList.push_back(object); + object->setTaskIF(this); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/osal/freertos/PeriodicTask.h b/src/fsfw/osal/freertos/PeriodicTask.h index cc395176..fc8e9092 100644 --- a/src/fsfw/osal/freertos/PeriodicTask.h +++ b/src/fsfw/osal/freertos/PeriodicTask.h @@ -63,6 +63,16 @@ class PeriodicTask : public PeriodicTaskIF, public FreeRTOSTaskIF { */ ReturnValue_t addComponent(object_id_t object) override; + /** + * Adds an object to the list of objects to be executed. + * The objects are executed in the order added. + * @param object Id of the object to add. + * @return + * -@c RETURN_OK on success + * -@c RETURN_FAILED if the object could not be added. + */ + ReturnValue_t addComponent(ExecutableObjectIF* object) override; + uint32_t getPeriodMs() const override; ReturnValue_t sleepFor(uint32_t ms) override; diff --git a/src/fsfw/osal/host/PeriodicTask.cpp b/src/fsfw/osal/host/PeriodicTask.cpp index 1de4aedf..cdcfafa6 100644 --- a/src/fsfw/osal/host/PeriodicTask.cpp +++ b/src/fsfw/osal/host/PeriodicTask.cpp @@ -102,11 +102,15 @@ void PeriodicTask::taskFunctionality() { ReturnValue_t PeriodicTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = ObjectManager::instance()->get(object); - if (newObject == nullptr) { + return addComponent(newObject); +} + +ReturnValue_t PeriodicTask::addComponent(ExecutableObjectIF* object) { + if (object == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } - newObject->setTaskIF(this); - objectList.push_back(newObject); + object->setTaskIF(this); + objectList.push_back(object); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/osal/host/PeriodicTask.h b/src/fsfw/osal/host/PeriodicTask.h index 0c41c0f7..6c4d5e8b 100644 --- a/src/fsfw/osal/host/PeriodicTask.h +++ b/src/fsfw/osal/host/PeriodicTask.h @@ -59,6 +59,16 @@ class PeriodicTask : public PeriodicTaskIF { */ ReturnValue_t addComponent(object_id_t object); + /** + * Adds an object to the list of objects to be executed. + * The objects are executed in the order added. + * @param object pointer to the object to add. + * @return + * -@c RETURN_OK on success + * -@c RETURN_FAILED if the object could not be added. + */ + ReturnValue_t addComponent(ExecutableObjectIF* object); + uint32_t getPeriodMs() const; ReturnValue_t sleepFor(uint32_t ms); diff --git a/src/fsfw/osal/linux/PeriodicPosixTask.cpp b/src/fsfw/osal/linux/PeriodicPosixTask.cpp index ca346670..e1937df4 100644 --- a/src/fsfw/osal/linux/PeriodicPosixTask.cpp +++ b/src/fsfw/osal/linux/PeriodicPosixTask.cpp @@ -28,7 +28,11 @@ void* PeriodicPosixTask::taskEntryPoint(void* arg) { ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = ObjectManager::instance()->get(object); - if (newObject == nullptr) { + return addComponent(newObject); +} + +ReturnValue_t PeriodicPosixTask::addComponent(ExecutableObjectIF* object) { + if (object == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" << " it implements ExecutableObjectIF!" << std::endl; @@ -39,8 +43,8 @@ ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) { #endif return HasReturnvaluesIF::RETURN_FAILED; } - objectList.push_back(newObject); - newObject->setTaskIF(this); + objectList.push_back(object); + object->setTaskIF(this); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/osal/linux/PeriodicPosixTask.h b/src/fsfw/osal/linux/PeriodicPosixTask.h index 1c3a52c7..3cd9847a 100644 --- a/src/fsfw/osal/linux/PeriodicPosixTask.h +++ b/src/fsfw/osal/linux/PeriodicPosixTask.h @@ -42,6 +42,14 @@ class PeriodicPosixTask : public PosixThread, public PeriodicTaskIF { */ ReturnValue_t addComponent(object_id_t object) override; + /** + * Adds an object to the list of objects to be executed. + * The objects are executed in the order added. + * @param object pointer to the object to add. + * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. + */ + ReturnValue_t addComponent(ExecutableObjectIF* object) override; + uint32_t getPeriodMs() const override; ReturnValue_t sleepFor(uint32_t ms) override; diff --git a/src/fsfw/osal/rtems/PeriodicTask.cpp b/src/fsfw/osal/rtems/PeriodicTask.cpp index 1785c8cf..ae2ec426 100644 --- a/src/fsfw/osal/rtems/PeriodicTask.cpp +++ b/src/fsfw/osal/rtems/PeriodicTask.cpp @@ -68,11 +68,15 @@ void PeriodicTask::taskFunctionality() { ReturnValue_t PeriodicTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = ObjectManager::instance()->get(object); - if (newObject == nullptr) { + return addComponent(newObject); +} + +ReturnValue_t PeriodicTask::addComponent(ExecutableObjectIF* object) { + if (object == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } - objectList.push_back(newObject); - newObject->setTaskIF(this); + objectList.push_back(object); + object->setTaskIF(this); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/osal/rtems/PeriodicTask.h b/src/fsfw/osal/rtems/PeriodicTask.h index 119329f2..24ce4af1 100644 --- a/src/fsfw/osal/rtems/PeriodicTask.h +++ b/src/fsfw/osal/rtems/PeriodicTask.h @@ -59,6 +59,15 @@ class PeriodicTask : public RTEMSTaskBase, public PeriodicTaskIF { */ ReturnValue_t addComponent(object_id_t object) override; +/** + * Adds an object to the list of objects to be executed. + * The objects are executed in the order added. + * @param object pointer to the object to add. + * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. + */ + ReturnValue_t addComponent(ExecutableObjectIF* object) override; + + uint32_t getPeriodMs() const override; ReturnValue_t sleepFor(uint32_t ms) override; diff --git a/src/fsfw/tasks/PeriodicTaskIF.h b/src/fsfw/tasks/PeriodicTaskIF.h index a8a51229..c78a32de 100644 --- a/src/fsfw/tasks/PeriodicTaskIF.h +++ b/src/fsfw/tasks/PeriodicTaskIF.h @@ -26,21 +26,25 @@ class PeriodicTaskIF { virtual ReturnValue_t startTask() = 0; /** - * Add a component (object) to a periodic task. The pointer to the - * task can be set optionally + * Add a component (object) to a periodic task. * @param object - * Add an object to the task. The most important case is to add an - * executable object with a function which will be called regularly - * (see ExecutableObjectIF) - * @param setTaskIF - * Can be used to specify whether the task object pointer is passed - * to the component. + * Add an object to the task. The object needs to implement ExecutableObjectIF * @return */ virtual ReturnValue_t addComponent(object_id_t object) { return HasReturnvaluesIF::RETURN_FAILED; }; + /** + * Add an object to a periodic task. + * @param object + * Add an object to the task. + * @return + */ + virtual ReturnValue_t addComponent(ExecutableObjectIF* object) { + return HasReturnvaluesIF::RETURN_FAILED; + }; + virtual ReturnValue_t sleepFor(uint32_t ms) = 0; virtual uint32_t getPeriodMs() const = 0; From 6c1db8473bdd7639065e230341d52007c58ecf49 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 31 Mar 2022 14:36:45 +0200 Subject: [PATCH 4/7] get alternative reply from device command info --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 31 ++++++++++++++----- src/fsfw/devicehandlers/DeviceHandlerBase.h | 6 +++- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 08a15d5f..0e2802ac 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -410,7 +410,7 @@ ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap( DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, LocalPoolDataSetBase* replyDataSet, size_t replyLen, bool periodic, bool hasDifferentReplyId, DeviceCommandId_t replyId) { // No need to check, as we may try to insert multiple times. - insertInCommandMap(deviceCommand); + insertInCommandMap(deviceCommand, hasDifferentReplyId, replyId); if (hasDifferentReplyId) { return insertInReplyMap(replyId, maxDelayCycles, replyDataSet, replyLen, periodic); } else { @@ -437,11 +437,15 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, } } -ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceCommand) { +ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceCommand, + bool useAlternativeReply, + DeviceCommandId_t alternativeReplyId) { DeviceCommandInfo info; info.expectedReplies = 0; info.isExecuting = false; info.sendReplyTo = NO_COMMANDER; + info.useAlternativeReplyId = alternativeReplyId; + info.alternativeReplyId = alternativeReplyId; auto resultPair = deviceCommandMap.emplace(deviceCommand, info); if (resultPair.second) { return RETURN_OK; @@ -451,12 +455,21 @@ ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceComm } size_t DeviceHandlerBase::getNextReplyLength(DeviceCommandId_t commandId) { - DeviceReplyIter iter = deviceReplyMap.find(commandId); - if (iter != deviceReplyMap.end()) { - return iter->second.replyLen; - } else { - return 0; + DeviceCommandId_t replyId = NO_COMMAND_ID; + DeviceCommandMap::iterator command = cookieInfo.pendingCommand; + if (command->second.useAlternativeReplyId) { + replyId = command->second.alternativeReplyId; } + else { + replyId = commandId; + } + DeviceReplyIter iter = deviceReplyMap.find(replyId); + if (iter != deviceReplyMap.end()) { + if (iter->second.delayCycles != 0) { + return iter->second.replyLen; + } + } + return 0; } ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceReply, @@ -651,7 +664,9 @@ void DeviceHandlerBase::doGetWrite() { // We need to distinguish here, because a raw command never expects a reply. //(Could be done in eRIRM, but then child implementations need to be careful. - result = enableReplyInReplyMap(cookieInfo.pendingCommand); + DeviceCommandMap::iterator command = cookieInfo.pendingCommand; + result = enableReplyInReplyMap(command, 1, command->second.useAlternativeReplyId, + command->second.alternativeReplyId); } else { // always generate a failure event, so that FDIR knows what's up triggerEvent(DEVICE_SENDING_COMMAND_FAILED, result, cookieInfo.pendingCommand->first); diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index c8b8b86d..5e974831 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -478,7 +478,9 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @return - @c RETURN_OK when the command was successfully inserted, * - @c RETURN_FAILED else. */ - ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand); + ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand, + bool useAlternativeReply = false, + DeviceCommandId_t alternativeReplyId = 0); /** * Enables a periodic reply for a given command. It sets to delay cycles to the specified @@ -751,6 +753,8 @@ class DeviceHandlerBase : public DeviceHandlerIF, //! if this is != NO_COMMANDER, DHB was commanded externally and shall //! report everything to commander. MessageQueueId_t sendReplyTo; + bool useAlternativeReplyId; + DeviceCommandId_t alternativeReplyId; }; using DeviceCommandMap = std::map; /** From 17771c0497857dc8f968b8a047bb7dcbf45509e3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Apr 2022 13:57:18 +0200 Subject: [PATCH 5/7] progagate reply returnvalue --- src/fsfw/datapoollocal/LocalDataPoolManager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index acfa23c5..fe9ed3a4 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -801,8 +801,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i HousekeepingMessage::setHkStuctureReportReply(&reply, sid, storeId); } - hkQueue->reply(&reply); - return result; + return hkQueue->reply(&reply); } void LocalDataPoolManager::clearReceiversList() { From acc4c8d975bb05c704ad94613ea10782f707d106 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Apr 2022 14:33:28 +0200 Subject: [PATCH 6/7] check serialize result as well --- src/fsfw/datapoollocal/LocalDataPoolManager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index fe9ed3a4..0c255571 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -787,6 +787,10 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i // Serialize set packet into store. size_t size = 0; result = setPacket.serialize(&storePtr, &size, expectedSize, SerializeIF::Endianness::BIG); + if(result != HasReturnvaluesIF::RETURN_OK) { + ipcStore->deleteData(storeId); + return result; + } if (expectedSize != size) { printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateSetStructurePacket", HasReturnvaluesIF::RETURN_FAILED, From 7761b66fe240b604a3fc4f3f6283ac5bbfe39c9f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Apr 2022 14:35:16 +0200 Subject: [PATCH 7/7] delete data from ipc store if reply fails --- src/fsfw/datapoollocal/LocalDataPoolManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 0c255571..6053bd43 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -805,7 +805,11 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i HousekeepingMessage::setHkStuctureReportReply(&reply, sid, storeId); } - return hkQueue->reply(&reply); + result = hkQueue->reply(&reply); + if(result != HasReturnvaluesIF::RETURN_OK) { + ipcStore->deleteData(storeId); + } + return result; } void LocalDataPoolManager::clearReceiversList() {