diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..ec53b72b
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,7 @@
+---
+BasedOnStyle: Google
+IndentWidth: 2
+---
+Language: Cpp
+ColumnLimit: 100
+---
diff --git a/CHANGELOG b/CHANGELOG.md
similarity index 50%
rename from CHANGELOG
rename to CHANGELOG.md
index 8f86c147..335c0f7b 100644
--- a/CHANGELOG
+++ b/CHANGELOG.md
@@ -1,4 +1,214 @@
-# 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
+- 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
+- Dockumentation for DHB
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/551
+
+### 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
+ 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
+- 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
+
+- Aforementioned changes to existing TMTC stack
+
+## Known bugs
+
+-
+
+# [v3.0.1]
+
+## API Changes
+
+*
+
+## Bugfixes
+
+* Version number was not updated for v3.0.0 #542
+
+## Enhancement
+
+*
+
+## Known bugs
+
+*
+
+# [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
+
+* Version number was not updated for v3.0.0 #542
+
+
+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 +237,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
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c7bd64e4..79258db2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.13)
-set(FSFW_VERSION 2)
+set(FSFW_VERSION 4)
set(FSFW_SUBVERSION 0)
set(FSFW_REVISION 0)
@@ -56,10 +56,12 @@ if(FSFW_BUILD_UNITTESTS)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
- GIT_TAG v3.0.0-preview3
+ GIT_TAG v3.0.0-preview4
)
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)
@@ -90,7 +92,7 @@ set(FSFW_CORE_INC_PATH "inc")
set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos)
-# Configure Files
+# For configure files
target_include_directories(${LIB_FSFW_NAME} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
)
@@ -152,13 +154,8 @@ else()
set(OS_FSFW "host")
endif()
-if(FSFW_BUILD_UNITTESTS OR FSFW_BUILD_DOCS)
- configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h)
- configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h)
-else()
- configure_file(src/fsfw/FSFW.h.in FSFW.h)
- configure_file(src/fsfw/FSFWVersion.h.in FSFWVersion.h)
-endif()
+configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h)
+configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h)
message(STATUS "Compiling FSFW for the ${FSFW_OS_NAME} operating system.")
diff --git a/README.md b/README.md
index c63db634..89a10f4b 100644
--- a/README.md
+++ b/README.md
@@ -107,6 +107,48 @@ 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
+`.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.
+
## Index
[1. High-level overview](docs/README-highlevel.md#top)
diff --git a/automation/Dockerfile b/automation/Dockerfile
index 93a4fe7d..9df67fc8 100644
--- a/automation/Dockerfile
+++ b/automation/Dockerfile
@@ -5,4 +5,4 @@ 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
+RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping
diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile
index ba3f5afb..3424f986 100644
--- a/automation/Jenkinsfile
+++ b/automation/Jenkinsfile
@@ -1,28 +1,17 @@
pipeline {
- agent any
environment {
BUILDDIR = 'build-tests'
}
+ agent {
+ docker { image 'fsfw-ci:d1'}
+ }
stages {
- stage('Create Docker') {
- agent {
- dockerfile {
- dir 'automation'
- additionalBuildArgs '--no-cache'
- reuseNode true
- }
- }
+ stage('Clean') {
steps {
sh 'rm -rf $BUILDDIR'
}
}
stage('Configure') {
- agent {
- dockerfile {
- dir 'automation'
- reuseNode true
- }
- }
steps {
dir(BUILDDIR) {
sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..'
@@ -30,12 +19,6 @@ pipeline {
}
}
stage('Build') {
- agent {
- dockerfile {
- dir 'automation'
- reuseNode true
- }
- }
steps {
dir(BUILDDIR) {
sh 'cmake --build . -j'
@@ -43,12 +26,6 @@ pipeline {
}
}
stage('Unittests') {
- agent {
- dockerfile {
- dir 'automation'
- reuseNode true
- }
- }
steps {
dir(BUILDDIR) {
sh 'cmake --build . -- fsfw-tests_coverage -j'
@@ -56,12 +33,6 @@ pipeline {
}
}
stage('Valgrind') {
- agent {
- dockerfile {
- dir 'automation'
- reuseNode true
- }
- }
steps {
dir(BUILDDIR) {
sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests'
diff --git a/docs/.gitignore b/docs/.gitignore
new file mode 100644
index 00000000..a485625d
--- /dev/null
+++ b/docs/.gitignore
@@ -0,0 +1 @@
+/_build
diff --git a/docs/devicehandlers.rst b/docs/devicehandlers.rst
index 58c2df78..0008edb3 100644
--- a/docs/devicehandlers.rst
+++ b/docs/devicehandlers.rst
@@ -1,3 +1,110 @@
+.. _dhb-prim-doc:
+
Device Handlers
==================
+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 certain interfaces:
+
+- 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: :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`
+ 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;
+ }
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
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
--------------------
diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt
index 7a9a0ffa..424a012d 100644
--- a/hal/CMakeLists.txt
+++ b/hal/CMakeLists.txt
@@ -3,7 +3,13 @@ cmake_minimum_required(VERSION 3.13)
# Can also be changed by upper CMakeLists.txt file
find_library(LIB_FSFW_NAME fsfw REQUIRED)
-option(FSFW_HAL_ADD_LINUX "Add the Linux HAL to the sources. Required gpiod library" OFF)
+option(FSFW_HAL_ADD_LINUX "Add the Linux HAL to the sources. Requires gpiod library" OFF)
+# On by default for now because I did not have an issue including and compiling those files
+# and libraries on a Desktop Linux system and the primary target of the FSFW is still embedded
+# Linux. The only exception from this is the gpiod library which requires a dedicated installation,
+# but CMake is able to determine whether this library is installed with find_library.
+option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add peripheral drivers for embedded Linux" ON)
+
option(FSFW_HAL_ADD_RASPBERRY_PI "Add Raspberry Pi specific code to the sources" OFF)
option(FSFW_HAL_ADD_STM32H7 "Add the STM32H7 HAL to the sources" OFF)
option(FSFW_HAL_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
diff --git a/hal/src/fsfw_hal/CMakeLists.txt b/hal/src/fsfw_hal/CMakeLists.txt
index f5901e91..b7559d4b 100644
--- a/hal/src/fsfw_hal/CMakeLists.txt
+++ b/hal/src/fsfw_hal/CMakeLists.txt
@@ -1,7 +1,7 @@
add_subdirectory(devicehandlers)
add_subdirectory(common)
-if(FSFW_HAL_ADD_LINUX)
+if(UNIX)
add_subdirectory(linux)
endif()
diff --git a/hal/src/fsfw_hal/common/gpio/GpioCookie.cpp b/hal/src/fsfw_hal/common/gpio/GpioCookie.cpp
index 7c56ebcf..4c4b4d14 100644
--- a/hal/src/fsfw_hal/common/gpio/GpioCookie.cpp
+++ b/hal/src/fsfw_hal/common/gpio/GpioCookie.cpp
@@ -1,50 +1,48 @@
#include "fsfw_hal/common/gpio/GpioCookie.h"
+
#include "fsfw/serviceinterface/ServiceInterface.h"
-GpioCookie::GpioCookie() {
-}
+GpioCookie::GpioCookie() {}
ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) {
- if (gpioConfig == nullptr) {
+ if (gpioConfig == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::warning << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl;
+ sif::warning << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl;
#else
- sif::printWarning("GpioCookie::addGpio: gpioConfig is nullpointer\n");
-#endif
- return HasReturnvaluesIF::RETURN_FAILED;
- }
- auto gpioMapIter = gpioMap.find(gpioId);
- if(gpioMapIter == gpioMap.end()) {
- auto statusPair = gpioMap.emplace(gpioId, gpioConfig);
- if (statusPair.second == false) {
-#if FSFW_VERBOSE_LEVEL >= 1
-#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::warning << "GpioCookie::addGpio: Failed to add GPIO " << gpioId <<
- " to GPIO map" << std::endl;
-#else
- sif::printWarning("GpioCookie::addGpio: Failed to add GPIO %d to GPIO map\n", gpioId);
-#endif
-#endif
- return HasReturnvaluesIF::RETURN_FAILED;
- }
- return HasReturnvaluesIF::RETURN_OK;
- }
-#if FSFW_VERBOSE_LEVEL >= 1
-#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::warning << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl;
-#else
- sif::printWarning("GpioCookie::addGpio: GPIO already exists in GPIO map\n");
-#endif
+ sif::printWarning("GpioCookie::addGpio: gpioConfig is nullpointer\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
+ }
+ auto gpioMapIter = gpioMap.find(gpioId);
+ if (gpioMapIter == gpioMap.end()) {
+ auto statusPair = gpioMap.emplace(gpioId, gpioConfig);
+ if (statusPair.second == false) {
+#if FSFW_VERBOSE_LEVEL >= 1
+#if FSFW_CPP_OSTREAM_ENABLED == 1
+ sif::warning << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << " to GPIO map"
+ << std::endl;
+#else
+ sif::printWarning("GpioCookie::addGpio: Failed to add GPIO %d to GPIO map\n", gpioId);
+#endif
+#endif
+ return HasReturnvaluesIF::RETURN_FAILED;
+ }
+ return HasReturnvaluesIF::RETURN_OK;
+ }
+#if FSFW_VERBOSE_LEVEL >= 1
+#if FSFW_CPP_OSTREAM_ENABLED == 1
+ sif::warning << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl;
+#else
+ sif::printWarning("GpioCookie::addGpio: GPIO already exists in GPIO map\n");
+#endif
+#endif
+ return HasReturnvaluesIF::RETURN_FAILED;
}
-GpioMap GpioCookie::getGpioMap() const {
- return gpioMap;
-}
+GpioMap GpioCookie::getGpioMap() const { return gpioMap; }
GpioCookie::~GpioCookie() {
- for(auto& config: gpioMap) {
- delete(config.second);
- }
+ for (auto& config : gpioMap) {
+ delete (config.second);
+ }
}
diff --git a/hal/src/fsfw_hal/common/gpio/GpioCookie.h b/hal/src/fsfw_hal/common/gpio/GpioCookie.h
index 0473fe0f..cf836eae 100644
--- a/hal/src/fsfw_hal/common/gpio/GpioCookie.h
+++ b/hal/src/fsfw_hal/common/gpio/GpioCookie.h
@@ -1,12 +1,12 @@
#ifndef COMMON_GPIO_GPIOCOOKIE_H_
#define COMMON_GPIO_GPIOCOOKIE_H_
-#include "GpioIF.h"
-#include "gpioDefinitions.h"
-
#include
#include
+#include "GpioIF.h"
+#include "gpioDefinitions.h"
+
/**
* @brief Cookie for the GpioIF. Allows the GpioIF to determine which
* GPIOs to initialize and whether they should be configured as in- or
@@ -17,25 +17,24 @@
*
* @author J. Meier
*/
-class GpioCookie: public CookieIF {
-public:
+class GpioCookie : public CookieIF {
+ public:
+ GpioCookie();
- GpioCookie();
+ virtual ~GpioCookie();
- virtual ~GpioCookie();
+ ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig);
- ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig);
+ /**
+ * @brief Get map with registered GPIOs.
+ */
+ GpioMap getGpioMap() const;
- /**
- * @brief Get map with registered GPIOs.
- */
- GpioMap getGpioMap() const;
-
-private:
- /**
- * Returns a copy of the internal GPIO map.
- */
- GpioMap gpioMap;
+ private:
+ /**
+ * Returns a copy of the internal GPIO map.
+ */
+ GpioMap gpioMap;
};
#endif /* COMMON_GPIO_GPIOCOOKIE_H_ */
diff --git a/hal/src/fsfw_hal/common/gpio/GpioIF.h b/hal/src/fsfw_hal/common/gpio/GpioIF.h
index af73f94c..5cca1481 100644
--- a/hal/src/fsfw_hal/common/gpio/GpioIF.h
+++ b/hal/src/fsfw_hal/common/gpio/GpioIF.h
@@ -1,9 +1,10 @@
#ifndef COMMON_GPIO_GPIOIF_H_
#define COMMON_GPIO_GPIOIF_H_
-#include "gpioDefinitions.h"
-#include
#include
+#include
+
+#include "gpioDefinitions.h"
class GpioCookie;
@@ -13,42 +14,41 @@ class GpioCookie;
* @author J. Meier
*/
class GpioIF : public HasReturnvaluesIF {
-public:
+ public:
+ virtual ~GpioIF(){};
- virtual ~GpioIF() {};
+ /**
+ * @brief Called by the GPIO using object.
+ * @param cookie Cookie specifying informations of the GPIOs required
+ * by a object.
+ */
+ virtual ReturnValue_t addGpios(GpioCookie* cookie) = 0;
- /**
- * @brief Called by the GPIO using object.
- * @param cookie Cookie specifying informations of the GPIOs required
- * by a object.
- */
- virtual ReturnValue_t addGpios(GpioCookie* cookie) = 0;
+ /**
+ * @brief By implementing this function a child must provide the
+ * functionality to pull a certain GPIO to high logic level.
+ *
+ * @param gpioId A unique number which specifies the GPIO to drive.
+ * @return Returns RETURN_OK for success. This should never return RETURN_FAILED.
+ */
+ virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0;
- /**
- * @brief By implementing this function a child must provide the
- * functionality to pull a certain GPIO to high logic level.
- *
- * @param gpioId A unique number which specifies the GPIO to drive.
- * @return Returns RETURN_OK for success. This should never return RETURN_FAILED.
- */
- virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0;
+ /**
+ * @brief By implementing this function a child must provide the
+ * functionality to pull a certain GPIO to low logic level.
+ *
+ * @param gpioId A unique number which specifies the GPIO to drive.
+ */
+ virtual ReturnValue_t pullLow(gpioId_t gpioId) = 0;
- /**
- * @brief By implementing this function a child must provide the
- * functionality to pull a certain GPIO to low logic level.
- *
- * @param gpioId A unique number which specifies the GPIO to drive.
- */
- virtual ReturnValue_t pullLow(gpioId_t gpioId) = 0;
-
- /**
- * @brief This function requires a child to implement the functionality to read the state of
- * an ouput or input gpio.
- *
- * @param gpioId A unique number which specifies the GPIO to read.
- * @param gpioState State of GPIO will be written to this pointer.
- */
- virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0;
+ /**
+ * @brief This function requires a child to implement the functionality to read the state of
+ * an ouput or input gpio.
+ *
+ * @param gpioId A unique number which specifies the GPIO to read.
+ * @param gpioState State of GPIO will be written to this pointer.
+ */
+ virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0;
};
#endif /* COMMON_GPIO_GPIOIF_H_ */
diff --git a/hal/src/fsfw_hal/common/gpio/gpioDefinitions.h b/hal/src/fsfw_hal/common/gpio/gpioDefinitions.h
index c6f21195..b429449b 100644
--- a/hal/src/fsfw_hal/common/gpio/gpioDefinitions.h
+++ b/hal/src/fsfw_hal/common/gpio/gpioDefinitions.h
@@ -1,44 +1,34 @@
#ifndef COMMON_GPIO_GPIODEFINITIONS_H_
#define COMMON_GPIO_GPIODEFINITIONS_H_
+#include