From ad5bb4c69452e10ab9afdf56f3f9011198661ca2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Feb 2022 10:40:00 +0100 Subject: [PATCH 01/44] update changelog.md --- CHANGELOG => CHANGELOG.md | 168 +++++++++++++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 2 deletions(-) rename CHANGELOG => CHANGELOG.md (57%) diff --git a/CHANGELOG b/CHANGELOG.md similarity index 57% rename from CHANGELOG rename to CHANGELOG.md index 8f86c147..e7d4f880 100644 --- a/CHANGELOG +++ b/CHANGELOG.md @@ -1,4 +1,168 @@ -# Changed from ASTP 1.1.0 to 1.2.0 +Change Log +======= + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +# [unreleased] + +# [v4.0.0] + +## Additions + +- CFDP Packet Stack and related tests added. It also refactors the existing TMTC infastructure to + allow sending of CFDP packets to the CCSDS handlers. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/528 + +## Changes + +- Applied the `clang-format` auto-formatter to all source code + +## Bugfix + +- CMake fixes in PR https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/533 , was problematic + if the uppermost user `CMakeLists.txt` did not have the include paths set up properly, which + could lead to compile errors that `#include "fsfw/FSFW.h"` was not found. + +## API Changes + +- Aforementioned changes to existing TMTC stack + +# [v3.0.0] + +## API Changes + +#### TCP Socket Changes + +* Keep Open TCP Implementation #496 + * The socket will now kept open after disconnect. This allows reconnecting. + * Only one connection is allowed + * No internal influence but clients need to change their Code. + +### GPIO IF + +* Add feature to open GPIO by line name #506 + +### Bitutil + +* Unittests for Op Divider and Bitutility #510 + +### Filesystem IF changed + +* Filesystem Base Interface: Use IF instead of void pointer #511 + +### STM32 + +* STM32 SPI Updates #518 + +## Bugfixes + +* Small bugfix for LIS3 handler #504 +* Spelling fixed for function names #509 +* CMakeLists fixes #517 +* Out of bound reads and writes in unittests #519 +* Bug in TmPacketStoredPusC (#478) +* Windows ifdef fixed #529 + +## Enhancement + +* FSFW.h.in more default values #491 +* Minor updates for PUS services #498 +* HasReturnvaluesIF naming for parameter #499 +* Tests can now be built as part of FSFW and versioning moved to CMake #500 +* Added integration test code #508 +* More printouts for rejected TC packets #505 +* Arrayprinter format improvements #514 +* Adding code for CI with docker and jenkins #520 +* Added new function in SerializeAdapter #513 + * Enables simple deSerialize if you keep track of the buffer position yourself + * `` static ReturnValue_t deSerialize(T *object, const uint8_t* buffer, + size_t* deserSize, SerializeIF::Endianness streamEndianness) `` +* Unittest helper scripts has a new Parameter to open the coverage html in the webrowser #525 + * ``'-o', '--open', Open coverage data in webbrowser`` +* Documentation updated. Sphinx Documentation can now be build with python script #526 + +## Known bugs + +* + + +All Pull Requests: + +Milestone: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/milestone/19 + +# [v2.0.0] + +## API Changes + + +### File Structure changed to fit more common structure + +* See pull request (#445) + * HAL is now part of the main project + * **See Instructions below:** + +#### Instruction how to update existing / user code + +* Changes in `#include`: + * Rename `internalError` in includes to `internalerror` + * Rename `fsfw/hal` to `fsfw_hal` + * Rename `fsfw/tests` to `fsfw_tests` + * Rename `osal/FreeRTOS` to `osal/freertos` + +* Changes in `CMakeLists.txt`: + * Rename `OS_FSFW` to `FSFW_OSAL` + +* Changes in `DleEncoder.cpp` + * Create an instance of the `DleEncoder` first before calling the `encode` and `decode` functions + +### Removed osal/linux/Timer (#486) + +* Was redundant to timemanager/Countdown + +#### Instruction how to update existing / user code + +* Use timemanager/Countdown instead + +## Bugfixes + +### TM Stack + +* Increased TM stack robustness by introducing `nullptr` checks and more printouts (#483) + +#### Host OSAL / FreeRTOS + +* QueueMapManager Bugfix (NO_QUEUE was used as MessageQueueId) (#444) + +#### Events + +* Event output is now consistent (#447) + +#### DLE Encoder + +* Fixed possible out of bounds access in DLE Encoder (#492) + +## Enhancment + +* HAL as major new feature, also includes three MEMS devicehandlers as part of #481 +* Linux HAL updates (#456) +* FreeRTOS Header cleaning update and Cmake tweaks (#442) +* Printer updates (#453) +* New returnvalue for for empty PST (#485) +* TMTC Bridge: Increase limit of packets stored (#484) + +## Known bugs + +* Bug in TmPacketStoredPusC (#478) + + +All Pull Requests: + +Milestone: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/milestone/5 + +# [v1.2.0] ## API Changes @@ -27,7 +191,7 @@ - See API changes chapter. This change will keep the internal API consistent in the future -# Changes from ASTP 1.0.0 to 1.1.0 +# [v1.1.0] ## API Changes From 79936a33356d021ca99b27d2cbe1576f2a99afea Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 3 Feb 2022 10:14:47 +0100 Subject: [PATCH 02/44] uio mapper --- hal/src/fsfw_hal/linux/uio/CMakeLists.txt | 3 + hal/src/fsfw_hal/linux/uio/UioMapper.cpp | 80 +++++++++++++++++++++++ hal/src/fsfw_hal/linux/uio/UioMapper.h | 58 ++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 hal/src/fsfw_hal/linux/uio/CMakeLists.txt create mode 100644 hal/src/fsfw_hal/linux/uio/UioMapper.cpp create mode 100644 hal/src/fsfw_hal/linux/uio/UioMapper.h diff --git a/hal/src/fsfw_hal/linux/uio/CMakeLists.txt b/hal/src/fsfw_hal/linux/uio/CMakeLists.txt new file mode 100644 index 00000000..e98a0865 --- /dev/null +++ b/hal/src/fsfw_hal/linux/uio/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${LIB_FSFW_NAME} PUBLIC + UioMapper.cpp +) diff --git a/hal/src/fsfw_hal/linux/uio/UioMapper.cpp b/hal/src/fsfw_hal/linux/uio/UioMapper.cpp new file mode 100644 index 00000000..bc2d06eb --- /dev/null +++ b/hal/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -0,0 +1,80 @@ +#include "UioMapper.h" + +#include +#include + +#include +#include +#include + +#include "fsfw/serviceinterface.h" + +const char UioMapper::UIO_PATH_PREFIX[] = "/sys/class/uio/"; +const char UioMapper::MAP_SUBSTR[] = "/maps/map"; +const char UioMapper::SIZE_FILE_PATH[] = "/size"; + +UioMapper::UioMapper(std::string uioFile, int mapNum) : uioFile(uioFile), mapNum(mapNum) {} + +UioMapper::~UioMapper() {} + +ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permissions) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + int fd = open(uioFile.c_str(), O_RDWR); + if (fd < 1) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl; +#endif + return HasReturnvaluesIF::RETURN_FAILED; + } + size_t size = 0; + result = getMapSize(&size); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + *address = static_cast( + mmap(NULL, size, static_cast(permissions), MAP_SHARED, fd, mapNum * getpagesize())); + + if (*address == MAP_FAILED) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "UioMapper::getMappedAdress: Failed to map physical address of uio device " + << uioFile.c_str() << " and map" << static_cast(mapNum) << std::endl; +#endif + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t UioMapper::getMapSize(size_t* size) { + std::stringstream namestream; + namestream << UIO_PATH_PREFIX << uioFile.substr(5, std::string::npos) << MAP_SUBSTR << mapNum + << SIZE_FILE_PATH; + FILE* fp; + fp = fopen(namestream.str().c_str(), "r"); + if (fp == nullptr) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "UioMapper::getMapSize: Failed to open file " << namestream.str() << std::endl; +#endif + return HasReturnvaluesIF::RETURN_FAILED; + } + char hexstring[SIZE_HEX_STRING] = ""; + int items = fscanf(fp, "%s", hexstring); + if (items != 1) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "UioMapper::getMapSize: Failed with error code " << errno + << " to read size " + "string from file " + << namestream.str() << std::endl; +#endif + return HasReturnvaluesIF::RETURN_FAILED; + } + items = sscanf(hexstring, "%lx", size); + if (items != 1) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "UioMapper::getMapSize: Failed with error code " << errno << "to convert " + << "size of map" << mapNum << " to integer" << std::endl; +#endif + return HasReturnvaluesIF::RETURN_FAILED; + } + fclose(fp); + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/hal/src/fsfw_hal/linux/uio/UioMapper.h b/hal/src/fsfw_hal/linux/uio/UioMapper.h new file mode 100644 index 00000000..20c90b4d --- /dev/null +++ b/hal/src/fsfw_hal/linux/uio/UioMapper.h @@ -0,0 +1,58 @@ +#ifndef FSFW_HAL_SRC_FSFW_HAL_LINUX_UIO_UIOMAPPER_H_ +#define FSFW_HAL_SRC_FSFW_HAL_LINUX_UIO_UIOMAPPER_H_ + +#include + +#include + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +/** + * @brief Class to help opening uio device files and mapping the physical addresses into the user + * address space. + * + * @author J. Meier + */ +class UioMapper { + public: + enum class Permissions : int { + READ_ONLY = PROT_READ, + WRITE_ONLY = PROT_WRITE, + READ_WRITE = PROT_READ | PROT_WRITE + }; + + /** + * @brief Constructor + * + * @param uioFile The device file of the uiO to open + * @param uioMap Number of memory map. Most UIO drivers have only one map which has than 0. + */ + UioMapper(std::string uioFile, int mapNum = 0); + virtual ~UioMapper(); + + /** + * @brief Maps the physical address into user address space and returns the mapped address + * + * @address The mapped user space address + * @permissions Specifies the read/write permissions of the address region + */ + ReturnValue_t getMappedAdress(uint32_t** address, Permissions permissions); + + private: + static const char UIO_PATH_PREFIX[]; + static const char MAP_SUBSTR[]; + static const char SIZE_FILE_PATH[]; + static constexpr int SIZE_HEX_STRING = 10; + + std::string uioFile; + int mapNum = 0; + + /** + * @brief Reads the map size from the associated sysfs size file + * + * @param size The read map size + */ + ReturnValue_t getMapSize(size_t* size); +}; + +#endif /* FSFW_HAL_SRC_FSFW_HAL_LINUX_UIO_UIOMAPPER_H_ */ From 2d52042ed6923103ac4942b6961a00b77f52830c Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 3 Feb 2022 10:16:06 +0100 Subject: [PATCH 03/44] add uio subdir --- hal/src/fsfw_hal/linux/CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hal/src/fsfw_hal/linux/CMakeLists.txt b/hal/src/fsfw_hal/linux/CMakeLists.txt index 5944b0e5..0fb2d385 100644 --- a/hal/src/fsfw_hal/linux/CMakeLists.txt +++ b/hal/src/fsfw_hal/linux/CMakeLists.txt @@ -4,10 +4,15 @@ endif() target_sources(${LIB_FSFW_NAME} PRIVATE UnixFileGuard.cpp + CommandExecutor.cpp utility.cpp ) -add_subdirectory(gpio) -add_subdirectory(spi) -add_subdirectory(i2c) -add_subdirectory(uart) \ No newline at end of file +if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS) + add_subdirectory(gpio) + add_subdirectory(spi) + add_subdirectory(i2c) + add_subdirectory(uart) +endif() + +add_subdirectory(uio) From 40329a33b2b28b0d96e80ba8dc005f23a00f2245 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 3 Feb 2022 10:19:33 +0100 Subject: [PATCH 04/44] prepared for proper pr --- hal/src/fsfw_hal/linux/CMakeLists.txt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hal/src/fsfw_hal/linux/CMakeLists.txt b/hal/src/fsfw_hal/linux/CMakeLists.txt index 0fb2d385..056b59c8 100644 --- a/hal/src/fsfw_hal/linux/CMakeLists.txt +++ b/hal/src/fsfw_hal/linux/CMakeLists.txt @@ -4,15 +4,11 @@ endif() target_sources(${LIB_FSFW_NAME} PRIVATE UnixFileGuard.cpp - CommandExecutor.cpp utility.cpp ) -if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS) - add_subdirectory(gpio) - add_subdirectory(spi) - add_subdirectory(i2c) - add_subdirectory(uart) -endif() - +add_subdirectory(gpio) +add_subdirectory(spi) +add_subdirectory(i2c) +add_subdirectory(uart) add_subdirectory(uio) From e9b0951a95aeb7e4aa1f16e7cf38bb4851b9b7f6 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 3 Feb 2022 10:37:07 +0100 Subject: [PATCH 05/44] virtual function to print datasets --- src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp | 2 ++ src/fsfw/datapoollocal/LocalPoolDataSetBase.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp index e2fe7d39..4a076212 100644 --- a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp @@ -291,3 +291,5 @@ float LocalPoolDataSetBase::getCollectionInterval() const { return 0.0; } } + +void LocalPoolDataSetBase::printSet() { return; } diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.h b/src/fsfw/datapoollocal/LocalPoolDataSetBase.h index c2de2c54..17cf8be2 100644 --- a/src/fsfw/datapoollocal/LocalPoolDataSetBase.h +++ b/src/fsfw/datapoollocal/LocalPoolDataSetBase.h @@ -171,6 +171,11 @@ class LocalPoolDataSetBase : public PoolDataSetBase, public MarkChangedIF { */ float getCollectionInterval() const; + /** + * @brief Can be overwritten by a specific implementation of a dataset to print the set. + */ + virtual void printSet(); + protected: sid_t sid; //! This mutex is used if the data is created by one object only. From 06ffe27fcc5e8008d5a1b8d53cbead2e08951aef Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 3 Feb 2022 10:46:14 +0100 Subject: [PATCH 06/44] do send read hook --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 7 +++++++ src/fsfw/devicehandlers/DeviceHandlerBase.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 08d7c1d8..ea1fcdf1 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -665,6 +665,11 @@ void DeviceHandlerBase::doGetWrite() { void DeviceHandlerBase::doSendRead() { ReturnValue_t result; + result = doSendReadHook(); + if (result != RETURN_OK) { + return; + } + size_t replyLen = 0; if (cookieInfo.pendingCommand != deviceCommandMap.end()) { replyLen = getNextReplyLength(cookieInfo.pendingCommand->first); @@ -920,6 +925,8 @@ void DeviceHandlerBase::commandSwitch(ReturnValue_t onOff) { } } +ReturnValue_t DeviceHandlerBase::doSendReadHook() { return RETURN_OK; } + ReturnValue_t DeviceHandlerBase::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { return DeviceHandlerBase::NO_SWITCH; } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index f3dda5c8..037f4bd7 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -1082,6 +1082,12 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ void commandSwitch(ReturnValue_t onOff); + /** + * @brief This function can be used to insert device specific code during the do-send-read + * step. + */ + virtual ReturnValue_t doSendReadHook(); + private: /** * State a cookie is in. From f08d291e3e22950e729c327c101d22a943910e9b Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 3 Feb 2022 11:07:51 +0100 Subject: [PATCH 07/44] fix to remove compiler warning --- hal/src/fsfw_hal/linux/uio/UioMapper.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hal/src/fsfw_hal/linux/uio/UioMapper.cpp b/hal/src/fsfw_hal/linux/uio/UioMapper.cpp index bc2d06eb..b29ed63e 100644 --- a/hal/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/hal/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -67,7 +67,11 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { #endif return HasReturnvaluesIF::RETURN_FAILED; } - items = sscanf(hexstring, "%lx", size); + uint32_t sizeTmp = 0; + items = sscanf(hexstring, "%x", &sizeTmp); + if(size != nullptr) { + *size = sizeTmp; + } if (items != 1) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UioMapper::getMapSize: Failed with error code " << errno << "to convert " From 0d4bd856bd6753db60e2465a754ee728ac44cabc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Feb 2022 17:33:46 +0100 Subject: [PATCH 08/44] removed HK switch helper from cmake file --- src/fsfw/datapool/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/fsfw/datapool/CMakeLists.txt b/src/fsfw/datapool/CMakeLists.txt index 0d53e1ba..535be2b0 100644 --- a/src/fsfw/datapool/CMakeLists.txt +++ b/src/fsfw/datapool/CMakeLists.txt @@ -1,6 +1,4 @@ -target_sources(${LIB_FSFW_NAME} - PRIVATE - HkSwitchHelper.cpp - PoolDataSetBase.cpp - PoolEntry.cpp +target_sources(${LIB_FSFW_NAME} PRIVATE + PoolDataSetBase.cpp + PoolEntry.cpp ) \ No newline at end of file From 32a9e0c7044665f0265c10108c8d62d45c047769 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Feb 2022 17:37:11 +0100 Subject: [PATCH 09/44] another include removed --- src/fsfw/controller/ControllerBase.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h index db75982c..7032f817 100644 --- a/src/fsfw/controller/ControllerBase.h +++ b/src/fsfw/controller/ControllerBase.h @@ -1,7 +1,6 @@ #ifndef FSFW_CONTROLLER_CONTROLLERBASE_H_ #define FSFW_CONTROLLER_CONTROLLERBASE_H_ -#include "fsfw/datapool/HkSwitchHelper.h" #include "fsfw/health/HasHealthIF.h" #include "fsfw/health/HealthHelper.h" #include "fsfw/modes/HasModesIF.h" From 1b41153ee6f4002c6215493bd50ec076fd0806df Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Feb 2022 10:16:37 +0100 Subject: [PATCH 10/44] add uio subdirectory --- hal/src/fsfw_hal/linux/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hal/src/fsfw_hal/linux/CMakeLists.txt b/hal/src/fsfw_hal/linux/CMakeLists.txt index 5ec8af06..0fb2d385 100644 --- a/hal/src/fsfw_hal/linux/CMakeLists.txt +++ b/hal/src/fsfw_hal/linux/CMakeLists.txt @@ -14,3 +14,5 @@ if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS) add_subdirectory(i2c) add_subdirectory(uart) endif() + +add_subdirectory(uio) From 43b7a314b6d965915850489f96f9c3982c1e4626 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Feb 2022 18:41:44 +0100 Subject: [PATCH 11/44] bump version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb3d48b8..2d65637f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.13) -set(FSFW_VERSION 2) +set(FSFW_VERSION 3) set(FSFW_SUBVERSION 0) set(FSFW_REVISION 0) From bd296883078e188fce44bc87e1013d930d129dbc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Feb 2022 10:11:24 +0100 Subject: [PATCH 12/44] bump revision --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d65637f..8a230133 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13) set(FSFW_VERSION 3) set(FSFW_SUBVERSION 0) -set(FSFW_REVISION 0) +set(FSFW_REVISION 1) # Add the cmake folder so the FindSphinx module is found set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) From 80a610141ae21dda993fe960ff170d14d433f083 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 4 Feb 2022 13:45:09 +0100 Subject: [PATCH 13/44] added v3.0.1 to changelog --- CHANGELOG.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7d4f880..b6adddf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Aforementioned changes to existing TMTC stack +# [v3.0.1] + +## API Changes + +* + +## Bugfixes + +* Version number was not updated for v3.0.0 #542 + +## Enhancement + +* + +## Known bugs + +* + # [v3.0.0] ## API Changes @@ -86,7 +104,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Known bugs -* +* Version number was not updated for v3.0.0 #542 All Pull Requests: From baddbf7340c78223e1494dac71dc735dfbef403d Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 7 Feb 2022 13:44:25 +0100 Subject: [PATCH 14/44] Updated changelog for v4.0.0 --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6adddf0..c3cb934d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,10 +15,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - CFDP Packet Stack and related tests added. It also refactors the existing TMTC infastructure to allow sending of CFDP packets to the CCSDS handlers. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/528 +- Linux Command Executor, which can execute shell commands in blocking and non-blocking mode + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/536 +- added virtual function to print datasets + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/544 ## Changes - Applied the `clang-format` auto-formatter to all source code + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/534 +- Updated Catch2 to v3.0.0-preview4, might fail installing with cmake, see known bugs below + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/538 ## Bugfix @@ -30,6 +37,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Aforementioned changes to existing TMTC stack +## Known bugs + +* on some platforms building Catch2 from cmake might fail. In this case, it is advised to build and + install locally from git, see automation/Dockerfile for an example + # [v3.0.1] ## API Changes From 6dc34fc1f006d147555af68c4dfc1e52c3865f03 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 7 Feb 2022 15:41:10 +0100 Subject: [PATCH 15/44] removed cmake warning as I have a workaround --- CHANGELOG.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3cb934d..5869a0a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,16 +15,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - CFDP Packet Stack and related tests added. It also refactors the existing TMTC infastructure to allow sending of CFDP packets to the CCSDS handlers. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/528 -- Linux Command Executor, which can execute shell commands in blocking and non-blocking mode - PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/536 - added virtual function to print datasets PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/544 +- doSendRead Hook + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/545 + +### HAL additions + +- Linux Command Executor, which can execute shell commands in blocking and non-blocking mode + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/536 +- uio Mapper + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/543 ## Changes - Applied the `clang-format` auto-formatter to all source code PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/534 -- Updated Catch2 to v3.0.0-preview4, might fail installing with cmake, see known bugs below +- Updated Catch2 to v3.0.0-preview4 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/538 ## Bugfix @@ -39,8 +46,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Known bugs -* on some platforms building Catch2 from cmake might fail. In this case, it is advised to build and - install locally from git, see automation/Dockerfile for an example +- # [v3.0.1] From 2e4cd8055617568bc66725aa43f63b6125631b03 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 7 Feb 2022 15:51:06 +0100 Subject: [PATCH 16/44] workaround for build regression catch2-v3.0.0-preview4 --- CMakeLists.txt | 2 ++ automation/Dockerfile | 6 ------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b090ca8..19fedb64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,8 @@ if(FSFW_BUILD_UNITTESTS) ) FetchContent_MakeAvailable(Catch2) + #fixes regression -preview4, to be confirmed in later releases + set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "") endif() set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg) diff --git a/automation/Dockerfile b/automation/Dockerfile index a530a671..9df67fc8 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -6,9 +6,3 @@ RUN apt-get --yes upgrade #tzdata is a dependency, won't install otherwise ARG DEBIAN_FRONTEND=noninteractive RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping - -RUN git clone https://github.com/catchorg/Catch2.git && \ - cd Catch2 && \ - git checkout v3.0.0-preview4 && \ - cmake -Bbuild -H. -DBUILD_TESTING=OFF && \ - cmake --build build/ --target install From 7a83289b3d4e62a20547c1652d850533756a5291 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 7 Feb 2022 16:48:41 +0100 Subject: [PATCH 17/44] using prebuild, static docker image --- automation/Jenkinsfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index dae2da2c..f76496d1 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -3,13 +3,7 @@ pipeline { BUILDDIR = 'build-tests' } agent { - dockerfile { - dir 'automation' - //force docker to redownload base image and rebuild all steps instead of caching them - //this way, we always get an up to date docker image one each build - additionalBuildArgs '--no-cache --pull' - reuseNode true - } + docker { image: fsfw-ci:d1} } stages { stage('Clean') { From 54f3d7bd2df092776d0e3ae2170428a18e7896b7 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 7 Feb 2022 16:49:42 +0100 Subject: [PATCH 18/44] Jenkinsfile typo --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index f76496d1..abd4532b 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { BUILDDIR = 'build-tests' } agent { - docker { image: fsfw-ci:d1} + docker { image: 'fsfw-ci:d1'} } stages { stage('Clean') { From 720813963090b28faa66a08b6e324aa99830e6ca Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 7 Feb 2022 16:50:59 +0100 Subject: [PATCH 19/44] Jenkinsfile another typo --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index abd4532b..3424f986 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { BUILDDIR = 'build-tests' } agent { - docker { image: 'fsfw-ci:d1'} + docker { image 'fsfw-ci:d1'} } stages { stage('Clean') { From c6d152a01d9e1691065040883df7ffcf7aa358e1 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 7 Feb 2022 17:11:04 +0100 Subject: [PATCH 20/44] updated changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5869a0a9..cda8037c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,12 +33,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/). PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/534 - Updated Catch2 to v3.0.0-preview4 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/538 +- Changed CI to use prebuilt docker image + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/549 ## Bugfix - CMake fixes in PR https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/533 , was problematic if the uppermost user `CMakeLists.txt` did not have the include paths set up properly, which could lead to compile errors that `#include "fsfw/FSFW.h"` was not found. +- Fix for build regression in Catch2 v3.0.0-preview4 + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/548 ## API Changes From 062e93fd8805b019e6e0c1d7f1323f214439158b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Feb 2022 13:53:01 +0100 Subject: [PATCH 21/44] started DHB docs --- docs/devicehandlers.rst | 102 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/docs/devicehandlers.rst b/docs/devicehandlers.rst index 58c2df78..d1a5fb67 100644 --- a/docs/devicehandlers.rst +++ b/docs/devicehandlers.rst @@ -1,3 +1,105 @@ Device Handlers ================== +Device handler components rerpresent, control and monitor equipment, for example sensors or actuators of a spacecraft or the payload. + +Most device handlers have the same common functionality or +requirements, which are fulfilled by implementing an certain interface: + +- The handler/device needs to be commandable: :cpp:class:`HasActionsIF` +- The handler needs to communicate with the physical device via a dedicated + communication bus, for example SpaceWire, UART or SPI: :cpp:class:`DeviceCommunicationIF` +- The handler has housekeeping data which has to be exposed to the operator and/or other software + components: :cpp:class:`HasLocalDataPoolIF` +- The handler has configurable parameters +- The handler has health states, for example to indicate a broken device: + :cpp:class:`HasHealthIF` +- The handler has modes. For example there are the core modes `MODE_ON`, `MODE_OFF` + and `MODE_NORMAL` provided by the FSFW. `MODE_ON` means that a device is physically powered + but that it is not periodically polling data from the + physical device, `MODE_NORMAL` means that it is able to do that: :cpp:class`HasModesIF` + +The device handler base therefore provides abstractions for a lot of common +functionality, which can potentially avoid high amounts or logic and code duplication. + +Template Device Handler Base File +---------------------------------- + +This is an example template device handler header file with all necessary +functions implemented: + +.. code-block:: cpp + + #ifndef __TESTDEVICEHANDLER_H_ + #define __TESTDEVICEHANDLER_H_ + + #include + + class TestDeviceHandler: DeviceHandlerBase { + public: + TestDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie); + private: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override; + void fillCommandAndReplyMap() override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, + size_t* foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + + }; + + #endif /* __TESTDEVICEHANDLER_H_ */ + +and the respective source file with sensible default return values: + +.. code-block:: cpp + #include "TestDeviceHandler.h" + + TestDeviceHandler::TestDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie) + : DeviceHandlerBase(objectId, comIF, cookie) {} + + void TestDeviceHandler::doStartUp() {} + + void TestDeviceHandler::doShutDown() {} + + ReturnValue_t TestDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; + } + + ReturnValue_t TestDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; + } + + void TestDeviceHandler::fillCommandAndReplyMap() {} + + ReturnValue_t TestDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + return HasReturnvaluesIF::RETURN_OK; + } + + ReturnValue_t TestDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + return HasReturnvaluesIF::RETURN_OK; + } + + ReturnValue_t TestDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t* packet) { + return HasReturnvaluesIF::RETURN_OK; + } + + uint32_t TestDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 10000; + } + + ReturnValue_t TestDeviceHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + return HasReturnvaluesIF::RETURN_OK; + } From b25555a533dfd20c8b36bff409a4af963a79e7b8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Feb 2022 13:53:01 +0100 Subject: [PATCH 22/44] started DHB docs --- docs/devicehandlers.rst | 102 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/docs/devicehandlers.rst b/docs/devicehandlers.rst index 58c2df78..d1a5fb67 100644 --- a/docs/devicehandlers.rst +++ b/docs/devicehandlers.rst @@ -1,3 +1,105 @@ Device Handlers ================== +Device handler components rerpresent, control and monitor equipment, for example sensors or actuators of a spacecraft or the payload. + +Most device handlers have the same common functionality or +requirements, which are fulfilled by implementing an certain interface: + +- The handler/device needs to be commandable: :cpp:class:`HasActionsIF` +- The handler needs to communicate with the physical device via a dedicated + communication bus, for example SpaceWire, UART or SPI: :cpp:class:`DeviceCommunicationIF` +- The handler has housekeeping data which has to be exposed to the operator and/or other software + components: :cpp:class:`HasLocalDataPoolIF` +- The handler has configurable parameters +- The handler has health states, for example to indicate a broken device: + :cpp:class:`HasHealthIF` +- The handler has modes. For example there are the core modes `MODE_ON`, `MODE_OFF` + and `MODE_NORMAL` provided by the FSFW. `MODE_ON` means that a device is physically powered + but that it is not periodically polling data from the + physical device, `MODE_NORMAL` means that it is able to do that: :cpp:class`HasModesIF` + +The device handler base therefore provides abstractions for a lot of common +functionality, which can potentially avoid high amounts or logic and code duplication. + +Template Device Handler Base File +---------------------------------- + +This is an example template device handler header file with all necessary +functions implemented: + +.. code-block:: cpp + + #ifndef __TESTDEVICEHANDLER_H_ + #define __TESTDEVICEHANDLER_H_ + + #include + + class TestDeviceHandler: DeviceHandlerBase { + public: + TestDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie); + private: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override; + void fillCommandAndReplyMap() override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, + size_t* foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + + }; + + #endif /* __TESTDEVICEHANDLER_H_ */ + +and the respective source file with sensible default return values: + +.. code-block:: cpp + #include "TestDeviceHandler.h" + + TestDeviceHandler::TestDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie) + : DeviceHandlerBase(objectId, comIF, cookie) {} + + void TestDeviceHandler::doStartUp() {} + + void TestDeviceHandler::doShutDown() {} + + ReturnValue_t TestDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; + } + + ReturnValue_t TestDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; + } + + void TestDeviceHandler::fillCommandAndReplyMap() {} + + ReturnValue_t TestDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + return HasReturnvaluesIF::RETURN_OK; + } + + ReturnValue_t TestDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + return HasReturnvaluesIF::RETURN_OK; + } + + ReturnValue_t TestDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t* packet) { + return HasReturnvaluesIF::RETURN_OK; + } + + uint32_t TestDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 10000; + } + + ReturnValue_t TestDeviceHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + return HasReturnvaluesIF::RETURN_OK; + } From cdf2a90f90ed8119a6d23e05efc40b4220b8e7c5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Feb 2022 14:02:30 +0100 Subject: [PATCH 23/44] fixed up cross-ref --- docs/devicehandlers.rst | 8 ++++++-- docs/highlevel.rst | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/devicehandlers.rst b/docs/devicehandlers.rst index d1a5fb67..affaa6d9 100644 --- a/docs/devicehandlers.rst +++ b/docs/devicehandlers.rst @@ -1,7 +1,10 @@ +.. _dhb-prim-doc: + Device Handlers ================== -Device handler components rerpresent, control and monitor equipment, for example sensors or actuators of a spacecraft or the payload. +Device handler components represent, control and monitor equipment, for example sensors or actuators +of a spacecraft or the payload. Most device handlers have the same common functionality or requirements, which are fulfilled by implementing an certain interface: @@ -17,7 +20,7 @@ requirements, which are fulfilled by implementing an certain interface: - The handler has modes. For example there are the core modes `MODE_ON`, `MODE_OFF` and `MODE_NORMAL` provided by the FSFW. `MODE_ON` means that a device is physically powered but that it is not periodically polling data from the - physical device, `MODE_NORMAL` means that it is able to do that: :cpp:class`HasModesIF` + physical device, `MODE_NORMAL` means that it is able to do that: :cpp:class:`HasModesIF` The device handler base therefore provides abstractions for a lot of common functionality, which can potentially avoid high amounts or logic and code duplication. @@ -60,6 +63,7 @@ functions implemented: and the respective source file with sensible default return values: .. code-block:: cpp + #include "TestDeviceHandler.h" TestDeviceHandler::TestDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie) diff --git a/docs/highlevel.rst b/docs/highlevel.rst index 08f44777..04eb5e7b 100644 --- a/docs/highlevel.rst +++ b/docs/highlevel.rst @@ -118,7 +118,7 @@ The DH has mechanisms to monitor the communication with the physical device whic for FDIR reaction. Device Handlers can be created by implementing ``DeviceHandlerBase``. A standard FDIR component for the DH will be created automatically but can be overwritten by the user. More information on DeviceHandlers can be found in the -related [documentation section](doc/README-devicehandlers.md#top). +related :ref:`documentation section `. Modes and Health -------------------- From 2dcf896ccad5c99130148cd67a84d70caa1a1215 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Feb 2022 14:04:23 +0100 Subject: [PATCH 24/44] this sounds better --- docs/devicehandlers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/devicehandlers.rst b/docs/devicehandlers.rst index affaa6d9..80b9e7a3 100644 --- a/docs/devicehandlers.rst +++ b/docs/devicehandlers.rst @@ -7,7 +7,7 @@ Device handler components represent, control and monitor equipment, for example of a spacecraft or the payload. Most device handlers have the same common functionality or -requirements, which are fulfilled by implementing an certain interface: +requirements, which are fulfilled by implementing certain interfaces: - The handler/device needs to be commandable: :cpp:class:`HasActionsIF` - The handler needs to communicate with the physical device via a dedicated From 4f87e24f603653cdf7013074e100b54df3468065 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Feb 2022 14:08:52 +0100 Subject: [PATCH 25/44] increase test limit --- tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp index d2a15137..a6360338 100644 --- a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp +++ b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp @@ -72,7 +72,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { result = cmdExecutor.check(bytesHaveBeenRead); REQUIRE(result != CommandExecutor::COMMAND_ERROR); usleep(500); - REQUIRE(limitIdx < 20); + REQUIRE(limitIdx < 50); } limitIdx = 0; CHECK(bytesHaveBeenRead == true); @@ -102,7 +102,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { result = cmdExecutor.check(bytesHaveBeenRead); REQUIRE(result != CommandExecutor::COMMAND_ERROR); usleep(500); - REQUIRE(limitIdx < 20); + REQUIRE(limitIdx < 50); } REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); REQUIRE(cmdExecutor.getLastError() == 1); From 9897f5130720fd5a6c9a1dc40da3bf5b895fb29f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 14 Feb 2022 08:43:10 +0100 Subject: [PATCH 26/44] added flose and changed warning message to error message --- hal/src/fsfw_hal/linux/uio/UioMapper.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hal/src/fsfw_hal/linux/uio/UioMapper.cpp b/hal/src/fsfw_hal/linux/uio/UioMapper.cpp index b29ed63e..6a7673e3 100644 --- a/hal/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/hal/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -22,7 +22,7 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss int fd = open(uioFile.c_str(), O_RDWR); if (fd < 1) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl; + sif::error << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -36,7 +36,7 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss if (*address == MAP_FAILED) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UioMapper::getMappedAdress: Failed to map physical address of uio device " + sif::error << "UioMapper::getMappedAdress: Failed to map physical address of uio device " << uioFile.c_str() << " and map" << static_cast(mapNum) << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; @@ -52,19 +52,21 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { fp = fopen(namestream.str().c_str(), "r"); if (fp == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UioMapper::getMapSize: Failed to open file " << namestream.str() << std::endl; + sif::error << "UioMapper::getMapSize: Failed to open file " << namestream.str() << std::endl; #endif + fclose(fp); return HasReturnvaluesIF::RETURN_FAILED; } char hexstring[SIZE_HEX_STRING] = ""; int items = fscanf(fp, "%s", hexstring); if (items != 1) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UioMapper::getMapSize: Failed with error code " << errno + sif::error << "UioMapper::getMapSize: Failed with error code " << errno << " to read size " "string from file " << namestream.str() << std::endl; #endif + fclose(fp); return HasReturnvaluesIF::RETURN_FAILED; } uint32_t sizeTmp = 0; @@ -74,9 +76,10 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { } if (items != 1) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UioMapper::getMapSize: Failed with error code " << errno << "to convert " + sif::error << "UioMapper::getMapSize: Failed with error code " << errno << "to convert " << "size of map" << mapNum << " to integer" << std::endl; #endif + fclose(fp); return HasReturnvaluesIF::RETURN_FAILED; } fclose(fp); From 120750f22aab31cfa6f3d8edec1fe784a707b64e Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 14 Feb 2022 08:51:53 +0100 Subject: [PATCH 27/44] removed one fclose --- hal/src/fsfw_hal/linux/uio/UioMapper.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/hal/src/fsfw_hal/linux/uio/UioMapper.cpp b/hal/src/fsfw_hal/linux/uio/UioMapper.cpp index 6a7673e3..5eb44c5e 100644 --- a/hal/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/hal/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -54,7 +54,6 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "UioMapper::getMapSize: Failed to open file " << namestream.str() << std::endl; #endif - fclose(fp); return HasReturnvaluesIF::RETURN_FAILED; } char hexstring[SIZE_HEX_STRING] = ""; From 9e958e752e2565da2ac704a6752f7f47d3cec026 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 14 Feb 2022 14:54:20 +0100 Subject: [PATCH 28/44] applied clang format --- hal/src/fsfw_hal/linux/uio/UioMapper.cpp | 12 +++++------ src/fsfw/datalinklayer/DataLinkLayer.h | 2 +- .../datalinklayer/VirtualChannelReception.cpp | 4 ++-- src/fsfw/globalfunctions/CRC.cpp | 4 ++-- src/fsfw/modes/ModeMessage.h | 16 +++++++-------- src/fsfw/osal/linux/PeriodicPosixTask.h | 4 ++-- src/fsfw/osal/rtems/PeriodicTask.h | 4 ++-- src/fsfw/osal/rtems/RTEMSTaskBase.h | 4 ++-- src/fsfw/rmap/RMAP.h | 18 ++++++++--------- src/fsfw/rmap/RMAPChannelIF.h | 20 +++++++++---------- src/fsfw/rmap/rmapStructs.h | 6 +++--- 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/hal/src/fsfw_hal/linux/uio/UioMapper.cpp b/hal/src/fsfw_hal/linux/uio/UioMapper.cpp index 5eb44c5e..43ca2727 100644 --- a/hal/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/hal/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -37,7 +37,7 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss if (*address == MAP_FAILED) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "UioMapper::getMappedAdress: Failed to map physical address of uio device " - << uioFile.c_str() << " and map" << static_cast(mapNum) << std::endl; + << uioFile.c_str() << " and map" << static_cast(mapNum) << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -61,22 +61,22 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { if (items != 1) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "UioMapper::getMapSize: Failed with error code " << errno - << " to read size " - "string from file " - << namestream.str() << std::endl; + << " to read size " + "string from file " + << namestream.str() << std::endl; #endif fclose(fp); return HasReturnvaluesIF::RETURN_FAILED; } uint32_t sizeTmp = 0; items = sscanf(hexstring, "%x", &sizeTmp); - if(size != nullptr) { + if (size != nullptr) { *size = sizeTmp; } if (items != 1) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "UioMapper::getMapSize: Failed with error code " << errno << "to convert " - << "size of map" << mapNum << " to integer" << std::endl; + << "size of map" << mapNum << " to integer" << std::endl; #endif fclose(fp); return HasReturnvaluesIF::RETURN_FAILED; diff --git a/src/fsfw/datalinklayer/DataLinkLayer.h b/src/fsfw/datalinklayer/DataLinkLayer.h index edfba8a6..8735feb6 100644 --- a/src/fsfw/datalinklayer/DataLinkLayer.h +++ b/src/fsfw/datalinklayer/DataLinkLayer.h @@ -30,7 +30,7 @@ class DataLinkLayer : public CCSDSReturnValuesIF { //! [EXPORT] : [COMMENT] A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0 static const Event BIT_LOCK_LOST = MAKE_EVENT(3, severity::INFO); // static const Event RF_CHAIN_LOST = MAKE_EVENT(4, severity::INFO); //!< The CCSDS Board - //detected that either bit lock or RF available or both are lost. No parameters. + // detected that either bit lock or RF available or both are lost. No parameters. //! [EXPORT] : [COMMENT] The CCSDS Board could not interpret a TC static const Event FRAME_PROCESSING_FAILED = MAKE_EVENT(5, severity::LOW); /** diff --git a/src/fsfw/datalinklayer/VirtualChannelReception.cpp b/src/fsfw/datalinklayer/VirtualChannelReception.cpp index 4ee0c008..258bc1e6 100644 --- a/src/fsfw/datalinklayer/VirtualChannelReception.cpp +++ b/src/fsfw/datalinklayer/VirtualChannelReception.cpp @@ -30,9 +30,9 @@ ReturnValue_t VirtualChannelReception::mapDemultiplexing(TcTransferFrame* frame) mapChannelIterator iter = mapChannels.find(mapId); if (iter == mapChannels.end()) { // error << "VirtualChannelReception::mapDemultiplexing on VC " << std::hex << (int) - //channelId + // channelId // << ": MapChannel " << (int) mapId << std::dec << " not found." << - //std::endl; + // std::endl; return VC_NOT_FOUND; } else { return (iter->second)->extractPackets(frame); diff --git a/src/fsfw/globalfunctions/CRC.cpp b/src/fsfw/globalfunctions/CRC.cpp index 942e4a1a..6b8140c5 100644 --- a/src/fsfw/globalfunctions/CRC.cpp +++ b/src/fsfw/globalfunctions/CRC.cpp @@ -116,8 +116,8 @@ uint16_t CRC::crc16ccitt(uint8_t const input[], uint32_t length, uint16_t starti // for (int i=0; i<16 ;i++) // { // if (xor_out[i] == true) - // crc_value = crc_value + pow(2,(15 -i)); // reverse CrC result before Final - //XOR + // crc_value = crc_value + pow(2,(15 -i)); // reverse CrC result before + //Final XOR // } // // crc_value = 0;// for debug mode diff --git a/src/fsfw/modes/ModeMessage.h b/src/fsfw/modes/ModeMessage.h index e3638ee0..84429e84 100644 --- a/src/fsfw/modes/ModeMessage.h +++ b/src/fsfw/modes/ModeMessage.h @@ -14,30 +14,30 @@ class ModeMessage { static const uint8_t MESSAGE_ID = messagetypes::MODE_COMMAND; static const Command_t CMD_MODE_COMMAND = MAKE_COMMAND_ID(0x01); //!> Command to set the specified Mode, replies are: REPLY_MODE_REPLY, - //!REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any replies, - //!as this will break the subsystem mode machine!! + //! REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any replies, + //! as this will break the subsystem mode machine!! static const Command_t CMD_MODE_COMMAND_FORCED = MAKE_COMMAND_ID( 0xF1); //!> Command to set the specified Mode, regardless of external control flag, replies - //!are: REPLY_MODE_REPLY, REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any - //!replies, as this will break the subsystem mode machine!! + //! are: REPLY_MODE_REPLY, REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any + //! replies, as this will break the subsystem mode machine!! 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) + //! 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 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 + //! 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. static const Command_t CMD_MODE_ANNOUNCE_RECURSIVELY = MAKE_COMMAND_ID(0x08); //!> Command to trigger an ModeInfo Event and to send this command to - //!every child. This command does NOT have a reply. + //! every child. This command does NOT have a reply. static Mode_t getMode(const CommandMessage* message); static Submode_t getSubmode(const CommandMessage* message); diff --git a/src/fsfw/osal/linux/PeriodicPosixTask.h b/src/fsfw/osal/linux/PeriodicPosixTask.h index e2db042d..3c9a3a0d 100644 --- a/src/fsfw/osal/linux/PeriodicPosixTask.h +++ b/src/fsfw/osal/linux/PeriodicPosixTask.h @@ -65,8 +65,8 @@ class PeriodicPosixTask : public PosixThread, public PeriodicTaskIF { /** * @brief The function containing the actual functionality of the task. * @details The method sets and starts - * the task's period, then enters a loop that is repeated indefinitely. Within the loop, - * all performOperation methods of the added objects are called. Afterwards the task will be + * the task's period, then enters a loop that is repeated indefinitely. Within the + * loop, all performOperation methods of the added objects are called. Afterwards the task will be * blocked until the next period. On missing the deadline, the deadlineMissedFunction is executed. */ virtual void taskFunctionality(void); diff --git a/src/fsfw/osal/rtems/PeriodicTask.h b/src/fsfw/osal/rtems/PeriodicTask.h index e2643ec7..ff8617fc 100644 --- a/src/fsfw/osal/rtems/PeriodicTask.h +++ b/src/fsfw/osal/rtems/PeriodicTask.h @@ -13,8 +13,8 @@ class ExecutableObjectIF; * @brief This class represents a specialized task for periodic activities of multiple objects. * * @details MultiObjectTask is an extension to ObjectTask in the way that it is able to execute - * multiple objects that implement the ExecutableObjectIF interface. The objects must - * be added prior to starting the task. + * multiple objects that implement the ExecutableObjectIF interface. The objects + * must be added prior to starting the task. * @author baetz * @ingroup task_handling */ diff --git a/src/fsfw/osal/rtems/RTEMSTaskBase.h b/src/fsfw/osal/rtems/RTEMSTaskBase.h index 784d3594..9ae9e755 100644 --- a/src/fsfw/osal/rtems/RTEMSTaskBase.h +++ b/src/fsfw/osal/rtems/RTEMSTaskBase.h @@ -25,8 +25,8 @@ class RTEMSTaskBase { * all other attributes are set with default values. * @param priority Sets the priority of a task. Values range from a low 0 to a high 99. * @param stack_size The stack size reserved by the operating system for the task. - * @param nam The name of the Task, as a null-terminated String. Currently max 4 chars - * supported (excluding Null-terminator), rest will be truncated + * @param nam The name of the Task, as a null-terminated String. Currently max 4 + * chars supported (excluding Null-terminator), rest will be truncated */ RTEMSTaskBase(rtems_task_priority priority, size_t stack_size, const char *name); /** diff --git a/src/fsfw/rmap/RMAP.h b/src/fsfw/rmap/RMAP.h index d46fc318..42ee1ac5 100644 --- a/src/fsfw/rmap/RMAP.h +++ b/src/fsfw/rmap/RMAP.h @@ -51,9 +51,9 @@ class RMAP : public HasReturnvaluesIF { // MAKE_RETURN_CODE(0xE4); //the data that was to be sent was too long for the hw to handle (write // command) or the expected len was bigger than maximal expected len (read command) command was // not sent - // replaced by DeviceCommunicationIF::NULLPOINTER static const ReturnValue_t COMMAND_NULLPOINTER - // = MAKE_RETURN_CODE(0xE5); //datalen was != 0 but data was == NULL in write command, or - // nullpointer in read command + // replaced by DeviceCommunicationIF::NULLPOINTER static const ReturnValue_t + // COMMAND_NULLPOINTER = MAKE_RETURN_CODE(0xE5); //datalen was != 0 but data was == NULL in write + // command, or nullpointer in read command static const ReturnValue_t COMMAND_CHANNEL_DEACTIVATED = MAKE_RETURN_CODE(0xE6); // the channel has no port set static const ReturnValue_t COMMAND_PORT_OUT_OF_RANGE = @@ -73,8 +73,8 @@ class RMAP : public HasReturnvaluesIF { static const ReturnValue_t REPLY_MISSMATCH = MAKE_RETURN_CODE( 0xD3); // a read command was issued, but get_write_rply called, or other way round static const ReturnValue_t REPLY_TIMEOUT = MAKE_RETURN_CODE(0xD4); // timeout - // replaced by DeviceCommunicationIF::NULLPOINTER static const ReturnValue_t REPLY_NULLPOINTER = - // MAKE_RETURN_CODE(0xD5);//one of the arguments in a read reply was NULL return values for + // replaced by DeviceCommunicationIF::NULLPOINTER static const ReturnValue_t REPLY_NULLPOINTER + // = MAKE_RETURN_CODE(0xD5);//one of the arguments in a read reply was NULL return values for // get_reply static const ReturnValue_t REPLY_INTERFACE_BUSY = MAKE_RETURN_CODE(0xC0); // Interface is busy (transmission buffer still being processed) @@ -169,8 +169,8 @@ class RMAP : public HasReturnvaluesIF { * @param buffer the data to write * @param length length of data * @return - * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL in write - * command + * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL in + * write command * - return codes of RMAPChannelIF::sendCommand() */ static ReturnValue_t sendWriteCommand(RMAPCookie *cookie, const uint8_t *buffer, size_t length); @@ -205,8 +205,8 @@ class RMAP : public HasReturnvaluesIF { * @param cookie to cookie to read from * @param expLength the expected maximum length of the reply * @return - * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL in write - * command, or nullpointer in read command + * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL in + * write command, or nullpointer in read command * - return codes of RMAPChannelIF::sendCommand() */ static ReturnValue_t sendReadCommand(RMAPCookie *cookie, uint32_t expLength); diff --git a/src/fsfw/rmap/RMAPChannelIF.h b/src/fsfw/rmap/RMAPChannelIF.h index 77b56eb9..20dfd5f8 100644 --- a/src/fsfw/rmap/RMAPChannelIF.h +++ b/src/fsfw/rmap/RMAPChannelIF.h @@ -73,16 +73,16 @@ class RMAPChannelIF { * @param datalen length of data * @return * - @c RETURN_OK - * - @c COMMAND_NO_DESCRIPTORS_AVAILABLE no descriptors available for sending command; - * command was not sent - * - @c COMMAND_BUFFER_FULL no receiver buffer available for expected len; command - * was not sent - * - @c COMMAND_TOO_BIG the data that was to be sent was too long for the hw to - * handle (write command) or the expected len was bigger than maximal expected len (read command) + * - @c COMMAND_NO_DESCRIPTORS_AVAILABLE no descriptors available for sending + * command; command was not sent + * - @c COMMAND_BUFFER_FULL no receiver buffer available for expected len; * command was not sent + * - @c COMMAND_TOO_BIG the data that was to be sent was too long for the hw + * to handle (write command) or the expected len was bigger than maximal expected len (read + * command) command was not sent * - @c COMMAND_CHANNEL_DEACTIVATED the channel has no port set - * - @c NOT_SUPPORTED if you dont feel like implementing - * something... + * - @c NOT_SUPPORTED if you dont feel like + * implementing something... */ virtual ReturnValue_t sendCommand(RMAPCookie *cookie, uint8_t instruction, const uint8_t *data, size_t datalen) = 0; @@ -97,8 +97,8 @@ class RMAPChannelIF { * - @c REPLY_NO_REPLY no reply was received * - @c REPLY_NOT_SENT command was not sent, implies no reply * - @c REPLY_NOT_YET_SENT command is still waiting to be sent - * - @c WRITE_REPLY_INTERFACE_BUSY Interface is busy (transmission buffer still being - * processed) + * - @c WRITE_REPLY_INTERFACE_BUSY Interface is busy (transmission buffer still + * being processed) * - @c WRITE_REPLY_TRANSMISSION_ERROR Interface encountered errors during last * operation, data could not be processed. (transmission error) * - @c WRITE_REPLY_INVALID_DATA Invalid data (amount / value) diff --git a/src/fsfw/rmap/rmapStructs.h b/src/fsfw/rmap/rmapStructs.h index 44eedc16..55e32606 100644 --- a/src/fsfw/rmap/rmapStructs.h +++ b/src/fsfw/rmap/rmapStructs.h @@ -32,10 +32,10 @@ static const uint8_t RMAP_COMMAND_READ = ((1 << RMAP_COMMAND_BIT) | (1 << RMAP_C static const uint8_t RMAP_REPLY_WRITE = ((1 << RMAP_COMMAND_BIT_WRITE) | (1 << RMAP_COMMAND_BIT_REPLY)); static const uint8_t RMAP_REPLY_READ = ((1 << RMAP_COMMAND_BIT_REPLY)); -//#define RMAP_COMMAND_WRITE ((1< Date: Mon, 14 Feb 2022 16:00:43 +0100 Subject: [PATCH 29/44] increase test limit --- tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp index a6360338..5ced030b 100644 --- a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp +++ b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp @@ -71,8 +71,9 @@ TEST_CASE("Command Executor", "[cmd-exec]") { limitIdx++; result = cmdExecutor.check(bytesHaveBeenRead); REQUIRE(result != CommandExecutor::COMMAND_ERROR); + // This ensures that the tests do not block indefinitely usleep(500); - REQUIRE(limitIdx < 50); + REQUIRE(limitIdx < 500); } limitIdx = 0; CHECK(bytesHaveBeenRead == true); @@ -101,8 +102,9 @@ TEST_CASE("Command Executor", "[cmd-exec]") { limitIdx++; result = cmdExecutor.check(bytesHaveBeenRead); REQUIRE(result != CommandExecutor::COMMAND_ERROR); + // This ensures that the tests do not block indefinitely usleep(500); - REQUIRE(limitIdx < 50); + REQUIRE(limitIdx < 500); } REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); REQUIRE(cmdExecutor.getLastError() == 1); From 0d38ac62d8e5e3a51bc456f60810abebc9a19c83 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Feb 2022 16:12:48 +0100 Subject: [PATCH 30/44] this should work an ALL systems --- tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp index 5ced030b..e2e1e9d7 100644 --- a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp +++ b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp @@ -90,7 +90,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { std::string allTheReply(reinterpret_cast(largerReadBuffer)); // I am just going to assume that this string is the same across ping implementations // of different Linux systems - REQUIRE(allTheReply.find("localhost ping statistics") != std::string::npos); + REQUIRE(allTheReply.find("PING localhost") != std::string::npos); // Now check failing command result = cmdExecutor.load("false", false, false); From 22bc300902b134f36b01fe71ae4d85c4a03dbcec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Feb 2022 16:14:14 +0100 Subject: [PATCH 31/44] increase other limits --- tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp index e2e1e9d7..3ad26876 100644 --- a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp +++ b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp @@ -45,7 +45,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { result = cmdExecutor.check(bytesHaveBeenRead); REQUIRE(result != CommandExecutor::COMMAND_ERROR); usleep(500); - REQUIRE(limitIdx < 5); + REQUIRE(limitIdx < 500); } limitIdx = 0; From 074ef29b86409568783f6c2ac11f0f086eda9bf4 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Mon, 14 Feb 2022 15:19:47 +0100 Subject: [PATCH 32/44] Fixed valgrind python script --- scripts/helper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/helper.py b/scripts/helper.py index 4e8a62b4..68693c40 100755 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -143,7 +143,10 @@ def handle_tests_type(args, build_dir_list: list): if which("valgrind") is None: print("Please install valgrind first") sys.exit(1) - os.chdir(UNITTEST_FOLDER_NAME) + if os.path.split(os.getcwd())[1] != UNITTEST_FOLDER_NAME: + # If we are in a different directory we try to switch into it but + # this might fail + os.chdir(UNITTEST_FOLDER_NAME) os.system("valgrind --leak-check=full ./fsfw-tests") os.chdir("..") From a612fb446cb72b732d73358b17202ee3dfb96b7a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Feb 2022 16:23:21 +0100 Subject: [PATCH 33/44] added two links --- docs/devicehandlers.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/devicehandlers.rst b/docs/devicehandlers.rst index 80b9e7a3..0008edb3 100644 --- a/docs/devicehandlers.rst +++ b/docs/devicehandlers.rst @@ -14,7 +14,8 @@ requirements, which are fulfilled by implementing certain interfaces: communication bus, for example SpaceWire, UART or SPI: :cpp:class:`DeviceCommunicationIF` - The handler has housekeeping data which has to be exposed to the operator and/or other software components: :cpp:class:`HasLocalDataPoolIF` -- The handler has configurable parameters +- The handler has configurable parameters: :cpp:class:`ReceivesParameterMessagesIF` which + also implements :cpp:class:`HasParametersIF` - The handler has health states, for example to indicate a broken device: :cpp:class:`HasHealthIF` - The handler has modes. For example there are the core modes `MODE_ON`, `MODE_OFF` From 6744a55b9b7faf8c72bb9bf4d7bff83ce87c8952 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Feb 2022 16:31:13 +0100 Subject: [PATCH 34/44] docs update --- README.md | 36 ++++++++++++++++++++++++++++++++++++ docs/getting_started.rst | 25 +++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a2261c99..89a10f4b 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,42 @@ cmake --build . -- fsfw-tests_coverage -j The `coverage.py` script located in the `script` folder can also be used to do this conveniently. +## Building the documentations + +The FSFW documentation is built using the tools Sphinx, doxygen and breathe based on the +instructions provided in [this blogpost](https://devblogs.microsoft.com/cppblog/clear-functional-c-documentation-with-sphinx-breathe-doxygen-cmake/). If you +want to do this locally, set up the prerequisites first. This requires a ``python3`` +installation as well. Example here is for Ubuntu. + +```sh +sudo apt-get install doxygen graphviz +``` + +And the following Python packages + +```sh +python3 -m pip install sphinx breathe +``` + +You can set up a documentation build system using the following commands + +```sh +mkdir build-docs && cd build-docs +cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host .. +``` + +Then you can generate the documentation using + +```sh +cmake --build . -j +``` + +You can find the generated documentation inside the `docs/sphinx` folder inside the build +folder. Simply open the `index.html` in the webbrowser of your choice. + +The `helper.py` script located in the script` folder can also be used to create, build +and open the documentation conveniently. Try `helper.py -h for more information. + ## Formatting the sources The formatting is done by the `clang-format` tool. The configuration is contained within the diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 069e98cd..34547211 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -90,8 +90,21 @@ Building the documentation ---------------------------- The FSFW documentation is built using the tools Sphinx, doxygen and breathe based on the -instructions provided in `this blogpost `_. You can set up a -documentation build system using the following commands +instructions provided in `this blogpost `_. If you +want to do this locally, set up the prerequisites first. This requires a ``python3`` +installation as well. Example here is for Ubuntu. + +.. code-block:: console + + sudo apt-get install doxygen graphviz + +And the following Python packages + +.. code-block:: console + + python3 -m pip install sphinx breathe + +You can set up a documentation build system using the following commands .. code-block:: bash @@ -110,6 +123,14 @@ folder. Simply open the ``index.html`` in the webbrowser of your choice. The ``helper.py`` script located in the ``script`` folder can also be used to create, build and open the documentation conveniently. Try ``helper.py -h`` for more information. +Formatting the source +----------------------- + +The formatting is done by the ``clang-format`` tool. The configuration is contained within the +``.clang-format`` file in the repository root. As long as ``clang-format`` is installed, you +can run the ``apply-clang-format.sh`` helper script to format all source files consistently. + + .. _`Hosted FSFW example`: https://egit.irs.uni-stuttgart.de/fsfw/fsfw-example-hosted .. _`Catch2 library`: https://github.com/catchorg/Catch2 .. _`Code coverage`: https://github.com/bilke/cmake-modules/tree/master From c3d78120eace13652b8c7dcb2f4913efebdf7d7e Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 14 Feb 2022 16:42:40 +0100 Subject: [PATCH 35/44] preparing 4.0.0 --- CHANGELOG.md | 6 ++++++ CMakeLists.txt | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cda8037c..335c0f7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/544 - doSendRead Hook PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/545 +- Dockumentation for DHB + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/551 ### HAL additions @@ -43,6 +45,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). could lead to compile errors that `#include "fsfw/FSFW.h"` was not found. - Fix for build regression in Catch2 v3.0.0-preview4 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/548 +- Fix in unittest which failed on CI + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/552 +- Fix in helper script + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/553 ## API Changes diff --git a/CMakeLists.txt b/CMakeLists.txt index 19fedb64..79258db2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.13) -set(FSFW_VERSION 3) +set(FSFW_VERSION 4) set(FSFW_SUBVERSION 0) -set(FSFW_REVISION 1) +set(FSFW_REVISION 0) # Add the cmake folder so the FindSphinx module is found set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) From 9e92afbf076b57df843a1ee526bd63c3303995a5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 16 Feb 2022 18:54:55 +0100 Subject: [PATCH 36/44] bugfix in test task --- tests/src/fsfw_tests/integration/task/TestTask.cpp | 1 - tests/src/fsfw_tests/integration/task/TestTask.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/src/fsfw_tests/integration/task/TestTask.cpp b/tests/src/fsfw_tests/integration/task/TestTask.cpp index 65e444e3..765f780e 100644 --- a/tests/src/fsfw_tests/integration/task/TestTask.cpp +++ b/tests/src/fsfw_tests/integration/task/TestTask.cpp @@ -3,7 +3,6 @@ #include #include -bool TestTask::oneShotAction = true; MutexIF* TestTask::testLock = nullptr; TestTask::TestTask(object_id_t objectId) : SystemObject(objectId), testMode(testModes::A) { diff --git a/tests/src/fsfw_tests/integration/task/TestTask.h b/tests/src/fsfw_tests/integration/task/TestTask.h index 557b50b2..cd630ee3 100644 --- a/tests/src/fsfw_tests/integration/task/TestTask.h +++ b/tests/src/fsfw_tests/integration/task/TestTask.h @@ -29,7 +29,7 @@ class TestTask : public SystemObject, public ExecutableObjectIF, public HasRetur bool testFlag = false; private: - static bool oneShotAction; + bool oneShotAction = true; static MutexIF* testLock; StorageManagerIF* IPCStore; }; From b3482eba245520ffc248c0b18a28b7bfe45d11b1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 17 Feb 2022 20:41:47 +0100 Subject: [PATCH 37/44] error check in event manager --- src/fsfw/events/EventManager.cpp | 13 ++++++++++--- src/fsfw/globalfunctions/CRC.cpp | 2 +- src/fsfw/osal/linux/MessageQueue.cpp | 2 +- src/fsfw/osal/linux/PeriodicPosixTask.h | 7 ++++--- src/fsfw/osal/rtems/PeriodicTask.h | 4 ++-- src/fsfw/rmap/RMAP.h | 8 ++++---- src/fsfw/rmap/RMAPChannelIF.h | 12 ++++++------ 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index aaa7d6c5..ca45ef04 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -46,9 +46,16 @@ ReturnValue_t EventManager::performOperation(uint8_t opCode) { void EventManager::notifyListeners(EventMessage* message) { lockMutex(); - for (auto iter = listenerList.begin(); iter != listenerList.end(); ++iter) { - if (iter->second.match(message)) { - MessageQueueSenderIF::sendMessage(iter->first, message, message->getSender()); + for (auto& listener : listenerList) { + if (listener.second.match(message)) { + ReturnValue_t result = + MessageQueueSenderIF::sendMessage(listener.first, message, message->getSender()); + if (result != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "Sending message to listener failed with result " << std::hex << std::setw(4) + << result << std::endl; +#endif + } } } unlockMutex(); diff --git a/src/fsfw/globalfunctions/CRC.cpp b/src/fsfw/globalfunctions/CRC.cpp index 6b8140c5..033920d0 100644 --- a/src/fsfw/globalfunctions/CRC.cpp +++ b/src/fsfw/globalfunctions/CRC.cpp @@ -117,7 +117,7 @@ uint16_t CRC::crc16ccitt(uint8_t const input[], uint32_t length, uint16_t starti // { // if (xor_out[i] == true) // crc_value = crc_value + pow(2,(15 -i)); // reverse CrC result before - //Final XOR + // Final XOR // } // // crc_value = 0;// for debug mode diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index f876ec6e..c806783b 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -256,7 +256,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, if (!ignoreFault) { InternalErrorReporterIF* internalErrorReporter = ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); - if (internalErrorReporter != NULL) { + if (internalErrorReporter != nullptr) { internalErrorReporter->queueMessageNotSent(); } } diff --git a/src/fsfw/osal/linux/PeriodicPosixTask.h b/src/fsfw/osal/linux/PeriodicPosixTask.h index 3c9a3a0d..1c3a52c7 100644 --- a/src/fsfw/osal/linux/PeriodicPosixTask.h +++ b/src/fsfw/osal/linux/PeriodicPosixTask.h @@ -65,9 +65,10 @@ class PeriodicPosixTask : public PosixThread, public PeriodicTaskIF { /** * @brief The function containing the actual functionality of the task. * @details The method sets and starts - * the task's period, then enters a loop that is repeated indefinitely. Within the - * loop, all performOperation methods of the added objects are called. Afterwards the task will be - * blocked until the next period. On missing the deadline, the deadlineMissedFunction is executed. + * the task's period, then enters a loop that is repeated indefinitely. Within + * the loop, all performOperation methods of the added objects are called. Afterwards the task + * will be blocked until the next period. On missing the deadline, the deadlineMissedFunction is + * executed. */ virtual void taskFunctionality(void); /** diff --git a/src/fsfw/osal/rtems/PeriodicTask.h b/src/fsfw/osal/rtems/PeriodicTask.h index ff8617fc..119329f2 100644 --- a/src/fsfw/osal/rtems/PeriodicTask.h +++ b/src/fsfw/osal/rtems/PeriodicTask.h @@ -13,8 +13,8 @@ class ExecutableObjectIF; * @brief This class represents a specialized task for periodic activities of multiple objects. * * @details MultiObjectTask is an extension to ObjectTask in the way that it is able to execute - * multiple objects that implement the ExecutableObjectIF interface. The objects - * must be added prior to starting the task. + * multiple objects that implement the ExecutableObjectIF interface. The + * objects must be added prior to starting the task. * @author baetz * @ingroup task_handling */ diff --git a/src/fsfw/rmap/RMAP.h b/src/fsfw/rmap/RMAP.h index 42ee1ac5..7c654262 100644 --- a/src/fsfw/rmap/RMAP.h +++ b/src/fsfw/rmap/RMAP.h @@ -169,8 +169,8 @@ class RMAP : public HasReturnvaluesIF { * @param buffer the data to write * @param length length of data * @return - * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL in - * write command + * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL + * in write command * - return codes of RMAPChannelIF::sendCommand() */ static ReturnValue_t sendWriteCommand(RMAPCookie *cookie, const uint8_t *buffer, size_t length); @@ -205,8 +205,8 @@ class RMAP : public HasReturnvaluesIF { * @param cookie to cookie to read from * @param expLength the expected maximum length of the reply * @return - * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL in - * write command, or nullpointer in read command + * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL + * in write command, or nullpointer in read command * - return codes of RMAPChannelIF::sendCommand() */ static ReturnValue_t sendReadCommand(RMAPCookie *cookie, uint32_t expLength); diff --git a/src/fsfw/rmap/RMAPChannelIF.h b/src/fsfw/rmap/RMAPChannelIF.h index 20dfd5f8..7dab07c1 100644 --- a/src/fsfw/rmap/RMAPChannelIF.h +++ b/src/fsfw/rmap/RMAPChannelIF.h @@ -75,10 +75,10 @@ class RMAPChannelIF { * - @c RETURN_OK * - @c COMMAND_NO_DESCRIPTORS_AVAILABLE no descriptors available for sending * command; command was not sent - * - @c COMMAND_BUFFER_FULL no receiver buffer available for expected len; - * command was not sent - * - @c COMMAND_TOO_BIG the data that was to be sent was too long for the hw - * to handle (write command) or the expected len was bigger than maximal expected len (read + * - @c COMMAND_BUFFER_FULL no receiver buffer available for expected + * len; command was not sent + * - @c COMMAND_TOO_BIG the data that was to be sent was too long for the + * hw to handle (write command) or the expected len was bigger than maximal expected len (read * command) command was not sent * - @c COMMAND_CHANNEL_DEACTIVATED the channel has no port set * - @c NOT_SUPPORTED if you dont feel like @@ -97,8 +97,8 @@ class RMAPChannelIF { * - @c REPLY_NO_REPLY no reply was received * - @c REPLY_NOT_SENT command was not sent, implies no reply * - @c REPLY_NOT_YET_SENT command is still waiting to be sent - * - @c WRITE_REPLY_INTERFACE_BUSY Interface is busy (transmission buffer still - * being processed) + * - @c WRITE_REPLY_INTERFACE_BUSY Interface is busy (transmission buffer + * still being processed) * - @c WRITE_REPLY_TRANSMISSION_ERROR Interface encountered errors during last * operation, data could not be processed. (transmission error) * - @c WRITE_REPLY_INVALID_DATA Invalid data (amount / value) From bd05afbddd7e2da43b19b8ceafb6272e73d5464d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 18 Feb 2022 13:09:18 +0100 Subject: [PATCH 38/44] printout improvements --- src/fsfw/events/EventManager.cpp | 2 ++ src/fsfw/internalerror/InternalErrorReporter.cpp | 15 +++++++-------- src/fsfw/rmap/RMAP.h | 8 ++++---- src/fsfw/rmap/RMAPChannelIF.h | 12 ++++++------ 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index ca45ef04..35dc9d22 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -54,6 +54,8 @@ void EventManager::notifyListeners(EventMessage* message) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Sending message to listener failed with result " << std::hex << std::setw(4) << result << std::endl; +#else + sif::printError("Sending message to listener failed with result %04x\n", result); #endif } } diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index e7088e2c..a085cc5b 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -36,15 +36,14 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { if ((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "InternalErrorReporter::performOperation: Errors " - << "occured!" << std::endl; - sif::debug << "Queue errors: " << newQueueHits << std::endl; - sif::debug << "TM errors: " << newTmHits << std::endl; - sif::debug << "Store errors: " << newStoreHits << std::endl; + << "occured: Queue | TM | Store : " << newQueueHits << " | " << newTmHits << " | " + << newStoreHits << std::endl; #else - sif::printDebug("InternalErrorReporter::performOperation: Errors occured!\n"); - sif::printDebug("Queue errors: %lu\n", static_cast(newQueueHits)); - sif::printDebug("TM errors: %lu\n", static_cast(newTmHits)); - sif::printDebug("Store errors: %lu\n", static_cast(newStoreHits)); + sif::printDebug( + "InternalErrorReporter::performOperation: Errors occured: Queue | TM | Store: %lu | %lu " + "| %lu\n", + static_cast(newQueueHits), static_cast(newTmHits), + static_cast(newStoreHits)); #endif } } diff --git a/src/fsfw/rmap/RMAP.h b/src/fsfw/rmap/RMAP.h index 7c654262..d274fb15 100644 --- a/src/fsfw/rmap/RMAP.h +++ b/src/fsfw/rmap/RMAP.h @@ -169,8 +169,8 @@ class RMAP : public HasReturnvaluesIF { * @param buffer the data to write * @param length length of data * @return - * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL - * in write command + * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == + * NULL in write command * - return codes of RMAPChannelIF::sendCommand() */ static ReturnValue_t sendWriteCommand(RMAPCookie *cookie, const uint8_t *buffer, size_t length); @@ -205,8 +205,8 @@ class RMAP : public HasReturnvaluesIF { * @param cookie to cookie to read from * @param expLength the expected maximum length of the reply * @return - * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL - * in write command, or nullpointer in read command + * - @c COMMAND_NULLPOINTER datalen was != 0 but data was == + * NULL in write command, or nullpointer in read command * - return codes of RMAPChannelIF::sendCommand() */ static ReturnValue_t sendReadCommand(RMAPCookie *cookie, uint32_t expLength); diff --git a/src/fsfw/rmap/RMAPChannelIF.h b/src/fsfw/rmap/RMAPChannelIF.h index 7dab07c1..0c937dc8 100644 --- a/src/fsfw/rmap/RMAPChannelIF.h +++ b/src/fsfw/rmap/RMAPChannelIF.h @@ -75,10 +75,10 @@ class RMAPChannelIF { * - @c RETURN_OK * - @c COMMAND_NO_DESCRIPTORS_AVAILABLE no descriptors available for sending * command; command was not sent - * - @c COMMAND_BUFFER_FULL no receiver buffer available for expected - * len; command was not sent - * - @c COMMAND_TOO_BIG the data that was to be sent was too long for the - * hw to handle (write command) or the expected len was bigger than maximal expected len (read + * - @c COMMAND_BUFFER_FULL no receiver buffer available for + * expected len; command was not sent + * - @c COMMAND_TOO_BIG the data that was to be sent was too long for + * the hw to handle (write command) or the expected len was bigger than maximal expected len (read * command) command was not sent * - @c COMMAND_CHANNEL_DEACTIVATED the channel has no port set * - @c NOT_SUPPORTED if you dont feel like @@ -97,8 +97,8 @@ class RMAPChannelIF { * - @c REPLY_NO_REPLY no reply was received * - @c REPLY_NOT_SENT command was not sent, implies no reply * - @c REPLY_NOT_YET_SENT command is still waiting to be sent - * - @c WRITE_REPLY_INTERFACE_BUSY Interface is busy (transmission buffer - * still being processed) + * - @c WRITE_REPLY_INTERFACE_BUSY Interface is busy (transmission + * buffer still being processed) * - @c WRITE_REPLY_TRANSMISSION_ERROR Interface encountered errors during last * operation, data could not be processed. (transmission error) * - @c WRITE_REPLY_INVALID_DATA Invalid data (amount / value) From a12e98d9481e224a30a1150e9dfd0a48501f410f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 18 Feb 2022 13:39:42 +0100 Subject: [PATCH 39/44] update event mngr printout --- src/fsfw/events/EventManager.cpp | 23 ++++++++++++++++++++--- src/fsfw/events/EventManager.h | 1 + src/fsfw/osal/linux/MessageQueue.cpp | 4 ++-- src/fsfw/pus/Service5EventReporting.cpp | 1 + src/fsfw/rmap/RMAPChannelIF.h | 6 +++--- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index 35dc9d22..c027fce5 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -52,10 +52,12 @@ void EventManager::notifyListeners(EventMessage* message) { MessageQueueSenderIF::sendMessage(listener.first, message, message->getSender()); if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Sending message to listener failed with result " << std::hex << std::setw(4) - << result << std::endl; + sif::error << std::hex << "EventManager::notifyListeners: MSG to " << std::setw(8) + << std::setfill('0') << "0x" << listener.first << " failed with result " + << std::setw(4) << "0x" << result << std::setfill(' ') << std::endl; #else - sif::printError("Sending message to listener failed with result %04x\n", result); + sif::printError("Sending message to listener 0x%08x failed with result %04x\n", + listener.first, result); #endif } } @@ -198,4 +200,19 @@ void EventManager::printUtility(sif::OutputTypes printType, EventMessage* messag } } +void EventManager::printListeners() { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::info << "Event manager listener MQ IDs:" << std::endl; + for (auto& listener : listenerList) { + sif::info << std::hex << std::setw(8) << std::setfill('0') << "0x" << listener.first << std::dec + << std::setfill(' ') << std::endl; + } +#else + sif::printInfo("Event manager listener MQ IDs:\n"); + for (auto& listener : listenerList) { + sif::printInfo("0x%08x\n", listener.first); + } +#endif +} + #endif /* FSFW_OBJ_EVENT_TRANSLATION == 1 */ diff --git a/src/fsfw/events/EventManager.h b/src/fsfw/events/EventManager.h index f2d642ff..e2a8dd95 100644 --- a/src/fsfw/events/EventManager.h +++ b/src/fsfw/events/EventManager.h @@ -42,6 +42,7 @@ class EventManager : public EventManagerIF, public ExecutableObjectIF, public Sy object_id_t reporterFrom = 0, object_id_t reporterTo = 0, bool reporterInverted = false); ReturnValue_t performOperation(uint8_t opCode); + void printListeners(); protected: MessageQueueIF* eventReportQueue = nullptr; diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index c806783b..bdba912e 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -240,9 +240,9 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, bool ignoreFault) { if (message == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "MessageQueue::sendMessageFromMessageQueue: Message is nullptr!" << std::endl; + sif::error << "MessageQueue::sendMessageFromMessageQueue: Message is nullptr" << std::endl; #else - sif::printError("MessageQueue::sendMessageFromMessageQueue: Message is nullptr!\n"); + sif::printError("MessageQueue::sendMessageFromMessageQueue: Message is nullptr\n"); #endif return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index 4517bc26..dfce9ba2 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -13,6 +13,7 @@ Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t ap : PusServiceBase(objectId, apid, serviceId), maxNumberReportsPerCycle(maxNumberReportsPerCycle) { eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); + sif::info << eventQueue->getId() << std::endl; } Service5EventReporting::~Service5EventReporting() { diff --git a/src/fsfw/rmap/RMAPChannelIF.h b/src/fsfw/rmap/RMAPChannelIF.h index 0c937dc8..9e666dfb 100644 --- a/src/fsfw/rmap/RMAPChannelIF.h +++ b/src/fsfw/rmap/RMAPChannelIF.h @@ -77,9 +77,9 @@ class RMAPChannelIF { * command; command was not sent * - @c COMMAND_BUFFER_FULL no receiver buffer available for * expected len; command was not sent - * - @c COMMAND_TOO_BIG the data that was to be sent was too long for - * the hw to handle (write command) or the expected len was bigger than maximal expected len (read - * command) command was not sent + * - @c COMMAND_TOO_BIG the data that was to be sent was too + * long for the hw to handle (write command) or the expected len was bigger than maximal expected + * len (read command) command was not sent * - @c COMMAND_CHANNEL_DEACTIVATED the channel has no port set * - @c NOT_SUPPORTED if you dont feel like * implementing something... From a5871ed0b123f809145393f868b95e8d31cb60fa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 18 Feb 2022 14:00:06 +0100 Subject: [PATCH 40/44] added void* args to queue factory and mq ctor --- src/fsfw/events/EventManager.cpp | 12 ++++++------ src/fsfw/ipc/QueueFactory.h | 3 ++- src/fsfw/osal/freertos/MessageQueue.cpp | 2 +- src/fsfw/osal/freertos/MessageQueue.h | 3 ++- src/fsfw/osal/freertos/QueueFactory.cpp | 4 ++-- src/fsfw/osal/host/MessageQueue.cpp | 2 +- src/fsfw/osal/host/MessageQueue.h | 3 ++- src/fsfw/osal/host/QueueFactory.cpp | 4 ++-- src/fsfw/osal/linux/MessageQueue.cpp | 2 +- src/fsfw/osal/linux/MessageQueue.h | 3 ++- src/fsfw/osal/linux/QueueFactory.cpp | 4 ++-- src/fsfw/osal/rtems/MessageQueue.cpp | 2 +- src/fsfw/osal/rtems/MessageQueue.h | 3 ++- src/fsfw/osal/rtems/QueueFactory.cpp | 4 ++-- 14 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index c027fce5..d24e893a 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -52,9 +52,9 @@ void EventManager::notifyListeners(EventMessage* message) { MessageQueueSenderIF::sendMessage(listener.first, message, message->getSender()); if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << std::hex << "EventManager::notifyListeners: MSG to " << std::setw(8) - << std::setfill('0') << "0x" << listener.first << " failed with result " - << std::setw(4) << "0x" << result << std::setfill(' ') << std::endl; + sif::error << std::hex << "EventManager::notifyListeners: MSG to 0x" << std::setfill('0') + << std::setw(8) << listener.first << " failed with result 0x" + << std::setw(4) << result << std::setfill(' ') << std::endl; #else sif::printError("Sending message to listener 0x%08x failed with result %04x\n", listener.first, result); @@ -202,11 +202,11 @@ void EventManager::printUtility(sif::OutputTypes printType, EventMessage* messag void EventManager::printListeners() { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Event manager listener MQ IDs:" << std::endl; + sif::info << "Event manager listener MQ IDs:" << std::setfill('0') << std::hex << std::endl; for (auto& listener : listenerList) { - sif::info << std::hex << std::setw(8) << std::setfill('0') << "0x" << listener.first << std::dec - << std::setfill(' ') << std::endl; + sif::info << "0x" << std::setw(8) << listener.first << std::endl; } + sif::info << std::dec << std::setfill(' '); #else sif::printInfo("Event manager listener MQ IDs:\n"); for (auto& listener : listenerList) { diff --git a/src/fsfw/ipc/QueueFactory.h b/src/fsfw/ipc/QueueFactory.h index 864c456d..07107bec 100644 --- a/src/fsfw/ipc/QueueFactory.h +++ b/src/fsfw/ipc/QueueFactory.h @@ -22,7 +22,8 @@ class QueueFactory { static QueueFactory* instance(); MessageQueueIF* createMessageQueue(uint32_t messageDepth = 3, - size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE); + size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, + void* args = nullptr); void deleteMessageQueue(MessageQueueIF* queue); diff --git a/src/fsfw/osal/freertos/MessageQueue.cpp b/src/fsfw/osal/freertos/MessageQueue.cpp index a8333fe5..6e9bdd44 100644 --- a/src/fsfw/osal/freertos/MessageQueue.cpp +++ b/src/fsfw/osal/freertos/MessageQueue.cpp @@ -4,7 +4,7 @@ #include "fsfw/osal/freertos/QueueMapManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize) +MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, void* args) : maxMessageSize(maxMessageSize) { handle = xQueueCreate(messageDepth, maxMessageSize); if (handle == nullptr) { diff --git a/src/fsfw/osal/freertos/MessageQueue.h b/src/fsfw/osal/freertos/MessageQueue.h index 1cb343d1..24054bda 100644 --- a/src/fsfw/osal/freertos/MessageQueue.h +++ b/src/fsfw/osal/freertos/MessageQueue.h @@ -53,7 +53,8 @@ class MessageQueue : public MessageQueueIF { * This should be left default. */ MessageQueue(size_t messageDepth = 3, - size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE); + size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, + void* args = nullptr); /** Copying message queues forbidden */ MessageQueue(const MessageQueue&) = delete; diff --git a/src/fsfw/osal/freertos/QueueFactory.cpp b/src/fsfw/osal/freertos/QueueFactory.cpp index f4941481..d2914929 100644 --- a/src/fsfw/osal/freertos/QueueFactory.cpp +++ b/src/fsfw/osal/freertos/QueueFactory.cpp @@ -22,8 +22,8 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize) { - return new MessageQueue(messageDepth, maxMessageSize); +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) { + return new MessageQueue(messageDepth, maxMessageSize, args); } void QueueFactory::deleteMessageQueue(MessageQueueIF* queue) { delete queue; } diff --git a/src/fsfw/osal/host/MessageQueue.cpp b/src/fsfw/osal/host/MessageQueue.cpp index db66b671..b822578d 100644 --- a/src/fsfw/osal/host/MessageQueue.cpp +++ b/src/fsfw/osal/host/MessageQueue.cpp @@ -8,7 +8,7 @@ #include "fsfw/osal/host/QueueMapManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize) +MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, void* args) : messageSize(maxMessageSize), messageDepth(messageDepth) { queueLock = MutexFactory::instance()->createMutex(); auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId); diff --git a/src/fsfw/osal/host/MessageQueue.h b/src/fsfw/osal/host/MessageQueue.h index 49375bb5..20a2a7e1 100644 --- a/src/fsfw/osal/host/MessageQueue.h +++ b/src/fsfw/osal/host/MessageQueue.h @@ -54,7 +54,8 @@ class MessageQueue : public MessageQueueIF { * This should be left default. */ MessageQueue(size_t messageDepth = 3, - size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE); + size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, + void* args); /** Copying message queues forbidden */ MessageQueue(const MessageQueue&) = delete; diff --git a/src/fsfw/osal/host/QueueFactory.cpp b/src/fsfw/osal/host/QueueFactory.cpp index 3c63e6c9..0ecc5207 100644 --- a/src/fsfw/osal/host/QueueFactory.cpp +++ b/src/fsfw/osal/host/QueueFactory.cpp @@ -27,12 +27,12 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize) { +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) { // A thread-safe queue can be implemented by using a combination // of std::queue and std::mutex. This uses dynamic memory allocation // which could be alleviated by using a custom allocator, external library // (etl::queue) or simply using std::queue, we're on a host machine anyway. - return new MessageQueue(messageDepth, maxMessageSize); + return new MessageQueue(messageDepth, maxMessageSize, args); } void QueueFactory::deleteMessageQueue(MessageQueueIF* queue) { delete queue; } diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index bdba912e..28e84ece 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -11,7 +11,7 @@ #include "fsfw/osal/linux/unixUtility.h" #include "fsfw/serviceinterface/ServiceInterface.h" -MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize) +MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) : id(MessageQueueIF::NO_QUEUE), lastPartner(MessageQueueIF::NO_QUEUE), defaultDestination(MessageQueueIF::NO_QUEUE), diff --git a/src/fsfw/osal/linux/MessageQueue.h b/src/fsfw/osal/linux/MessageQueue.h index dbf6555e..8fd6f11c 100644 --- a/src/fsfw/osal/linux/MessageQueue.h +++ b/src/fsfw/osal/linux/MessageQueue.h @@ -42,7 +42,8 @@ class MessageQueue : public MessageQueueIF { * This should be left default. */ MessageQueue(uint32_t messageDepth = 3, - size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE); + size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, + void* args = nullptr); /** * @brief The destructor deletes the formerly created message queue. * @details This is accomplished by using the delete call provided by the operating system. diff --git a/src/fsfw/osal/linux/QueueFactory.cpp b/src/fsfw/osal/linux/QueueFactory.cpp index d1b1cfdb..7ef4bc0f 100644 --- a/src/fsfw/osal/linux/QueueFactory.cpp +++ b/src/fsfw/osal/linux/QueueFactory.cpp @@ -28,8 +28,8 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize) { - return new MessageQueue(messageDepth, maxMessageSize); +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) { + return new MessageQueue(messageDepth, maxMessageSize, args); } void QueueFactory::deleteMessageQueue(MessageQueueIF* queue) { delete queue; } diff --git a/src/fsfw/osal/rtems/MessageQueue.cpp b/src/fsfw/osal/rtems/MessageQueue.cpp index e45679d5..d47b4df2 100644 --- a/src/fsfw/osal/rtems/MessageQueue.cpp +++ b/src/fsfw/osal/rtems/MessageQueue.cpp @@ -6,7 +6,7 @@ #include "fsfw/osal/rtems/RtemsBasic.h" #include "fsfw/serviceinterface/ServiceInterface.h" -MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size) +MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size, void* args) : id(0), lastPartner(0), defaultDestination(NO_QUEUE), internalErrorReporter(nullptr) { rtems_name name = ('Q' << 24) + (queueCounter++ << 8); rtems_status_code status = diff --git a/src/fsfw/osal/rtems/MessageQueue.h b/src/fsfw/osal/rtems/MessageQueue.h index 89aae2ad..f0efa9f5 100644 --- a/src/fsfw/osal/rtems/MessageQueue.h +++ b/src/fsfw/osal/rtems/MessageQueue.h @@ -34,7 +34,8 @@ class MessageQueue : public MessageQueueIF { * This should be left default. */ MessageQueue(size_t message_depth = 3, - size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE); + size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE, + void* args); /** * @brief The destructor deletes the formerly created message queue. * @details This is accomplished by using the delete call provided by the operating system. diff --git a/src/fsfw/osal/rtems/QueueFactory.cpp b/src/fsfw/osal/rtems/QueueFactory.cpp index 3d517f60..63d0de8a 100644 --- a/src/fsfw/osal/rtems/QueueFactory.cpp +++ b/src/fsfw/osal/rtems/QueueFactory.cpp @@ -49,8 +49,8 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize) { - return new MessageQueue(messageDepth, maxMessageSize); +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) { + return new MessageQueue(messageDepth, maxMessageSize, args); } void QueueFactory::deleteMessageQueue(MessageQueueIF* queue) { delete queue; } From 0d66569687eac9fb5a1ae7eaad8a4c9fbe187b14 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 18 Feb 2022 14:07:41 +0100 Subject: [PATCH 41/44] this is a bit cleaner --- src/fsfw/ipc/QueueFactory.h | 3 ++- src/fsfw/ipc/definitions.h | 10 ++++++++++ src/fsfw/osal/freertos/MessageQueue.cpp | 2 +- src/fsfw/osal/freertos/MessageQueue.h | 3 ++- src/fsfw/osal/freertos/QueueFactory.cpp | 2 +- src/fsfw/osal/host/MessageQueue.cpp | 2 +- src/fsfw/osal/host/MessageQueue.h | 3 ++- src/fsfw/osal/host/QueueFactory.cpp | 2 +- src/fsfw/osal/linux/MessageQueue.cpp | 2 +- src/fsfw/osal/linux/MessageQueue.h | 3 ++- src/fsfw/osal/linux/QueueFactory.cpp | 2 +- src/fsfw/osal/rtems/MessageQueue.cpp | 2 +- src/fsfw/osal/rtems/MessageQueue.h | 3 ++- src/fsfw/osal/rtems/QueueFactory.cpp | 2 +- 14 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 src/fsfw/ipc/definitions.h diff --git a/src/fsfw/ipc/QueueFactory.h b/src/fsfw/ipc/QueueFactory.h index 07107bec..e9e5adf1 100644 --- a/src/fsfw/ipc/QueueFactory.h +++ b/src/fsfw/ipc/QueueFactory.h @@ -4,6 +4,7 @@ #include #include "MessageQueueIF.h" +#include "definitions.h" #include "MessageQueueMessage.h" /** @@ -23,7 +24,7 @@ class QueueFactory { MessageQueueIF* createMessageQueue(uint32_t messageDepth = 3, size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, - void* args = nullptr); + MqArgs* args = nullptr); void deleteMessageQueue(MessageQueueIF* queue); diff --git a/src/fsfw/ipc/definitions.h b/src/fsfw/ipc/definitions.h new file mode 100644 index 00000000..5273f5ca --- /dev/null +++ b/src/fsfw/ipc/definitions.h @@ -0,0 +1,10 @@ +#ifndef FSFW_SRC_FSFW_IPC_DEFINITIONS_H_ +#define FSFW_SRC_FSFW_IPC_DEFINITIONS_H_ +#include + +struct MqArgs { + object_id_t objectId = 0; + void* args = nullptr; +}; + +#endif /* FSFW_SRC_FSFW_IPC_DEFINITIONS_H_ */ diff --git a/src/fsfw/osal/freertos/MessageQueue.cpp b/src/fsfw/osal/freertos/MessageQueue.cpp index 6e9bdd44..927d7820 100644 --- a/src/fsfw/osal/freertos/MessageQueue.cpp +++ b/src/fsfw/osal/freertos/MessageQueue.cpp @@ -4,7 +4,7 @@ #include "fsfw/osal/freertos/QueueMapManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, void* args) +MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, MqArgs* args) : maxMessageSize(maxMessageSize) { handle = xQueueCreate(messageDepth, maxMessageSize); if (handle == nullptr) { diff --git a/src/fsfw/osal/freertos/MessageQueue.h b/src/fsfw/osal/freertos/MessageQueue.h index 24054bda..52708990 100644 --- a/src/fsfw/osal/freertos/MessageQueue.h +++ b/src/fsfw/osal/freertos/MessageQueue.h @@ -7,6 +7,7 @@ #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueMessage.h" #include "fsfw/ipc/MessageQueueMessageIF.h" +#include "fsfw/ipc/definitions.h" #include "queue.h" /** @@ -54,7 +55,7 @@ class MessageQueue : public MessageQueueIF { */ MessageQueue(size_t messageDepth = 3, size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, - void* args = nullptr); + MqArgs* args = nullptr); /** Copying message queues forbidden */ MessageQueue(const MessageQueue&) = delete; diff --git a/src/fsfw/osal/freertos/QueueFactory.cpp b/src/fsfw/osal/freertos/QueueFactory.cpp index d2914929..588653cf 100644 --- a/src/fsfw/osal/freertos/QueueFactory.cpp +++ b/src/fsfw/osal/freertos/QueueFactory.cpp @@ -22,7 +22,7 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) { +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) { return new MessageQueue(messageDepth, maxMessageSize, args); } diff --git a/src/fsfw/osal/host/MessageQueue.cpp b/src/fsfw/osal/host/MessageQueue.cpp index b822578d..eed29555 100644 --- a/src/fsfw/osal/host/MessageQueue.cpp +++ b/src/fsfw/osal/host/MessageQueue.cpp @@ -8,7 +8,7 @@ #include "fsfw/osal/host/QueueMapManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, void* args) +MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, MqArgs* args) : messageSize(maxMessageSize), messageDepth(messageDepth) { queueLock = MutexFactory::instance()->createMutex(); auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId); diff --git a/src/fsfw/osal/host/MessageQueue.h b/src/fsfw/osal/host/MessageQueue.h index 20a2a7e1..aa662dae 100644 --- a/src/fsfw/osal/host/MessageQueue.h +++ b/src/fsfw/osal/host/MessageQueue.h @@ -7,6 +7,7 @@ #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueMessage.h" +#include "fsfw/ipc/definitions.h" #include "fsfw/ipc/MutexIF.h" #include "fsfw/timemanager/Clock.h" @@ -55,7 +56,7 @@ class MessageQueue : public MessageQueueIF { */ MessageQueue(size_t messageDepth = 3, size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, - void* args); + MqArgs* args = nullptr); /** Copying message queues forbidden */ MessageQueue(const MessageQueue&) = delete; diff --git a/src/fsfw/osal/host/QueueFactory.cpp b/src/fsfw/osal/host/QueueFactory.cpp index 0ecc5207..caea8af7 100644 --- a/src/fsfw/osal/host/QueueFactory.cpp +++ b/src/fsfw/osal/host/QueueFactory.cpp @@ -27,7 +27,7 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) { +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) { // A thread-safe queue can be implemented by using a combination // of std::queue and std::mutex. This uses dynamic memory allocation // which could be alleviated by using a custom allocator, external library diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index 28e84ece..c1de8f13 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -11,7 +11,7 @@ #include "fsfw/osal/linux/unixUtility.h" #include "fsfw/serviceinterface/ServiceInterface.h" -MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) +MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) : id(MessageQueueIF::NO_QUEUE), lastPartner(MessageQueueIF::NO_QUEUE), defaultDestination(MessageQueueIF::NO_QUEUE), diff --git a/src/fsfw/osal/linux/MessageQueue.h b/src/fsfw/osal/linux/MessageQueue.h index 8fd6f11c..84052914 100644 --- a/src/fsfw/osal/linux/MessageQueue.h +++ b/src/fsfw/osal/linux/MessageQueue.h @@ -5,6 +5,7 @@ #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/ipc/definitions.h" #include "fsfw/ipc/MessageQueueMessage.h" /** * @brief This class manages sending and receiving of message queue messages. @@ -43,7 +44,7 @@ class MessageQueue : public MessageQueueIF { */ MessageQueue(uint32_t messageDepth = 3, size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, - void* args = nullptr); + MqArgs* args = nullptr); /** * @brief The destructor deletes the formerly created message queue. * @details This is accomplished by using the delete call provided by the operating system. diff --git a/src/fsfw/osal/linux/QueueFactory.cpp b/src/fsfw/osal/linux/QueueFactory.cpp index 7ef4bc0f..d74eb8c5 100644 --- a/src/fsfw/osal/linux/QueueFactory.cpp +++ b/src/fsfw/osal/linux/QueueFactory.cpp @@ -28,7 +28,7 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) { +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) { return new MessageQueue(messageDepth, maxMessageSize, args); } diff --git a/src/fsfw/osal/rtems/MessageQueue.cpp b/src/fsfw/osal/rtems/MessageQueue.cpp index d47b4df2..87073067 100644 --- a/src/fsfw/osal/rtems/MessageQueue.cpp +++ b/src/fsfw/osal/rtems/MessageQueue.cpp @@ -6,7 +6,7 @@ #include "fsfw/osal/rtems/RtemsBasic.h" #include "fsfw/serviceinterface/ServiceInterface.h" -MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size, void* args) +MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size, MqArgs* args) : id(0), lastPartner(0), defaultDestination(NO_QUEUE), internalErrorReporter(nullptr) { rtems_name name = ('Q' << 24) + (queueCounter++ << 8); rtems_status_code status = diff --git a/src/fsfw/osal/rtems/MessageQueue.h b/src/fsfw/osal/rtems/MessageQueue.h index f0efa9f5..b18b2eaf 100644 --- a/src/fsfw/osal/rtems/MessageQueue.h +++ b/src/fsfw/osal/rtems/MessageQueue.h @@ -4,6 +4,7 @@ #include "RtemsBasic.h" #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/ipc/definitions.h" #include "fsfw/ipc/MessageQueueMessage.h" /** @@ -35,7 +36,7 @@ class MessageQueue : public MessageQueueIF { */ MessageQueue(size_t message_depth = 3, size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE, - void* args); + MqArgs* args = nullptr); /** * @brief The destructor deletes the formerly created message queue. * @details This is accomplished by using the delete call provided by the operating system. diff --git a/src/fsfw/osal/rtems/QueueFactory.cpp b/src/fsfw/osal/rtems/QueueFactory.cpp index 63d0de8a..8b625da8 100644 --- a/src/fsfw/osal/rtems/QueueFactory.cpp +++ b/src/fsfw/osal/rtems/QueueFactory.cpp @@ -49,7 +49,7 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) { +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) { return new MessageQueue(messageDepth, maxMessageSize, args); } From 508979d32d4e5910259bfb52b8fe16d1bb4f1cdb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 18 Feb 2022 14:52:25 +0100 Subject: [PATCH 42/44] cache mq args --- src/fsfw/events/EventManager.cpp | 8 ++++---- src/fsfw/ipc/QueueFactory.h | 4 ++-- src/fsfw/ipc/definitions.h | 6 ++++-- src/fsfw/osal/freertos/MessageQueue.h | 2 +- src/fsfw/osal/freertos/QueueFactory.cpp | 3 ++- src/fsfw/osal/host/MessageQueue.h | 4 ++-- src/fsfw/osal/host/QueueFactory.cpp | 3 ++- src/fsfw/osal/linux/MessageQueue.cpp | 3 +++ src/fsfw/osal/linux/MessageQueue.h | 6 ++++-- src/fsfw/osal/linux/QueueFactory.cpp | 3 ++- src/fsfw/osal/rtems/MessageQueue.h | 4 ++-- src/fsfw/osal/rtems/QueueFactory.cpp | 3 ++- 12 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index d24e893a..0fd893b2 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -53,8 +53,8 @@ void EventManager::notifyListeners(EventMessage* message) { if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << std::hex << "EventManager::notifyListeners: MSG to 0x" << std::setfill('0') - << std::setw(8) << listener.first << " failed with result 0x" - << std::setw(4) << result << std::setfill(' ') << std::endl; + << std::setw(8) << listener.first << " failed with result 0x" << std::setw(4) + << result << std::setfill(' ') << std::endl; #else sif::printError("Sending message to listener 0x%08x failed with result %04x\n", listener.first, result); @@ -204,9 +204,9 @@ void EventManager::printListeners() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "Event manager listener MQ IDs:" << std::setfill('0') << std::hex << std::endl; for (auto& listener : listenerList) { - sif::info << "0x" << std::setw(8) << listener.first << std::endl; + sif::info << "0x" << std::setw(8) << listener.first << std::endl; } - sif::info << std::dec << std::setfill(' '); + sif::info << std::dec << std::setfill(' '); #else sif::printInfo("Event manager listener MQ IDs:\n"); for (auto& listener : listenerList) { diff --git a/src/fsfw/ipc/QueueFactory.h b/src/fsfw/ipc/QueueFactory.h index e9e5adf1..8069d836 100644 --- a/src/fsfw/ipc/QueueFactory.h +++ b/src/fsfw/ipc/QueueFactory.h @@ -4,8 +4,8 @@ #include #include "MessageQueueIF.h" -#include "definitions.h" #include "MessageQueueMessage.h" +#include "definitions.h" /** * Creates message queues. @@ -24,7 +24,7 @@ class QueueFactory { MessageQueueIF* createMessageQueue(uint32_t messageDepth = 3, size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, - MqArgs* args = nullptr); + MqArgs* args = nullptr); void deleteMessageQueue(MessageQueueIF* queue); diff --git a/src/fsfw/ipc/definitions.h b/src/fsfw/ipc/definitions.h index 5273f5ca..1cc7a3c4 100644 --- a/src/fsfw/ipc/definitions.h +++ b/src/fsfw/ipc/definitions.h @@ -3,8 +3,10 @@ #include struct MqArgs { - object_id_t objectId = 0; - void* args = nullptr; + MqArgs(){}; + MqArgs(object_id_t objectId, void* args = nullptr) : objectId(objectId), args(args) {} + object_id_t objectId = 0; + void* args = nullptr; }; #endif /* FSFW_SRC_FSFW_IPC_DEFINITIONS_H_ */ diff --git a/src/fsfw/osal/freertos/MessageQueue.h b/src/fsfw/osal/freertos/MessageQueue.h index 52708990..fc1d78e5 100644 --- a/src/fsfw/osal/freertos/MessageQueue.h +++ b/src/fsfw/osal/freertos/MessageQueue.h @@ -55,7 +55,7 @@ class MessageQueue : public MessageQueueIF { */ MessageQueue(size_t messageDepth = 3, size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, - MqArgs* args = nullptr); + MqArgs* args = nullptr); /** Copying message queues forbidden */ MessageQueue(const MessageQueue&) = delete; diff --git a/src/fsfw/osal/freertos/QueueFactory.cpp b/src/fsfw/osal/freertos/QueueFactory.cpp index 588653cf..8424123c 100644 --- a/src/fsfw/osal/freertos/QueueFactory.cpp +++ b/src/fsfw/osal/freertos/QueueFactory.cpp @@ -22,7 +22,8 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) { +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, + MqArgs* args) { return new MessageQueue(messageDepth, maxMessageSize, args); } diff --git a/src/fsfw/osal/host/MessageQueue.h b/src/fsfw/osal/host/MessageQueue.h index aa662dae..d090d269 100644 --- a/src/fsfw/osal/host/MessageQueue.h +++ b/src/fsfw/osal/host/MessageQueue.h @@ -7,8 +7,8 @@ #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueMessage.h" -#include "fsfw/ipc/definitions.h" #include "fsfw/ipc/MutexIF.h" +#include "fsfw/ipc/definitions.h" #include "fsfw/timemanager/Clock.h" /** @@ -56,7 +56,7 @@ class MessageQueue : public MessageQueueIF { */ MessageQueue(size_t messageDepth = 3, size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, - MqArgs* args = nullptr); + MqArgs* args = nullptr); /** Copying message queues forbidden */ MessageQueue(const MessageQueue&) = delete; diff --git a/src/fsfw/osal/host/QueueFactory.cpp b/src/fsfw/osal/host/QueueFactory.cpp index caea8af7..732892ca 100644 --- a/src/fsfw/osal/host/QueueFactory.cpp +++ b/src/fsfw/osal/host/QueueFactory.cpp @@ -27,7 +27,8 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) { +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, + MqArgs* args) { // A thread-safe queue can be implemented by using a combination // of std::queue and std::mutex. This uses dynamic memory allocation // which could be alleviated by using a custom allocator, external library diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index c1de8f13..bfc1d0f7 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -37,6 +37,9 @@ MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* // Successful mq_open call this->id = tempId; } + if (args != nullptr) { + this->mqArgs = *args; + } } MessageQueue::~MessageQueue() { diff --git a/src/fsfw/osal/linux/MessageQueue.h b/src/fsfw/osal/linux/MessageQueue.h index 84052914..58afccd6 100644 --- a/src/fsfw/osal/linux/MessageQueue.h +++ b/src/fsfw/osal/linux/MessageQueue.h @@ -5,8 +5,8 @@ #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/ipc/definitions.h" #include "fsfw/ipc/MessageQueueMessage.h" +#include "fsfw/ipc/definitions.h" /** * @brief This class manages sending and receiving of message queue messages. * @@ -44,7 +44,7 @@ class MessageQueue : public MessageQueueIF { */ MessageQueue(uint32_t messageDepth = 3, size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE, - MqArgs* args = nullptr); + MqArgs* args = nullptr); /** * @brief The destructor deletes the formerly created message queue. * @details This is accomplished by using the delete call provided by the operating system. @@ -186,6 +186,8 @@ class MessageQueue : public MessageQueueIF { */ char name[16]; + MqArgs mqArgs = {}; + static uint16_t queueCounter; const size_t maxMessageSize; diff --git a/src/fsfw/osal/linux/QueueFactory.cpp b/src/fsfw/osal/linux/QueueFactory.cpp index d74eb8c5..24ace1ae 100644 --- a/src/fsfw/osal/linux/QueueFactory.cpp +++ b/src/fsfw/osal/linux/QueueFactory.cpp @@ -28,7 +28,8 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) { +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, + MqArgs* args) { return new MessageQueue(messageDepth, maxMessageSize, args); } diff --git a/src/fsfw/osal/rtems/MessageQueue.h b/src/fsfw/osal/rtems/MessageQueue.h index b18b2eaf..0f1ee6ee 100644 --- a/src/fsfw/osal/rtems/MessageQueue.h +++ b/src/fsfw/osal/rtems/MessageQueue.h @@ -4,8 +4,8 @@ #include "RtemsBasic.h" #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/ipc/definitions.h" #include "fsfw/ipc/MessageQueueMessage.h" +#include "fsfw/ipc/definitions.h" /** * @brief This class manages sending and receiving of message queue messages. @@ -36,7 +36,7 @@ class MessageQueue : public MessageQueueIF { */ MessageQueue(size_t message_depth = 3, size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE, - MqArgs* args = nullptr); + MqArgs* args = nullptr); /** * @brief The destructor deletes the formerly created message queue. * @details This is accomplished by using the delete call provided by the operating system. diff --git a/src/fsfw/osal/rtems/QueueFactory.cpp b/src/fsfw/osal/rtems/QueueFactory.cpp index 8b625da8..2519f444 100644 --- a/src/fsfw/osal/rtems/QueueFactory.cpp +++ b/src/fsfw/osal/rtems/QueueFactory.cpp @@ -49,7 +49,8 @@ QueueFactory::QueueFactory() {} QueueFactory::~QueueFactory() {} -MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) { +MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, + MqArgs* args) { return new MessageQueue(messageDepth, maxMessageSize, args); } From cf69af4e7e523bfcd73318f64e9d720f4779ea39 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 19 Feb 2022 16:14:02 +0100 Subject: [PATCH 43/44] passing mqArgs to all mq ctor calls --- src/fsfw/cfdp/CFDPHandler.cpp | 4 +++- src/fsfw/controller/ControllerBase.cpp | 4 +++- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 3 ++- src/fsfw/devicehandlers/HealthDevice.cpp | 3 ++- src/fsfw/events/EventManager.cpp | 4 +++- src/fsfw/fdir/FailureIsolationBase.cpp | 3 ++- src/fsfw/internalerror/InternalErrorReporter.cpp | 3 ++- src/fsfw/power/PowerSensor.cpp | 3 ++- src/fsfw/pus/Service1TelecommandVerification.cpp | 3 ++- src/fsfw/pus/Service5EventReporting.cpp | 3 ++- src/fsfw/subsystem/SubsystemBase.cpp | 8 +++++--- src/fsfw/tcdistribution/TcDistributor.cpp | 3 ++- src/fsfw/thermal/AbstractTemperatureSensor.cpp | 6 +++--- src/fsfw/thermal/AbstractTemperatureSensor.h | 2 +- src/fsfw/thermal/Heater.cpp | 3 ++- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 6 ++++-- src/fsfw/tmtcservices/PusServiceBase.cpp | 3 ++- src/fsfw/tmtcservices/TmTcBridge.cpp | 3 ++- 18 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/fsfw/cfdp/CFDPHandler.cpp b/src/fsfw/cfdp/CFDPHandler.cpp index 96baa98c..1d41a80d 100644 --- a/src/fsfw/cfdp/CFDPHandler.cpp +++ b/src/fsfw/cfdp/CFDPHandler.cpp @@ -12,7 +12,9 @@ object_id_t CFDPHandler::packetDestination = 0; CFDPHandler::CFDPHandler(object_id_t setObjectId, CFDPDistributor* dist) : SystemObject(setObjectId) { - requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION); + auto mqArgs = MqArgs(setObjectId, static_cast(this)); + requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION, + MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); distributor = dist; } diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index 953dacb4..6af4dd7d 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -13,7 +13,9 @@ ControllerBase::ControllerBase(object_id_t setObjectId, object_id_t parentId, submode(SUBMODE_NONE), modeHelper(this), healthHelper(this, setObjectId) { - commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth); + auto mqArgs = MqArgs(setObjectId, static_cast(this)); + commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth, + MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } ControllerBase::~ControllerBase() { QueueFactory::instance()->deleteMessageQueue(commandQueue); } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index ea1fcdf1..3f90a72c 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -39,8 +39,9 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(SUBMODE_NONE) { + auto mqArgs = MqArgs(setObjectId, static_cast(this)); commandQueue = QueueFactory::instance()->createMessageQueue( - cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); insertInCommandMap(RAW_COMMAND_ID); cookieInfo.state = COOKIE_UNUSED; cookieInfo.pendingCommand = deviceCommandMap.end(); diff --git a/src/fsfw/devicehandlers/HealthDevice.cpp b/src/fsfw/devicehandlers/HealthDevice.cpp index a626fa6c..c666ceb8 100644 --- a/src/fsfw/devicehandlers/HealthDevice.cpp +++ b/src/fsfw/devicehandlers/HealthDevice.cpp @@ -8,7 +8,8 @@ HealthDevice::HealthDevice(object_id_t setObjectId, MessageQueueId_t parentQueue parentQueue(parentQueue), commandQueue(), healthHelper(this, setObjectId) { - commandQueue = QueueFactory::instance()->createMessageQueue(3); + auto mqArgs = MqArgs(setObjectId, static_cast(this)); + commandQueue = QueueFactory::instance()->createMessageQueue(3, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } HealthDevice::~HealthDevice() { QueueFactory::instance()->deleteMessageQueue(commandQueue); } diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index 0fd893b2..7583bafd 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -18,8 +18,10 @@ const LocalPool::LocalPoolConfig EventManager::poolConfig = { EventManager::EventManager(object_id_t setObjectId) : SystemObject(setObjectId), factoryBackend(0, poolConfig, false, true) { mutex = MutexFactory::instance()->createMutex(); + auto mqArgs = MqArgs(setObjectId, static_cast(this)); eventReportQueue = QueueFactory::instance()->createMessageQueue(MAX_EVENTS_PER_CYCLE, - EventMessage::EVENT_MESSAGE_SIZE); + EventMessage::EVENT_MESSAGE_SIZE, + &mqArgs); } EventManager::~EventManager() { diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index fedef869..ca7077a9 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -9,8 +9,9 @@ FailureIsolationBase::FailureIsolationBase(object_id_t owner, object_id_t parent, uint8_t messageDepth, uint8_t parameterDomainBase) : ownerId(owner), faultTreeParent(parent), parameterDomainBase(parameterDomainBase) { + auto mqArgs = MqArgs(owner, static_cast(this)); eventQueue = - QueueFactory::instance()->createMessageQueue(messageDepth, EventMessage::EVENT_MESSAGE_SIZE); + QueueFactory::instance()->createMessageQueue(messageDepth, EventMessage::EVENT_MESSAGE_SIZE, &mqArgs); } FailureIsolationBase::~FailureIsolationBase() { diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index a085cc5b..0ad60492 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -7,11 +7,12 @@ InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth) : SystemObject(setObjectId), - commandQueue(QueueFactory::instance()->createMessageQueue(messageQueueDepth)), poolManager(this, commandQueue), internalErrorSid(setObjectId, InternalErrorDataset::ERROR_SET_ID), internalErrorDataset(this) { mutex = MutexFactory::instance()->createMutex(); + auto mqArgs = MqArgs(setObjectId, static_cast(this)); + commandQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } InternalErrorReporter::~InternalErrorReporter() { MutexFactory::instance()->deleteMutex(mutex); } diff --git a/src/fsfw/power/PowerSensor.cpp b/src/fsfw/power/PowerSensor.cpp index 08ff4724..74cf60f7 100644 --- a/src/fsfw/power/PowerSensor.cpp +++ b/src/fsfw/power/PowerSensor.cpp @@ -15,7 +15,8 @@ PowerSensor::PowerSensor(object_id_t objectId, sid_t setId, VariableIds ids, Def limits.currentMin, limits.currentMax, events.currentLow, events.currentHigh), voltageLimit(objectId, MODULE_ID_VOLTAGE, ids.pidVoltage, confirmationCount, limits.voltageMin, limits.voltageMax, events.voltageLow, events.voltageHigh) { - commandQueue = QueueFactory::instance()->createMessageQueue(); + auto mqArgs = MqArgs(objectId, static_cast(this)); + commandQueue = QueueFactory::instance()->createMessageQueue(3, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } PowerSensor::~PowerSensor() { QueueFactory::instance()->deleteMessageQueue(commandQueue); } diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 13d6a1c4..9418ceb2 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -16,7 +16,8 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj apid(apid), serviceId(serviceId), targetDestination(targetDestination) { - tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); + auto mqArgs = MqArgs(objectId, static_cast(this)); + tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } Service1TelecommandVerification::~Service1TelecommandVerification() { diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index dfce9ba2..918abff0 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -12,7 +12,8 @@ Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t ap uint32_t messageQueueDepth) : PusServiceBase(objectId, apid, serviceId), maxNumberReportsPerCycle(maxNumberReportsPerCycle) { - eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); + auto mqArgs = MqArgs(objectId, static_cast(this)); + eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); sif::info << eventQueue->getId() << std::endl; } diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 104db3c3..974459d3 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -8,11 +8,13 @@ SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent, Mode_t uint16_t commandQueueDepth) : SystemObject(setObjectId), mode(initialMode), - commandQueue(QueueFactory::instance()->createMessageQueue(commandQueueDepth, - CommandMessage::MAX_MESSAGE_SIZE)), healthHelper(this, setObjectId), modeHelper(this), - parentId(parent) {} + parentId(parent) { + auto mqArgs = MqArgs(setObjectId, static_cast(this)); + commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth, + CommandMessage::MAX_MESSAGE_SIZE, &mqArgs); +} SubsystemBase::~SubsystemBase() { QueueFactory::instance()->deleteMessageQueue(commandQueue); } diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index a650546c..5ce41826 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -5,7 +5,8 @@ #include "fsfw/tmtcservices/TmTcMessage.h" TcDistributor::TcDistributor(object_id_t objectId) : SystemObject(objectId) { - tcQueue = QueueFactory::instance()->createMessageQueue(DISTRIBUTER_MAX_PACKETS); + auto mqArgs = MqArgs(objectId); + tcQueue = QueueFactory::instance()->createMessageQueue(DISTRIBUTER_MAX_PACKETS, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } TcDistributor::~TcDistributor() { QueueFactory::instance()->deleteMessageQueue(tcQueue); } diff --git a/src/fsfw/thermal/AbstractTemperatureSensor.cpp b/src/fsfw/thermal/AbstractTemperatureSensor.cpp index 68cd3aca..003f857e 100644 --- a/src/fsfw/thermal/AbstractTemperatureSensor.cpp +++ b/src/fsfw/thermal/AbstractTemperatureSensor.cpp @@ -5,13 +5,13 @@ AbstractTemperatureSensor::AbstractTemperatureSensor(object_id_t setObjectid, ThermalModuleIF *thermalModule) : SystemObject(setObjectid), - commandQueue(NULL), healthHelper(this, setObjectid), parameterHelper(this) { - if (thermalModule != NULL) { + if (thermalModule != nullptr) { thermalModule->registerSensor(this); } - commandQueue = QueueFactory::instance()->createMessageQueue(); + auto mqArgs = MqArgs(setObjectid, static_cast(this)); + commandQueue = QueueFactory::instance()->createMessageQueue(3, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } AbstractTemperatureSensor::~AbstractTemperatureSensor() { diff --git a/src/fsfw/thermal/AbstractTemperatureSensor.h b/src/fsfw/thermal/AbstractTemperatureSensor.h index 0c6493fe..b790b0ca 100644 --- a/src/fsfw/thermal/AbstractTemperatureSensor.h +++ b/src/fsfw/thermal/AbstractTemperatureSensor.h @@ -51,7 +51,7 @@ class AbstractTemperatureSensor : public HasHealthIF, HasHealthIF::HealthState getHealth(); protected: - MessageQueueIF* commandQueue; + MessageQueueIF* commandQueue = nullptr; HealthHelper healthHelper; ParameterHelper parameterHelper; diff --git a/src/fsfw/thermal/Heater.cpp b/src/fsfw/thermal/Heater.cpp index 4f0f8060..2755b855 100644 --- a/src/fsfw/thermal/Heater.cpp +++ b/src/fsfw/thermal/Heater.cpp @@ -12,7 +12,8 @@ Heater::Heater(uint32_t objectId, uint8_t switch0, uint8_t switch1) switch1(switch1), heaterOnCountdown(10800000) /*about two orbits*/, parameterHelper(this) { - eventQueue = QueueFactory::instance()->createMessageQueue(); + auto mqArgs = MqArgs(objectId, static_cast(this)); + eventQueue = QueueFactory::instance()->createMessageQueue(3, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } Heater::~Heater() { QueueFactory::instance()->deleteMessageQueue(eventQueue); } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index bbdf8d2a..1bbd7fd1 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -20,8 +20,10 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t a service(service), timeoutSeconds(commandTimeoutSeconds), commandMap(numberOfParallelCommands) { - commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); - requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); + auto mqArgs = MqArgs(setObjectId, static_cast(this)); + size_t mqSz = MessageQueueMessage::MAX_MESSAGE_SIZE; + commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth, mqSz, &mqArgs); + requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth, mqSz, &mqArgs); } void CommandingServiceBase::setPacketSource(object_id_t packetSource) { diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 3af2b82c..cedcb0a2 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -13,7 +13,8 @@ object_id_t PusServiceBase::packetDestination = 0; PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId) : SystemObject(setObjectId), apid(setApid), serviceId(setServiceId) { - requestQueue = QueueFactory::instance()->createMessageQueue(PUS_SERVICE_MAX_RECEPTION); + auto mqArgs = MqArgs(setObjectId, static_cast(this)); + requestQueue = QueueFactory::instance()->createMessageQueue(PUS_SERVICE_MAX_RECEPTION, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } PusServiceBase::~PusServiceBase() { QueueFactory::instance()->deleteMessageQueue(requestQueue); } diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index bacadd6d..6b96856b 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -15,7 +15,8 @@ TmTcBridge::TmTcBridge(object_id_t objectId, object_id_t tcDestination, object_i tcDestination(tcDestination) { - tmTcReceptionQueue = QueueFactory::instance()->createMessageQueue(TMTC_RECEPTION_QUEUE_DEPTH); + auto mqArgs = MqArgs(objectId, static_cast(this)); + tmTcReceptionQueue = QueueFactory::instance()->createMessageQueue(TMTC_RECEPTION_QUEUE_DEPTH, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } TmTcBridge::~TmTcBridge() { QueueFactory::instance()->deleteMessageQueue(tmTcReceptionQueue); } From d74a373f1d6bc341c11d7ad89f369da5ff957928 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 19 Feb 2022 16:41:30 +0100 Subject: [PATCH 44/44] make periodic printout run time configurable --- .../devicehandlers/GyroL3GD20Handler.cpp | 39 ++++++------ .../devicehandlers/GyroL3GD20Handler.h | 13 ++-- .../devicehandlers/MgmLIS3MDLHandler.cpp | 60 ++++++++++--------- .../devicehandlers/MgmLIS3MDLHandler.h | 9 +-- .../devicehandlers/MgmRM3100Handler.cpp | 41 +++++++------ .../devicehandlers/MgmRM3100Handler.h | 11 ++-- src/fsfw/FSFW.h.in | 12 ---- 7 files changed, 92 insertions(+), 93 deletions(-) diff --git a/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp b/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp index f92f5f1f..1bd0665d 100644 --- a/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp +++ b/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp @@ -9,9 +9,6 @@ GyroHandlerL3GD20H::GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceC : DeviceHandlerBase(objectId, deviceCommunication, comCookie), transitionDelayMs(transitionDelayMs), dataset(this) { -#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - debugDivider = new PeriodicOperationDivider(10); -#endif } GyroHandlerL3GD20H::~GyroHandlerL3GD20H() {} @@ -193,22 +190,23 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id, int8_t temperaturOffset = (-1) * packet[L3GD20H::TEMPERATURE_IDX]; float temperature = 25.0 + temperaturOffset; -#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - if (debugDivider->checkAndIncrement()) { - /* Set terminal to utf-8 if there is an issue with micro printout. */ -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "GyroHandlerL3GD20H: Angular velocities (deg/s):" << std::endl; - sif::info << "X: " << angVelocX << std::endl; - sif::info << "Y: " << angVelocY << std::endl; - sif::info << "Z: " << angVelocZ << std::endl; -#else - sif::printInfo("GyroHandlerL3GD20H: Angular velocities (deg/s):\n"); - sif::printInfo("X: %f\n", angVelocX); - sif::printInfo("Y: %f\n", angVelocY); - sif::printInfo("Z: %f\n", angVelocZ); -#endif + if(periodicPrintout) { + if (debugDivider.checkAndIncrement()) { + /* Set terminal to utf-8 if there is an issue with micro printout. */ + #if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::info << "GyroHandlerL3GD20H: Angular velocities (deg/s):" << std::endl; + sif::info << "X: " << angVelocX << std::endl; + sif::info << "Y: " << angVelocY << std::endl; + sif::info << "Z: " << angVelocZ << std::endl; + #else + sif::printInfo("GyroHandlerL3GD20H: Angular velocities (deg/s):\n"); + sif::printInfo("X: %f\n", angVelocX); + sif::printInfo("Y: %f\n", angVelocY); + sif::printInfo("Z: %f\n", angVelocZ); + #endif + } } -#endif + PoolReadGuard readSet(&dataset); if (readSet.getReadResult() == HasReturnvaluesIF::RETURN_OK) { @@ -272,3 +270,8 @@ void GyroHandlerL3GD20H::setAbsoluteLimits(float limitX, float limitY, float lim this->absLimitY = limitY; this->absLimitZ = limitZ; } + +void GyroHandlerL3GD20H::enablePeriodicPrintouts(bool enable, uint8_t divider) { + periodicPrintout = enable; + debugDivider.setDivider(divider); +} diff --git a/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.h b/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.h index 784dcf4c..806fb5c0 100644 --- a/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.h +++ b/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.h @@ -1,12 +1,11 @@ #ifndef MISSION_DEVICES_GYROL3GD20HANDLER_H_ #define MISSION_DEVICES_GYROL3GD20HANDLER_H_ +#include "devicedefinitions/GyroL3GD20Definitions.h" + #include #include -#include "devicedefinitions/GyroL3GD20Definitions.h" -#include "fsfw/FSFW.h" - /** * @brief Device Handler for the L3GD20H gyroscope sensor * (https://www.st.com/en/mems-and-sensors/l3gd20h.html) @@ -22,6 +21,8 @@ class GyroHandlerL3GD20H : public DeviceHandlerBase { uint32_t transitionDelayMs); virtual ~GyroHandlerL3GD20H(); + void enablePeriodicPrintouts(bool enable, uint8_t divider); + /** * Set the absolute limit for the values on the axis in degrees per second. * The dataset values will be marked as invalid if that limit is exceeded @@ -58,6 +59,7 @@ class GyroHandlerL3GD20H : public DeviceHandlerBase { uint32_t transitionDelayMs = 0; GyroPrimaryDataset dataset; + float absLimitX = L3GD20H::RANGE_DPS_00; float absLimitY = L3GD20H::RANGE_DPS_00; float absLimitZ = L3GD20H::RANGE_DPS_00; @@ -80,9 +82,8 @@ class GyroHandlerL3GD20H : public DeviceHandlerBase { // Set default value float sensitivity = L3GD20H::SENSITIVITY_00; -#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - PeriodicOperationDivider *debugDivider = nullptr; -#endif + bool periodicPrintout = false; + PeriodicOperationDivider debugDivider = PeriodicOperationDivider(3); }; #endif /* MISSION_DEVICES_GYROL3GD20HANDLER_H_ */ diff --git a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index cf1d934a..a20a3a0f 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -12,9 +12,6 @@ MgmLIS3MDLHandler::MgmLIS3MDLHandler(object_id_t objectId, object_id_t deviceCom : DeviceHandlerBase(objectId, deviceCommunication, comCookie), dataset(this), transitionDelay(transitionDelay) { -#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - debugDivider = new PeriodicOperationDivider(10); -#endif // Set to default values right away registers[0] = MGMLIS3MDL::CTRL_REG1_DEFAULT; registers[1] = MGMLIS3MDL::CTRL_REG2_DEFAULT; @@ -272,23 +269,25 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons float mgmZ = static_cast(mgmMeasurementRawZ) * sensitivityFactor * MGMLIS3MDL::GAUSS_TO_MICROTESLA_FACTOR; -#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - if (debugDivider->checkAndIncrement()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "MGMHandlerLIS3: Magnetic field strength in" - " microtesla:" - << std::endl; - sif::info << "X: " << mgmX << " uT" << std::endl; - sif::info << "Y: " << mgmY << " uT" << std::endl; - sif::info << "Z: " << mgmZ << " uT" << std::endl; -#else - sif::printInfo("MGMHandlerLIS3: Magnetic field strength in microtesla:\n"); - sif::printInfo("X: %f uT\n", mgmX); - sif::printInfo("Y: %f uT\n", mgmY); - sif::printInfo("Z: %f uT\n", mgmZ); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ + if(periodicPrintout) { + if (debugDivider.checkAndIncrement()) { + #if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::info << "MGMHandlerLIS3: Magnetic field strength in" + " microtesla:" + << std::endl; + sif::info << "X: " << mgmX << " uT" << std::endl; + sif::info << "Y: " << mgmY << " uT" << std::endl; + sif::info << "Z: " << mgmZ << " uT" << std::endl; + #else + sif::printInfo("MGMHandlerLIS3: Magnetic field strength in microtesla:\n"); + sif::printInfo("X: %f uT\n", mgmX); + sif::printInfo("Y: %f uT\n", mgmY); + sif::printInfo("Z: %f uT\n", mgmZ); + #endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ + } } -#endif /* OBSW_VERBOSE_LEVEL >= 1 */ + + PoolReadGuard readHelper(&dataset); if (readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) { if (std::abs(mgmX) < absLimitX) { @@ -318,15 +317,16 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons case MGMLIS3MDL::READ_TEMPERATURE: { int16_t tempValueRaw = packet[2] << 8 | packet[1]; float tempValue = 25.0 + ((static_cast(tempValueRaw)) / 8.0); -#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - if (debugDivider->check()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" << std::endl; -#else - sif::printInfo("MGMHandlerLIS3: Temperature: %f C\n"); -#endif + if(periodicPrintout) { + if (debugDivider.check()) { + #if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" << std::endl; + #else + sif::printInfo("MGMHandlerLIS3: Temperature: %f C\n"); + #endif + } } -#endif + ReturnValue_t result = dataset.read(); if (result == HasReturnvaluesIF::RETURN_OK) { dataset.temperature = tempValue; @@ -484,3 +484,9 @@ void MgmLIS3MDLHandler::setAbsoluteLimits(float xLimit, float yLimit, float zLim this->absLimitY = yLimit; this->absLimitZ = zLimit; } + + +void MgmLIS3MDLHandler::enablePeriodicPrintouts(bool enable, uint8_t divider) { + periodicPrintout = enable; + debugDivider.setDivider(divider); +} diff --git a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h index b7cfc378..6605f763 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h +++ b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h @@ -1,9 +1,10 @@ #ifndef MISSION_DEVICES_MGMLIS3MDLHANDLER_H_ #define MISSION_DEVICES_MGMLIS3MDLHANDLER_H_ + #include "devicedefinitions/MgmLIS3HandlerDefs.h" #include "events/subsystemIdRanges.h" -#include "fsfw/FSFW.h" +#include "fsfw/globalfunctions/PeriodicOperationDivider.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" class PeriodicOperationDivider; @@ -30,6 +31,7 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase { uint32_t transitionDelay); virtual ~MgmLIS3MDLHandler(); + void enablePeriodicPrintouts(bool enable, uint8_t divider); /** * Set the absolute limit for the values on the axis in microtesla. The dataset values will * be marked as invalid if that limit is exceeded @@ -167,9 +169,8 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase { */ ReturnValue_t prepareCtrlRegisterWrite(); -#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - PeriodicOperationDivider *debugDivider; -#endif + bool periodicPrintout = false; + PeriodicOperationDivider debugDivider = PeriodicOperationDivider(3); }; #endif /* MISSION_DEVICES_MGMLIS3MDLHANDLER_H_ */ diff --git a/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index a2e2e85f..b0ba8e88 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -11,9 +11,6 @@ MgmRM3100Handler::MgmRM3100Handler(object_id_t objectId, object_id_t deviceCommu : DeviceHandlerBase(objectId, deviceCommunication, comCookie), primaryDataset(this), transitionDelay(transitionDelay) { -#if FSFW_HAL_RM3100_MGM_DEBUG == 1 - debugDivider = new PeriodicOperationDivider(10); -#endif } MgmRM3100Handler::~MgmRM3100Handler() {} @@ -337,23 +334,24 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) { float fieldStrengthY = fieldStrengthRawY * scaleFactorX; float fieldStrengthZ = fieldStrengthRawZ * scaleFactorX; -#if FSFW_HAL_RM3100_MGM_DEBUG == 1 - if (debugDivider->checkAndIncrement()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "MgmRM3100Handler: Magnetic field strength in" - " microtesla:" - << std::endl; - sif::info << "X: " << fieldStrengthX << " uT" << std::endl; - sif::info << "Y: " << fieldStrengthY << " uT" << std::endl; - sif::info << "Z: " << fieldStrengthZ << " uT" << std::endl; -#else - sif::printInfo("MgmRM3100Handler: Magnetic field strength in microtesla:\n"); - sif::printInfo("X: %f uT\n", fieldStrengthX); - sif::printInfo("Y: %f uT\n", fieldStrengthY); - sif::printInfo("Z: %f uT\n", fieldStrengthZ); -#endif + if(periodicPrintout) { + if (debugDivider.checkAndIncrement()) { + #if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::info << "MgmRM3100Handler: Magnetic field strength in" + " microtesla:" + << std::endl; + sif::info << "X: " << fieldStrengthX << " uT" << std::endl; + sif::info << "Y: " << fieldStrengthY << " uT" << std::endl; + sif::info << "Z: " << fieldStrengthZ << " uT" << std::endl; + #else + sif::printInfo("MgmRM3100Handler: Magnetic field strength in microtesla:\n"); + sif::printInfo("X: %f uT\n", fieldStrengthX); + sif::printInfo("Y: %f uT\n", fieldStrengthY); + sif::printInfo("Z: %f uT\n", fieldStrengthZ); + #endif + } } -#endif + // TODO: Sanity check on values? PoolReadGuard readGuard(&primaryDataset); @@ -365,3 +363,8 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) { } return RETURN_OK; } + +void MgmRM3100Handler::enablePeriodicPrintouts(bool enable, uint8_t divider) { + periodicPrintout = enable; + debugDivider.setDivider(divider); +} diff --git a/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h b/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h index 67362f59..d1048cb6 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h +++ b/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h @@ -2,12 +2,8 @@ #define MISSION_DEVICES_MGMRM3100HANDLER_H_ #include "devicedefinitions/MgmRM3100HandlerDefs.h" -#include "fsfw/FSFW.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" - -#if FSFW_HAL_RM3100_MGM_DEBUG == 1 #include "fsfw/globalfunctions/PeriodicOperationDivider.h" -#endif /** * @brief Device Handler for the RM3100 geomagnetic magnetometer sensor @@ -33,6 +29,7 @@ class MgmRM3100Handler : public DeviceHandlerBase { uint32_t transitionDelay); virtual ~MgmRM3100Handler(); + void enablePeriodicPrintouts(bool enable, uint8_t divider); /** * Configure device handler to go to normal mode after startup immediately * @param enable @@ -98,9 +95,9 @@ class MgmRM3100Handler : public DeviceHandlerBase { size_t commandDataLen); ReturnValue_t handleDataReadout(const uint8_t *packet); -#if FSFW_HAL_RM3100_MGM_DEBUG == 1 - PeriodicOperationDivider *debugDivider; -#endif + + bool periodicPrintout = false; + PeriodicOperationDivider debugDivider = PeriodicOperationDivider(3); }; #endif /* MISSION_DEVICEHANDLING_MGMRM3100HANDLER_H_ */ diff --git a/src/fsfw/FSFW.h.in b/src/fsfw/FSFW.h.in index 7e8bcd79..9cfeab61 100644 --- a/src/fsfw/FSFW.h.in +++ b/src/fsfw/FSFW.h.in @@ -62,16 +62,4 @@ #define FSFW_HAL_I2C_WIRETAPPING 0 #endif -#ifndef FSFW_HAL_L3GD20_GYRO_DEBUG -#define FSFW_HAL_L3GD20_GYRO_DEBUG 0 -#endif /* FSFW_HAL_L3GD20_GYRO_DEBUG */ - -#ifndef FSFW_HAL_RM3100_MGM_DEBUG -#define FSFW_HAL_RM3100_MGM_DEBUG 0 -#endif /* FSFW_HAL_RM3100_MGM_DEBUG */ - -#ifndef FSFW_HAL_LIS3MDL_MGM_DEBUG -#define FSFW_HAL_LIS3MDL_MGM_DEBUG 0 -#endif /* FSFW_HAL_LIS3MDL_MGM_DEBUG */ - #endif /* FSFW_FSFW_H_ */