diff --git a/.run/fsfw-tests_coverage.run.xml b/.run/fsfw-tests_coverage.run.xml
deleted file mode 100644
index 49d9b135..00000000
--- a/.run/fsfw-tests_coverage.run.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.run/fsfw.run.xml b/.run/fsfw.run.xml
deleted file mode 100644
index 72f74939..00000000
--- a/.run/fsfw.run.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9ba6d754..693e59e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,232 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
# [unreleased]
-# [v5.0.0]
+## Fixes
+
+- PUS Health Service: Size check for set health command.
+ Perform operation completion for announce health command.
+ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/746
+- Linux OSAL `getUptime` fix: Check validity of `/proc/uptime` file before reading uptime.
+ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/745
+- Small tweak for version getter
+ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/744
+
+## Added
+
+- add CFDP subsystem ID
+ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/742
+
+## Changed
+- Bump ETL version to 20.35.14
+ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/748
+- Renamed `PCDU_2` subsystem ID to `POWER_SWITCH_IF`.
+ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/743
+- Add new `PowerSwitchIF::SWITCH_UNKNOWN` returnvalue.
+ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/743
+- Assert that `FixedArrayList` is larger than 0 at compile time.
+ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/740
+
+# [v6.0.0] 2023-02-10
+
+## Fixes
+
+- Mode Service: Add allowed subservice
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/739
+- `CService200ModeManagement`: Various bugfixes which lead to now execution complete being generated
+ on mode announcements, duplicate mode reply generated on announce commands, and the mode read
+ subservice not working properly.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/736
+- Memory leak fixes for the TCP/IP TMTC bridge.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/737
+- `Service9TimeManagement`: Fix the time dump at the `SET_TIME` subservice: Include clock timeval
+ seconds instead of uptime.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/726
+- HAL MGM3100 Handler: Use axis specific gain/scaling factors. Previously,
+ only the X scaling factor was used.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/724
+- HAL MGM3100 Handler: Z value was previously calculated with bytes of the X value.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/733
+- DHB `setNormalDatapoolEntriesInvalid`: The default implementation did not set the validity
+ to false correctly because the `read` and `write` calls were missing.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/728
+- PUS TMTC creator module: Sequence flags were set to continuation segment (0b00) instead
+ of the correct unsegmented flags (0b11) as specified in the standard.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/727
+- TC Scheduler Service 11: Add size and CRC check for contained TC.
+ Bug: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/issues/719
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/720
+- Only delete health table entry in `HealthHelper` destructor if
+ health table was set.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/710
+- I2C Bugfixes: Do not keep iterator as member and fix some incorrect handling with the iterator.
+ Also properly reset the reply size for successfull transfers and erroneous transfers.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/700
+- Bugfix for Serial Buffer Stream: Setting `doActive` to false now
+ actually fully disables printing.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/680
+- `TcpTmTcServer.cpp`: The server was actually not able to handle
+ CCSDS packets which were clumped together. This has been fixed now.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/673
+- `CServiceHealthCommanding`: Add announce all health info implementation
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/725
+- various fixes related to linux Unittests and memory leaks
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/715
+- small fix to allow teardown handling
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/713
+- fix compiler warning for fixed array list copy ctor
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/704
+- missing include
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/703
+- defaultconfig did not build anymore
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/702
+- hotfix
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/699
+- small fix for helper
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/698
+- missing retval conv
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/697
+- DHB Countdown Bug
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/693
+- doc corrections
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/687
+- better error printout
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/686
+- include correction
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/683
+- better warning for missing include paths
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/676
+- Service 11 regression
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/670
+
+## Added
+
+- Empty constructor for `CdsShortTimeStamper` which does not do an object manager registration.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/730
+- `Service9TimeManagement`: Add `DUMP_TIME` (129) subservice.
+- `TcpTmTcServer`: Allow setting the `SO_REUSEADDR` and `SO_REUSEPORT`
+ option on the TCP server. CTOR prototype has changed and expects an explicit
+ TCP configuration struct to be passed.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/722
+- `DleParser` helper class to parse DLE encoded packets from a byte stream.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/711
+- `UioMapper` is able to resolve symlinks now.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/709
+- Add new `UnsignedByteField` class
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/660
+- publish documentation for development and master branch
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/681
+- Add Linux HAL options
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/663
+- Expand SerializeIF
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/656
+- PUS Service 11: Additional Safety Check
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/666
+- improvements for auto-formatter script
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/665
+- provide a weak print char impl
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/674
+
+## Removed
+
+- now that doc server is up, remove markdown files
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/688
+- remove bsp specific code
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/679
+
+## Changes
+
+- `CService201HealthCommanding` renamed to `CServiceHealthCommanding`,
+ service ID customizable now. `CServiceHealthCommanding` expects configuration struct
+ `HealthServiceCfg` now
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/725
+- `AcceptsTelemetryIF`: `getReportReceptionQueue` is const now
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/712
+- Moved some container returnvalues to dedicated header and namespace
+ so they can be used without template specification.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/707
+- Remove default secondary header argument for
+ `uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag)` and
+ `uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag)`
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/689
+- Removed `HasReturnvaluesIF` class in favor of `returnvalue` namespace with `OK` and `FAILED`
+ constants.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/659
+- Overhaul of the TMTC stack, including various changes and improvements
+ for other modules
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/655
+ which also includes a migration guide
+- Bump Catch2 dependency to regular version `v3.1.0`
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/678
+- `SerialBufferAdapter`: Rename `setBuffer` to `setConstBuffer` and update
+ API to expect `const uint8_t*` accordingly.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/677
+- Remove the following user includes from `fsfw/events/Event.h` and
+ `fsfw/returnvalues/returnvalue.h`:
+ - `#include "events/subsystemIdRanges.h"`
+ - `#include "returnvalues/classIds.h"`
+ The user has to include those themselves now
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/675
+- `DeviceHandlerBase`: Set command sender before calling `buildCommandFromCommand`.
+ This allows finishing action commands immediately inside the function.
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/672
+- `DeviceHandlerBase`: New signature of `handleDeviceTm` which expects
+ a `const SerializeIF&` and additional helper variant which expects `const uint8_t*`
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/671
+- Improvements for `AcceptsTelemetryIF` and `AcceptsTelecommandsIF`:
+ - Make functions `const` where it makes sense
+ - Add `const char* getName const` abstract function
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/684
+- Generic TMTC Bridge Update
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/734
+- comment tweak to event parser can read everything
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/732
+- CMakeLists file updates
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/731
+- improve srv20 error messages
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/723
+- I2C Linux: remove duplicate printout
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/718
+- printout handling improvements
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/717
+- vec getter, reset for content
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/716
+- updates for source sequence counter
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/714
+- SP reader getPacketData is const now
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/708
+- refactoring of serial drivers for linux
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/705
+- Local Pool Update Remove Add Data Ignore Fault Argument
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/701
+- Switch to new documentation server
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/694
+- Windows Tweaks
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/691
+- Refactor Local Pool API
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/667
+- group MGM data in local pool vectors
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/664
+
+
+## CFDP
+
+- Refactoring of CFDP stack which was done during implementation of the CFDP source and destination
+ handlers.
+ - New filesystem module, changes for filesystem abstraction `HasFileSystemIF` to better
+ fit requirements of CFDP
+ - New `HostFilesystem` implementation of the `HasFileSystemIF`
+ - New `cfdp::UserBase` class which is the abstraction for the CFDP user in an OBSW context.
+ - mib module for the CFDP stack
+ - PDU classes renamed from `...Serializer`/`...Deserializer` to `...Creator`/`...Reader`
+ respetively
+ - Renamed `TcDistributor` to `TcDistributorBase` to prevent confusion
+ - Refactored `TcDisitributorBase` to be more flexible and usable for CFDP distribution
+ - Renamed `CCSDSDistributor` to `CcsdsDistributor` and add feature which allows it
+ to remove the CCSDS header when routing a packet. This allows CCSDS agnostic receiver
+ implementation without an extra component
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/682
+
+# [v5.0.0] 2022-07-25
## Changes
@@ -19,16 +244,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Bump C++ required version to C++17. Every project which uses the FSFW and every modern
compiler supports it
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/622
-- HAL Linux SPI: Set the Clock Default State when setting new SPI speed
- and mode
- PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/573
-- GPIO HAL: `Direction`, `GpioOperation` and `Levels` are enum classes now, which prevents
- name clashes with Windows defines.
- PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572
- New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572
- HAL Devicehandlers: Periodic printout is run-time configurable now
- `oneShotAction` flag in the `TestTask` class is not static anymore
+- `SimpleRingBuffer::writeData` now checks if the amount is larger than the total size of the
+ Buffer and rejects such writeData calls with `returnvalue::FAILED`
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/586
- Major update for version handling, using `git describe` to fetch version information with git.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/601
- Add helper functions provided by [`cmake-modules`](https://github.com/bilke/cmake-modules)
@@ -46,6 +268,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
creation call. It allows passing context information and an arbitrary user argument into
the message queue. Also streamlined and simplified `MessageQueue` implementation for all OSALs
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/583
+- Internal API change: Moved the `fsfw_hal` to the `src` folder and integration and internal
+ tests part of `fsfw_tests` to `src`. Unittests are now in a dedicated folder called `unittests`
+ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/653
### Task Module Refactoring
@@ -120,6 +345,8 @@ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/593
## Additions
+- New constructor for PoolEntry which allows to simply specify the length of the pool entry.
+ This is also the new default constructor for scalar value with 0 as an initial value
- Added options for CI/CD builds: `FSFW_CICD_BUILD`. This allows the source code to know
whether it is running in CI/CD
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/623
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d8163f3e..5d35e6ff 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@ list(APPEND CMAKE_MODULE_PATH
# Version file handling #
# ##############################################################################
-set(FSFW_VERSION_IF_GIT_FAILS 4)
+set(FSFW_VERSION_IF_GIT_FAILS 6)
set(FSFW_SUBVERSION_IF_GIT_FAILS 0)
set(FSFW_REVISION_IF_GIT_FAILS 0)
@@ -67,11 +67,12 @@ endif()
set(FSFW_SOURCES_DIR "${CMAKE_SOURCE_DIR}/src/fsfw")
set(FSFW_ETL_LIB_NAME etl)
+set(FSFW_ETL_LINK_TARGET etl::etl)
set(FSFW_ETL_LIB_MAJOR_VERSION
20
CACHE STRING "ETL library major version requirement")
set(FSFW_ETL_LIB_VERSION
- ${FSFW_ETL_LIB_MAJOR_VERSION}.28.0
+ ${FSFW_ETL_LIB_MAJOR_VERSION}.35.14
CACHE STRING "ETL library exact version requirement")
set(FSFW_ETL_LINK_TARGET etl::etl)
@@ -79,7 +80,7 @@ set(FSFW_CATCH2_LIB_MAJOR_VERSION
3
CACHE STRING "Catch2 library major version requirement")
set(FSFW_CATCH2_LIB_VERSION
- v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5
+ v${FSFW_CATCH2_LIB_MAJOR_VERSION}.1.0
CACHE STRING "Catch2 library exact version requirement")
# Keep this off by default for now. See PR:
@@ -103,20 +104,27 @@ if(FSFW_GENERATE_SECTIONS)
option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON)
endif()
-option(FSFW_BUILD_UNITTESTS
- "Build unittest binary in addition to static library" OFF)
+option(FSFW_BUILD_TESTS
+ "Build unittest binary in addition to static library. Requires Catch2"
+ OFF)
option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF)
option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF)
-if(FSFW_BUILD_UNITTESTS)
+if(FSFW_BUILD_TESTS)
option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON)
endif()
option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
# Options to exclude parts of the FSFW from compilation.
option(FSFW_ADD_INTERNAL_TESTS "Add internal unit tests" ON)
-option(FSFW_ADD_UNITTESTS "Add regular unittests. Requires Catch2" OFF)
option(FSFW_ADD_HAL "Add Hardware Abstraction Layer" ON)
+if(UNIX)
+ option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add Linux peripheral drivers"
+ OFF)
+ option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Attempt to add Linux GPIOD drivers" OFF)
+ option(FSFW_HAL_LINUX_ADD_SERIAL_DRIVERS "Add serial drivers" ON)
+endif()
+
# Optional sources
option(FSFW_ADD_PUS "Compile with PUS sources" ON)
option(FSFW_ADD_MONITORING "Compile with monitoring components" ON)
@@ -139,18 +147,18 @@ if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
TRUE)
endif()
-if(FSFW_BUILD_UNITTESTS)
+if(FSFW_BUILD_TESTS)
message(
STATUS
"${MSG_PREFIX} Building the FSFW unittests in addition to the static library"
)
# Check whether the user has already installed Catch2 first
- find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION})
+ find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION} QUIET)
# Not installed, so use FetchContent to download and provide Catch2
if(NOT Catch2_FOUND)
message(
STATUS
- "${MSG_PREFIX} Catch2 installation not found. Downloading Catch2 library with FetchContent"
+ "${MSG_PREFIX} Catch2 installation not found. Downloading Catch2 library with FetchContent."
)
include(FetchContent)
@@ -162,10 +170,9 @@ if(FSFW_BUILD_UNITTESTS)
list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2)
endif()
- set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg)
- configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h)
- configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in
- tests/TestsConfig.h)
+ set(FSFW_CONFIG_PATH unittests/testcfg)
+ configure_file(unittests/testcfg/FSFWConfig.h.in FSFWConfig.h)
+ configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h)
project(${FSFW_TEST_TGT} CXX C)
add_executable(${FSFW_TEST_TGT})
@@ -183,7 +190,10 @@ if(FSFW_BUILD_UNITTESTS)
endif()
endif()
-message(STATUS "${MSG_PREFIX} Finding and/or providing ETL library")
+message(
+ STATUS
+ "${MSG_PREFIX} Finding and/or providing etl library with version ${FSFW_ETL_LIB_MAJOR_VERSION}"
+)
# Check whether the user has already installed ETL first
find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET)
@@ -191,8 +201,8 @@ find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET)
if(NOT ${FSFW_ETL_LIB_NAME}_FOUND)
message(
STATUS
- "No ETL installation was found with find_package. Installing and providing "
- "etl with FindPackage")
+ "${MSG_PREFIX} ETL installation not found. Downloading ETL with FetchContent."
+ )
include(FetchContent)
FetchContent_Declare(
@@ -281,16 +291,15 @@ message(
)
add_subdirectory(src)
-add_subdirectory(tests)
-if(FSFW_ADD_HAL)
- add_subdirectory(hal)
-endif()
add_subdirectory(contrib)
+if(FSFW_BUILD_TESTS)
+ add_subdirectory(unittests)
+endif()
if(FSFW_BUILD_DOCS)
add_subdirectory(docs)
endif()
-if(FSFW_BUILD_UNITTESTS)
+if(FSFW_BUILD_TESTS)
if(FSFW_TESTS_GEN_COV)
if(CMAKE_COMPILER_IS_GNUCXX)
include(CodeCoverage)
@@ -318,7 +327,8 @@ if(FSFW_BUILD_UNITTESTS)
"/usr/local/include/*"
"*/fsfw_tests/*"
"*/catch2-src/*"
- "*/fsfw_hal/*")
+ "*/fsfw_hal/*"
+ "unittests/*")
endif()
target_link_options(${FSFW_TEST_TGT} PRIVATE -fprofile-arcs
@@ -336,8 +346,15 @@ if(FSFW_BUILD_UNITTESTS)
DEPENDENCIES ${FSFW_TEST_TGT})
else()
setup_target_for_coverage_lcov(
- NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT}
- DEPENDENCIES ${FSFW_TEST_TGT})
+ NAME
+ ${FSFW_TEST_TGT}_coverage
+ EXECUTABLE
+ ${FSFW_TEST_TGT}
+ DEPENDENCIES
+ ${FSFW_TEST_TGT}
+ GENHTML_ARGS
+ --html-epilog
+ ${CMAKE_SOURCE_DIR}/unittests/lcov_epilog.html)
endif()
endif()
endif()
@@ -352,7 +369,8 @@ if(NOT FSFW_CONFIG_PATH)
if(NOT FSFW_BUILD_DOCS)
message(
WARNING
- "${MSG_PREFIX} Flight Software Framework configuration path not set")
+ "${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set"
+ )
message(
WARNING
"${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..")
@@ -447,8 +465,8 @@ target_include_directories(
target_compile_options(${LIB_FSFW_NAME} PRIVATE ${FSFW_WARNING_FLAGS}
${COMPILER_FLAGS})
-target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ETL_LINK_TARGET}
- ${FSFW_ADDITIONAL_LINK_LIBS})
+target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ADDITIONAL_LINK_LIBS})
+target_link_libraries(${LIB_FSFW_NAME} PUBLIC ${FSFW_ETL_LINK_TARGET})
string(
CONCAT
diff --git a/README.md b/README.md
index 8d611c57..7094e5dc 100644
--- a/README.md
+++ b/README.md
@@ -132,14 +132,14 @@ You can use the following commands inside the `fsfw` folder to set up the build
```sh
mkdir build-tests && cd build-tests
-cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug ..
+cmake -DFSFW_BUILD_TESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug ..
```
You can also use `-DFSFW_OSAL=linux` on Linux systems.
Coverage data in HTML format can be generated using the `CodeCoverage`
[CMake module](https://github.com/bilke/cmake-modules/tree/master).
-To build the unittests, run them and then generare the coverage data in this format,
+To build the unittests, run them and then generate the coverage data in this format,
the following command can be used inside the build directory after the build system was set up
```sh
@@ -175,7 +175,7 @@ cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..
Then you can generate the documentation using
```sh
-cmake --build . -j
+cmake --build . -- Sphinx -j
```
You can find the generated documentation inside the `docs/sphinx` folder inside the build
@@ -188,7 +188,10 @@ and open the documentation conveniently. Try `helper.py -h for more information.
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.
+can run the `auto-format.sh` helper script to format all source files consistently. Furthermore cmake-format is required to format CMake files which can be installed with:
+````sh
+sudo pip install cmakelang
+````
## Index
diff --git a/automation/Dockerfile b/automation/Dockerfile
index 0eb98fbb..1bd39b3f 100644
--- a/automation/Dockerfile
+++ b/automation/Dockerfile
@@ -5,10 +5,25 @@ 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 apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping python3 pip doxygen graphviz rsync
+
+RUN python3 -m pip install sphinx breathe
RUN git clone https://github.com/catchorg/Catch2.git && \
- cd Catch2 && \
- git checkout v3.0.0-preview5 && \
- cmake -Bbuild -H. -DBUILD_TESTING=OFF && \
- cmake --build build/ --target install
+ cd Catch2 && \
+ git checkout v3.1.0 && \
+ cmake -Bbuild -H. -DBUILD_TESTING=OFF && \
+ cmake --build build/ --target install
+
+RUN git clone https://github.com/ETLCPP/etl.git && \
+ cd etl && \
+ git checkout 20.28.0 && \
+ cmake -B build . && \
+ cmake --install build/
+
+#ssh needs a valid user to work
+RUN adduser --uid 114 jenkins
+
+#add documentation server to known hosts
+RUN echo "|1|/LzCV4BuTmTb2wKnD146l9fTKgQ=|NJJtVjvWbtRt8OYqFgcYRnMQyVw= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNL8ssTonYtgiR/6RRlSIK9WU1ywOcJmxFTLcEblAwH7oifZzmYq3XRfwXrgfMpylEfMFYfCU8JRqtmi19xc21A=" >> /etc/ssh/ssh_known_hosts
+RUN echo "|1|CcBvBc3EG03G+XM5rqRHs6gK/Gg=|oGeJQ+1I8NGI2THIkJsW92DpTzs= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNL8ssTonYtgiR/6RRlSIK9WU1ywOcJmxFTLcEblAwH7oifZzmYq3XRfwXrgfMpylEfMFYfCU8JRqtmi19xc21A=" >> /etc/ssh/ssh_known_hosts
\ No newline at end of file
diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile
index 798b6b1a..64c32237 100644
--- a/automation/Jenkinsfile
+++ b/automation/Jenkinsfile
@@ -1,41 +1,125 @@
pipeline {
environment {
- BUILDDIR = 'build-tests'
+ BUILDDIR_HOST = 'cmake-build-tests-host'
+ BUILDDIR_LINUX = 'cmake-build-tests-linux'
+ DOCDDIR = 'cmake-build-documentation'
}
agent {
- docker { image 'fsfw-ci:d2'}
+ docker {
+ image 'fsfw-ci:d6'
+ args '--network host --sysctl fs.mqueue.msg_max=100'
+ }
}
stages {
- stage('Clean') {
- steps {
- sh 'rm -rf $BUILDDIR'
- }
- }
- stage('Configure') {
- steps {
- dir(BUILDDIR) {
- sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON -DFSFW_CICD_BUILD=ON ..'
+ stage('Host') {
+ stages{
+ stage('Clean') {
+ steps {
+ sh 'rm -rf $BUILDDIR_HOST'
+ }
+ }
+ stage('Configure') {
+ steps {
+ dir(BUILDDIR_HOST) {
+ sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..'
+ }
+ }
+ }
+ stage('Build') {
+ steps {
+ dir(BUILDDIR_HOST) {
+ sh 'cmake --build . -j4'
+ }
+ }
+ }
+ stage('Unittests') {
+ steps {
+ dir(BUILDDIR_HOST) {
+ sh 'cmake --build . -- fsfw-tests_coverage -j4'
+ }
+ }
+ }
+ stage('Valgrind') {
+ steps {
+ dir(BUILDDIR_HOST) {
+ sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests'
+ }
+ }
}
}
}
- stage('Build') {
- steps {
- dir(BUILDDIR) {
- sh 'cmake --build . -j4'
+ stage('Linux') {
+ stages{
+ stage('Clean') {
+ steps {
+ sh 'rm -rf $BUILDDIR_LINUX'
+ }
+ }
+ stage('Configure') {
+ steps {
+ dir(BUILDDIR_LINUX) {
+ sh 'cmake -DFSFW_OSAL=linux -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..'
+ }
+ }
+ }
+ stage('Build') {
+ steps {
+ dir(BUILDDIR_LINUX) {
+ sh 'cmake --build . -j4'
+ }
+ }
+ }
+ stage('Unittests') {
+ steps {
+ dir(BUILDDIR_LINUX) {
+ sh 'cmake --build . -- fsfw-tests_coverage -j4'
+ }
+ }
+ }
+ stage('Valgrind') {
+ steps {
+ dir(BUILDDIR_LINUX) {
+ sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests'
+ }
+ }
}
}
}
- stage('Unittests') {
+ stage('Documentation') {
+ when {
+ branch 'development'
+ }
steps {
+ dir(DOCDDIR) {
+ sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..'
+ sh 'make Sphinx'
+ sshagent(credentials: ['documentation-buildfix']) {
+ sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/development'
+ }
+ }
dir(BUILDDIR) {
- sh 'cmake --build . -- fsfw-tests_coverage -j4'
+ sshagent(credentials: ['documentation-buildfix']) {
+ sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/development'
+ }
}
}
}
- stage('Valgrind') {
+ stage('Master Documentation') {
+ when {
+ branch 'master'
+ }
steps {
+ dir(DOCDDIR) {
+ sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..'
+ sh 'make Sphinx'
+ sshagent(credentials: ['documentation-buildfix']) {
+ sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/master'
+ }
+ }
dir(BUILDDIR) {
- sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests'
+ sshagent(credentials: ['documentation-buildfix']) {
+ sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/master'
+ }
}
}
}
diff --git a/cmake/cmake-modules/bilke/CodeCoverage.cmake b/cmake/cmake-modules/bilke/CodeCoverage.cmake
index aef3d943..c8b9e4ae 100644
--- a/cmake/cmake-modules/bilke/CodeCoverage.cmake
+++ b/cmake/cmake-modules/bilke/CodeCoverage.cmake
@@ -140,7 +140,7 @@ find_program( GCOV_PATH gcov )
find_program( LCOV_PATH NAMES lcov lcov.bat lcov.exe lcov.perl)
find_program( FASTCOV_PATH NAMES fastcov fastcov.py )
find_program( GENHTML_PATH NAMES genhtml genhtml.perl genhtml.bat )
-find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test)
+find_program( GCOVR_PATH gcovr )
find_program( CPPFILT_PATH NAMES c++filt )
if(NOT GCOV_PATH)
diff --git a/docs/README-config.md b/docs/README-config.md
deleted file mode 100644
index d71feb97..00000000
--- a/docs/README-config.md
+++ /dev/null
@@ -1,40 +0,0 @@
-Configuring the FSFW
-======
-
-The FSFW can be configured via the `fsfwconfig` folder. A template folder has
-been provided to have a starting point for this. The folder should be added
-to the include path. The primary configuration file is the `FSFWConfig.h` folder. Some
-of the available options will be explained in more detail here.
-
-# Auto-Translation of Events
-
-The FSFW allows the automatic translation of events, which allows developers to track triggered
-events directly via console output. Using this feature requires:
-
-1. `FSFW_OBJ_EVENT_TRANSLATION` set to 1 in the configuration file.
-2. Special auto-generated translation files which translate event IDs and object IDs into
- human readable strings. These files can be generated using the
- [modgen Python scripts](https://git.ksat-stuttgart.de/source/modgen.git).
-3. The generated translation files for the object IDs should be named `translatesObjects.cpp`
- and `translateObjects.h` and should be copied to the `fsfwconfig/objects` folder
-4. The generated translation files for the event IDs should be named `translateEvents.cpp` and
- `translateEvents.h` and should be copied to the `fsfwconfig/events` folder
-
-An example implementations of these translation file generators can be found as part
-of the [SOURCE project here](https://git.ksat-stuttgart.de/source/sourceobsw/-/tree/development/generators)
-or the [FSFW example](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example_public/src/branch/master/generators)
-
-## Configuring the Event Manager
-
-The number of allowed subscriptions can be modified with the following
-parameters:
-
-``` c++
-namespace fsfwconfig {
-//! Configure the allocated pool sizes for the event manager.
-static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
-static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120;
-static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
-}
-```
-
diff --git a/docs/README-controllers.md b/docs/README-controllers.md
deleted file mode 100644
index 7af0652d..00000000
--- a/docs/README-controllers.md
+++ /dev/null
@@ -1 +0,0 @@
-## Controllers
diff --git a/docs/README-core.md b/docs/README-core.md
deleted file mode 100644
index e34890ae..00000000
--- a/docs/README-core.md
+++ /dev/null
@@ -1,55 +0,0 @@
-## FSFW Core Modules
-
-These core modules provide the most important functionalities of the
-Flight Software Framework
-
-### Clock
-
- * This is a class of static functions that can be used at anytime
- * Leap Seconds must be set if any time conversions from UTC to other times is used
-
-### ObjectManager
-
-* Must be created during program startup
-* The component which handles all references. All SystemObjects register at this component.
-* Any SystemObject needs to have a unique ObjectId. Those can be managed like objects::framework_objects.
-* A reference to an object can be get by calling the following function. T must be the specific Interface you want to call.
-A nullptr check of the returning Pointer must be done. This function is based on Run-time type information.
-
-```cpp
-template T* ObjectManagerIF::get( object_id_t id )
-```
-* A typical way to create all objects on startup is a handing a static produce function to the
- ObjectManager on creation. By calling objectManager->initialize() the produce function will be
- called and all SystemObjects will be initialized afterwards.
-
-### Event Manager
-
-* Component which allows routing of events
-* Other objects can subscribe to specific events, ranges of events or all events of an object.
-* Subscriptions can be done during runtime but should be done during initialization
-* Amounts of allowed subscriptions can be configured in `FSFWConfig.h`
-
-### Health Table
-
-* A component which holds every health state
-* Provides a thread safe way to access all health states without the need of message exchanges
-
-### Stores
-
-* The message based communication can only exchange a few bytes of information inside the message
- itself. Therefore, additional information can be exchanged with Stores. With this, only the
- store address must be exchanged in the message.
-* Internally, the FSFW uses an IPC Store to exchange data between processes. For incoming TCs a TC
- Store is used. For outgoing TM a TM store is used.
-* All of them should use the Thread Safe Class storagemanager/PoolManager
-
-### Tasks
-
-There are two different types of tasks:
- * The PeriodicTask just executes objects that are of type ExecutableObjectIF in the order of the
- insertion to the Tasks.
- * FixedTimeslotTask executes a list of calls in the order of the given list. This is intended for
- DeviceHandlers, where polling should be in a defined order. An example can be found in
- `defaultcfg/fsfwconfig/pollingSequence` folder
-
diff --git a/docs/README-devicehandlers.md b/docs/README-devicehandlers.md
deleted file mode 100644
index 8b6551aa..00000000
--- a/docs/README-devicehandlers.md
+++ /dev/null
@@ -1 +0,0 @@
-## Device Handlers
diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md
deleted file mode 100644
index 262138a7..00000000
--- a/docs/README-highlevel.md
+++ /dev/null
@@ -1,135 +0,0 @@
-High-level overview
-======
-
-# Structure
-
-The general structure is driven by the usage of interfaces provided by objects.
-The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be
-widely available, even with older compilers.
-The FSFW uses dynamic allocation during the initialization but provides static containers during runtime.
-This simplifies the instantiation of objects and allows the usage of some standard containers.
-Dynamic Allocation after initialization is discouraged and different solutions are provided in the
-FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed.
-
-# Failure Handling
-
-Functions should return a defined `ReturnValue_t` to signal to the caller that something has
-gone wrong. Returnvalues must be unique. For this the function `HasReturnvaluesIF::makeReturnCode`
-or the macro `MAKE_RETURN` can be used. The `CLASS_ID` is a unique id for that type of object.
-See `returnvalues/FwClassIds` folder. The user can add custom `CLASS_ID`s via the
-`fsfwconfig` folder.
-
-# OSAL
-
-The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS.
-The OSAL provides periodic tasks, message queues, clocks and semaphores as well as mutexes.
-The [OSAL README](doc/README-osal.md#top) provides more detailed information on provided components
-and how to use them.
-
-# Core Components
-
-The FSFW has following core components. More detailed informations can be found in the
-[core component section](doc/README-core.md#top):
-
-1. Tasks: Abstraction for different (periodic) task types like periodic tasks or tasks
- with fixed timeslots
-2. ObjectManager: This module stores all `SystemObjects` by mapping a provided unique object ID
- to the object handles.
-3. Static Stores: Different stores are provided to store data of variable size (like telecommands
- or small telemetry) in a pool structure without using dynamic memory allocation.
- These pools are allocated up front.
-3. Clock: This module provided common time related functions
-4. EventManager: This module allows routing of events generated by `SystemObjects`
-5. HealthTable: A component which stores the health states of objects
-
-# Static IDs in the framework
-
-Some parts of the framework use a static routing address for communication.
-An example setup of ids can be found in the example config in `defaultcft/fsfwconfig/objects`
- inside the function `Factory::setStaticFrameworkObjectIds()`.
-
-# Events
-
-Events are tied to objects. EventIds can be generated by calling the Macro MAKE_EVENT.
-This works analog to the returnvalues. Every object that needs own EventIds has to get a
-unique SUBSYSTEM_ID. Every SystemObject can call triggerEvent from the parent class.
-Therefore, event messages contain the specific EventId and the objectId of the object that
-has triggered.
-
-# Internal Communication
-
-Components communicate mostly via Messages through Queues.
-Those queues are created by calling the singleton `QueueFactory::instance()->create()` which
-will create `MessageQueue` instances for the used OSAL.
-
-# External Communication
-
-The external communication with the mission control system is mostly up to the user implementation.
-The FSFW provides PUS Services which can be used to but don't need to be used.
-The services can be seen as a conversion from a TC to a message based communication and back.
-
-## TMTC Communication
-
-The FSFW provides some components to facilitate TMTC handling via the PUS commands.
-For example, a UDP or TCP PUS server socket can be opened on a specific port using the
-files located in `osal/common`. The FSFW example uses this functionality to allow sending telecommands
-and receiving telemetry using the [TMTC commander application](https://github.com/spacefisch/tmtccmd).
-Simple commands like the PUS Service 17 ping service can be tested by simply running the
-`tmtc_client_cli.py` or `tmtc_client_gui.py` utility in
-the [example tmtc folder](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example_public/src/branch/master/tmtc)
-while the `fsfw_example` application is running.
-
-More generally, any class responsible for handling incoming telecommands and sending telemetry
-can implement the generic `TmTcBridge` class located in `tmtcservices`. Many applications
-also use a dedicated polling task for reading telecommands which passes telecommands
-to the `TmTcBridge` implementation.
-
-## CCSDS Frames, CCSDS Space Packets and PUS
-
-If the communication is based on CCSDS Frames and Space Packets, several classes can be used to
-distributed the packets to the corresponding services. Those can be found in `tcdistribution`.
-If Space Packets are used, a timestamper has to be provided by the user.
-An example can be found in the `timemanager` folder, which uses `CCSDSTime::CDS_short`.
-
-# Device Handlers
-
-DeviceHandlers are another important component of the FSFW.
-The idea is, to have a software counterpart of every physical device to provide a simple mode,
-health and commanding interface. By separating the underlying Communication Interface with
-`DeviceCommunicationIF`, a device handler (DH) can be tested on different hardware.
-The DH has mechanisms to monitor the communication with the physical device which allow
-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).
-
-# Modes and Health
-
-The two interfaces `HasModesIF` and `HasHealthIF` provide access for commanding and monitoring
-of components. On-board Mode Management is implement in hierarchy system.
-DeviceHandlers and Controllers are the lowest part of the hierarchy.
-The next layer are Assemblies. Those assemblies act as a component which handle
-redundancies of handlers. Assemblies share a common core with the next level which
-are the Subsystems.
-
-Those Assemblies are intended to act as auto-generated components from a database which describes
-the subsystem modes. The definitions contain transition and target tables which contain the DH,
-Assembly and Controller Modes to be commanded.
-Transition tables contain as many steps as needed to reach the mode from any other mode, e.g. a
-switch into any higher AOCS mode might first turn on the sensors, than the actuators and the
-controller as last component.
-The target table is used to describe the state that is checked continuously by the subsystem.
-All of this allows System Modes to be generated as Subsystem object as well from the same database.
-This System contains list of subsystem modes in the transition and target tables.
-Therefore, it allows a modular system to create system modes and easy commanding of those, because
-only the highest components must be commanded.
-
-The health state represents if the component is able to perform its tasks.
-This can be used to signal the system to avoid using this component instead of a redundant one.
-The on-board FDIR uses the health state for isolation and recovery.
-
-# Unit Tests
-
-Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include
-catch2 itself. More information on how to run these tests can be found in the separate
-[`fsfw_tests` reposoitory](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_tests)
diff --git a/docs/README-localpools.md b/docs/README-localpools.md
deleted file mode 100644
index 2ee75189..00000000
--- a/docs/README-localpools.md
+++ /dev/null
@@ -1,174 +0,0 @@
-## Local Data Pools Developer Information
-
-The following text is targeted towards mission software developers which would like
-to use the local data pools provided by the FSFW to store data like sensor values so they can be
-used by other software objects like controllers as well. If a custom class should have a local
-pool which can be used by other software objects as well, following steps have to be performed:
-
-1. Create a `LocalDataPoolManager` member object in the custom class
-2. Implement the `HasLocalDataPoolIF` with specifies the interface between the local pool manager
-and the class owning the local pool.
-
-The local data pool manager is also able to process housekeeping service requests in form
-of messages, generate periodic housekeeping packet, generate notification and snapshots of changed
-variables and datasets and process notifications and snapshots coming from other objects.
-The two former tasks are related to the external interface using telemetry and telecommands (TMTC)
-while the later two are related to data consumers like controllers only acting on data change
-detected by the data creator instead of checking the data manually each cycle. Two important
-framework classes `DeviceHandlerBase` and `ExtendedControllerBase` already perform the two steps
-shown above so the steps required are altered slightly.
-
-### Storing and Accessing pool data
-
-The pool manager is responsible for thread-safe access of the pool data, but the actual
-access to the pool data from the point of view of a mission software developer happens via proxy
-classes like pool variable classes. These classes store a copy
-of the pool variable with the matching datatype and copy the actual data from the local pool
-on a `read` call. Changed variables can then be written to the local pool with a `commit` call.
-The `read` and `commit` calls are thread-safe and can be called concurrently from data creators
-and data consumers. Generally, a user will create a dataset class which in turn groups all
-cohesive pool variables. These sets simply iterator over the list of variables and call the
-`read` and `commit` functions of each variable. The following diagram shows the
-high-level architecture of the local data pools.
-
-.. image:: ../misc/logo/FSFW_Logo_V3_bw.png
- :alt: FSFW Logo
-
-
-An example is shown for using the local data pools with a Gyroscope.
-For example, the following code shows an implementation to access data from a Gyroscope taken
-from the SOURCE CubeSat project:
-
-```cpp
-class GyroPrimaryDataset: public StaticLocalDataSet<3 * sizeof(float)> {
-public:
- /**
- * Constructor for data users
- * @param gyroId
- */
- GyroPrimaryDataset(object_id_t gyroId):
- StaticLocalDataSet(sid_t(gyroId, gyrodefs::GYRO_DATA_SET_ID)) {
- setAllVariablesReadOnly();
- }
-
- lp_var_t angVelocityX = lp_var_t(sid.objectId,
- gyrodefs::ANGULAR_VELOCITY_X, this);
- lp_var_t angVelocityY = lp_var_t(sid.objectId,
- gyrodefs::ANGULAR_VELOCITY_Y, this);
- lp_var_t angVelocityZ = lp_var_t(sid.objectId,
- gyrodefs::ANGULAR_VELOCITY_Z, this);
-private:
-
- friend class GyroHandler;
- /**
- * Constructor for data creator
- * @param hkOwner
- */
- GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner):
- StaticLocalDataSet(hkOwner, gyrodefs::GYRO_DATA_SET_ID) {}
-};
-```
-
-There is a public constructor for users which sets all variables to read-only and there is a
-constructor for the GyroHandler data creator by marking it private and declaring the `GyroHandler`
-as a friend class. Both the atittude controller and the `GyroHandler` can now
-use the same class definition to access the pool variables with `read` and `commit` semantics
-in a thread-safe way. Generally, each class requiring access will have the set class as a member
-class. The data creator will also be generally a `DeviceHandlerBase` subclass and some additional
-steps are necessary to expose the set for housekeeping purposes.
-
-### Using the local data pools in a `DeviceHandlerBase` subclass
-
-It is very common to store data generated by devices like a sensor into a pool which can
-then be used by other objects. Therefore, the `DeviceHandlerBase` already has a
-local pool. Using the aforementioned example, our `GyroHandler` will now have the set class
-as a member:
-
-```cpp
-class GyroHandler: ... {
-
-public:
- ...
-private:
- ...
- GyroPrimaryDataset gyroData;
- ...
-};
-```
-
-The constructor used for the creators expects the owner class as a parameter, so we initialize
-the object in the `GyroHandler` constructor like this:
-
-```cpp
-GyroHandler::GyroHandler(object_id_t objectId, object_id_t comIF,
- CookieIF *comCookie, uint8_t switchId):
- DeviceHandlerBase(objectId, comIF, comCookie), switchId(switchId),
- gyroData(this) {}
-```
-
-We need to assign the set to a reply ID used in the `DeviceHandlerBase`.
-The combination of the `GyroHandler` object ID and the reply ID will be the 64-bit structure ID
-`sid_t` and is used to globally identify the set, for example when requesting housekeeping data or
-generating update messages. We need to assign our custom set class in some way so that the local
-pool manager can access the custom data sets as well.
-By default, the `getDataSetHandle` will take care of this tasks. The default implementation for a
-`DeviceHandlerBase` subclass will use the internal command map to retrieve
-a handle to a dataset from a given reply ID. Therefore,
-we assign the set in the `fillCommandAndReplyMap` function:
-
-```cpp
-void GyroHandler::fillCommandAndReplyMap() {
- ...
- this->insertInCommandAndReplyMap(gyrodefs::GYRO_DATA, 3, &gyroData);
- ...
-}
-```
-
-Now, we need to create the actual pool entries as well, using the `initializeLocalDataPool`
-function. Here, we also immediately subscribe for periodic housekeeping packets
-with an interval of 4 seconds. They are still disabled in this example and can be enabled
-with a housekeeping service command.
-
-```cpp
-ReturnValue_t GyroHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
- LocalDataPoolManager &poolManager) {
- localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_X,
- new PoolEntry({0.0}));
- localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_Y,
- new PoolEntry({0.0}));
- localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_Z,
- new PoolEntry({0.0}));
- localDataPoolMap.emplace(gyrodefs::GENERAL_CONFIG_REG42,
- new PoolEntry({0}));
- localDataPoolMap.emplace(gyrodefs::RANGE_CONFIG_REG43,
- new PoolEntry({0}));
-
- poolManager.subscribeForPeriodicPacket(gyroData.getSid(), false, 4.0, false);
- return HasReturnvaluesIF::RETURN_OK;
-}
-```
-
-Now, if we receive some sensor data and converted them into the right format,
-we can write it into the pool like this, using a guard class to ensure the set is commited back
-in any case:
-
-```cpp
-PoolReadGuard readHelper(&gyroData);
-if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
- if(not gyroData.isValid()) {
- gyroData.setValidity(true, true);
- }
-
- gyroData.angVelocityX = angularVelocityX;
- gyroData.angVelocityY = angularVelocityY;
- gyroData.angVelocityZ = angularVelocityZ;
-}
-```
-
-The guard class will commit the changed data on destruction automatically.
-
-### Using the local data pools in a `ExtendedControllerBase` subclass
-
-Coming soon
-
-
diff --git a/docs/README-osal.md b/docs/README-osal.md
deleted file mode 100644
index 6f8ce60f..00000000
--- a/docs/README-osal.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# Operating System Abstraction Layer (OSAL)
-
-Some specific information on the provided OSALs are provided.
-
-## Linux OSAL
-
-This OSAL can be used to compile for Linux host systems like Ubuntu 20.04 or for
-embedded Linux targets like the Raspberry Pi. This OSAL generally requires threading support
-and real-time functionalities. For most UNIX systems, this is done by adding `-lrt` and `-lpthread` to the linked libraries in the compilation process. The CMake build support provided will do this automatically for the `fsfw` target. It should be noted that most UNIX systems need to be configured specifically to allow the real-time functionalities required by the FSFW.
-
-More information on how to set up a Linux system accordingly can be found in the
-[Linux README of the FSFW example application](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example/src/branch/master/doc/README-linux.md#top)
-
-## Hosted OSAL
-
-This is the newest OSAL. Support for Semaphores has not been implemented yet and will propably be implemented as soon as C++20 with Semaphore support has matured. This OSAL can be used to run the FSFW on any host system, but currently has only been tested on Windows 10 and Ubuntu 20.04. Unlike the other OSALs, it uses dynamic memory allocation (e.g. for the message queue implementation). Cross-platform serial port (USB) support might be added soon.
-
-## FreeRTOS OSAL
-
-FreeRTOS is not included and the developer needs to take care of compiling the FreeRTOS sources and adding the `FreeRTOSConfig.h` file location to the include path. This OSAL has only been tested extensively with the pre-emptive scheduler configuration so far but it should in principle also be possible to use a cooperative scheduler. It is recommended to use the `heap_4` allocation scheme. When using newlib (nano), it is also recommended to add `#define configUSE_NEWLIB_REENTRANT` to the FreeRTOS configuration file to ensure thread-safety.
-
-When using this OSAL, developers also need to provide an implementation for the `vRequestContextSwitchFromISR` function. This has been done because the call to request a context switch from an ISR is generally located in the `portmacro.h` header and is different depending on the target architecture or device.
-
-## RTEMS OSAL
-
-The RTEMS OSAL was the first implemented OSAL which is also used on the active satellite Flying Laptop.
-
-## TCP/IP socket abstraction
-
-The Linux and Host OSAL provide abstraction layers for the socket API. Currently, only UDP sockets have been imlemented. This is very useful to test TMTC handling either on the host computer directly (targeting localhost with a TMTC application) or on embedded Linux devices, sending TMTC packets via Ethernet.
-
-
diff --git a/docs/README-pus.md b/docs/README-pus.md
deleted file mode 100644
index 928d2eda..00000000
--- a/docs/README-pus.md
+++ /dev/null
@@ -1 +0,0 @@
-## PUS Services
diff --git a/docs/api.rst b/docs/api.rst
index d2ee6c69..dc73c2c7 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -4,6 +4,7 @@ API
.. toctree::
:maxdepth: 4
+ api/cfdp
api/objectmanager
api/task
api/ipc
diff --git a/docs/api/cfdp.rst b/docs/api/cfdp.rst
new file mode 100644
index 00000000..335a2025
--- /dev/null
+++ b/docs/api/cfdp.rst
@@ -0,0 +1,8 @@
+CFDP API
+=================
+
+``UserBase``
+-----------------
+
+.. doxygenclass:: cfdp::UserBase
+ :members:
\ No newline at end of file
diff --git a/docs/api/returnvalue.rst b/docs/api/returnvalue.rst
index b0d43916..da65c141 100644
--- a/docs/api/returnvalue.rst
+++ b/docs/api/returnvalue.rst
@@ -3,7 +3,7 @@
Returnvalue API
==================
-.. doxygenfile:: HasReturnvaluesIF.h
+.. doxygenfile:: returnvalue.h
.. _fwclassids:
diff --git a/docs/conf.py b/docs/conf.py
index 62b17192..a4232026 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -17,12 +17,12 @@
# -- Project information -----------------------------------------------------
-project = 'Flight Software Framework'
-copyright = '2021, Institute of Space Systems (IRS)'
-author = 'Institute of Space Systems (IRS)'
+project = "Flight Software Framework"
+copyright = "2021, Institute of Space Systems (IRS)"
+author = "Institute of Space Systems (IRS)"
# The full version, including alpha/beta/rc tags
-release = '2.0.1'
+release = "5.0.0"
# -- General configuration ---------------------------------------------------
@@ -30,17 +30,17 @@ release = '2.0.1'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
-extensions = [ "breathe" ]
+extensions = ["breathe"]
breathe_default_project = "fsfw"
# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
+templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
-exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
# -- Options for HTML output -------------------------------------------------
@@ -48,9 +48,14 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
-html_theme = 'alabaster'
+html_theme = "alabaster"
+
+html_theme_options = {
+ "extra_nav_links": {"Impressum" : "https://www.uni-stuttgart.de/impressum", "Datenschutz": "https://info.irs.uni-stuttgart.de/datenschutz/datenschutzWebmit.html"}
+}
+
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = []
\ No newline at end of file
+html_static_path = []
diff --git a/docs/devicehandlers.rst b/docs/devicehandlers.rst
index 0008edb3..9c6929e8 100644
--- a/docs/devicehandlers.rst
+++ b/docs/devicehandlers.rst
@@ -75,11 +75,11 @@ and the respective source file with sensible default return values:
void TestDeviceHandler::doShutDown() {}
ReturnValue_t TestDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t TestDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
void TestDeviceHandler::fillCommandAndReplyMap() {}
@@ -87,17 +87,17 @@ and the respective source file with sensible default return values:
ReturnValue_t TestDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t TestDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t TestDeviceHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t* packet) {
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
uint32_t TestDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
@@ -106,5 +106,5 @@ and the respective source file with sensible default return values:
ReturnValue_t TestDeviceHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
diff --git a/docs/getting_started.rst b/docs/getting_started.rst
index 01724b3a..4f8ae543 100644
--- a/docs/getting_started.rst
+++ b/docs/getting_started.rst
@@ -106,7 +106,7 @@ You can use the following commands inside the ``fsfw`` folder to set up the buil
.. code-block:: console
mkdir build-tests && cd build-tests
- cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host ..
+ cmake -DFSFW_BUILD_TESTS=ON -DFSFW_OSAL=host ..
You can also use ``-DFSFW_OSAL=linux`` on Linux systems.
diff --git a/docs/highlevel.rst b/docs/highlevel.rst
index 04eb5e7b..ee35c549 100644
--- a/docs/highlevel.rst
+++ b/docs/highlevel.rst
@@ -6,19 +6,20 @@ High-level overview
Structure
----------
-The general structure is driven by the usage of interfaces provided by objects.
-The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be
-widely available, even with older compilers.
-The FSFW uses dynamic allocation during the initialization but provides static containers during runtime.
-This simplifies the instantiation of objects and allows the usage of some standard containers.
-Dynamic Allocation after initialization is discouraged and different solutions are provided in the
-FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed.
+The general structure is driven by the usage of interfaces provided by objects.
+The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this
+standard, even for micocontrollers.
+
+The FSFW might use dynamic allocation during program initialization but not during runtime.
+It offers pool objects, static containers and it also exposes the
+`Embedded Template Library `_ to allow writing code which does not perform
+allocation during runtime. The fsfw uses run-time type information but will not throw exceptions.
Failure Handling
-----------------
Functions should return a defined :cpp:type:`ReturnValue_t` to signal to the caller that something has
-gone wrong. Returnvalues must be unique. For this the function :cpp:func:`HasReturnvaluesIF::makeReturnCode`
+gone wrong. Returnvalues must be unique. For this the function :cpp:func:`returnvalue::makeCode`
or the :ref:`macro MAKE_RETURN_CODE ` can be used. The ``CLASS_ID`` is a unique ID for that type of object.
See the :ref:`FSFW Class IDs file `. The user can add custom ``CLASS_ID``\s via the
``fsfwconfig`` folder.
diff --git a/docs/localpools.rst b/docs/localpools.rst
index d2afd0a0..f7e1ca47 100644
--- a/docs/localpools.rst
+++ b/docs/localpools.rst
@@ -150,7 +150,7 @@ with a housekeeping service command.
new PoolEntry({0}));
poolManager.subscribeForPeriodicPacket(gyroData.getSid(), false, 4.0, false);
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
Now, if we receive some sensor data and converted them into the right format,
@@ -160,7 +160,7 @@ in any case:
.. code-block:: cpp
PoolReadGuard readHelper(&gyroData);
- if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
+ if(readHelper.getReadResult() == returnvalue::OK) {
if(not gyroData.isValid()) {
gyroData.setValidity(true, true);
}
diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt
deleted file mode 100644
index 7a97ae0f..00000000
--- a/hal/CMakeLists.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-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. 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_LINUX_ADD_LIBGPIOD "Target implements libgpiod" 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)
-
-set(LINUX_HAL_PATH_NAME linux)
-set(STM32H7_PATH_NAME stm32h7)
-
-add_subdirectory(src)
-
-foreach(INCLUDE_PATH ${FSFW_HAL_ADDITIONAL_INC_PATHS})
- if(IS_ABSOLUTE ${INCLUDE_PATH})
- set(CURR_ABS_INC_PATH "${INCLUDE_PATH}")
- else()
- get_filename_component(CURR_ABS_INC_PATH
- ${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR})
- endif()
-
- if(CMAKE_VERBOSE)
- message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}")
- endif()
-
- list(APPEND FSFW_HAL_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH})
-endforeach()
-
-target_include_directories(${LIB_FSFW_NAME} PRIVATE
- ${FSFW_HAL_ADD_INC_PATHS_ABS}
-)
-
-target_compile_definitions(${LIB_FSFW_NAME} PRIVATE
- ${FSFW_HAL_DEFINES}
-)
-
-target_link_libraries(${LIB_FSFW_NAME} PRIVATE
- ${FSFW_HAL_LINK_LIBS}
-)
diff --git a/hal/src/CMakeLists.txt b/hal/src/CMakeLists.txt
deleted file mode 100644
index 76ee45c6..00000000
--- a/hal/src/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-target_include_directories(${LIB_FSFW_NAME} PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}
-)
-
-target_include_directories(${LIB_FSFW_NAME} INTERFACE
- ${CMAKE_CURRENT_SOURCE_DIR}
-)
-
-add_subdirectory(fsfw_hal)
diff --git a/hal/src/fsfw_hal/common/CMakeLists.txt b/hal/src/fsfw_hal/common/CMakeLists.txt
deleted file mode 100644
index f1cfec52..00000000
--- a/hal/src/fsfw_hal/common/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(gpio)
diff --git a/hal/src/fsfw_hal/common/gpio/CMakeLists.txt b/hal/src/fsfw_hal/common/gpio/CMakeLists.txt
deleted file mode 100644
index 098c05fa..00000000
--- a/hal/src/fsfw_hal/common/gpio/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PRIVATE
- GpioCookie.cpp
-)
\ No newline at end of file
diff --git a/hal/src/fsfw_hal/devicehandlers/CMakeLists.txt b/hal/src/fsfw_hal/devicehandlers/CMakeLists.txt
deleted file mode 100644
index 94e67c72..00000000
--- a/hal/src/fsfw_hal/devicehandlers/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PRIVATE
- GyroL3GD20Handler.cpp
- MgmRM3100Handler.cpp
- MgmLIS3MDLHandler.cpp
-)
diff --git a/hal/src/fsfw_hal/host/CMakeLists.txt b/hal/src/fsfw_hal/host/CMakeLists.txt
deleted file mode 100644
index 8b137891..00000000
--- a/hal/src/fsfw_hal/host/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/hal/src/fsfw_hal/linux/CMakeLists.txt b/hal/src/fsfw_hal/linux/CMakeLists.txt
deleted file mode 100644
index f6d1a460..00000000
--- a/hal/src/fsfw_hal/linux/CMakeLists.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-if(FSFW_HAL_ADD_RASPBERRY_PI)
- add_subdirectory(rpi)
-endif()
-
-target_sources(${LIB_FSFW_NAME} PRIVATE
- UnixFileGuard.cpp
- CommandExecutor.cpp
- utility.cpp
-)
-
-if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS)
-if(FSFW_HAL_LINUX_ADD_LIBGPIOD)
- add_subdirectory(gpio)
-endif()
- add_subdirectory(uart)
- # Adding those does not really make sense on Apple systems which
- # are generally host systems. It won't even compile as the headers
- # are missing
- if(NOT APPLE)
- add_subdirectory(i2c)
- add_subdirectory(spi)
- endif()
-endif()
-
-add_subdirectory(uio)
diff --git a/hal/src/fsfw_hal/linux/gpio/CMakeLists.txt b/hal/src/fsfw_hal/linux/gpio/CMakeLists.txt
deleted file mode 100644
index b1609850..00000000
--- a/hal/src/fsfw_hal/linux/gpio/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-# This abstraction layer requires the gpiod library. You can install this library
-# with "sudo apt-get install -y libgpiod-dev". If you are cross-compiling, you need
-# to install the package before syncing the sysroot to your host computer.
-find_library(LIB_GPIO gpiod)
-
-if(${LIB_GPIO} MATCHES LIB_GPIO-NOTFOUND)
- message(STATUS "gpiod library not found, not linking against it")
-else()
- target_sources(${LIB_FSFW_NAME} PRIVATE
- LinuxLibgpioIF.cpp
- )
- target_link_libraries(${LIB_FSFW_NAME} PRIVATE
- ${LIB_GPIO}
- )
-endif()
-
diff --git a/hal/src/fsfw_hal/linux/i2c/CMakeLists.txt b/hal/src/fsfw_hal/linux/i2c/CMakeLists.txt
deleted file mode 100644
index 3eb0882c..00000000
--- a/hal/src/fsfw_hal/linux/i2c/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PUBLIC
- I2cComIF.cpp
- I2cCookie.cpp
-)
-
-
-
-
diff --git a/hal/src/fsfw_hal/linux/rpi/CMakeLists.txt b/hal/src/fsfw_hal/linux/rpi/CMakeLists.txt
deleted file mode 100644
index 47be218c..00000000
--- a/hal/src/fsfw_hal/linux/rpi/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PRIVATE
- GpioRPi.cpp
-)
\ No newline at end of file
diff --git a/hal/src/fsfw_hal/linux/spi/CMakeLists.txt b/hal/src/fsfw_hal/linux/spi/CMakeLists.txt
deleted file mode 100644
index 404e1f47..00000000
--- a/hal/src/fsfw_hal/linux/spi/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PUBLIC
- SpiComIF.cpp
- SpiCookie.cpp
-)
-
-
-
-
diff --git a/hal/src/fsfw_hal/linux/uart/CMakeLists.txt b/hal/src/fsfw_hal/linux/uart/CMakeLists.txt
deleted file mode 100644
index 21ed0278..00000000
--- a/hal/src/fsfw_hal/linux/uart/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PUBLIC
- UartComIF.cpp
- UartCookie.cpp
-)
diff --git a/hal/src/fsfw_hal/linux/uart/UartCookie.cpp b/hal/src/fsfw_hal/linux/uart/UartCookie.cpp
deleted file mode 100644
index 3fedc9d4..00000000
--- a/hal/src/fsfw_hal/linux/uart/UartCookie.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "UartCookie.h"
-
-#include
-
-UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartModes uartMode,
- UartBaudRate baudrate, size_t maxReplyLen)
- : handlerId(handlerId),
- deviceFile(deviceFile),
- uartMode(uartMode),
- baudrate(baudrate),
- maxReplyLen(maxReplyLen) {}
-
-UartCookie::~UartCookie() {}
-
-UartBaudRate UartCookie::getBaudrate() const { return baudrate; }
-
-size_t UartCookie::getMaxReplyLen() const { return maxReplyLen; }
-
-std::string UartCookie::getDeviceFile() const { return deviceFile; }
-
-void UartCookie::setParityOdd() { parity = Parity::ODD; }
-
-void UartCookie::setParityEven() { parity = Parity::EVEN; }
-
-Parity UartCookie::getParity() const { return parity; }
-
-void UartCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; }
-
-BitsPerWord UartCookie::getBitsPerWord() const { return bitsPerWord; }
-
-StopBits UartCookie::getStopBits() const { return stopBits; }
-
-void UartCookie::setTwoStopBits() { stopBits = StopBits::TWO_STOP_BITS; }
-
-void UartCookie::setOneStopBit() { stopBits = StopBits::ONE_STOP_BIT; }
-
-UartModes UartCookie::getUartMode() const { return uartMode; }
-
-void UartCookie::setReadCycles(uint8_t readCycles) { this->readCycles = readCycles; }
-
-void UartCookie::setToFlushInput(bool enable) { this->flushInput = enable; }
-
-uint8_t UartCookie::getReadCycles() const { return readCycles; }
-
-bool UartCookie::getInputShouldBeFlushed() { return this->flushInput; }
-
-object_id_t UartCookie::getHandlerId() const { return this->handlerId; }
-
-void UartCookie::setNoFixedSizeReply() { replySizeFixed = false; }
-
-bool UartCookie::isReplySizeFixed() { return replySizeFixed; }
diff --git a/hal/src/fsfw_hal/linux/uio/CMakeLists.txt b/hal/src/fsfw_hal/linux/uio/CMakeLists.txt
deleted file mode 100644
index e98a0865..00000000
--- a/hal/src/fsfw_hal/linux/uio/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PUBLIC
- UioMapper.cpp
-)
diff --git a/hal/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt b/hal/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt
deleted file mode 100644
index 7bd4c3a9..00000000
--- a/hal/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PRIVATE
- GyroL3GD20H.cpp
-)
\ No newline at end of file
diff --git a/hal/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt b/hal/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt
deleted file mode 100644
index 35245b25..00000000
--- a/hal/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PRIVATE
- gpio.cpp
-)
diff --git a/hal/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt b/hal/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt
deleted file mode 100644
index 5ecb0990..00000000
--- a/hal/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PRIVATE
-)
diff --git a/hal/src/fsfw_hal/stm32h7/spi/CMakeLists.txt b/hal/src/fsfw_hal/stm32h7/spi/CMakeLists.txt
deleted file mode 100644
index aa5541bc..00000000
--- a/hal/src/fsfw_hal/stm32h7/spi/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PRIVATE
- spiCore.cpp
- spiDefinitions.cpp
- spiInterrupts.cpp
- mspInit.cpp
- SpiCookie.cpp
- SpiComIF.cpp
- stm32h743zi.cpp
-)
diff --git a/hal/src/fsfw_hal/stm32h7/uart/CMakeLists.txt b/hal/src/fsfw_hal/stm32h7/uart/CMakeLists.txt
deleted file mode 100644
index 5ecb0990..00000000
--- a/hal/src/fsfw_hal/stm32h7/uart/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-target_sources(${LIB_FSFW_NAME} PRIVATE
-)
diff --git a/misc/defaultcfg/fsfwconfig/FSFWConfig.h b/misc/defaultcfg/fsfwconfig/FSFWConfig.h
index adf9912f..e80abf24 100644
--- a/misc/defaultcfg/fsfwconfig/FSFWConfig.h
+++ b/misc/defaultcfg/fsfwconfig/FSFWConfig.h
@@ -4,6 +4,10 @@
#include
#include
+// It is assumed the user has a subsystem and class ID list in some user header files.
+// #include "events/subsystemIdRanges.h"
+// #include "returnvalues/classIds.h"
+
//! Used to determine whether C++ ostreams are used which can increase
//! the binary size significantly. If this is disabled,
//! the C stdio functions can be used alternatively
diff --git a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp
index 5aef4980..85a733b4 100644
--- a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp
+++ b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp
@@ -4,7 +4,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -35,19 +34,15 @@ void Factory::produceFsfwObjects(void) {
}
void Factory::setStaticFrameworkObjectIds() {
- PusServiceBase::packetSource = objects::NO_OBJECT;
- PusServiceBase::packetDestination = objects::NO_OBJECT;
+ PusServiceBase::PUS_DISTRIBUTOR = objects::NO_OBJECT;
+ PusServiceBase::PACKET_DESTINATION = objects::NO_OBJECT;
CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT;
- VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
-
DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
DeviceHandlerBase::rawDataReceiverId = objects::PUS_SERVICE_2_DEVICE_ACCESS;
DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
-
- TmPacketBase::timeStamperId = objects::NO_OBJECT;
}
diff --git a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp
index b7f1fb3e..81b927dd 100644
--- a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp
+++ b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp
@@ -11,15 +11,15 @@ ReturnValue_t pst::pollingSequenceInitDefault(
/* Add polling sequence table here */
- if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
- return HasReturnvaluesIF::RETURN_OK;
+ if (thisSequence->checkSequence() == returnvalue::OK) {
+ return returnvalue::OK;
}
else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!"
<< std::endl;
#endif
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
diff --git a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.h b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.h
index c5d41b7d..622cc49a 100644
--- a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.h
+++ b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.h
@@ -1,7 +1,7 @@
#ifndef POLLINGSEQUENCEFACTORY_H_
#define POLLINGSEQUENCEFACTORY_H_
-#include
+#include
class FixedTimeslotTaskIF;
diff --git a/scripts/auto-formatter.sh b/scripts/auto-formatter.sh
index 405d1268..f7507c55 100755
--- a/scripts/auto-formatter.sh
+++ b/scripts/auto-formatter.sh
@@ -3,11 +3,17 @@ if [[ ! -f README.md ]]; then
cd ..
fi
+folder_list=(
+ "./src"
+ "./unittests"
+)
+
cmake_fmt="cmake-format"
file_selectors="-iname CMakeLists.txt"
if command -v ${cmake_fmt} &> /dev/null; then
${cmake_fmt} -i CMakeLists.txt
- find ./src ${file_selectors} | xargs ${cmake_fmt} -i
+ find ./src ${file_selectors} | xargs ${cmake_fmt} -i
+ find ./unittests ${file_selectors} | xargs ${cmake_fmt} -i
else
echo "No ${cmake_fmt} tool found, not formatting CMake files"
fi
@@ -15,9 +21,10 @@ fi
cpp_format="clang-format"
file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp"
if command -v ${cpp_format} &> /dev/null; then
- find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i
- find ./hal ${file_selectors} | xargs ${cpp_format} --style=file -i
- find ./tests ${file_selectors} | xargs ${cpp_format} --style=file -i
+ for dir in ${folder_list[@]}; do
+ echo "Auto-formatting ${dir} recursively"
+ find ${dir} ${file_selectors} | xargs clang-format --style=file -i
+ done
else
echo "No ${cpp_format} tool found, not formatting C++/C files"
fi
diff --git a/scripts/check_release.py b/scripts/check_release.py
new file mode 100755
index 00000000..eb5c89f9
--- /dev/null
+++ b/scripts/check_release.py
@@ -0,0 +1,110 @@
+#! /bin/python
+
+
+import argparse
+import json
+import urllib.request
+import re
+from pathlib import Path
+
+def main() -> None:
+ parser = argparse.ArgumentParser(
+ description="List undocumented PRs"
+ )
+ parser.add_argument("-v", "--version", type=str, required=True)
+ args = parser.parse_args()
+
+ match = re.search("([0-9]+\.[0-9]+\.[0-9]+)", args.version)
+
+ if not match:
+ print("invalid version")
+ exit(1)
+
+ version = "v" + match.group(1)
+
+ print("looking for milestone for " + version + " ...")
+
+
+ with urllib.request.urlopen("https://egit.irs.uni-stuttgart.de/api/v1/repos/fsfw/fsfw/milestones?name=" + version) as milestone_json:
+ milestones = json.load(milestone_json)
+ if (len(milestones) == 0):
+ print("did not find any milestone")
+ exit(1)
+ if (len(milestones) > 1):
+ print("found multiple milestons")
+ milestone_title = milestones[0]['title']
+ milestone = str(milestones[0]['id'])
+ print("Using Milestone \""+ milestone_title + "\" with id " + milestone)
+
+ milestone_prs = []
+
+ page = 1
+ last_count = 1;
+ while last_count != 0:
+ with urllib.request.urlopen("https://egit.irs.uni-stuttgart.de/api/v1/repos/fsfw/fsfw/pulls?state=closed&milestone=" + str(milestone) + "&limit=100&page=" + str(page)) as pull_requests_json:
+ pull_requests = json.load(pull_requests_json)
+ for pr in pull_requests:
+ milestone_prs.append({'number': str(pr['number']), 'title' : pr['title']})
+ page += 1
+ last_count = len(pull_requests)
+
+ print("Found " + str(len(milestone_prs)) + " closed PRs in Milestone")
+
+ print("looking for CHANGELOG.md ...")
+
+ path = Path(".")
+
+ files = list(path.glob("CHANGELOG.md"))
+
+ if (len(files) != 1):
+ files = list(path.glob("../CHANGELOG.md"))
+
+ if (len(files) != 1):
+ print("did not find CHANGELOG.md. Run script in either root directory or scripts subfolder.")
+ exit(1)
+
+ print("Scanning CHANGELOG.md ...")
+
+ changelog_prs = []
+
+ with open(files[0]) as changelog:
+ line = changelog.readline()
+ while (line):
+ #print("line: " + line)
+ match = re.search("\#.+(v[0-9]+\.[0-9]+\.[0-9]+)", line)
+ if (match):
+ if match.group(1) == version:
+ #print("found version")
+ line = changelog.readline()
+ continue
+ else:
+ #print("done with " + match.group(1))
+ break
+
+ match = re.search("PR: https://egit\.irs\.uni-stuttgart\.de/fsfw/fsfw/pulls/([0-9]+)", line)
+ if match:
+ changelog_prs.append(match.group(1))
+
+ line = changelog.readline()
+
+ print("Found " + str(len(changelog_prs)) + " PRs in CHANGELOG.md")
+
+ print("")
+
+ copy_array = changelog_prs.copy()
+ print("PRs in CHANGELOG.md that are not in Milestone:")
+ for pr in milestone_prs:
+ if pr['number'] in copy_array:
+ copy_array.remove(pr['number'])
+ for pr in copy_array:
+ print("https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/" + pr)
+
+ print("")
+
+ print("PRs in milestone that are not in CHANGELOG.md:")
+
+ for pr in milestone_prs:
+ if pr['number'] not in changelog_prs:
+ print("- " + pr['title'] + "\n PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/" + pr['number'])
+
+main()
diff --git a/scripts/helper.py b/scripts/helper.py
index 4dff908d..59a1b783 100755
--- a/scripts/helper.py
+++ b/scripts/helper.py
@@ -13,7 +13,7 @@ from shutil import which
from typing import List
-UNITTEST_FOLDER_NAME = "build-tests"
+UNITTEST_FOLDER_NAME = "cmake-build-tests"
DOCS_FOLDER_NAME = "build-docs"
@@ -48,6 +48,20 @@ def main():
action="store_true",
help="Run valgrind on generated test binary",
)
+ parser.add_argument(
+ "-g",
+ "--generators",
+ default="Ninja",
+ action="store",
+ help="CMake generators",
+ )
+ parser.add_argument(
+ "-w",
+ "--windows",
+ default=False,
+ action="store_true",
+ help="Run on windows",
+ )
args = parser.parse_args()
if args.all:
@@ -115,14 +129,14 @@ def handle_tests_type(args, build_dir_list: list):
if args.create:
if os.path.exists(UNITTEST_FOLDER_NAME):
shutil.rmtree(UNITTEST_FOLDER_NAME)
- create_tests_build_cfg()
+ create_tests_build_cfg(args)
build_directory = UNITTEST_FOLDER_NAME
elif len(build_dir_list) == 0:
print(
"No valid CMake tests build directory found. "
"Trying to set up test build system"
)
- create_tests_build_cfg()
+ create_tests_build_cfg(args)
build_directory = UNITTEST_FOLDER_NAME
elif len(build_dir_list) == 1:
build_directory = build_dir_list[0]
@@ -147,10 +161,23 @@ def handle_tests_type(args, build_dir_list: list):
os.chdir("..")
-def create_tests_build_cfg():
+def create_tests_build_cfg(args):
os.mkdir(UNITTEST_FOLDER_NAME)
os.chdir(UNITTEST_FOLDER_NAME)
- cmd_runner("cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..")
+ if args.windows:
+ cmake_cmd = (
+ 'cmake -G "'
+ + args.generators
+ + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON \
+ -DGCOVR_PATH="py -m gcovr" ..'
+ )
+ else:
+ cmake_cmd = (
+ 'cmake -G "'
+ + args.generators
+ + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON ..'
+ )
+ cmd_runner(cmake_cmd)
os.chdir("..")
@@ -180,7 +207,7 @@ def check_for_cmake_build_dir(build_dir_list: list) -> list:
def perform_lcov_operation(directory: str, chdir: bool):
if chdir:
os.chdir(directory)
- cmd_runner("cmake --build . -- fsfw-tests_coverage -j")
+ cmd_runner("cmake --build . -j -- fsfw-tests_coverage")
def determine_build_dir(build_dir_list: List[str]):
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 34f21c2f..57b24bd5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,3 +4,8 @@ target_include_directories(${LIB_FSFW_NAME}
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(fsfw)
+if(FSFW_ADD_HAL)
+ add_subdirectory(fsfw_hal)
+endif()
+
+add_subdirectory(fsfw_tests)
diff --git a/src/fsfw/CMakeLists.txt b/src/fsfw/CMakeLists.txt
index 1daad714..e645d34f 100644
--- a/src/fsfw/CMakeLists.txt
+++ b/src/fsfw/CMakeLists.txt
@@ -31,6 +31,7 @@ add_subdirectory(thermal)
add_subdirectory(timemanager)
add_subdirectory(tmtcpacket)
add_subdirectory(tmtcservices)
+add_subdirectory(filesystem)
# Optional
diff --git a/src/fsfw/action/ActionHelper.cpp b/src/fsfw/action/ActionHelper.cpp
index d41c78b4..fd6c8afb 100644
--- a/src/fsfw/action/ActionHelper.cpp
+++ b/src/fsfw/action/ActionHelper.cpp
@@ -6,13 +6,13 @@
ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue)
: owner(setOwner), queueToUse(useThisQueue) {}
-ActionHelper::~ActionHelper() {}
+ActionHelper::~ActionHelper() = default;
ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) {
if (command->getCommand() == ActionMessage::EXECUTE_ACTION) {
ActionId_t currentAction = ActionMessage::getActionId(command);
prepareExecution(command->getSender(), currentAction, ActionMessage::getStoreId(command));
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
} else {
return CommandMessage::UNKNOWN_COMMAND;
}
@@ -21,7 +21,7 @@ ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) {
ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
ipcStore = ObjectManager::instance()->get(objects::IPC_STORE);
if (ipcStore == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
if (queueToUse_ != nullptr) {
setQueueToUse(queueToUse_);
@@ -35,10 +35,10 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
sif::printWarning("ActionHelper::initialize: No queue set\n");
#endif
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId,
@@ -59,10 +59,10 @@ void ActionHelper::setQueueToUse(MessageQueueIF* queue) { queueToUse = queue; }
void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId,
store_address_t dataAddress) {
- const uint8_t* dataPtr = NULL;
+ const uint8_t* dataPtr = nullptr;
size_t size = 0;
ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
CommandMessage reply;
ActionMessage::setStepReply(&reply, actionId, 0, result);
queueToUse->sendMessage(commandedBy, &reply);
@@ -75,7 +75,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
ActionMessage::setCompletionReply(&reply, actionId, true, result);
queueToUse->sendMessage(commandedBy, &reply);
}
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
CommandMessage reply;
ActionMessage::setStepReply(&reply, actionId, 0, result);
queueToUse->sendMessage(commandedBy, &reply);
@@ -91,11 +91,11 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep
size_t maxSize = data->getSerializedSize();
if (maxSize == 0) {
/* No error, there's simply nothing to report. */
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
size_t size = 0;
ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize, &dataPtr);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "ActionHelper::reportData: Getting free element from IPC store failed!"
<< std::endl;
@@ -107,7 +107,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep
return result;
}
result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
ipcStore->deleteData(storeAddress);
return result;
}
@@ -124,7 +124,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep
result = queueToUse->sendMessage(reportTo, &reply);
}
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
ipcStore->deleteData(storeAddress);
}
return result;
@@ -137,7 +137,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep
CommandMessage reply;
store_address_t storeAddress;
ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "ActionHelper::reportData: Adding data to IPC store failed!" << std::endl;
#else
@@ -158,7 +158,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep
result = queueToUse->sendMessage(reportTo, &reply);
}
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
ipcStore->deleteData(storeAddress);
}
return result;
diff --git a/src/fsfw/action/ActionHelper.h b/src/fsfw/action/ActionHelper.h
index d86e87d2..4bcecbae 100644
--- a/src/fsfw/action/ActionHelper.h
+++ b/src/fsfw/action/ActionHelper.h
@@ -1,9 +1,9 @@
#ifndef FSFW_ACTION_ACTIONHELPER_H_
#define FSFW_ACTION_ACTIONHELPER_H_
-#include "../ipc/MessageQueueIF.h"
-#include "../serialize/SerializeIF.h"
#include "ActionMessage.h"
+#include "fsfw/ipc/MessageQueueIF.h"
+#include "fsfw/serialize/SerializeIF.h"
/**
* @brief Action Helper is a helper class which handles action messages
*
@@ -36,7 +36,7 @@ class ActionHelper {
* send to the sender of the message automatically.
*
* @param command Pointer to a command message received by the owner
- * @return HasReturnvaluesIF::RETURN_OK if the message is a action message,
+ * @return returnvalue::OK if the message is a action message,
* CommandMessage::UNKNOW_COMMAND if this message ID is unkown
*/
ReturnValue_t handleActionMessage(CommandMessage* command);
@@ -45,7 +45,7 @@ class ActionHelper {
* helper function
* @param queueToUse_ Pointer to the messageQueue to be used, optional
* if queue was set in constructor
- * @return Returns RETURN_OK if successful
+ * @return Returns returnvalue::OK if successful
*/
ReturnValue_t initialize(MessageQueueIF* queueToUse_ = nullptr);
/**
@@ -58,7 +58,7 @@ class ActionHelper {
* @param result Result of the execution
*/
void step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId,
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
+ ReturnValue_t result = returnvalue::OK);
/**
* Function to be called by the owner to send a action completion message
* @param success Specify whether action was completed successfully or not.
@@ -67,7 +67,7 @@ class ActionHelper {
* @param result Result of the execution
*/
void finish(bool success, MessageQueueId_t reportTo, ActionId_t commandId,
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
+ ReturnValue_t result = returnvalue::OK);
/**
* Function to be called by the owner if an action does report data.
* Takes a SerializeIF* pointer and serializes it into the IPC store.
@@ -75,7 +75,7 @@ class ActionHelper {
* message to
* @param replyId ID of the executed command
* @param data Pointer to the data
- * @return Returns RETURN_OK if successful, otherwise failure code
+ * @return Returns returnvalue::OK if successful, otherwise failure code
*/
ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId, SerializeIF* data,
bool hideSender = false);
@@ -86,7 +86,7 @@ class ActionHelper {
* message to
* @param replyId ID of the executed command
* @param data Pointer to the data
- * @return Returns RETURN_OK if successful, otherwise failure code
+ * @return Returns returnvalue::OK if successful, otherwise failure code
*/
ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId, const uint8_t* data,
size_t dataSize, bool hideSender = false);
diff --git a/src/fsfw/action/ActionMessage.cpp b/src/fsfw/action/ActionMessage.cpp
index 40a516b1..33088055 100644
--- a/src/fsfw/action/ActionMessage.cpp
+++ b/src/fsfw/action/ActionMessage.cpp
@@ -2,9 +2,9 @@
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
-ActionMessage::ActionMessage() {}
+ActionMessage::ActionMessage() = default;
-ActionMessage::~ActionMessage() {}
+ActionMessage::~ActionMessage() = default;
void ActionMessage::setCommand(CommandMessage* message, ActionId_t fid,
store_address_t parameters) {
@@ -25,7 +25,7 @@ store_address_t ActionMessage::getStoreId(const CommandMessage* message) {
void ActionMessage::setStepReply(CommandMessage* message, ActionId_t fid, uint8_t step,
ReturnValue_t result) {
- if (result == HasReturnvaluesIF::RETURN_OK) {
+ if (result == returnvalue::OK) {
message->setCommand(STEP_SUCCESS);
} else {
message->setCommand(STEP_FAILED);
@@ -64,9 +64,8 @@ void ActionMessage::clear(CommandMessage* message) {
switch (message->getCommand()) {
case EXECUTE_ACTION:
case DATA_REPLY: {
- StorageManagerIF* ipcStore =
- ObjectManager::instance()->get(objects::IPC_STORE);
- if (ipcStore != NULL) {
+ auto* ipcStore = ObjectManager::instance()->get(objects::IPC_STORE);
+ if (ipcStore != nullptr) {
ipcStore->deleteData(getStoreId(message));
}
break;
diff --git a/src/fsfw/action/ActionMessage.h b/src/fsfw/action/ActionMessage.h
index bd12cc19..38e3aa99 100644
--- a/src/fsfw/action/ActionMessage.h
+++ b/src/fsfw/action/ActionMessage.h
@@ -33,12 +33,12 @@ class ActionMessage {
static store_address_t getStoreId(const CommandMessage* message);
static void setStepReply(CommandMessage* message, ActionId_t fid, uint8_t step,
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
+ ReturnValue_t result = returnvalue::OK);
static uint8_t getStep(const CommandMessage* message);
static ReturnValue_t getReturnCode(const CommandMessage* message);
static void setDataReply(CommandMessage* message, ActionId_t actionId, store_address_t data);
static void setCompletionReply(CommandMessage* message, ActionId_t fid, bool success,
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
+ ReturnValue_t result = returnvalue::OK);
static void clear(CommandMessage* message);
};
diff --git a/src/fsfw/action/CommandActionHelper.cpp b/src/fsfw/action/CommandActionHelper.cpp
index 19d8e9b8..831cd862 100644
--- a/src/fsfw/action/CommandActionHelper.cpp
+++ b/src/fsfw/action/CommandActionHelper.cpp
@@ -2,26 +2,26 @@
#include "fsfw/objectmanager/ObjectManager.h"
CommandActionHelper::CommandActionHelper(CommandsActionsIF *setOwner)
- : owner(setOwner), queueToUse(NULL), ipcStore(NULL), commandCount(0), lastTarget(0) {}
+ : owner(setOwner), queueToUse(nullptr), ipcStore(nullptr), commandCount(0), lastTarget(0) {}
-CommandActionHelper::~CommandActionHelper() {}
+CommandActionHelper::~CommandActionHelper() = default;
ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId_t actionId,
SerializeIF *data) {
- HasActionsIF *receiver = ObjectManager::instance()->get(commandTo);
- if (receiver == NULL) {
+ auto *receiver = ObjectManager::instance()->get(commandTo);
+ if (receiver == nullptr) {
return CommandsActionsIF::OBJECT_HAS_NO_FUNCTIONS;
}
store_address_t storeId;
uint8_t *storePointer;
size_t maxSize = data->getSerializedSize();
ReturnValue_t result = ipcStore->getFreeElement(&storeId, maxSize, &storePointer);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
size_t size = 0;
result = data->serialize(&storePointer, &size, maxSize, SerializeIF::Endianness::BIG);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
return sendCommand(receiver->getCommandQueue(), actionId, storeId);
@@ -29,16 +29,13 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId
ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId_t actionId,
const uint8_t *data, uint32_t size) {
- // if (commandCount != 0) {
- // return CommandsFunctionsIF::ALREADY_COMMANDING;
- // }
- HasActionsIF *receiver = ObjectManager::instance()->get(commandTo);
- if (receiver == NULL) {
+ auto *receiver = ObjectManager::instance()->get(commandTo);
+ if (receiver == nullptr) {
return CommandsActionsIF::OBJECT_HAS_NO_FUNCTIONS;
}
store_address_t storeId;
ReturnValue_t result = ipcStore->addData(&storeId, data, size);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
return sendCommand(receiver->getCommandQueue(), actionId, storeId);
@@ -49,7 +46,7 @@ ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId, ActionI
CommandMessage command;
ActionMessage::setCommand(&command, actionId, storeId);
ReturnValue_t result = queueToUse->sendMessage(queueId, &command);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
ipcStore->deleteData(storeId);
}
lastTarget = queueId;
@@ -59,55 +56,55 @@ ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId, ActionI
ReturnValue_t CommandActionHelper::initialize() {
ipcStore = ObjectManager::instance()->get(objects::IPC_STORE);
- if (ipcStore == NULL) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ if (ipcStore == nullptr) {
+ return returnvalue::FAILED;
}
queueToUse = owner->getCommandQueuePtr();
- if (queueToUse == NULL) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ if (queueToUse == nullptr) {
+ return returnvalue::FAILED;
}
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t CommandActionHelper::handleReply(CommandMessage *reply) {
if (reply->getSender() != lastTarget) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
switch (reply->getCommand()) {
case ActionMessage::COMPLETION_SUCCESS:
commandCount--;
owner->completionSuccessfulReceived(ActionMessage::getActionId(reply));
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
case ActionMessage::COMPLETION_FAILED:
commandCount--;
owner->completionFailedReceived(ActionMessage::getActionId(reply),
ActionMessage::getReturnCode(reply));
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
case ActionMessage::STEP_SUCCESS:
owner->stepSuccessfulReceived(ActionMessage::getActionId(reply),
ActionMessage::getStep(reply));
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
case ActionMessage::STEP_FAILED:
commandCount--;
owner->stepFailedReceived(ActionMessage::getActionId(reply), ActionMessage::getStep(reply),
ActionMessage::getReturnCode(reply));
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
case ActionMessage::DATA_REPLY:
extractDataForOwner(ActionMessage::getActionId(reply), ActionMessage::getStoreId(reply));
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
default:
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
uint8_t CommandActionHelper::getCommandCount() const { return commandCount; }
void CommandActionHelper::extractDataForOwner(ActionId_t actionId, store_address_t storeId) {
- const uint8_t *data = NULL;
+ const uint8_t *data = nullptr;
size_t size = 0;
ReturnValue_t result = ipcStore->getData(storeId, &data, &size);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return;
}
owner->dataReceived(actionId, data, size);
diff --git a/src/fsfw/action/CommandActionHelper.h b/src/fsfw/action/CommandActionHelper.h
index dd8ad7f1..55176e09 100644
--- a/src/fsfw/action/CommandActionHelper.h
+++ b/src/fsfw/action/CommandActionHelper.h
@@ -4,7 +4,7 @@
#include "ActionMessage.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/objectmanager/ObjectManagerIF.h"
-#include "fsfw/returnvalues/HasReturnvaluesIF.h"
+#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/serialize/SerializeIF.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
@@ -14,14 +14,14 @@ class CommandActionHelper {
friend class CommandsActionsIF;
public:
- CommandActionHelper(CommandsActionsIF* owner);
+ explicit CommandActionHelper(CommandsActionsIF* owner);
virtual ~CommandActionHelper();
ReturnValue_t commandAction(object_id_t commandTo, ActionId_t actionId, const uint8_t* data,
uint32_t size);
ReturnValue_t commandAction(object_id_t commandTo, ActionId_t actionId, SerializeIF* data);
ReturnValue_t initialize();
ReturnValue_t handleReply(CommandMessage* reply);
- uint8_t getCommandCount() const;
+ [[nodiscard]] uint8_t getCommandCount() const;
private:
CommandsActionsIF* owner;
diff --git a/src/fsfw/action/CommandsActionsIF.h b/src/fsfw/action/CommandsActionsIF.h
index 5870a9f2..a183051d 100644
--- a/src/fsfw/action/CommandsActionsIF.h
+++ b/src/fsfw/action/CommandsActionsIF.h
@@ -1,9 +1,9 @@
#ifndef FSFW_ACTION_COMMANDSACTIONSIF_H_
#define FSFW_ACTION_COMMANDSACTIONSIF_H_
-#include "../ipc/MessageQueueIF.h"
-#include "../returnvalues/HasReturnvaluesIF.h"
#include "CommandActionHelper.h"
+#include "fsfw/ipc/MessageQueueIF.h"
+#include "fsfw/returnvalues/returnvalue.h"
/**
* Interface to separate commanding actions of other objects.
@@ -21,7 +21,7 @@ class CommandsActionsIF {
static const uint8_t INTERFACE_ID = CLASS_ID::COMMANDS_ACTIONS_IF;
static const ReturnValue_t OBJECT_HAS_NO_FUNCTIONS = MAKE_RETURN_CODE(1);
static const ReturnValue_t ALREADY_COMMANDING = MAKE_RETURN_CODE(2);
- virtual ~CommandsActionsIF() {}
+ virtual ~CommandsActionsIF() = default;
virtual MessageQueueIF* getCommandQueuePtr() = 0;
protected:
diff --git a/src/fsfw/action/HasActionsIF.h b/src/fsfw/action/HasActionsIF.h
index acc502d7..29e267a0 100644
--- a/src/fsfw/action/HasActionsIF.h
+++ b/src/fsfw/action/HasActionsIF.h
@@ -1,11 +1,11 @@
#ifndef FSFW_ACTION_HASACTIONSIF_H_
#define FSFW_ACTION_HASACTIONSIF_H_
-#include "../ipc/MessageQueueIF.h"
-#include "../returnvalues/HasReturnvaluesIF.h"
#include "ActionHelper.h"
#include "ActionMessage.h"
#include "SimpleActionHelper.h"
+#include "fsfw/ipc/MessageQueueIF.h"
+#include "fsfw/returnvalues/returnvalue.h"
/**
* @brief
@@ -40,12 +40,12 @@ class HasActionsIF {
static const ReturnValue_t INVALID_PARAMETERS = MAKE_RETURN_CODE(2);
static const ReturnValue_t EXECUTION_FINISHED = MAKE_RETURN_CODE(3);
static const ReturnValue_t INVALID_ACTION_ID = MAKE_RETURN_CODE(4);
- virtual ~HasActionsIF() {}
+ virtual ~HasActionsIF() = default;
/**
* Function to get the MessageQueueId_t of the implementing object
* @return MessageQueueId_t of the object
*/
- virtual MessageQueueId_t getCommandQueue() const = 0;
+ [[nodiscard]] virtual MessageQueueId_t getCommandQueue() const = 0;
/**
* Execute or initialize the execution of a certain function.
* The ActionHelpers will execute this function and behave differently
@@ -53,7 +53,7 @@ class HasActionsIF {
*
* @return
* -@c EXECUTION_FINISHED Finish reply will be generated
- * -@c Not RETURN_OK Step failure reply will be generated
+ * -@c Not returnvalue::OK Step failure reply will be generated
*/
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) = 0;
diff --git a/src/fsfw/action/SimpleActionHelper.cpp b/src/fsfw/action/SimpleActionHelper.cpp
index 894f0df6..b9b9922e 100644
--- a/src/fsfw/action/SimpleActionHelper.cpp
+++ b/src/fsfw/action/SimpleActionHelper.cpp
@@ -3,13 +3,13 @@
SimpleActionHelper::SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue)
: ActionHelper(setOwner, useThisQueue), isExecuting(false) {}
-SimpleActionHelper::~SimpleActionHelper() {}
+SimpleActionHelper::~SimpleActionHelper() = default;
void SimpleActionHelper::step(ReturnValue_t result) {
// STEP_OFFESET is subtracted to compensate for adding offset in base
// method, which is not necessary here.
ActionHelper::step(stepCount - STEP_OFFSET, lastCommander, lastAction, result);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
resetHelper();
}
}
@@ -38,10 +38,10 @@ void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId
ActionMessage::setStepReply(&reply, actionId, 0, HasActionsIF::IS_BUSY);
queueToUse->sendMessage(commandedBy, &reply);
}
- const uint8_t* dataPtr = NULL;
+ const uint8_t* dataPtr = nullptr;
size_t size = 0;
ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
ActionMessage::setStepReply(&reply, actionId, 0, result);
queueToUse->sendMessage(commandedBy, &reply);
return;
@@ -51,12 +51,12 @@ void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId
result = owner->executeAction(actionId, commandedBy, dataPtr, size);
ipcStore->deleteData(dataAddress);
switch (result) {
- case HasReturnvaluesIF::RETURN_OK:
+ case returnvalue::OK:
isExecuting = true;
stepCount++;
break;
case HasActionsIF::EXECUTION_FINISHED:
- ActionMessage::setCompletionReply(&reply, actionId, true, HasReturnvaluesIF::RETURN_OK);
+ ActionMessage::setCompletionReply(&reply, actionId, true, returnvalue::OK);
queueToUse->sendMessage(commandedBy, &reply);
break;
default:
diff --git a/src/fsfw/action/SimpleActionHelper.h b/src/fsfw/action/SimpleActionHelper.h
index 5cb85fbd..cfe05231 100644
--- a/src/fsfw/action/SimpleActionHelper.h
+++ b/src/fsfw/action/SimpleActionHelper.h
@@ -11,15 +11,15 @@
class SimpleActionHelper : public ActionHelper {
public:
SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue);
- virtual ~SimpleActionHelper();
- void step(ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
- void finish(ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
+ ~SimpleActionHelper() override;
+ void step(ReturnValue_t result = returnvalue::OK);
+ void finish(ReturnValue_t result = returnvalue::OK);
ReturnValue_t reportData(SerializeIF* data);
protected:
void prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId,
- store_address_t dataAddress);
- virtual void resetHelper();
+ store_address_t dataAddress) override;
+ void resetHelper() override;
private:
bool isExecuting;
@@ -28,4 +28,4 @@ class SimpleActionHelper : public ActionHelper {
uint8_t stepCount = 0;
};
-#endif /* SIMPLEACTIONHELPER_H_ */
+#endif /* FSFW_ACTION_SIMPLEACTIONHELPER_H_ */
diff --git a/src/fsfw/cfdp.h b/src/fsfw/cfdp.h
new file mode 100644
index 00000000..86086432
--- /dev/null
+++ b/src/fsfw/cfdp.h
@@ -0,0 +1,10 @@
+#ifndef FSFW_CFDP_H
+#define FSFW_CFDP_H
+
+#include "cfdp/definitions.h"
+#include "cfdp/handler/FaultHandlerBase.h"
+#include "cfdp/tlv/Lv.h"
+#include "cfdp/tlv/StringLv.h"
+#include "cfdp/tlv/Tlv.h"
+
+#endif // FSFW_CFDP_H
diff --git a/src/fsfw/cfdp/CFDPHandler.cpp b/src/fsfw/cfdp/CFDPHandler.cpp
deleted file mode 100644
index 96baa98c..00000000
--- a/src/fsfw/cfdp/CFDPHandler.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "fsfw/cfdp/CFDPHandler.h"
-
-#include "fsfw/cfdp/CFDPMessage.h"
-#include "fsfw/ipc/CommandMessage.h"
-#include "fsfw/ipc/QueueFactory.h"
-#include "fsfw/objectmanager/ObjectManager.h"
-#include "fsfw/storagemanager/storeAddress.h"
-#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
-
-object_id_t CFDPHandler::packetSource = 0;
-object_id_t CFDPHandler::packetDestination = 0;
-
-CFDPHandler::CFDPHandler(object_id_t setObjectId, CFDPDistributor* dist)
- : SystemObject(setObjectId) {
- requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION);
- distributor = dist;
-}
-
-CFDPHandler::~CFDPHandler() {}
-
-ReturnValue_t CFDPHandler::initialize() {
- ReturnValue_t result = SystemObject::initialize();
- if (result != RETURN_OK) {
- return result;
- }
- this->distributor->registerHandler(this);
- return HasReturnvaluesIF::RETURN_OK;
-}
-
-ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) {
-#if FSFW_VERBOSE_LEVEL >= 1
-#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::debug << "CFDPHandler::handleRequest" << std::endl;
-#else
- sif::printDebug("CFDPHandler::handleRequest\n");
-#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
-#endif
-
- // TODO read out packet from store using storeId
-
- return RETURN_OK;
-}
-
-ReturnValue_t CFDPHandler::performOperation(uint8_t opCode) {
- ReturnValue_t status = RETURN_OK;
- CommandMessage currentMessage;
- for (status = this->requestQueue->receiveMessage(¤tMessage); status == RETURN_OK;
- status = this->requestQueue->receiveMessage(¤tMessage)) {
- store_address_t storeId = CFDPMessage::getStoreId(¤tMessage);
- this->handleRequest(storeId);
- }
- return RETURN_OK;
-}
-
-uint16_t CFDPHandler::getIdentifier() { return 0; }
-
-MessageQueueId_t CFDPHandler::getRequestQueue() { return this->requestQueue->getId(); }
diff --git a/src/fsfw/cfdp/CFDPHandler.h b/src/fsfw/cfdp/CFDPHandler.h
deleted file mode 100644
index abbac6b6..00000000
--- a/src/fsfw/cfdp/CFDPHandler.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef FSFW_CFDP_CFDPHANDLER_H_
-#define FSFW_CFDP_CFDPHANDLER_H_
-
-#include "fsfw/ipc/MessageQueueIF.h"
-#include "fsfw/objectmanager/SystemObject.h"
-#include "fsfw/returnvalues/HasReturnvaluesIF.h"
-#include "fsfw/tasks/ExecutableObjectIF.h"
-#include "fsfw/tcdistribution/CFDPDistributor.h"
-#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
-
-namespace Factory {
-void setStaticFrameworkObjectIds();
-}
-
-class CFDPHandler : public ExecutableObjectIF,
- public AcceptsTelecommandsIF,
- public SystemObject,
- public HasReturnvaluesIF {
- friend void(Factory::setStaticFrameworkObjectIds)();
-
- public:
- CFDPHandler(object_id_t setObjectId, CFDPDistributor* distributor);
- /**
- * The destructor is empty.
- */
- virtual ~CFDPHandler();
-
- virtual ReturnValue_t handleRequest(store_address_t storeId);
-
- virtual ReturnValue_t initialize() override;
- virtual uint16_t getIdentifier() override;
- MessageQueueId_t getRequestQueue() override;
- ReturnValue_t performOperation(uint8_t opCode) override;
-
- protected:
- /**
- * This is a complete instance of the telecommand reception queue
- * of the class. It is initialized on construction of the class.
- */
- MessageQueueIF* requestQueue = nullptr;
-
- CFDPDistributor* distributor = nullptr;
-
- /**
- * The current CFDP packet to be processed.
- * It is deleted after handleRequest was executed.
- */
- CFDPPacketStored currentPacket;
-
- static object_id_t packetSource;
-
- static object_id_t packetDestination;
-
- private:
- /**
- * This constant sets the maximum number of packets accepted per call.
- * Remember that one packet must be completely handled in one
- * #handleRequest call.
- */
- static const uint8_t CFDP_HANDLER_MAX_RECEPTION = 100;
-};
-
-#endif /* FSFW_CFDP_CFDPHANDLER_H_ */
diff --git a/src/fsfw/cfdp/CFDPMessage.cpp b/src/fsfw/cfdp/CFDPMessage.cpp
deleted file mode 100644
index fee55715..00000000
--- a/src/fsfw/cfdp/CFDPMessage.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "CFDPMessage.h"
-
-CFDPMessage::CFDPMessage() {}
-
-CFDPMessage::~CFDPMessage() {}
-
-void CFDPMessage::setCommand(CommandMessage *message, store_address_t cfdpPacket) {
- message->setParameter(cfdpPacket.raw);
-}
-
-store_address_t CFDPMessage::getStoreId(const CommandMessage *message) {
- store_address_t storeAddressCFDPPacket;
- storeAddressCFDPPacket = message->getParameter();
- return storeAddressCFDPPacket;
-}
-
-void CFDPMessage::clear(CommandMessage *message) {}
diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt
index 0b926a9a..f4d60201 100644
--- a/src/fsfw/cfdp/CMakeLists.txt
+++ b/src/fsfw/cfdp/CMakeLists.txt
@@ -1,4 +1,6 @@
-target_sources(${LIB_FSFW_NAME} PRIVATE CFDPHandler.cpp CFDPMessage.cpp)
+target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp
+ VarLenFields.cpp helpers.cpp)
add_subdirectory(pdu)
add_subdirectory(tlv)
+add_subdirectory(handler)
diff --git a/src/fsfw/cfdp/CfdpDistributor.cpp b/src/fsfw/cfdp/CfdpDistributor.cpp
new file mode 100644
index 00000000..b233e67e
--- /dev/null
+++ b/src/fsfw/cfdp/CfdpDistributor.cpp
@@ -0,0 +1,55 @@
+#include "CfdpDistributor.h"
+
+#include "fsfw/tcdistribution/definitions.h"
+
+CfdpDistributor::CfdpDistributor(CfdpDistribCfg cfg)
+ : TcDistributorBase(cfg.objectId, cfg.tcQueue), cfg(cfg) {}
+
+ReturnValue_t CfdpDistributor::registerTcDestination(const cfdp::EntityId& address,
+ AcceptsTelecommandsIF& tcDest) {
+ for (const auto& dest : tcDestinations) {
+ if (dest.id == address) {
+ return returnvalue::FAILED;
+ }
+ }
+ tcDestinations.emplace_back(address, tcDest.getName(), tcDest.getRequestQueue());
+ return returnvalue::OK;
+}
+
+ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) {
+ auto accessorPair = cfg.tcStore.getData(currentMessage.getStorageId());
+ if (accessorPair.first != returnvalue::OK) {
+ return accessorPair.first;
+ }
+ ReturnValue_t result =
+ pduReader.setReadOnlyData(accessorPair.second.data(), accessorPair.second.size());
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ result = pduReader.parseData();
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ cfdp::EntityId foundId;
+ pduReader.getDestId(foundId);
+ bool destFound = false;
+ for (const auto& dest : tcDestinations) {
+ if (dest.id == foundId) {
+ destId = dest.queueId;
+ destFound = true;
+ }
+ }
+ if (not destFound) {
+ // TODO: Warning and event?
+ return tmtcdistrib::NO_DESTINATION_FOUND;
+ }
+ // Packet was forwarded successfully, so do not delete it.
+ accessorPair.second.release();
+ return returnvalue::OK;
+}
+
+const char* CfdpDistributor::getName() const { return "CFDP Distributor"; }
+
+uint32_t CfdpDistributor::getIdentifier() const { return 0; }
+
+MessageQueueId_t CfdpDistributor::getRequestQueue() const { return tcQueue->getId(); }
diff --git a/src/fsfw/cfdp/CfdpDistributor.h b/src/fsfw/cfdp/CfdpDistributor.h
new file mode 100644
index 00000000..13d000eb
--- /dev/null
+++ b/src/fsfw/cfdp/CfdpDistributor.h
@@ -0,0 +1,76 @@
+#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
+#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
+
+#include
+#include
+
+#include "fsfw/cfdp/pdu/PduHeaderReader.h"
+#include "fsfw/returnvalues/returnvalue.h"
+#include "fsfw/tcdistribution/CfdpPacketChecker.h"
+#include "fsfw/tcdistribution/TcDistributorBase.h"
+#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h"
+#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
+#include "fsfw/tmtcservices/VerificationReporter.h"
+
+struct CfdpDistribCfg {
+ CfdpDistribCfg(object_id_t objectId, StorageManagerIF& tcStore, MessageQueueIF* tcQueue)
+ : objectId(objectId), tcStore(tcStore), tcQueue(tcQueue) {}
+
+ object_id_t objectId;
+ StorageManagerIF& tcStore;
+ MessageQueueIF* tcQueue;
+};
+
+/**
+ * This will be the primary component to perform PDU forwading procedures. This includes forwarding
+ * CFDP TC packets to registered source or destination handlers, and forwarding all telemetry
+ * generated by them to registered TM sinks.
+ * @ingroup tc_distribution
+ */
+class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF {
+ public:
+ /**
+ * The ctor passes @c set_apid to the checker class and calls the
+ * TcDistribution ctor with a certain object id.
+ * @param setApid The APID of this receiving Application.
+ * @param setObjectId Object ID of the distributor itself
+ * @param setPacketSource Object ID of the source of TC packets.
+ * Must implement CcsdsDistributorIF.
+ */
+ explicit CfdpDistributor(CfdpDistribCfg cfg);
+
+ [[nodiscard]] const char* getName() const override;
+ [[nodiscard]] uint32_t getIdentifier() const override;
+ [[nodiscard]] MessageQueueId_t getRequestQueue() const override;
+
+ /**
+ * Register a new CFDP entity which can receive PDUs.
+ * @param address
+ * @param tcDest
+ * @return
+ * - @c RETURN_FAILED: Entry already exists for the given address
+ */
+ ReturnValue_t registerTcDestination(const cfdp::EntityId& address, AcceptsTelecommandsIF& tcDest);
+
+ protected:
+ struct EntityInfo {
+ EntityInfo(cfdp::EntityId id, const char* name, MessageQueueId_t queueId)
+ : id(std::move(id)), name(name), queueId(queueId) {}
+ cfdp::EntityId id;
+ const char* name;
+ MessageQueueId_t queueId;
+ };
+ PduHeaderReader pduReader;
+ ReturnValue_t lastTcError = returnvalue::OK;
+ ReturnValue_t lastTmError = returnvalue::OK;
+ // I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think
+ // it is okay to accept the overhead here
+ std::vector tcDestinations;
+ CfdpDistribCfg cfg;
+
+ ReturnValue_t selectDestination(MessageQueueId_t& destId) override;
+
+ private:
+};
+
+#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ */
diff --git a/src/fsfw/cfdp/CfdpMessage.cpp b/src/fsfw/cfdp/CfdpMessage.cpp
new file mode 100644
index 00000000..ea4e2c98
--- /dev/null
+++ b/src/fsfw/cfdp/CfdpMessage.cpp
@@ -0,0 +1,17 @@
+#include "CfdpMessage.h"
+
+CfdpMessage::CfdpMessage() = default;
+
+CfdpMessage::~CfdpMessage() = default;
+
+void CfdpMessage::setCommand(CommandMessage *message, store_address_t cfdpPacket) {
+ message->setParameter(cfdpPacket.raw);
+}
+
+store_address_t CfdpMessage::getStoreId(const CommandMessage *message) {
+ store_address_t storeId;
+ storeId = static_cast(message->getParameter());
+ return storeId;
+}
+
+void CfdpMessage::clear(CommandMessage *message) {}
diff --git a/src/fsfw/cfdp/CFDPMessage.h b/src/fsfw/cfdp/CfdpMessage.h
similarity index 89%
rename from src/fsfw/cfdp/CFDPMessage.h
rename to src/fsfw/cfdp/CfdpMessage.h
index 3de723eb..a3ee9421 100644
--- a/src/fsfw/cfdp/CFDPMessage.h
+++ b/src/fsfw/cfdp/CfdpMessage.h
@@ -5,14 +5,14 @@
#include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
-class CFDPMessage {
+class CfdpMessage {
private:
- CFDPMessage();
+ CfdpMessage();
public:
static const uint8_t MESSAGE_ID = messagetypes::CFDP;
- virtual ~CFDPMessage();
+ virtual ~CfdpMessage();
static void setCommand(CommandMessage* message, store_address_t cfdpPacket);
static store_address_t getStoreId(const CommandMessage* message);
diff --git a/src/fsfw/cfdp/FileSize.h b/src/fsfw/cfdp/FileSize.h
index 6dae9683..b0b48452 100644
--- a/src/fsfw/cfdp/FileSize.h
+++ b/src/fsfw/cfdp/FileSize.h
@@ -1,5 +1,7 @@
-#ifndef FSFW_SRC_FSFW_CFDP_FILESIZE_H_
-#define FSFW_SRC_FSFW_CFDP_FILESIZE_H_
+#ifndef FSFW_CFDP_FILESIZE_H_
+#define FSFW_CFDP_FILESIZE_H_
+
+#include
#include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/serialize/SerializeIF.h"
@@ -8,9 +10,11 @@ namespace cfdp {
struct FileSize : public SerializeIF {
public:
- FileSize() : largeFile(false){};
+ FileSize() = default;
- FileSize(uint64_t fileSize, bool isLarge = false) { setFileSize(fileSize, isLarge); };
+ explicit FileSize(uint64_t fileSize, bool isLarge = false) { setFileSize(fileSize, isLarge); };
+
+ [[nodiscard]] uint64_t value() const { return fileSize; }
ReturnValue_t serialize(bool isLarge, uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) {
@@ -27,7 +31,7 @@ struct FileSize : public SerializeIF {
return SerializeAdapter::serialize(&fileSize, buffer, size, maxSize, streamEndianness);
}
- size_t getSerializedSize() const override {
+ [[nodiscard]] size_t getSerializedSize() const override {
if (largeFile) {
return 8;
} else {
@@ -43,27 +47,29 @@ struct FileSize : public SerializeIF {
uint32_t sizeTmp = 0;
ReturnValue_t result =
SerializeAdapter::deSerialize(&sizeTmp, buffer, size, streamEndianness);
- if (result == HasReturnvaluesIF::RETURN_OK) {
+ if (result == returnvalue::OK) {
fileSize = sizeTmp;
}
return result;
}
}
- ReturnValue_t setFileSize(uint64_t fileSize, bool largeFile) {
+ ReturnValue_t setFileSize(uint64_t fileSize_, std::optional largeFile_) {
+ if (largeFile_) {
+ largeFile = largeFile_.value();
+ }
if (not largeFile and fileSize > UINT32_MAX) {
// TODO: emit warning here
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
- this->fileSize = fileSize;
- this->largeFile = largeFile;
- return HasReturnvaluesIF::RETURN_OK;
+ this->fileSize = fileSize_;
+ return returnvalue::OK;
}
- bool isLargeFile() const { return largeFile; }
- uint64_t getSize(bool *largeFile = nullptr) const {
- if (largeFile != nullptr) {
- *largeFile = this->largeFile;
+ [[nodiscard]] bool isLargeFile() const { return largeFile; }
+ uint64_t getSize(bool *largeFile_ = nullptr) const {
+ if (largeFile_ != nullptr) {
+ *largeFile_ = this->largeFile;
}
return fileSize;
}
@@ -75,4 +81,4 @@ struct FileSize : public SerializeIF {
} // namespace cfdp
-#endif /* FSFW_SRC_FSFW_CFDP_FILESIZE_H_ */
+#endif /* FSFW_CFDP_FILESIZE_H_ */
diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/VarLenFields.cpp
similarity index 71%
rename from src/fsfw/cfdp/pdu/VarLenField.cpp
rename to src/fsfw/cfdp/VarLenFields.cpp
index b11c3b09..b9e0b3a8 100644
--- a/src/fsfw/cfdp/pdu/VarLenField.cpp
+++ b/src/fsfw/cfdp/VarLenFields.cpp
@@ -1,12 +1,11 @@
-#include "VarLenField.h"
+#include "VarLenFields.h"
-#include "fsfw/FSFW.h"
#include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/serviceinterface.h"
cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, size_t value) : VarLenField() {
ReturnValue_t result = this->setValue(width, value);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
#if FSFW_DISABLE_PRINTOUT == 0
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "cfdp::VarLenField: Setting value failed" << std::endl;
@@ -21,27 +20,27 @@ cfdp::VarLenField::VarLenField() : width(cfdp::WidthInBytes::ONE_BYTE) { value.o
cfdp::WidthInBytes cfdp::VarLenField::getWidth() const { return width; }
-ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_t value) {
+ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_t value_) {
switch (widthInBytes) {
case (cfdp::WidthInBytes::ONE_BYTE): {
- if (value > UINT8_MAX) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ if (value_ > UINT8_MAX) {
+ return returnvalue::FAILED;
}
- this->value.oneByte = value;
+ this->value.oneByte = value_;
break;
}
case (cfdp::WidthInBytes::TWO_BYTES): {
- if (value > UINT16_MAX) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ if (value_ > UINT16_MAX) {
+ return returnvalue::FAILED;
}
- this->value.twoBytes = value;
+ this->value.twoBytes = value_;
break;
}
case (cfdp::WidthInBytes::FOUR_BYTES): {
- if (value > UINT32_MAX) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ if (value_ > UINT32_MAX) {
+ return returnvalue::FAILED;
}
- this->value.fourBytes = value;
+ this->value.fourBytes = value_;
break;
}
default: {
@@ -49,7 +48,7 @@ ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_
}
}
this->width = widthInBytes;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
size_t cfdp::VarLenField::getValue() const {
@@ -77,7 +76,7 @@ ReturnValue_t cfdp::VarLenField::serialize(uint8_t **buffer, size_t *size, size_
**buffer = value.oneByte;
*size += 1;
*buffer += 1;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
case (cfdp::WidthInBytes::TWO_BYTES): {
return SerializeAdapter::serialize(&value.twoBytes, buffer, size, maxSize, streamEndianness);
@@ -86,16 +85,16 @@ ReturnValue_t cfdp::VarLenField::serialize(uint8_t **buffer, size_t *size, size_
return SerializeAdapter::serialize(&value.fourBytes, buffer, size, maxSize, streamEndianness);
}
default: {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
}
size_t cfdp::VarLenField::getSerializedSize() const { return width; }
-ReturnValue_t cfdp::VarLenField::deSerialize(cfdp::WidthInBytes width, const uint8_t **buffer,
+ReturnValue_t cfdp::VarLenField::deSerialize(cfdp::WidthInBytes width_, const uint8_t **buffer,
size_t *size, Endianness streamEndianness) {
- this->width = width;
+ this->width = width_;
return deSerialize(buffer, size, streamEndianness);
}
@@ -105,7 +104,7 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz
case (cfdp::WidthInBytes::ONE_BYTE): {
value.oneByte = **buffer;
*size += 1;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
case (cfdp::WidthInBytes::TWO_BYTES): {
return SerializeAdapter::deSerialize(&value.twoBytes, buffer, size, streamEndianness);
@@ -114,7 +113,25 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz
return SerializeAdapter::deSerialize(&value.fourBytes, buffer, size, streamEndianness);
}
default: {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
}
+
+bool cfdp::VarLenField::operator<(const cfdp::VarLenField &other) const {
+ if (getWidth() < other.getWidth()) {
+ return true;
+ } else if (getWidth() == other.getWidth()) {
+ return getValue() < other.getValue();
+ } else {
+ return false;
+ }
+}
+
+bool cfdp::VarLenField::operator==(const cfdp::VarLenField &other) const {
+ return getWidth() == other.getWidth() and getValue() == other.getValue();
+}
+
+bool cfdp::VarLenField::operator!=(const cfdp::VarLenField &other) const {
+ return not(*this == other);
+}
diff --git a/src/fsfw/cfdp/VarLenFields.h b/src/fsfw/cfdp/VarLenFields.h
new file mode 100644
index 00000000..37602c75
--- /dev/null
+++ b/src/fsfw/cfdp/VarLenFields.h
@@ -0,0 +1,107 @@
+#ifndef FSFW_CFDP_PDU_VARLENFIELD_H_
+#define FSFW_CFDP_PDU_VARLENFIELD_H_
+
+#include
+#include
+#include
+
+#include "fsfw/cfdp/definitions.h"
+#include "fsfw/serialize/SerializeIF.h"
+#include "fsfw/serviceinterface.h"
+#include "fsfw/util/UnsignedByteField.h"
+
+namespace cfdp {
+
+class VarLenField : public SerializeIF {
+ public:
+ union LengthFieldLen {
+ uint8_t oneByte;
+ uint16_t twoBytes;
+ uint32_t fourBytes;
+ uint64_t eightBytes;
+ };
+
+ VarLenField();
+ template
+ explicit VarLenField(UnsignedByteField byteField);
+
+ VarLenField(cfdp::WidthInBytes width, size_t value);
+
+ bool operator==(const VarLenField &other) const;
+ bool operator!=(const VarLenField &other) const;
+ bool operator<(const VarLenField &other) const;
+
+ ReturnValue_t setValue(cfdp::WidthInBytes, size_t value);
+
+ ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const override;
+
+ [[nodiscard]] size_t getSerializedSize() const override;
+
+ ReturnValue_t deSerialize(cfdp::WidthInBytes width, const uint8_t **buffer, size_t *size,
+ Endianness streamEndianness);
+
+ [[nodiscard]] cfdp::WidthInBytes getWidth() const;
+ [[nodiscard]] size_t getValue() const;
+
+#if FSFW_CPP_OSTREAM_ENABLED == 1
+ friend std::ostream &operator<<(std::ostream &os, const VarLenField &id) {
+ os << "dec: " << id.getValue() << ", hex: " << std::hex << std::setw(id.getWidth())
+ << std::setfill('0') << id.getValue() << std::dec << std::setfill('0');
+ return os;
+ }
+#endif
+
+ private:
+ ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
+ Endianness streamEndianness) override;
+
+ cfdp::WidthInBytes width;
+ LengthFieldLen value{};
+};
+
+template
+cfdp::VarLenField::VarLenField(UnsignedByteField byteField)
+ : width(static_cast(sizeof(T))) {
+ static_assert((sizeof(T) % 2) == 0);
+ setValue(width, byteField.getValue());
+}
+
+struct EntityId : public VarLenField {
+ public:
+ EntityId() : VarLenField() {}
+ template
+ explicit EntityId(UnsignedByteField byteField) : VarLenField(byteField) {}
+ EntityId(cfdp::WidthInBytes width, size_t entityId) : VarLenField(width, entityId) {}
+};
+
+struct TransactionSeqNum : public VarLenField {
+ public:
+ TransactionSeqNum() : VarLenField() {}
+ template
+ explicit TransactionSeqNum(UnsignedByteField byteField) : VarLenField(byteField) {}
+ TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {}
+};
+
+struct TransactionId {
+ TransactionId() = default;
+ TransactionId(EntityId entityId, TransactionSeqNum seqNum)
+ : entityId(std::move(entityId)), seqNum(std::move(seqNum)) {}
+
+ bool operator==(const TransactionId &other) const {
+ return entityId == other.entityId and seqNum == other.seqNum;
+ }
+
+#if FSFW_CPP_OSTREAM_ENABLED == 1
+ friend std::ostream &operator<<(std::ostream &os, const TransactionId &id) {
+ os << "Source ID { " << id.entityId << " }, Sequence Number " << id.seqNum.getValue();
+ return os;
+ }
+#endif
+ EntityId entityId;
+ TransactionSeqNum seqNum;
+};
+
+} // namespace cfdp
+
+#endif /* FSFW_CFDP_PDU_VARLENFIELD_H_ */
diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h
index eb21f5bf..2d7a37fc 100644
--- a/src/fsfw/cfdp/definitions.h
+++ b/src/fsfw/cfdp/definitions.h
@@ -7,36 +7,37 @@
#include
#include "fsfw/returnvalues/FwClassIds.h"
-#include "fsfw/returnvalues/HasReturnvaluesIF.h"
+#include "fsfw/returnvalues/returnvalue.h"
namespace cfdp {
-static constexpr uint8_t VERSION_BITS = 0b00100000;
+static constexpr char CFDP_VERSION_2_NAME[] = "CCSDS 727.0-B-5";
+
+// Second version of the protocol, only this one is supported here
+static constexpr uint8_t CFDP_VERSION_2 = 0b001;
+static constexpr uint8_t VERSION_BITS = CFDP_VERSION_2 << 5;
static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP;
-static constexpr ReturnValue_t INVALID_TLV_TYPE =
- HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 1);
-static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS =
- HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 2);
-static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN =
- HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 3);
+static constexpr ReturnValue_t INVALID_TLV_TYPE = returnvalue::makeCode(CFDP_CLASS_ID, 1);
+static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELD = returnvalue::makeCode(CFDP_CLASS_ID, 2);
+static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = returnvalue::makeCode(CFDP_CLASS_ID, 3);
static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS =
- HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 4);
+ returnvalue::makeCode(CFDP_CLASS_ID, 4);
//! Can not parse options. This can also occur because there are options
//! available but the user did not pass a valid options array
static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS =
- HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 5);
-static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS =
- HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 6);
+ returnvalue::makeCode(CFDP_CLASS_ID, 5);
+static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = returnvalue::makeCode(CFDP_CLASS_ID, 6);
static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES =
- HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 6);
+ returnvalue::makeCode(CFDP_CLASS_ID, 7);
static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE =
- HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 8);
+ returnvalue::makeCode(CFDP_CLASS_ID, 8);
//! Can not parse filestore response because user did not pass a valid instance
//! or remaining size is invalid
static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE =
- HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 9);
+ returnvalue::makeCode(CFDP_CLASS_ID, 9);
+static constexpr ReturnValue_t INVALID_PDU_FORMAT = returnvalue::makeCode(CFDP_CLASS_ID, 10);
//! Checksum types according to the SANA Checksum Types registry
//! https://sanaregistry.org/r/checksum_identifiers/
@@ -49,17 +50,17 @@ enum ChecksumType {
NULL_CHECKSUM = 15
};
-enum PduType : bool { FILE_DIRECTIVE = 0, FILE_DATA = 1 };
+enum PduType : uint8_t { FILE_DIRECTIVE = 0, FILE_DATA = 1 };
-enum TransmissionModes : bool { ACKNOWLEDGED = 0, UNACKNOWLEDGED = 1 };
+enum TransmissionMode : uint8_t { ACKNOWLEDGED = 0, UNACKNOWLEDGED = 1 };
-enum SegmentMetadataFlag : bool { NOT_PRESENT = 0, PRESENT = 1 };
+enum SegmentMetadataFlag : bool { NOT_PRESENT = false, PRESENT = true };
-enum Direction : bool { TOWARDS_RECEIVER = 0, TOWARDS_SENDER = 1 };
+enum Direction : uint8_t { TOWARDS_RECEIVER = 0, TOWARDS_SENDER = 1 };
enum SegmentationControl : bool {
- NO_RECORD_BOUNDARIES_PRESERVATION = 0,
- RECORD_BOUNDARIES_PRESERVATION = 1
+ NO_RECORD_BOUNDARIES_PRESERVATION = false,
+ RECORD_BOUNDARIES_PRESERVATION = true
};
enum WidthInBytes : uint8_t {
@@ -69,8 +70,9 @@ enum WidthInBytes : uint8_t {
FOUR_BYTES = 4,
};
-enum FileDirectives : uint8_t {
+enum FileDirective : uint8_t {
INVALID_DIRECTIVE = 0x0f,
+ // The _DIRECTIVE suffix is mandatory here because of some nameclash!
EOF_DIRECTIVE = 0x04,
FINISH = 0x05,
ACK = 0x06,
@@ -97,6 +99,14 @@ enum ConditionCode : uint8_t {
CANCEL_REQUEST_RECEIVED = 0b1111
};
+enum FaultHandlerCode {
+ RESERVED = 0b0000,
+ NOTICE_OF_CANCELLATION = 0b0001,
+ NOTICE_OF_SUSPENSION = 0b0010,
+ IGNORE_ERROR = 0b0011,
+ ABANDON_TRANSACTION = 0b0100
+};
+
enum AckTransactionStatus {
UNDEFINED = 0b00,
ACTIVE = 0b01,
@@ -104,18 +114,18 @@ enum AckTransactionStatus {
UNRECOGNIZED = 0b11
};
-enum FinishedDeliveryCode { DATA_COMPLETE = 0, DATA_INCOMPLETE = 1 };
+enum FileDeliveryCode { DATA_COMPLETE = 0, DATA_INCOMPLETE = 1 };
-enum FinishedFileStatus {
+enum FileDeliveryStatus {
DISCARDED_DELIBERATELY = 0,
DISCARDED_FILESTORE_REJECTION = 1,
RETAINED_IN_FILESTORE = 2,
FILE_STATUS_UNREPORTED = 3
};
-enum PromptResponseRequired : bool { PROMPT_NAK = 0, PROMPT_KEEP_ALIVE = 1 };
+enum PromptResponseRequired : uint8_t { PROMPT_NAK = 0, PROMPT_KEEP_ALIVE = 1 };
-enum TlvTypes : uint8_t {
+enum TlvType : uint8_t {
FILESTORE_REQUEST = 0x00,
FILESTORE_RESPONSE = 0x01,
MSG_TO_USER = 0x02,
diff --git a/src/fsfw/cfdp/handler/CMakeLists.txt b/src/fsfw/cfdp/handler/CMakeLists.txt
new file mode 100644
index 00000000..90130806
--- /dev/null
+++ b/src/fsfw/cfdp/handler/CMakeLists.txt
@@ -0,0 +1 @@
+target_sources(${LIB_FSFW_NAME} PRIVATE FaultHandlerBase.cpp UserBase.cpp)
diff --git a/src/fsfw/cfdp/handler/FaultHandlerBase.cpp b/src/fsfw/cfdp/handler/FaultHandlerBase.cpp
new file mode 100644
index 00000000..4e16692e
--- /dev/null
+++ b/src/fsfw/cfdp/handler/FaultHandlerBase.cpp
@@ -0,0 +1,51 @@
+#include "FaultHandlerBase.h"
+
+namespace cfdp {
+
+FaultHandlerBase::FaultHandlerBase() = default;
+FaultHandlerBase::~FaultHandlerBase() = default;
+
+bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCode code,
+ cfdp::FaultHandlerCode& handler) const {
+ auto iter = faultHandlerMap.find(code);
+ if (iter == faultHandlerMap.end()) {
+ return false;
+ }
+ handler = iter->second;
+ return true;
+}
+
+bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCode handler) {
+ if (not faultHandlerMap.contains(code)) {
+ return false;
+ }
+ if (handler != FaultHandlerCode::NOTICE_OF_SUSPENSION and
+ handler != FaultHandlerCode::ABANDON_TRANSACTION and
+ handler != FaultHandlerCode::NOTICE_OF_CANCELLATION and
+ handler != FaultHandlerCode::IGNORE_ERROR) {
+ return false;
+ }
+ faultHandlerMap[code] = handler;
+ return true;
+}
+
+bool FaultHandlerBase::reportFault(cfdp::TransactionId& id, cfdp::ConditionCode code) {
+ if (not faultHandlerMap.contains(code)) {
+ return false;
+ }
+ cfdp::FaultHandlerCode fh = faultHandlerMap[code];
+ if (fh == cfdp::FaultHandlerCode::IGNORE_ERROR) {
+ ignoreCb(id, code);
+ } else if (fh == cfdp::FaultHandlerCode::ABANDON_TRANSACTION) {
+ abandonCb(id, code);
+ } else if (fh == cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION) {
+ noticeOfCancellationCb(id, code);
+ } else if (fh == cfdp::FaultHandlerCode::NOTICE_OF_SUSPENSION) {
+ noticeOfSuspensionCb(id, code);
+ } else {
+ // Should never happen, but use defensive programming
+ return false;
+ }
+ return true;
+}
+} // namespace cfdp
diff --git a/src/fsfw/cfdp/handler/FaultHandlerBase.h b/src/fsfw/cfdp/handler/FaultHandlerBase.h
new file mode 100644
index 00000000..39b8e180
--- /dev/null
+++ b/src/fsfw/cfdp/handler/FaultHandlerBase.h
@@ -0,0 +1,77 @@
+#ifndef FSFW_CFDP_FAULTHANDLERBASE_H
+#define FSFW_CFDP_FAULTHANDLERBASE_H
+
+#include
+
+#include "fsfw/cfdp/VarLenFields.h"
+#include "fsfw/cfdp/definitions.h"
+
+namespace cfdp {
+
+/**
+ * @brief Provides a way to implement the fault handling procedures as specified
+ * in chapter 4.8 of the CFDP standard.
+ *
+ * @details
+ * It is passed into the CFDP handlers as part of the local entity configuration and provides
+ * a way to specify custom user error handlers.
+ *
+ * It does so by mapping each applicable CFDP condition code to a fault handler which
+ * is denoted by the four @cfdp::FaultHandlerCodes. This code is used to dispatch
+ * to a user-provided callback function:
+ *
+ * 1. @FaultHandlerCodes::IGNORE_ERROR -> @ignore_cb
+ * 2. @FaultHandlerCodes::NOTICE_OF_CANCELLATION` -> @notice_of_cancellation_cb
+ * 3. @FaultHandlerCodes::NOTICE_OF_SUSPENSION` -> @notice_of_suspension_cb
+ * 4. @FaultHandlerCodes::ABANDON_TRANSACTION` -> @abandon_transaction_cb
+ *
+ * For each error reported by @reportError, the appropriate fault handler callback
+ * will be called. The user provides the callbacks by providing a custom class which implements
+ * these base class and all abstract fault handler callbacks.
+ */
+class FaultHandlerBase {
+ public:
+ virtual ~FaultHandlerBase();
+ FaultHandlerBase();
+
+ /**
+ * Get the fault handler code for the given condition code
+ * @param code
+ * @param handler [out] Will be set to the approrpiate handler for the condition code if
+ * it is valid
+ * @return
+ * - true if the condition code is valid
+ * - false otherwise
+ */
+ bool getFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCode& handler) const;
+
+ bool setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCode handler);
+
+ bool reportFault(cfdp::TransactionId& id, cfdp::ConditionCode code);
+
+ virtual void noticeOfSuspensionCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0;
+ virtual void noticeOfCancellationCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0;
+ virtual void abandonCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0;
+ virtual void ignoreCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0;
+
+ private:
+ etl::flat_map faultHandlerMap = {
+ etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED,
+ cfdp::FaultHandlerCode::IGNORE_ERROR},
+ etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED,
+ cfdp::FaultHandlerCode::IGNORE_ERROR},
+ etl::pair{cfdp::ConditionCode::INVALID_TRANSMISSION_MODE,
+ cfdp::FaultHandlerCode::IGNORE_ERROR},
+ etl::pair{cfdp::ConditionCode::FILE_CHECKSUM_FAILURE, cfdp::FaultHandlerCode::IGNORE_ERROR},
+ etl::pair{cfdp::ConditionCode::FILE_SIZE_ERROR, cfdp::FaultHandlerCode::IGNORE_ERROR},
+ etl::pair{cfdp::ConditionCode::NAK_LIMIT_REACHED, cfdp::FaultHandlerCode::IGNORE_ERROR},
+ etl::pair{cfdp::ConditionCode::INACTIVITY_DETECTED, cfdp::FaultHandlerCode::IGNORE_ERROR},
+ etl::pair{cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE,
+ cfdp::FaultHandlerCode::IGNORE_ERROR},
+ etl::pair{cfdp::ConditionCode::FILESTORE_REJECTION, cfdp::FaultHandlerCode::IGNORE_ERROR},
+ etl::pair{cfdp::ConditionCode::CHECK_LIMIT_REACHED, cfdp::FaultHandlerCode::IGNORE_ERROR}};
+};
+
+} // namespace cfdp
+
+#endif // FSFW_CFDP_FAULTHANDLERBASE_H
diff --git a/src/fsfw/cfdp/handler/RemoteConfigTableIF.h b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h
new file mode 100644
index 00000000..d0e6121d
--- /dev/null
+++ b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h
@@ -0,0 +1,35 @@
+#ifndef FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H
+#define FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H
+
+#include "fsfw/cfdp/handler/mib.h"
+
+namespace cfdp {
+
+class RemoteConfigTableIF {
+ public:
+ virtual ~RemoteConfigTableIF() = default;
+ virtual bool getRemoteCfg(const cfdp::EntityId& remoteId, cfdp::RemoteEntityCfg** cfg) = 0;
+};
+
+/**
+ * Helper class for the common case that there is exactly one remote entity
+ */
+class OneRemoteConfigProvider : public RemoteConfigTableIF {
+ public:
+ explicit OneRemoteConfigProvider(RemoteEntityCfg cfg) : cfg(std::move(cfg)) {}
+
+ bool getRemoteCfg(const EntityId& remoteId, cfdp::RemoteEntityCfg** cfg_) override {
+ if (remoteId != cfg.remoteId) {
+ return false;
+ }
+ *cfg_ = &cfg;
+ return true;
+ }
+
+ private:
+ RemoteEntityCfg cfg;
+};
+
+} // namespace cfdp
+
+#endif // FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H
diff --git a/src/fsfw/cfdp/handler/StatusReportIF.h b/src/fsfw/cfdp/handler/StatusReportIF.h
new file mode 100644
index 00000000..1bf98628
--- /dev/null
+++ b/src/fsfw/cfdp/handler/StatusReportIF.h
@@ -0,0 +1,12 @@
+#ifndef FSFW_CFDP_HANDLER_STATUSREPORTIF_H
+#define FSFW_CFDP_HANDLER_STATUSREPORTIF_H
+
+namespace cfdp {
+
+class StatusReportIF {
+ virtual ~StatusReportIF() = default;
+};
+
+} // namespace cfdp
+
+#endif // FSFW_CFDP_HANDLER_STATUSREPORTIF_H
diff --git a/src/fsfw/cfdp/handler/UserBase.cpp b/src/fsfw/cfdp/handler/UserBase.cpp
new file mode 100644
index 00000000..212396fb
--- /dev/null
+++ b/src/fsfw/cfdp/handler/UserBase.cpp
@@ -0,0 +1,3 @@
+#include "UserBase.h"
+
+cfdp::UserBase::UserBase(HasFileSystemIF& vfs) : vfs(vfs) {}
diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h
new file mode 100644
index 00000000..e367b4a8
--- /dev/null
+++ b/src/fsfw/cfdp/handler/UserBase.h
@@ -0,0 +1,101 @@
+#ifndef FSFW_CFDP_USERBASE_H
+#define FSFW_CFDP_USERBASE_H
+
+#include
+#include
+#include
+
+#include "StatusReportIF.h"
+#include "fsfw/cfdp/VarLenFields.h"
+#include "fsfw/cfdp/tlv/FilestoreResponseTlv.h"
+#include "fsfw/cfdp/tlv/MessageToUserTlv.h"
+#include "fsfw/filesystem/HasFileSystemIF.h"
+
+namespace cfdp {
+
+struct TransactionFinishedParams {
+ TransactionFinishedParams(const TransactionId& id, ConditionCode code, FileDeliveryCode delivCode,
+ FileDeliveryStatus status)
+ : id(id), condCode(code), status(status), deliveryCode(delivCode) {}
+
+ const TransactionId& id;
+ ConditionCode condCode;
+ FileDeliveryStatus status;
+ FileDeliveryCode deliveryCode;
+ std::vector fsResponses;
+ StatusReportIF* statusReport = nullptr;
+};
+
+struct MetadataRecvdParams {
+ MetadataRecvdParams(const TransactionId& id, const EntityId& sourceId)
+ : id(id), sourceId(sourceId) {}
+ const TransactionId& id;
+ const EntityId& sourceId;
+ uint64_t fileSize = 0;
+ const char* sourceFileName = "";
+ const char* destFileName = "";
+ size_t msgsToUserLen = 0;
+ const MessageToUserTlv* msgsToUserArray = nullptr;
+};
+
+struct FileSegmentRecvdParams {
+ TransactionId id;
+ size_t offset;
+ size_t length;
+ std::optional recContState = std::nullopt;
+ std::pair segmentMetadata;
+};
+
+/**
+ * @brief Base class which provides a user interface to interact with CFDP handlers.
+ *
+ * @details
+ * This class is also used to pass the Virtual Filestore (VFS) Implementation to the CFDP
+ * handlers so the filestore operations can be mapped to the underlying filestore.
+ *
+ * It is used by implementing it in a child class and then passing it to the CFDP
+ * handler objects. The base class provides default implementation for the user indication
+ * primitives specified in the CFDP standard. The user can override these implementations
+ * to provide custom indication handlers.
+ *
+ * Please note that for all indication callbacks, the passed transaction ID reference will
+ * become invalid shortly after the function has been executed. If the transaction ID is to be
+ * cached or used, create an own copy of it.
+ * @param vfs Virtual Filestore Object. Will be used for all file operations
+ */
+class UserBase {
+ friend class DestHandler;
+
+ public:
+ explicit UserBase(HasFileSystemIF& vfs);
+
+ virtual void transactionIndication(const TransactionId& id) = 0;
+ virtual void eofSentIndication(const TransactionId& id) = 0;
+ virtual void transactionFinishedIndication(const TransactionFinishedParams& params) = 0;
+ /**
+ * Will be called if metadata was received.
+ *
+ * IMPORTANT: The passed struct contains the messages to the user in form of a raw C array.
+ * The TLVs in these arrays are zero-copy types, which means that they point to the raw data
+ * inside the metadata packet directly. The metadata packet will be deleted from the TC store
+ * shortly after it was processed. If some of the data is to be cached and/or used after the
+ * function call, it needs to be copied into another user-provided buffer.
+ * @param params
+ */
+ virtual void metadataRecvdIndication(const MetadataRecvdParams& params) = 0;
+ virtual void fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) = 0;
+ virtual void reportIndication(const TransactionId& id, StatusReportIF& report) = 0;
+ virtual void suspendedIndication(const TransactionId& id, ConditionCode code) = 0;
+ virtual void resumedIndication(const TransactionId& id, size_t progress) = 0;
+ virtual void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) = 0;
+ virtual void abandonedIndication(const TransactionId& id, ConditionCode code,
+ size_t progress) = 0;
+ virtual void eofRecvIndication(const TransactionId& id) = 0;
+
+ private:
+ HasFileSystemIF& vfs;
+};
+
+} // namespace cfdp
+
+#endif // FSFW_CFDP_USERBASE_H
diff --git a/src/fsfw/cfdp/handler/defs.h b/src/fsfw/cfdp/handler/defs.h
new file mode 100644
index 00000000..9e837a96
--- /dev/null
+++ b/src/fsfw/cfdp/handler/defs.h
@@ -0,0 +1,9 @@
+#ifndef FSFW_CFDP_HANDLER_DEFS_H
+#define FSFW_CFDP_HANDLER_DEFS_H
+
+namespace cfdp {
+
+enum class CfdpStates { IDLE, BUSY_CLASS_1_NACKED, BUSY_CLASS_2_ACKED, SUSPENDED };
+
+}
+#endif // FSFW_CFDP_HANDLER_DEFS_H
diff --git a/src/fsfw/cfdp/handler/mib.h b/src/fsfw/cfdp/handler/mib.h
new file mode 100644
index 00000000..553596a6
--- /dev/null
+++ b/src/fsfw/cfdp/handler/mib.h
@@ -0,0 +1,42 @@
+#ifndef FSFW_CFDP_MIB_H
+#define FSFW_CFDP_MIB_H
+
+#include
+
+#include "FaultHandlerBase.h"
+#include "fsfw/cfdp/pdu/PduConfig.h"
+
+namespace cfdp {
+
+struct IndicationCfg {
+ bool eofSentIndicRequired = true;
+ bool eofRecvIndicRequired = true;
+ bool fileSegmentRecvIndicRequired = true;
+ bool transactionFinishedIndicRequired = true;
+ bool suspendedIndicRequired = true;
+ bool resumedIndicRequired = true;
+};
+
+struct LocalEntityCfg {
+ LocalEntityCfg(EntityId localId, IndicationCfg indicationCfg, FaultHandlerBase& fhBase)
+ : localId(std::move(localId)), indicCfg(indicationCfg), fhBase(fhBase) {}
+
+ EntityId localId;
+ IndicationCfg indicCfg;
+ FaultHandlerBase& fhBase;
+};
+
+struct RemoteEntityCfg {
+ explicit RemoteEntityCfg(EntityId id) : remoteId(std::move(id)) {}
+ EntityId remoteId;
+ size_t maxFileSegmentLen = 2048;
+ bool closureRequested = false;
+ bool crcOnTransmission = false;
+ TransmissionMode defaultTransmissionMode = TransmissionMode::UNACKNOWLEDGED;
+ ChecksumType defaultChecksum = ChecksumType::NULL_CHECKSUM;
+ const uint8_t version = CFDP_VERSION_2;
+};
+
+} // namespace cfdp
+
+#endif // FSFW_CFDP_MIB_H
diff --git a/src/fsfw/cfdp/helpers.cpp b/src/fsfw/cfdp/helpers.cpp
new file mode 100644
index 00000000..fdb7d5ff
--- /dev/null
+++ b/src/fsfw/cfdp/helpers.cpp
@@ -0,0 +1,50 @@
+#include "helpers.h"
+
+const char* COND_CODE_STRINGS[14] = {"Unknown",
+ "No Error",
+ "Positive ACK Limit Reached",
+ "Keep Alive Limit Reached",
+ "Invalid Transmission Mode",
+ "Filestore Rejection",
+ "File Checksum Failure",
+ "File Size Error",
+ "NAK limit reached",
+ "Inactivity Detected",
+ "Check Limit Reached",
+ "Unsupported Checksum Type",
+ "Suspend Request Received",
+ "Cancel Request Received"};
+
+const char* cfdp::getConditionCodeString(cfdp::ConditionCode code) {
+ switch (code) {
+ case NO_CONDITION_FIELD:
+ return COND_CODE_STRINGS[0];
+ case NO_ERROR:
+ return COND_CODE_STRINGS[1];
+ case POSITIVE_ACK_LIMIT_REACHED:
+ return COND_CODE_STRINGS[2];
+ case KEEP_ALIVE_LIMIT_REACHED:
+ return COND_CODE_STRINGS[3];
+ case INVALID_TRANSMISSION_MODE:
+ return COND_CODE_STRINGS[4];
+ case FILESTORE_REJECTION:
+ return COND_CODE_STRINGS[5];
+ case FILE_CHECKSUM_FAILURE:
+ return COND_CODE_STRINGS[6];
+ case FILE_SIZE_ERROR:
+ return COND_CODE_STRINGS[7];
+ case NAK_LIMIT_REACHED:
+ return COND_CODE_STRINGS[8];
+ case INACTIVITY_DETECTED:
+ return COND_CODE_STRINGS[9];
+ case CHECK_LIMIT_REACHED:
+ return COND_CODE_STRINGS[10];
+ case UNSUPPORTED_CHECKSUM_TYPE:
+ return COND_CODE_STRINGS[11];
+ case SUSPEND_REQUEST_RECEIVED:
+ return COND_CODE_STRINGS[12];
+ case CANCEL_REQUEST_RECEIVED:
+ return COND_CODE_STRINGS[13];
+ }
+ return "Unknown";
+}
diff --git a/src/fsfw/cfdp/helpers.h b/src/fsfw/cfdp/helpers.h
new file mode 100644
index 00000000..37428108
--- /dev/null
+++ b/src/fsfw/cfdp/helpers.h
@@ -0,0 +1,11 @@
+#ifndef FSFW_EXAMPLE_HOSTED_HELPER_H
+#define FSFW_EXAMPLE_HOSTED_HELPER_H
+
+#include "definitions.h"
+
+namespace cfdp {
+
+const char* getConditionCodeString(cfdp::ConditionCode code);
+
+}
+#endif // FSFW_EXAMPLE_HOSTED_HELPER_H
diff --git a/src/fsfw/cfdp/pdu/AckInfo.cpp b/src/fsfw/cfdp/pdu/AckInfo.cpp
index f35cfbb1..963f7cbb 100644
--- a/src/fsfw/cfdp/pdu/AckInfo.cpp
+++ b/src/fsfw/cfdp/pdu/AckInfo.cpp
@@ -1,12 +1,12 @@
#include "AckInfo.h"
-AckInfo::AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCode ackedConditionCode,
+AckInfo::AckInfo(cfdp::FileDirective ackedDirective, cfdp::ConditionCode ackedConditionCode,
cfdp::AckTransactionStatus transactionStatus, uint8_t directiveSubtypeCode)
: ackedDirective(ackedDirective),
ackedConditionCode(ackedConditionCode),
transactionStatus(transactionStatus),
directiveSubtypeCode(directiveSubtypeCode) {
- if (ackedDirective == cfdp::FileDirectives::FINISH) {
+ if (ackedDirective == cfdp::FileDirective::FINISH) {
this->directiveSubtypeCode = 0b0001;
} else {
this->directiveSubtypeCode = 0b0000;
@@ -17,16 +17,16 @@ cfdp::ConditionCode AckInfo::getAckedConditionCode() const { return ackedConditi
void AckInfo::setAckedConditionCode(cfdp::ConditionCode ackedConditionCode) {
this->ackedConditionCode = ackedConditionCode;
- if (ackedDirective == cfdp::FileDirectives::FINISH) {
+ if (ackedDirective == cfdp::FileDirective::FINISH) {
this->directiveSubtypeCode = 0b0001;
} else {
this->directiveSubtypeCode = 0b0000;
}
}
-cfdp::FileDirectives AckInfo::getAckedDirective() const { return ackedDirective; }
+cfdp::FileDirective AckInfo::getAckedDirective() const { return ackedDirective; }
-void AckInfo::setAckedDirective(cfdp::FileDirectives ackedDirective) {
+void AckInfo::setAckedDirective(cfdp::FileDirective ackedDirective) {
this->ackedDirective = ackedDirective;
}
diff --git a/src/fsfw/cfdp/pdu/AckInfo.h b/src/fsfw/cfdp/pdu/AckInfo.h
index 572fc59f..23e4d6ab 100644
--- a/src/fsfw/cfdp/pdu/AckInfo.h
+++ b/src/fsfw/cfdp/pdu/AckInfo.h
@@ -6,14 +6,14 @@
class AckInfo {
public:
AckInfo();
- AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCode ackedConditionCode,
+ AckInfo(cfdp::FileDirective ackedDirective, cfdp::ConditionCode ackedConditionCode,
cfdp::AckTransactionStatus transactionStatus, uint8_t directiveSubtypeCode = 0);
cfdp::ConditionCode getAckedConditionCode() const;
void setAckedConditionCode(cfdp::ConditionCode ackedConditionCode);
- cfdp::FileDirectives getAckedDirective() const;
- void setAckedDirective(cfdp::FileDirectives ackedDirective);
+ cfdp::FileDirective getAckedDirective() const;
+ void setAckedDirective(cfdp::FileDirective ackedDirective);
uint8_t getDirectiveSubtypeCode() const;
void setDirectiveSubtypeCode(uint8_t directiveSubtypeCode);
@@ -22,7 +22,7 @@ class AckInfo {
void setTransactionStatus(cfdp::AckTransactionStatus transactionStatus);
private:
- cfdp::FileDirectives ackedDirective = cfdp::FileDirectives::INVALID_DIRECTIVE;
+ cfdp::FileDirective ackedDirective = cfdp::FileDirective::INVALID_DIRECTIVE;
cfdp::ConditionCode ackedConditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD;
cfdp::AckTransactionStatus transactionStatus = cfdp::AckTransactionStatus::UNDEFINED;
uint8_t directiveSubtypeCode = 0;
diff --git a/src/fsfw/cfdp/pdu/AckPduCreator.cpp b/src/fsfw/cfdp/pdu/AckPduCreator.cpp
new file mode 100644
index 00000000..f7623e57
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/AckPduCreator.cpp
@@ -0,0 +1,33 @@
+#include "AckPduCreator.h"
+
+AckPduCreator::AckPduCreator(AckInfo &ackInfo, PduConfig &pduConf)
+ : FileDirectiveCreator(pduConf, cfdp::FileDirective::ACK, 2), ackInfo(ackInfo) {}
+
+size_t AckPduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); }
+
+ReturnValue_t AckPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const {
+ ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ cfdp::FileDirective ackedDirective = ackInfo.getAckedDirective();
+ uint8_t directiveSubtypeCode = ackInfo.getDirectiveSubtypeCode();
+ cfdp::ConditionCode ackedConditionCode = ackInfo.getAckedConditionCode();
+ cfdp::AckTransactionStatus transactionStatus = ackInfo.getTransactionStatus();
+ if (ackedDirective != cfdp::FileDirective::FINISH and
+ ackedDirective != cfdp::FileDirective::EOF_DIRECTIVE) {
+ // TODO: better returncode
+ return returnvalue::FAILED;
+ }
+ if (*size + 2 > maxSize) {
+ return SerializeIF::BUFFER_TOO_SHORT;
+ }
+ **buffer = ackedDirective << 4 | directiveSubtypeCode;
+ *buffer += 1;
+ *size += 1;
+ **buffer = ackedConditionCode << 4 | transactionStatus;
+ *buffer += 1;
+ *size += 1;
+ return returnvalue::OK;
+}
diff --git a/src/fsfw/cfdp/pdu/AckPduSerializer.h b/src/fsfw/cfdp/pdu/AckPduCreator.h
similarity index 53%
rename from src/fsfw/cfdp/pdu/AckPduSerializer.h
rename to src/fsfw/cfdp/pdu/AckPduCreator.h
index 68a049e2..c0a89cc3 100644
--- a/src/fsfw/cfdp/pdu/AckPduSerializer.h
+++ b/src/fsfw/cfdp/pdu/AckPduCreator.h
@@ -1,11 +1,11 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_
+#ifndef FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_
+#define FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_
#include "AckInfo.h"
-#include "FileDirectiveDeserializer.h"
-#include "FileDirectiveSerializer.h"
+#include "FileDirectiveCreator.h"
+#include "FileDirectiveReader.h"
-class AckPduSerializer : public FileDirectiveSerializer {
+class AckPduCreator : public FileDirectiveCreator {
public:
/**
* @brief Serializer to pack ACK PDUs
@@ -16,9 +16,9 @@ class AckPduSerializer : public FileDirectiveSerializer {
* @param transactionStatus
* @param pduConf
*/
- AckPduSerializer(AckInfo& ackInfo, PduConfig& pduConf);
+ AckPduCreator(AckInfo& ackInfo, PduConfig& pduConf);
- size_t getSerializedSize() const override;
+ [[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
@@ -27,4 +27,4 @@ class AckPduSerializer : public FileDirectiveSerializer {
AckInfo& ackInfo;
};
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_ */
+#endif /* FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp
deleted file mode 100644
index f5babf4b..00000000
--- a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "AckPduDeserializer.h"
-
-AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info)
- : FileDirectiveDeserializer(pduBuf, maxSize), info(info) {}
-
-ReturnValue_t AckPduDeserializer::parseData() {
- ReturnValue_t result = FileDirectiveDeserializer::parseData();
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
- if (currentIdx + 2 > this->maxSize) {
- return SerializeIF::BUFFER_TOO_SHORT;
- }
- if (not checkAndSetCodes(rawPtr[currentIdx], rawPtr[currentIdx + 1])) {
- return cfdp::INVALID_ACK_DIRECTIVE_FIELDS;
- }
- return HasReturnvaluesIF::RETURN_OK;
-}
-
-bool AckPduDeserializer::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) {
- uint8_t ackedDirective = static_cast(firstByte >> 4);
-
- if (ackedDirective != cfdp::FileDirectives::EOF_DIRECTIVE and
- ackedDirective != cfdp::FileDirectives::FINISH) {
- return false;
- }
- this->info.setAckedDirective(static_cast(ackedDirective));
- uint8_t directiveSubtypeCode = firstByte & 0x0f;
- if (directiveSubtypeCode != 0b0000 and directiveSubtypeCode != 0b0001) {
- return false;
- }
- this->info.setDirectiveSubtypeCode(directiveSubtypeCode);
- this->info.setAckedConditionCode(static_cast(secondByte >> 4));
- this->info.setTransactionStatus(static_cast(secondByte & 0x0f));
- return true;
-}
diff --git a/src/fsfw/cfdp/pdu/AckPduReader.cpp b/src/fsfw/cfdp/pdu/AckPduReader.cpp
new file mode 100644
index 00000000..7204ced0
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/AckPduReader.cpp
@@ -0,0 +1,45 @@
+#include "AckPduReader.h"
+
+AckPduReader::AckPduReader(const uint8_t* pduBuf, size_t maxSize, AckInfo& info)
+ : FileDirectiveReader(pduBuf, maxSize), info(info) {}
+
+ReturnValue_t AckPduReader::parseData() {
+ ReturnValue_t result = FileDirectiveReader::parseData();
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ size_t currentIdx = FileDirectiveReader::getHeaderSize();
+ if (currentIdx + 2 > this->maxSize) {
+ return SerializeIF::BUFFER_TOO_SHORT;
+ }
+ if (not checkAndSetCodes(pointers.rawPtr[currentIdx], pointers.rawPtr[currentIdx + 1])) {
+ return cfdp::INVALID_ACK_DIRECTIVE_FIELDS;
+ }
+ return returnvalue::OK;
+}
+
+bool AckPduReader::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) {
+ cfdp::FileDirective directive;
+ if (not checkAckedDirectiveField(firstByte, directive)) {
+ return false;
+ }
+ this->info.setAckedDirective(directive);
+ uint8_t directiveSubtypeCode = firstByte & 0x0f;
+ if (directiveSubtypeCode != 0b0000 and directiveSubtypeCode != 0b0001) {
+ return false;
+ }
+ this->info.setDirectiveSubtypeCode(directiveSubtypeCode);
+ this->info.setAckedConditionCode(static_cast(secondByte >> 4));
+ this->info.setTransactionStatus(static_cast(secondByte & 0x0f));
+ return true;
+}
+bool AckPduReader::checkAckedDirectiveField(uint8_t firstPduDataByte,
+ cfdp::FileDirective& ackedDirective) {
+ uint8_t ackedDirectiveRaw = static_cast(firstPduDataByte >> 4);
+ if (ackedDirectiveRaw != cfdp::FileDirective::EOF_DIRECTIVE and
+ ackedDirectiveRaw != cfdp::FileDirective::FINISH) {
+ return false;
+ }
+ ackedDirective = (static_cast(ackedDirectiveRaw));
+ return true;
+}
diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.h b/src/fsfw/cfdp/pdu/AckPduReader.h
similarity index 52%
rename from src/fsfw/cfdp/pdu/AckPduDeserializer.h
rename to src/fsfw/cfdp/pdu/AckPduReader.h
index 0bb95071..8f8b515b 100644
--- a/src/fsfw/cfdp/pdu/AckPduDeserializer.h
+++ b/src/fsfw/cfdp/pdu/AckPduReader.h
@@ -2,18 +2,21 @@
#define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUDESERIALIZER_H_
#include "AckInfo.h"
-#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
+#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
-class AckPduDeserializer : public FileDirectiveDeserializer {
+class AckPduReader : public FileDirectiveReader {
public:
- AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info);
+ AckPduReader(const uint8_t* pduBuf, size_t maxSize, AckInfo& info);
/**
*
* @return
* - cfdp::INVALID_DIRECTIVE_FIELDS: Invalid fields
*/
- ReturnValue_t parseData();
+ ReturnValue_t parseData() override;
+
+ static bool checkAckedDirectiveField(uint8_t firstPduDataByte,
+ cfdp::FileDirective& ackedDirective);
private:
bool checkAndSetCodes(uint8_t rawAckedByte, uint8_t rawAckedConditionCode);
diff --git a/src/fsfw/cfdp/pdu/AckPduSerializer.cpp b/src/fsfw/cfdp/pdu/AckPduSerializer.cpp
deleted file mode 100644
index d19418f1..00000000
--- a/src/fsfw/cfdp/pdu/AckPduSerializer.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "AckPduSerializer.h"
-
-AckPduSerializer::AckPduSerializer(AckInfo &ackInfo, PduConfig &pduConf)
- : FileDirectiveSerializer(pduConf, cfdp::FileDirectives::ACK, 2), ackInfo(ackInfo) {}
-
-size_t AckPduSerializer::getSerializedSize() const {
- return FileDirectiveSerializer::getWholePduSize();
-}
-
-ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const {
- ReturnValue_t result =
- FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- cfdp::FileDirectives ackedDirective = ackInfo.getAckedDirective();
- uint8_t directiveSubtypeCode = ackInfo.getDirectiveSubtypeCode();
- cfdp::ConditionCode ackedConditionCode = ackInfo.getAckedConditionCode();
- cfdp::AckTransactionStatus transactionStatus = ackInfo.getTransactionStatus();
- if (ackedDirective != cfdp::FileDirectives::FINISH and
- ackedDirective != cfdp::FileDirectives::EOF_DIRECTIVE) {
- // TODO: better returncode
- return HasReturnvaluesIF::RETURN_FAILED;
- }
- if (*size + 2 > maxSize) {
- return SerializeIF::BUFFER_TOO_SHORT;
- }
- **buffer = ackedDirective << 4 | directiveSubtypeCode;
- *buffer += 1;
- *size += 1;
- **buffer = ackedConditionCode << 4 | transactionStatus;
- *buffer += 1;
- *size += 1;
- return HasReturnvaluesIF::RETURN_OK;
-}
diff --git a/src/fsfw/cfdp/pdu/CMakeLists.txt b/src/fsfw/cfdp/pdu/CMakeLists.txt
index 4f345bdc..c08a4b29 100644
--- a/src/fsfw/cfdp/pdu/CMakeLists.txt
+++ b/src/fsfw/cfdp/pdu/CMakeLists.txt
@@ -1,30 +1,29 @@
target_sources(
${LIB_FSFW_NAME}
PRIVATE PduConfig.cpp
- VarLenField.cpp
- HeaderSerializer.cpp
- HeaderDeserializer.cpp
- FileDirectiveDeserializer.cpp
- FileDirectiveSerializer.cpp
+ HeaderCreator.cpp
+ HeaderReader.cpp
+ FileDirectiveReader.cpp
+ FileDirectiveCreator.cpp
AckInfo.cpp
- AckPduSerializer.cpp
- AckPduDeserializer.cpp
+ AckPduCreator.cpp
+ AckPduReader.cpp
EofInfo.cpp
- EofPduSerializer.cpp
- EofPduDeserializer.cpp
+ EofPduCreator.cpp
+ EofPduReader.cpp
NakInfo.cpp
- NakPduSerializer.cpp
- NakPduDeserializer.cpp
+ NakPduCreator.cpp
+ NakPduReader.cpp
FinishedInfo.cpp
- FinishedPduSerializer.cpp
- FinishedPduDeserializer.cpp
+ FinishedPduCreator.cpp
+ FinishedPduReader.cpp
MetadataInfo.cpp
- MetadataPduSerializer.cpp
- MetadataPduDeserializer.cpp
- KeepAlivePduSerializer.cpp
- KeepAlivePduDeserializer.cpp
- PromptPduSerializer.cpp
- PromptPduDeserializer.cpp
- FileDataSerializer.cpp
- FileDataDeserializer.cpp
+ MetadataPduCreator.cpp
+ MetadataPduReader.cpp
+ KeepAlivePduCreator.cpp
+ KeepAlivePduReader.cpp
+ PromptPduCreator.cpp
+ PromptPduReader.cpp
+ FileDataCreator.cpp
+ FileDataReader.cpp
FileDataInfo.cpp)
diff --git a/src/fsfw/cfdp/pdu/EofInfo.h b/src/fsfw/cfdp/pdu/EofInfo.h
index fa8adfd9..4b4fb057 100644
--- a/src/fsfw/cfdp/pdu/EofInfo.h
+++ b/src/fsfw/cfdp/pdu/EofInfo.h
@@ -7,16 +7,16 @@
struct EofInfo {
public:
- EofInfo(EntityIdTlv* faultLoc = nullptr);
+ explicit EofInfo(EntityIdTlv* faultLoc = nullptr);
EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize,
EntityIdTlv* faultLoc = nullptr);
size_t getSerializedSize(bool fssLarge = false);
- uint32_t getChecksum() const;
- cfdp::ConditionCode getConditionCode() const;
+ [[nodiscard]] uint32_t getChecksum() const;
+ [[nodiscard]] cfdp::ConditionCode getConditionCode() const;
- EntityIdTlv* getFaultLoc() const;
+ [[nodiscard]] EntityIdTlv* getFaultLoc() const;
cfdp::FileSize& getFileSize();
void setChecksum(uint32_t checksum);
void setConditionCode(cfdp::ConditionCode conditionCode);
diff --git a/src/fsfw/cfdp/pdu/EofPduSerializer.cpp b/src/fsfw/cfdp/pdu/EofPduCreator.cpp
similarity index 54%
rename from src/fsfw/cfdp/pdu/EofPduSerializer.cpp
rename to src/fsfw/cfdp/pdu/EofPduCreator.cpp
index e9fe0ca0..12a3e696 100644
--- a/src/fsfw/cfdp/pdu/EofPduSerializer.cpp
+++ b/src/fsfw/cfdp/pdu/EofPduCreator.cpp
@@ -1,22 +1,18 @@
-#include "EofPduSerializer.h"
+#include "EofPduCreator.h"
#include "fsfw/FSFW.h"
-#include "fsfw/serviceinterface.h"
-EofPduSerializer::EofPduSerializer(PduConfig &conf, EofInfo &info)
- : FileDirectiveSerializer(conf, cfdp::FileDirectives::EOF_DIRECTIVE, 9), info(info) {
- setDirectiveDataFieldLen(info.getSerializedSize(getLargeFileFlag()));
+EofPduCreator::EofPduCreator(PduConfig &conf, EofInfo &info)
+ : FileDirectiveCreator(conf, cfdp::FileDirective::EOF_DIRECTIVE, 9), info(info) {
+ setDirectiveDataFieldLen(info.getSerializedSize(HeaderCreator::getLargeFileFlag()));
}
-size_t EofPduSerializer::getSerializedSize() const {
- return FileDirectiveSerializer::getWholePduSize();
-}
+size_t EofPduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); }
-ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const {
- ReturnValue_t result =
- FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ReturnValue_t EofPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const {
+ ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
return result;
}
if (*size + 1 > maxSize) {
@@ -27,7 +23,7 @@ ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t
*size += 1;
uint32_t checksum = info.getChecksum();
result = SerializeAdapter::serialize(&checksum, buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
if (info.getFileSize().isLargeFile()) {
diff --git a/src/fsfw/cfdp/pdu/EofPduSerializer.h b/src/fsfw/cfdp/pdu/EofPduCreator.h
similarity index 62%
rename from src/fsfw/cfdp/pdu/EofPduSerializer.h
rename to src/fsfw/cfdp/pdu/EofPduCreator.h
index fbdcfe67..f098a5d2 100644
--- a/src/fsfw/cfdp/pdu/EofPduSerializer.h
+++ b/src/fsfw/cfdp/pdu/EofPduCreator.h
@@ -2,18 +2,20 @@
#define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUSERIALIZER_H_
#include "EofInfo.h"
-#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
+#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
#include "fsfw/cfdp/tlv/EntityIdTlv.h"
-class EofPduSerializer : public FileDirectiveSerializer {
+class EofPduCreator : public FileDirectiveCreator {
public:
- EofPduSerializer(PduConfig& conf, EofInfo& info);
+ EofPduCreator(PduConfig& conf, EofInfo& info);
- size_t getSerializedSize() const override;
+ [[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
+ using FileDirectiveCreator::serialize;
+
private:
EofInfo& info;
};
diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.h b/src/fsfw/cfdp/pdu/EofPduDeserializer.h
deleted file mode 100644
index 8f62b25a..00000000
--- a/src/fsfw/cfdp/pdu/EofPduDeserializer.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_EOFPDUDESERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUDESERIALIZER_H_
-
-#include "EofInfo.h"
-#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
-
-class EofPduDeserializer : public FileDirectiveDeserializer {
- public:
- EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo);
-
- virtual ReturnValue_t parseData() override;
-
- private:
- EofInfo& info;
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_EOFPDUDESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp b/src/fsfw/cfdp/pdu/EofPduReader.cpp
similarity index 74%
rename from src/fsfw/cfdp/pdu/EofPduDeserializer.cpp
rename to src/fsfw/cfdp/pdu/EofPduReader.cpp
index e1ab8dc9..c80c501c 100644
--- a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp
+++ b/src/fsfw/cfdp/pdu/EofPduReader.cpp
@@ -1,23 +1,23 @@
-#include "EofPduDeserializer.h"
+#include "EofPduReader.h"
#include "fsfw/FSFW.h"
#include "fsfw/serviceinterface.h"
-EofPduDeserializer::EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo)
- : FileDirectiveDeserializer(pduBuf, maxSize), info(eofInfo) {}
+EofPduReader::EofPduReader(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo)
+ : FileDirectiveReader(pduBuf, maxSize), info(eofInfo) {}
-ReturnValue_t EofPduDeserializer::parseData() {
- ReturnValue_t result = FileDirectiveDeserializer::parseData();
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ReturnValue_t EofPduReader::parseData() {
+ ReturnValue_t result = FileDirectiveReader::parseData();
+ if (result != returnvalue::OK) {
return result;
}
- const uint8_t* bufPtr = rawPtr;
+ const uint8_t* bufPtr = pointers.rawPtr;
size_t expectedFileFieldLen = 4;
if (this->getLargeFileFlag()) {
expectedFileFieldLen = 8;
}
- size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
+ size_t currentIdx = FileDirectiveReader::getHeaderSize();
size_t deserLen = maxSize;
if (maxSize < currentIdx + 5 + expectedFileFieldLen) {
return SerializeIF::STREAM_TOO_SHORT;
@@ -31,7 +31,7 @@ ReturnValue_t EofPduDeserializer::parseData() {
uint32_t checksum = 0;
auto endianness = getEndianness();
result = SerializeAdapter::deSerialize(&checksum, &bufPtr, &deserLen, endianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
info.setChecksum(checksum);
@@ -44,7 +44,7 @@ ReturnValue_t EofPduDeserializer::parseData() {
result = SerializeAdapter::deSerialize(&fileSizeValue, &bufPtr, &deserLen, endianness);
info.setFileSize(fileSizeValue, false);
}
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) {
@@ -61,7 +61,7 @@ ReturnValue_t EofPduDeserializer::parseData() {
" given TLV pointer invalid");
#endif
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
result = tlvPtr->deSerialize(&bufPtr, &deserLen, endianness);
}
diff --git a/src/fsfw/cfdp/pdu/EofPduReader.h b/src/fsfw/cfdp/pdu/EofPduReader.h
new file mode 100644
index 00000000..456ea0dc
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/EofPduReader.h
@@ -0,0 +1,17 @@
+#ifndef FSFW_SRC_FSFW_CFDP_PDU_EOFPDUDESERIALIZER_H_
+#define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUDESERIALIZER_H_
+
+#include "EofInfo.h"
+#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
+
+class EofPduReader : public FileDirectiveReader {
+ public:
+ EofPduReader(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo);
+
+ ReturnValue_t parseData() override;
+
+ private:
+ EofInfo& info;
+};
+
+#endif /* FSFW_SRC_FSFW_CFDP_PDU_EOFPDUDESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/FileDataSerializer.cpp b/src/fsfw/cfdp/pdu/FileDataCreator.cpp
similarity index 56%
rename from src/fsfw/cfdp/pdu/FileDataSerializer.cpp
rename to src/fsfw/cfdp/pdu/FileDataCreator.cpp
index 837b418b..956752fb 100644
--- a/src/fsfw/cfdp/pdu/FileDataSerializer.cpp
+++ b/src/fsfw/cfdp/pdu/FileDataCreator.cpp
@@ -1,28 +1,31 @@
-#include "FileDataSerializer.h"
+#include "FileDataCreator.h"
#include
-FileDataSerializer::FileDataSerializer(PduConfig& conf, FileDataInfo& info)
- : HeaderSerializer(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()),
- info(info) {
+FileDataCreator::FileDataCreator(PduConfig& conf, FileDataInfo& info)
+ : HeaderCreator(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) {
update();
}
-void FileDataSerializer::update() {
+void FileDataCreator::update() {
this->setSegmentMetadataFlag(info.getSegmentMetadataFlag());
this->setSegmentationControl(info.getSegmentationControl());
setPduDataFieldLen(info.getSerializedSize(this->getLargeFileFlag()));
}
-ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
- Endianness streamEndianness) const {
- ReturnValue_t result = HeaderSerializer::serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
+ReturnValue_t FileDataCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
+ Endianness streamEndianness) const {
+ if (buffer == nullptr or size == nullptr) {
+ return returnvalue::FAILED;
}
- if (*size + this->getSerializedSize() > maxSize) {
+ if (*size + getSerializedSize() > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
+ ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
+ return result;
+ }
+
const uint8_t* readOnlyPtr = nullptr;
if (this->hasSegmentMetadataFlag()) {
size_t segmentMetadataLen = info.getSegmentMetadataLen();
@@ -36,7 +39,7 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size
}
cfdp::FileSize& offset = info.getOffset();
result = offset.serialize(this->getLargeFileFlag(), buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
size_t fileSize = 0;
@@ -47,9 +50,9 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size
std::memcpy(*buffer, readOnlyPtr, fileSize);
*buffer += fileSize;
*size += fileSize;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
-size_t FileDataSerializer::getSerializedSize() const {
- return HeaderSerializer::getSerializedSize() + info.getSerializedSize(this->getLargeFileFlag());
+size_t FileDataCreator::getSerializedSize() const {
+ return HeaderCreator::getSerializedSize() + info.getSerializedSize(this->getLargeFileFlag());
}
diff --git a/src/fsfw/cfdp/pdu/FileDataCreator.h b/src/fsfw/cfdp/pdu/FileDataCreator.h
new file mode 100644
index 00000000..2ce8989d
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/FileDataCreator.h
@@ -0,0 +1,27 @@
+#ifndef FSFW_CFDP_PDU_FILEDATASERIALIZER_H_
+#define FSFW_CFDP_PDU_FILEDATASERIALIZER_H_
+
+#include "../definitions.h"
+#include "FileDataInfo.h"
+#include "HeaderCreator.h"
+
+class FileDataCreator : public HeaderCreator {
+ public:
+ FileDataCreator(PduConfig& conf, FileDataInfo& info);
+
+ void update();
+
+ ReturnValue_t serialize(uint8_t* buf, size_t& serLen, size_t maxSize) const {
+ return SerializeIF::serialize(buf, serLen, maxSize, SerializeIF::Endianness::NETWORK);
+ }
+
+ ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
+ Endianness streamEndianness) const override;
+
+ [[nodiscard]] size_t getSerializedSize() const override;
+
+ private:
+ FileDataInfo& info;
+};
+
+#endif /* FSFW_CFDP_PDU_FILEDATASERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp b/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp
deleted file mode 100644
index 240c4188..00000000
--- a/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "FileDataDeserializer.h"
-
-FileDataDeserializer::FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize,
- FileDataInfo& info)
- : HeaderDeserializer(pduBuf, maxSize), info(info) {}
-
-ReturnValue_t FileDataDeserializer::parseData() {
- ReturnValue_t result = HeaderDeserializer::parseData();
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- size_t currentIdx = HeaderDeserializer::getHeaderSize();
- const uint8_t* buf = rawPtr + currentIdx;
- size_t remSize = HeaderDeserializer::getWholePduSize() - currentIdx;
- if (remSize < 1) {
- return SerializeIF::STREAM_TOO_SHORT;
- }
- if (hasSegmentMetadataFlag()) {
- info.setSegmentMetadataFlag(true);
- info.setRecordContinuationState(static_cast((*buf >> 6) & 0b11));
- size_t segmentMetadataLen = *buf & 0b00111111;
- info.setSegmentMetadataLen(segmentMetadataLen);
- if (remSize < segmentMetadataLen + 1) {
- return SerializeIF::STREAM_TOO_SHORT;
- }
- if (segmentMetadataLen > 0) {
- buf += 1;
- remSize -= 1;
- info.setSegmentMetadata(buf);
- buf += segmentMetadataLen;
- remSize -= segmentMetadataLen;
- }
- }
- result = info.getOffset().deSerialize(&buf, &remSize, this->getEndianness());
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- if (remSize > 0) {
- info.setFileData(buf, remSize);
- }
- return HasReturnvaluesIF::RETURN_OK;
-}
-
-SerializeIF::Endianness FileDataDeserializer::getEndianness() const { return endianness; }
-
-void FileDataDeserializer::setEndianness(SerializeIF::Endianness endianness) {
- this->endianness = endianness;
-}
diff --git a/src/fsfw/cfdp/pdu/FileDataInfo.cpp b/src/fsfw/cfdp/pdu/FileDataInfo.cpp
index c410adce..19fc00cd 100644
--- a/src/fsfw/cfdp/pdu/FileDataInfo.cpp
+++ b/src/fsfw/cfdp/pdu/FileDataInfo.cpp
@@ -50,23 +50,23 @@ ReturnValue_t FileDataInfo::addSegmentMetadataInfo(cfdp::RecordContinuationState
this->segmentMetadataFlag = cfdp::SegmentMetadataFlag::PRESENT;
this->recContState = recContState;
if (segmentMetadataLen > 63) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
this->segmentMetadata = segmentMetadata;
this->segmentMetadataLen = segmentMetadataLen;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
-const uint8_t *FileDataInfo::getFileData(size_t *fileSize) const {
- if (fileSize != nullptr) {
- *fileSize = this->fileSize;
+const uint8_t *FileDataInfo::getFileData(size_t *fileSize_) const {
+ if (fileSize_ != nullptr) {
+ *fileSize_ = this->fileSize;
}
return fileData;
}
-const uint8_t *FileDataInfo::getSegmentMetadata(size_t *segmentMetadataLen) {
- if (segmentMetadataLen != nullptr) {
- *segmentMetadataLen = this->segmentMetadataLen;
+const uint8_t *FileDataInfo::getSegmentMetadata(size_t *segmentMetadataLen_) {
+ if (segmentMetadataLen_ != nullptr) {
+ *segmentMetadataLen_ = this->segmentMetadataLen;
}
return segmentMetadata;
}
diff --git a/src/fsfw/cfdp/pdu/FileDataInfo.h b/src/fsfw/cfdp/pdu/FileDataInfo.h
index 7fd573db..36908d8b 100644
--- a/src/fsfw/cfdp/pdu/FileDataInfo.h
+++ b/src/fsfw/cfdp/pdu/FileDataInfo.h
@@ -6,25 +6,25 @@
class FileDataInfo {
public:
- FileDataInfo(cfdp::FileSize& offset);
+ explicit FileDataInfo(cfdp::FileSize& offset);
FileDataInfo(cfdp::FileSize& offset, const uint8_t* fileData, size_t fileSize);
- size_t getSerializedSize(bool largeFile = false) const;
+ [[nodiscard]] size_t getSerializedSize(bool largeFile = false) const;
cfdp::FileSize& getOffset();
const uint8_t* getFileData(size_t* fileSize = nullptr) const;
void setFileData(const uint8_t* fileData, size_t fileSize);
- cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const;
- cfdp::SegmentationControl getSegmentationControl() const;
- cfdp::RecordContinuationState getRecordContinuationState() const;
+ [[nodiscard]] cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const;
+ [[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const;
+ [[nodiscard]] cfdp::RecordContinuationState getRecordContinuationState() const;
void setRecordContinuationState(cfdp::RecordContinuationState recContState);
void setSegmentationControl(cfdp::SegmentationControl segCtrl);
- size_t getSegmentMetadataLen() const;
+ [[nodiscard]] size_t getSegmentMetadataLen() const;
void setSegmentMetadataLen(size_t len);
void setSegmentMetadata(const uint8_t* ptr);
- bool hasSegmentMetadata() const;
+ [[nodiscard]] bool hasSegmentMetadata() const;
void setSegmentMetadataFlag(bool enable);
ReturnValue_t addSegmentMetadataInfo(cfdp::RecordContinuationState recContState,
const uint8_t* segmentMetadata, size_t segmentMetadataLen);
diff --git a/src/fsfw/cfdp/pdu/FileDataReader.cpp b/src/fsfw/cfdp/pdu/FileDataReader.cpp
new file mode 100644
index 00000000..9155ef28
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/FileDataReader.cpp
@@ -0,0 +1,47 @@
+#include "FileDataReader.h"
+
+FileDataReader::FileDataReader(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info)
+ : PduHeaderReader(pduBuf, maxSize), info(info) {}
+
+ReturnValue_t FileDataReader::parseData() {
+ ReturnValue_t result = PduHeaderReader::parseData();
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ size_t currentIdx = PduHeaderReader::getHeaderSize();
+ const uint8_t* buf = pointers.rawPtr + currentIdx;
+ size_t remSize = PduHeaderReader::getWholePduSize() - currentIdx;
+ if (remSize < 1) {
+ return SerializeIF::STREAM_TOO_SHORT;
+ }
+ if (hasSegmentMetadataFlag()) {
+ info.setSegmentMetadataFlag(true);
+ info.setRecordContinuationState(static_cast((*buf >> 6) & 0b11));
+ size_t segmentMetadataLen = *buf & 0b00111111;
+ info.setSegmentMetadataLen(segmentMetadataLen);
+ if (remSize < segmentMetadataLen + 1) {
+ return SerializeIF::STREAM_TOO_SHORT;
+ }
+ if (segmentMetadataLen > 0) {
+ buf += 1;
+ remSize -= 1;
+ info.setSegmentMetadata(buf);
+ buf += segmentMetadataLen;
+ remSize -= segmentMetadataLen;
+ }
+ }
+ result = info.getOffset().deSerialize(&buf, &remSize, this->getEndianness());
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ if (remSize > 0) {
+ info.setFileData(buf, remSize);
+ }
+ return returnvalue::OK;
+}
+
+SerializeIF::Endianness FileDataReader::getEndianness() const { return endianness; }
+
+void FileDataReader::setEndianness(SerializeIF::Endianness endianness_) {
+ endianness = endianness_;
+}
diff --git a/src/fsfw/cfdp/pdu/FileDataDeserializer.h b/src/fsfw/cfdp/pdu/FileDataReader.h
similarity index 63%
rename from src/fsfw/cfdp/pdu/FileDataDeserializer.h
rename to src/fsfw/cfdp/pdu/FileDataReader.h
index 833c0561..aa962e2b 100644
--- a/src/fsfw/cfdp/pdu/FileDataDeserializer.h
+++ b/src/fsfw/cfdp/pdu/FileDataReader.h
@@ -3,14 +3,14 @@
#include "../definitions.h"
#include "FileDataInfo.h"
-#include "HeaderDeserializer.h"
+#include "PduHeaderReader.h"
-class FileDataDeserializer : public HeaderDeserializer {
+class FileDataReader : public PduHeaderReader {
public:
- FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info);
+ FileDataReader(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info);
- ReturnValue_t parseData();
- SerializeIF::Endianness getEndianness() const;
+ ReturnValue_t parseData() override;
+ [[nodiscard]] SerializeIF::Endianness getEndianness() const;
void setEndianness(SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK);
private:
diff --git a/src/fsfw/cfdp/pdu/FileDataSerializer.h b/src/fsfw/cfdp/pdu/FileDataSerializer.h
deleted file mode 100644
index 662b9b4d..00000000
--- a/src/fsfw/cfdp/pdu/FileDataSerializer.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_FILEDATASERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_FILEDATASERIALIZER_H_
-
-#include "../definitions.h"
-#include "FileDataInfo.h"
-#include "HeaderSerializer.h"
-
-class FileDataSerializer : public HeaderSerializer {
- public:
- FileDataSerializer(PduConfig& conf, FileDataInfo& info);
-
- void update();
-
- ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
- Endianness streamEndianness) const override;
-
- size_t getSerializedSize() const override;
-
- private:
- FileDataInfo& info;
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_FILEDATADESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp
new file mode 100644
index 00000000..20f93df9
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp
@@ -0,0 +1,39 @@
+#include "FileDirectiveCreator.h"
+
+FileDirectiveCreator::FileDirectiveCreator(PduConfig &pduConf, cfdp::FileDirective directiveCode,
+ size_t directiveParamFieldLen)
+ : HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1),
+ directiveCode(directiveCode) {}
+
+size_t FileDirectiveCreator::getSerializedSize() const {
+ return HeaderCreator::getSerializedSize() + 1;
+}
+
+ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const {
+ if (buffer == nullptr or size == nullptr) {
+ return returnvalue::FAILED;
+ }
+ if (FileDirectiveCreator::getWholePduSize() > maxSize) {
+ return BUFFER_TOO_SHORT;
+ }
+ ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
+ return result;
+ }
+
+ if (*size >= maxSize) {
+ return BUFFER_TOO_SHORT;
+ }
+ **buffer = directiveCode;
+ *buffer += 1;
+ *size += 1;
+ return returnvalue::OK;
+}
+
+void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) {
+ // Set length of data field plus 1 byte for the directive octet
+ HeaderCreator::setPduDataFieldLen(len + 1);
+}
+
+cfdp::FileDirective FileDirectiveCreator::getDirectiveCode() const { return directiveCode; }
diff --git a/src/fsfw/cfdp/pdu/FileDirectiveCreator.h b/src/fsfw/cfdp/pdu/FileDirectiveCreator.h
new file mode 100644
index 00000000..9b7f2f52
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.h
@@ -0,0 +1,34 @@
+#ifndef FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_
+#define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_
+
+#include "fsfw/cfdp/pdu/HeaderCreator.h"
+
+class FileDirectiveCreator : public HeaderCreator {
+ public:
+ FileDirectiveCreator(PduConfig& pduConf, cfdp::FileDirective directiveCode,
+ size_t directiveParamFieldLen);
+
+ [[nodiscard]] cfdp::FileDirective getDirectiveCode() const;
+
+ /**
+ * This only returns the size of the PDU header + 1 for the directive code octet.
+ * Use FileDirectiveCreator::getWholePduSize to get the full packet length, assuming
+ * the length fields was set correctly
+ * @return
+ */
+ [[nodiscard]] size_t getSerializedSize() const override;
+
+ [[nodiscard]] ReturnValue_t serialize(uint8_t* buffer, size_t& serLen, size_t maxSize) const {
+ return SerializeIF::serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK);
+ }
+
+ ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
+ Endianness streamEndianness) const override;
+
+ void setDirectiveDataFieldLen(size_t len);
+
+ private:
+ cfdp::FileDirective directiveCode = cfdp::FileDirective::INVALID_DIRECTIVE;
+};
+
+#endif /* FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp b/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp
deleted file mode 100644
index 3c0552f7..00000000
--- a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include "FileDirectiveDeserializer.h"
-
-FileDirectiveDeserializer::FileDirectiveDeserializer(const uint8_t *pduBuf, size_t maxSize)
- : HeaderDeserializer(pduBuf, maxSize) {}
-
-cfdp::FileDirectives FileDirectiveDeserializer::getFileDirective() const { return fileDirective; }
-
-ReturnValue_t FileDirectiveDeserializer::parseData() {
- ReturnValue_t result = HeaderDeserializer::parseData();
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- if (this->getPduDataFieldLen() < 1) {
- return cfdp::INVALID_PDU_DATAFIELD_LEN;
- }
- if (FileDirectiveDeserializer::getWholePduSize() > maxSize) {
- return SerializeIF::STREAM_TOO_SHORT;
- }
- size_t currentIdx = HeaderDeserializer::getHeaderSize();
- if (not checkFileDirective(rawPtr[currentIdx])) {
- return cfdp::INVALID_DIRECTIVE_FIELDS;
- }
- setFileDirective(static_cast(rawPtr[currentIdx]));
- return HasReturnvaluesIF::RETURN_OK;
-}
-
-size_t FileDirectiveDeserializer::getHeaderSize() const {
- // return size of header plus the directive byte
- return HeaderDeserializer::getHeaderSize() + 1;
-}
-
-bool FileDirectiveDeserializer::checkFileDirective(uint8_t rawByte) {
- if (rawByte < cfdp::FileDirectives::EOF_DIRECTIVE or
- (rawByte > cfdp::FileDirectives::PROMPT and rawByte != cfdp::FileDirectives::KEEP_ALIVE)) {
- // Invalid directive field. TODO: Custom returnvalue
- return false;
- }
- return true;
-}
-
-void FileDirectiveDeserializer::setFileDirective(cfdp::FileDirectives fileDirective) {
- this->fileDirective = fileDirective;
-}
-
-void FileDirectiveDeserializer::setEndianness(SerializeIF::Endianness endianness) {
- this->endianness = endianness;
-}
-
-SerializeIF::Endianness FileDirectiveDeserializer::getEndianness() const { return endianness; }
diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp
new file mode 100644
index 00000000..f5fc6e58
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp
@@ -0,0 +1,49 @@
+#include "FileDirectiveReader.h"
+
+FileDirectiveReader::FileDirectiveReader(const uint8_t *pduBuf, size_t maxSize)
+ : PduHeaderReader(pduBuf, maxSize) {}
+
+cfdp::FileDirective FileDirectiveReader::getFileDirective() const { return fileDirective; }
+
+ReturnValue_t FileDirectiveReader::parseData() {
+ ReturnValue_t result = PduHeaderReader::parseData();
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ if (this->getPduDataFieldLen() < 1) {
+ return cfdp::INVALID_PDU_DATAFIELD_LEN;
+ }
+ if (FileDirectiveReader::getWholePduSize() > maxSize) {
+ return SerializeIF::STREAM_TOO_SHORT;
+ }
+ size_t currentIdx = PduHeaderReader::getHeaderSize();
+ if (not checkFileDirective(pointers.rawPtr[currentIdx])) {
+ return cfdp::INVALID_DIRECTIVE_FIELD;
+ }
+ setFileDirective(static_cast(pointers.rawPtr[currentIdx]));
+ return returnvalue::OK;
+}
+
+size_t FileDirectiveReader::getHeaderSize() const {
+ // return size of header plus the directive byte
+ return PduHeaderReader::getHeaderSize() + 1;
+}
+
+bool FileDirectiveReader::checkFileDirective(uint8_t rawByte) {
+ if (rawByte < cfdp::FileDirective::EOF_DIRECTIVE or
+ (rawByte > cfdp::FileDirective::PROMPT and rawByte != cfdp::FileDirective::KEEP_ALIVE)) {
+ // Invalid directive field
+ return false;
+ }
+ return true;
+}
+
+void FileDirectiveReader::setFileDirective(cfdp::FileDirective fileDirective_) {
+ fileDirective = fileDirective_;
+}
+
+void FileDirectiveReader::setEndianness(SerializeIF::Endianness endianness_) {
+ endianness = endianness_;
+}
+
+SerializeIF::Endianness FileDirectiveReader::getEndianness() const { return endianness; }
diff --git a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h b/src/fsfw/cfdp/pdu/FileDirectiveReader.h
similarity index 57%
rename from src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h
rename to src/fsfw/cfdp/pdu/FileDirectiveReader.h
index 064cb64a..9e88e006 100644
--- a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h
+++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.h
@@ -2,7 +2,7 @@
#define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVEDESERIALIZER_H_
#include "../definitions.h"
-#include "fsfw/cfdp/pdu/HeaderDeserializer.h"
+#include "fsfw/cfdp/pdu/PduHeaderReader.h"
/**
* @brief This class is used to deserialize a PDU file directive header from raw memory.
@@ -11,28 +11,27 @@
* This is a zero-copy implementation and #parseData needs to be called to ensure the data is
* valid.
*/
-class FileDirectiveDeserializer : public HeaderDeserializer {
+class FileDirectiveReader : public PduHeaderReader {
public:
- FileDirectiveDeserializer(const uint8_t* pduBuf, size_t maxSize);
+ FileDirectiveReader(const uint8_t* pduBuf, size_t maxSize);
/**
* This needs to be called before accessing the PDU fields to avoid segmentation faults.
* @return
*/
- virtual ReturnValue_t parseData();
- size_t getHeaderSize() const;
+ ReturnValue_t parseData() override;
+ [[nodiscard]] size_t getHeaderSize() const override;
- cfdp::FileDirectives getFileDirective() const;
+ [[nodiscard]] cfdp::FileDirective getFileDirective() const;
void setEndianness(SerializeIF::Endianness endianness);
- SerializeIF::Endianness getEndianness() const;
+ [[nodiscard]] SerializeIF::Endianness getEndianness() const;
+ static bool checkFileDirective(uint8_t rawByte);
protected:
- bool checkFileDirective(uint8_t rawByte);
-
private:
- void setFileDirective(cfdp::FileDirectives fileDirective);
- cfdp::FileDirectives fileDirective = cfdp::FileDirectives::INVALID_DIRECTIVE;
+ void setFileDirective(cfdp::FileDirective fileDirective);
+ cfdp::FileDirective fileDirective = cfdp::FileDirective::INVALID_DIRECTIVE;
SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK;
};
diff --git a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp b/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp
deleted file mode 100644
index 98b2d0a2..00000000
--- a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "FileDirectiveSerializer.h"
-
-FileDirectiveSerializer::FileDirectiveSerializer(PduConfig &pduConf,
- cfdp::FileDirectives directiveCode,
- size_t directiveParamFieldLen)
- : HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1),
- directiveCode(directiveCode) {}
-
-size_t FileDirectiveSerializer::getSerializedSize() const {
- return HeaderSerializer::getSerializedSize() + 1;
-}
-
-ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const {
- if (buffer == nullptr or size == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
- }
- if (FileDirectiveSerializer::getWholePduSize() > maxSize) {
- return BUFFER_TOO_SHORT;
- }
- ReturnValue_t result = HeaderSerializer::serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
-
- if (*size >= maxSize) {
- return BUFFER_TOO_SHORT;
- }
- **buffer = directiveCode;
- *buffer += 1;
- *size += 1;
- return HasReturnvaluesIF::RETURN_OK;
-}
-
-void FileDirectiveSerializer::setDirectiveDataFieldLen(size_t len) {
- // Set length of data field plus 1 byte for the directive octet
- HeaderSerializer::setPduDataFieldLen(len + 1);
-}
diff --git a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.h b/src/fsfw/cfdp/pdu/FileDirectiveSerializer.h
deleted file mode 100644
index 8f86a5e1..00000000
--- a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_
-
-#include "fsfw/cfdp/pdu/HeaderSerializer.h"
-
-class FileDirectiveSerializer : public HeaderSerializer {
- public:
- FileDirectiveSerializer(PduConfig& pduConf, cfdp::FileDirectives directiveCode,
- size_t directiveParamFieldLen);
-
- /**
- * This only returns the size of the PDU header + 1 for the directive code octet.
- * Use FileDirectiveSerializer::getWholePduSize to get the full packet length, assuming
- * the length fields was set correctly
- * @return
- */
- size_t getSerializedSize() const override;
-
- ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
- Endianness streamEndianness) const override;
-
- void setDirectiveDataFieldLen(size_t len);
-
- private:
- cfdp::FileDirectives directiveCode = cfdp::FileDirectives::INVALID_DIRECTIVE;
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.cpp b/src/fsfw/cfdp/pdu/FinishedInfo.cpp
index c32372a1..2f986e85 100644
--- a/src/fsfw/cfdp/pdu/FinishedInfo.cpp
+++ b/src/fsfw/cfdp/pdu/FinishedInfo.cpp
@@ -2,9 +2,8 @@
FinishedInfo::FinishedInfo() {}
-FinishedInfo::FinishedInfo(cfdp::ConditionCode conditionCode,
- cfdp::FinishedDeliveryCode deliveryCode,
- cfdp::FinishedFileStatus fileStatus)
+FinishedInfo::FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode,
+ cfdp::FileDeliveryStatus fileStatus)
: conditionCode(conditionCode), deliveryCode(deliveryCode), fileStatus(fileStatus) {}
size_t FinishedInfo::getSerializedSize() const {
@@ -46,14 +45,14 @@ ReturnValue_t FinishedInfo::setFilestoreResponsesArray(FilestoreResponseTlv** fs
if (maxFsResponsesLen != nullptr) {
this->fsResponsesMaxLen = *maxFsResponsesLen;
}
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t FinishedInfo::getFilestoreResonses(FilestoreResponseTlv*** fsResponses,
size_t* fsResponsesLen,
size_t* fsResponsesMaxLen) {
if (fsResponses == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
*fsResponses = this->fsResponses;
if (fsResponsesLen != nullptr) {
@@ -62,7 +61,7 @@ ReturnValue_t FinishedInfo::getFilestoreResonses(FilestoreResponseTlv*** fsRespo
if (fsResponsesMaxLen != nullptr) {
*fsResponsesMaxLen = this->fsResponsesMaxLen;
}
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
void FinishedInfo::setFaultLocation(EntityIdTlv* faultLocation) {
@@ -71,10 +70,10 @@ void FinishedInfo::setFaultLocation(EntityIdTlv* faultLocation) {
ReturnValue_t FinishedInfo::getFaultLocation(EntityIdTlv** faultLocation) {
if (this->faultLocation == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
*faultLocation = this->faultLocation;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
cfdp::ConditionCode FinishedInfo::getConditionCode() const { return conditionCode; }
@@ -83,13 +82,13 @@ void FinishedInfo::setConditionCode(cfdp::ConditionCode conditionCode) {
this->conditionCode = conditionCode;
}
-cfdp::FinishedDeliveryCode FinishedInfo::getDeliveryCode() const { return deliveryCode; }
+cfdp::FileDeliveryCode FinishedInfo::getDeliveryCode() const { return deliveryCode; }
-void FinishedInfo::setDeliveryCode(cfdp::FinishedDeliveryCode deliveryCode) {
+void FinishedInfo::setDeliveryCode(cfdp::FileDeliveryCode deliveryCode) {
this->deliveryCode = deliveryCode;
}
-cfdp::FinishedFileStatus FinishedInfo::getFileStatus() const { return fileStatus; }
+cfdp::FileDeliveryStatus FinishedInfo::getFileStatus() const { return fileStatus; }
void FinishedInfo::setFilestoreResponsesArrayLen(size_t fsResponsesLen) {
this->fsResponsesLen = fsResponsesLen;
@@ -97,6 +96,6 @@ void FinishedInfo::setFilestoreResponsesArrayLen(size_t fsResponsesLen) {
size_t FinishedInfo::getFsResponsesLen() const { return fsResponsesLen; }
-void FinishedInfo::setFileStatus(cfdp::FinishedFileStatus fileStatus) {
+void FinishedInfo::setFileStatus(cfdp::FileDeliveryStatus fileStatus) {
this->fileStatus = fileStatus;
}
diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.h b/src/fsfw/cfdp/pdu/FinishedInfo.h
index 5768a298..49d7c64d 100644
--- a/src/fsfw/cfdp/pdu/FinishedInfo.h
+++ b/src/fsfw/cfdp/pdu/FinishedInfo.h
@@ -8,13 +8,13 @@
class FinishedInfo {
public:
FinishedInfo();
- FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FinishedDeliveryCode deliveryCode,
- cfdp::FinishedFileStatus fileStatus);
+ FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode,
+ cfdp::FileDeliveryStatus fileStatus);
- size_t getSerializedSize() const;
+ [[nodiscard]] size_t getSerializedSize() const;
- bool hasFsResponses() const;
- bool canHoldFsResponses() const;
+ [[nodiscard]] bool hasFsResponses() const;
+ [[nodiscard]] bool canHoldFsResponses() const;
ReturnValue_t setFilestoreResponsesArray(FilestoreResponseTlv** fsResponses,
size_t* fsResponsesLen, const size_t* maxFsResponseLen);
@@ -22,20 +22,20 @@ class FinishedInfo {
ReturnValue_t getFilestoreResonses(FilestoreResponseTlv*** fsResponses, size_t* fsResponsesLen,
size_t* fsResponsesMaxLen);
- size_t getFsResponsesLen() const;
+ [[nodiscard]] size_t getFsResponsesLen() const;
void setFilestoreResponsesArrayLen(size_t fsResponsesLen);
ReturnValue_t getFaultLocation(EntityIdTlv** entityId);
- cfdp::ConditionCode getConditionCode() const;
+ [[nodiscard]] cfdp::ConditionCode getConditionCode() const;
void setConditionCode(cfdp::ConditionCode conditionCode);
- cfdp::FinishedDeliveryCode getDeliveryCode() const;
- void setDeliveryCode(cfdp::FinishedDeliveryCode deliveryCode);
- cfdp::FinishedFileStatus getFileStatus() const;
- void setFileStatus(cfdp::FinishedFileStatus fileStatus);
+ [[nodiscard]] cfdp::FileDeliveryCode getDeliveryCode() const;
+ void setDeliveryCode(cfdp::FileDeliveryCode deliveryCode);
+ [[nodiscard]] cfdp::FileDeliveryStatus getFileStatus() const;
+ void setFileStatus(cfdp::FileDeliveryStatus fileStatus);
private:
cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD;
- cfdp::FinishedDeliveryCode deliveryCode = cfdp::FinishedDeliveryCode::DATA_COMPLETE;
- cfdp::FinishedFileStatus fileStatus = cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY;
+ cfdp::FileDeliveryCode deliveryCode = cfdp::FileDeliveryCode::DATA_COMPLETE;
+ cfdp::FileDeliveryStatus fileStatus = cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY;
FilestoreResponseTlv** fsResponses = nullptr;
size_t fsResponsesLen = 0;
size_t fsResponsesMaxLen = 0;
diff --git a/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp b/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp
new file mode 100644
index 00000000..d002e8aa
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp
@@ -0,0 +1,44 @@
+#include "FinishedPduCreator.h"
+
+FinishPduCreator::FinishPduCreator(PduConfig &conf, FinishedInfo &finishInfo)
+ : FileDirectiveCreator(conf, cfdp::FileDirective::FINISH, 0), finishInfo(finishInfo) {
+ updateDirectiveFieldLen();
+}
+
+size_t FinishPduCreator::getSerializedSize() const { return FinishPduCreator::getWholePduSize(); }
+
+void FinishPduCreator::updateDirectiveFieldLen() {
+ setDirectiveDataFieldLen(finishInfo.getSerializedSize());
+}
+
+ReturnValue_t FinishPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const {
+ ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ if (*size + 1 > maxSize) {
+ return SerializeIF::BUFFER_TOO_SHORT;
+ }
+ **buffer = finishInfo.getConditionCode() << 4 | finishInfo.getDeliveryCode() << 2 |
+ finishInfo.getFileStatus();
+ *size += 1;
+ *buffer += 1;
+
+ if (finishInfo.hasFsResponses()) {
+ FilestoreResponseTlv **fsResponsesArray = nullptr;
+ size_t fsResponsesArrayLen = 0;
+ finishInfo.getFilestoreResonses(&fsResponsesArray, &fsResponsesArrayLen, nullptr);
+ for (size_t idx = 0; idx < fsResponsesArrayLen; idx++) {
+ result = fsResponsesArray[idx]->serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ }
+ }
+ EntityIdTlv *entityId = nullptr;
+ if (finishInfo.getFaultLocation(&entityId) == returnvalue::OK) {
+ result = entityId->serialize(buffer, size, maxSize, streamEndianness);
+ }
+ return result;
+}
diff --git a/src/fsfw/cfdp/pdu/FinishedPduCreator.h b/src/fsfw/cfdp/pdu/FinishedPduCreator.h
new file mode 100644
index 00000000..bef59ada
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/FinishedPduCreator.h
@@ -0,0 +1,24 @@
+#ifndef FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_
+#define FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_
+
+#include "FinishedInfo.h"
+#include "fsfw/cfdp/pdu/FileDataCreator.h"
+#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
+
+class FinishPduCreator : public FileDirectiveCreator {
+ public:
+ FinishPduCreator(PduConfig& pduConf, FinishedInfo& finishInfo);
+
+ void updateDirectiveFieldLen();
+
+ [[nodiscard]] size_t getSerializedSize() const override;
+
+ ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
+ Endianness streamEndianness) const override;
+ using FileDirectiveCreator::serialize;
+
+ private:
+ FinishedInfo& finishInfo;
+};
+
+#endif /* FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.h b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.h
deleted file mode 100644
index a34fc4cb..00000000
--- a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_
-
-#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
-#include "fsfw/cfdp/pdu/FinishedInfo.h"
-
-class FinishPduDeserializer : public FileDirectiveDeserializer {
- public:
- FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info);
-
- ReturnValue_t parseData() override;
-
- FinishedInfo& getInfo();
-
- private:
- FinishedInfo& finishedInfo;
-
- ReturnValue_t parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf,
- cfdp::ConditionCode conditionCode);
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduReader.cpp
similarity index 57%
rename from src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp
rename to src/fsfw/cfdp/pdu/FinishedPduReader.cpp
index feeca617..08dd3a82 100644
--- a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp
+++ b/src/fsfw/cfdp/pdu/FinishedPduReader.cpp
@@ -1,25 +1,24 @@
-#include "FinishedPduDeserializer.h"
+#include "FinishedPduReader.h"
-FinishPduDeserializer::FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize,
- FinishedInfo& info)
- : FileDirectiveDeserializer(pduBuf, maxSize), finishedInfo(info) {}
+FinishPduReader::FinishPduReader(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info)
+ : FileDirectiveReader(pduBuf, maxSize), finishedInfo(info) {}
-ReturnValue_t FinishPduDeserializer::parseData() {
- ReturnValue_t result = FileDirectiveDeserializer::parseData();
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ReturnValue_t FinishPduReader::parseData() {
+ ReturnValue_t result = FileDirectiveReader::parseData();
+ if (result != returnvalue::OK) {
return result;
}
- size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
- const uint8_t* buf = rawPtr + currentIdx;
- size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx;
+ size_t currentIdx = FileDirectiveReader::getHeaderSize();
+ const uint8_t* buf = pointers.rawPtr + currentIdx;
+ size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx;
if (remSize < 1) {
return SerializeIF::STREAM_TOO_SHORT;
}
uint8_t firstByte = *buf;
- cfdp::ConditionCode condCode = static_cast((firstByte >> 4) & 0x0f);
+ auto condCode = static_cast((firstByte >> 4) & 0x0f);
finishedInfo.setConditionCode(condCode);
- finishedInfo.setDeliveryCode(static_cast(firstByte >> 2 & 0b1));
- finishedInfo.setFileStatus(static_cast(firstByte & 0b11));
+ finishedInfo.setDeliveryCode(static_cast(firstByte >> 2 & 0b1));
+ finishedInfo.setFileStatus(static_cast(firstByte & 0b11));
buf += 1;
remSize -= 1;
currentIdx += 1;
@@ -29,17 +28,17 @@ ReturnValue_t FinishPduDeserializer::parseData() {
return result;
}
-FinishedInfo& FinishPduDeserializer::getInfo() { return finishedInfo; }
+FinishedInfo& FinishPduReader::getInfo() { return finishedInfo; }
-ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf,
- cfdp::ConditionCode conditionCode) {
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
+ReturnValue_t FinishPduReader::parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf,
+ cfdp::ConditionCode conditionCode) {
+ ReturnValue_t result = returnvalue::OK;
size_t fsResponsesIdx = 0;
auto endianness = getEndianness();
FilestoreResponseTlv** fsResponseArray = nullptr;
size_t fsResponseMaxArrayLen = 0;
EntityIdTlv* faultLocation = nullptr;
- cfdp::TlvTypes nextTlv = cfdp::TlvTypes::INVALID_TLV;
+ cfdp::TlvType nextTlv = cfdp::TlvType::INVALID_TLV;
while (remLen > 0) {
// Simply forward parse the TLV type. Every TLV type except the last one must be a Filestore
// Response TLV, and even the last one can be a Filestore Response TLV if the fault
@@ -47,8 +46,8 @@ ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx,
if (currentIdx + 2 > maxSize) {
return SerializeIF::STREAM_TOO_SHORT;
}
- nextTlv = static_cast(*buf);
- if (nextTlv == cfdp::TlvTypes::FILESTORE_RESPONSE) {
+ nextTlv = static_cast(*buf);
+ if (nextTlv == cfdp::TlvType::FILESTORE_RESPONSE) {
if (fsResponseArray == nullptr) {
if (not finishedInfo.canHoldFsResponses()) {
return cfdp::FINISHED_CANT_PARSE_FS_RESPONSES;
@@ -60,11 +59,11 @@ ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx,
return cfdp::FINISHED_CANT_PARSE_FS_RESPONSES;
}
result = fsResponseArray[fsResponsesIdx]->deSerialize(&buf, &remLen, endianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
fsResponsesIdx += 1;
- } else if (nextTlv == cfdp::TlvTypes::ENTITY_ID) {
+ } else if (nextTlv == cfdp::TlvType::ENTITY_ID) {
// This needs to be the last TLV and it should not be here if the condition code
// is "No Error" or "Unsupported Checksum Type"
if (conditionCode == cfdp::ConditionCode::NO_ERROR or
@@ -72,11 +71,11 @@ ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx,
return cfdp::INVALID_TLV_TYPE;
}
result = finishedInfo.getFaultLocation(&faultLocation);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = faultLocation->deSerialize(&buf, &remLen, endianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
} else {
diff --git a/src/fsfw/cfdp/pdu/FinishedPduReader.h b/src/fsfw/cfdp/pdu/FinishedPduReader.h
new file mode 100644
index 00000000..791a2ef4
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/FinishedPduReader.h
@@ -0,0 +1,22 @@
+#ifndef FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_
+#define FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_
+
+#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
+#include "fsfw/cfdp/pdu/FinishedInfo.h"
+
+class FinishPduReader : public FileDirectiveReader {
+ public:
+ FinishPduReader(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info);
+
+ ReturnValue_t parseData() override;
+
+ FinishedInfo& getInfo();
+
+ private:
+ FinishedInfo& finishedInfo;
+
+ ReturnValue_t parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf,
+ cfdp::ConditionCode conditionCode);
+};
+
+#endif /* FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp
deleted file mode 100644
index 115a2c9c..00000000
--- a/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "FinishedPduSerializer.h"
-
-FinishPduSerializer::FinishPduSerializer(PduConfig &conf, FinishedInfo &finishInfo)
- : FileDirectiveSerializer(conf, cfdp::FileDirectives::FINISH, 0), finishInfo(finishInfo) {
- updateDirectiveFieldLen();
-}
-
-size_t FinishPduSerializer::getSerializedSize() const {
- return FinishPduSerializer::getWholePduSize();
-}
-
-void FinishPduSerializer::updateDirectiveFieldLen() {
- setDirectiveDataFieldLen(finishInfo.getSerializedSize());
-}
-
-ReturnValue_t FinishPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const {
- ReturnValue_t result =
- FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- if (*size + 1 >= maxSize) {
- return SerializeIF::BUFFER_TOO_SHORT;
- }
- **buffer = finishInfo.getConditionCode() << 4 | finishInfo.getDeliveryCode() << 2 |
- finishInfo.getFileStatus();
- *size += 1;
- *buffer += 1;
-
- if (finishInfo.hasFsResponses()) {
- FilestoreResponseTlv **fsResponsesArray = nullptr;
- size_t fsResponsesArrayLen = 0;
- finishInfo.getFilestoreResonses(&fsResponsesArray, &fsResponsesArrayLen, nullptr);
- for (size_t idx = 0; idx < fsResponsesArrayLen; idx++) {
- result = fsResponsesArray[idx]->serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- }
- }
- EntityIdTlv *entityId = nullptr;
- if (finishInfo.getFaultLocation(&entityId) == HasReturnvaluesIF::RETURN_OK) {
- result = entityId->serialize(buffer, size, maxSize, streamEndianness);
- }
- return result;
-}
diff --git a/src/fsfw/cfdp/pdu/FinishedPduSerializer.h b/src/fsfw/cfdp/pdu/FinishedPduSerializer.h
deleted file mode 100644
index d66b25f2..00000000
--- a/src/fsfw/cfdp/pdu/FinishedPduSerializer.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_
-
-#include "FinishedInfo.h"
-#include "fsfw/cfdp/pdu/FileDataSerializer.h"
-#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
-
-class FinishPduSerializer : public FileDirectiveSerializer {
- public:
- FinishPduSerializer(PduConfig& pduConf, FinishedInfo& finishInfo);
-
- void updateDirectiveFieldLen();
-
- size_t getSerializedSize() const override;
-
- ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
- Endianness streamEndianness) const override;
-
- private:
- FinishedInfo& finishInfo;
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.cpp b/src/fsfw/cfdp/pdu/HeaderCreator.cpp
new file mode 100644
index 00000000..29688575
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/HeaderCreator.cpp
@@ -0,0 +1,111 @@
+#include "HeaderCreator.h"
+
+HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
+ cfdp::SegmentMetadataFlag segmentMetadataFlag,
+ cfdp::SegmentationControl segCtrl)
+ : pduType(pduType),
+ segmentMetadataFlag(segmentMetadataFlag),
+ segmentationCtrl(segCtrl),
+ pduDataFieldLen(initPduDataFieldLen),
+ pduConf(pduConf) {}
+
+ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const {
+ if (buffer == nullptr or size == nullptr) {
+ return returnvalue::FAILED;
+ }
+ if (maxSize < this->getSerializedSize()) {
+ return BUFFER_TOO_SHORT;
+ }
+ **buffer = cfdp::VERSION_BITS | this->pduType << 4 | pduConf.direction << 3 | pduConf.mode << 2 |
+ pduConf.crcFlag << 1 | pduConf.largeFile;
+ *buffer += 1;
+ **buffer = (pduDataFieldLen & 0xff00) >> 8;
+ *buffer += 1;
+ **buffer = pduDataFieldLen & 0x00ff;
+ *buffer += 1;
+ **buffer = segmentationCtrl << 7 | pduConf.sourceId.getWidth() << 4 | segmentMetadataFlag << 3 |
+ pduConf.seqNum.getWidth();
+ *buffer += 1;
+ *size += 4;
+ ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
+ return result;
+ }
+
+ return returnvalue::OK;
+}
+
+size_t HeaderCreator::getSerializedSize() const {
+ return pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4;
+}
+
+ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size,
+ Endianness streamEndianness) {
+ // We could implement this, but I prefer dedicated classes
+ return returnvalue::FAILED;
+}
+
+size_t HeaderCreator::getWholePduSize() const {
+ // Return size of header plus the PDU data field length
+ return pduDataFieldLen + HeaderCreator::getSerializedSize();
+}
+
+size_t HeaderCreator::getPduDataFieldLen() const { return pduDataFieldLen; }
+
+void HeaderCreator::setPduDataFieldLen(size_t pduDataFieldLen_) {
+ pduDataFieldLen = pduDataFieldLen_;
+}
+
+void HeaderCreator::setPduType(cfdp::PduType pduType_) { pduType = pduType_; }
+
+void HeaderCreator::setSegmentMetadataFlag(cfdp::SegmentMetadataFlag segmentMetadataFlag_) {
+ segmentMetadataFlag = segmentMetadataFlag_;
+}
+
+cfdp::PduType HeaderCreator::getPduType() const { return pduType; }
+
+cfdp::Direction HeaderCreator::getDirection() const { return pduConf.direction; }
+
+cfdp::TransmissionMode HeaderCreator::getTransmissionMode() const { return pduConf.mode; }
+
+bool HeaderCreator::getCrcFlag() const { return pduConf.crcFlag; }
+
+bool HeaderCreator::getLargeFileFlag() const { return pduConf.largeFile; }
+
+cfdp::SegmentationControl HeaderCreator::getSegmentationControl() const { return segmentationCtrl; }
+
+cfdp::WidthInBytes HeaderCreator::getLenEntityIds() const { return pduConf.sourceId.getWidth(); }
+
+cfdp::WidthInBytes HeaderCreator::getLenSeqNum() const { return pduConf.seqNum.getWidth(); }
+
+cfdp::SegmentMetadataFlag HeaderCreator::getSegmentMetadataFlag() const {
+ return segmentMetadataFlag;
+}
+
+void HeaderCreator::getSourceId(cfdp::EntityId &sourceId) const { sourceId = pduConf.sourceId; }
+
+void HeaderCreator::getDestId(cfdp::EntityId &destId) const { destId = pduConf.destId; }
+
+void HeaderCreator::setSegmentationControl(cfdp::SegmentationControl segmentationControl) {
+ this->segmentationCtrl = segmentationControl;
+}
+
+void HeaderCreator::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const {
+ seqNum = pduConf.seqNum;
+}
+
+bool HeaderCreator::hasSegmentMetadataFlag() const {
+ if (this->segmentMetadataFlag == cfdp::SegmentMetadataFlag::PRESENT) {
+ return true;
+ }
+ return false;
+}
diff --git a/src/fsfw/cfdp/pdu/HeaderSerializer.h b/src/fsfw/cfdp/pdu/HeaderCreator.h
similarity index 63%
rename from src/fsfw/cfdp/pdu/HeaderSerializer.h
rename to src/fsfw/cfdp/pdu/HeaderCreator.h
index 1de97d63..173a6239 100644
--- a/src/fsfw/cfdp/pdu/HeaderSerializer.h
+++ b/src/fsfw/cfdp/pdu/HeaderCreator.h
@@ -1,14 +1,14 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_HEADERSERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_HEADERSERIALIZER_H_
-#include "../definitions.h"
#include "PduConfig.h"
#include "PduHeaderIF.h"
+#include "fsfw/cfdp/definitions.h"
#include "fsfw/serialize/SerializeIF.h"
-class HeaderSerializer : public SerializeIF, public PduHeaderIF {
+class HeaderCreator : public SerializeIF, public PduHeaderIF {
public:
- HeaderSerializer(
+ HeaderCreator(
PduConfig& pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
cfdp::SegmentMetadataFlag segmentMetadataFlag = cfdp::SegmentMetadataFlag::NOT_PRESENT,
cfdp::SegmentationControl segCtrl =
@@ -23,7 +23,7 @@ class HeaderSerializer : public SerializeIF, public PduHeaderIF {
* data field length was not properly.
* @return
*/
- size_t getSerializedSize() const override;
+ [[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
@@ -32,19 +32,19 @@ class HeaderSerializer : public SerializeIF, public PduHeaderIF {
void setPduType(cfdp::PduType pduType);
void setSegmentMetadataFlag(cfdp::SegmentMetadataFlag);
- size_t getPduDataFieldLen() const override;
- size_t getWholePduSize() const override;
+ [[nodiscard]] size_t getPduDataFieldLen() const override;
+ [[nodiscard]] size_t getWholePduSize() const override;
- cfdp::PduType getPduType() const override;
- cfdp::Direction getDirection() const override;
- cfdp::TransmissionModes getTransmissionMode() const override;
- bool getCrcFlag() const override;
- bool getLargeFileFlag() const override;
- cfdp::SegmentationControl getSegmentationControl() const override;
- cfdp::WidthInBytes getLenEntityIds() const override;
- cfdp::WidthInBytes getLenSeqNum() const override;
- cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override;
- bool hasSegmentMetadataFlag() const override;
+ [[nodiscard]] cfdp::PduType getPduType() const override;
+ [[nodiscard]] cfdp::Direction getDirection() const override;
+ [[nodiscard]] cfdp::TransmissionMode getTransmissionMode() const override;
+ [[nodiscard]] bool getCrcFlag() const override;
+ [[nodiscard]] bool getLargeFileFlag() const override;
+ [[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override;
+ [[nodiscard]] cfdp::WidthInBytes getLenEntityIds() const override;
+ [[nodiscard]] cfdp::WidthInBytes getLenSeqNum() const override;
+ [[nodiscard]] cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override;
+ [[nodiscard]] bool hasSegmentMetadataFlag() const override;
void setSegmentationControl(cfdp::SegmentationControl);
void getSourceId(cfdp::EntityId& sourceId) const override;
diff --git a/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp b/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp
deleted file mode 100644
index 70f397f8..00000000
--- a/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-#include "HeaderDeserializer.h"
-
-#include
-
-#include
-
-HeaderDeserializer::HeaderDeserializer(const uint8_t *pduBuf, size_t maxSize)
- : rawPtr(pduBuf), maxSize(maxSize) {}
-
-ReturnValue_t HeaderDeserializer::parseData() {
- if (maxSize < 7) {
- return SerializeIF::STREAM_TOO_SHORT;
- }
- return setData(const_cast(rawPtr), maxSize);
-}
-
-ReturnValue_t HeaderDeserializer::setData(uint8_t *dataPtr, size_t maxSize, void *args) {
- if (dataPtr == nullptr) {
- // Allowed for now
- this->fixedHeader = nullptr;
- return HasReturnvaluesIF::RETURN_OK;
- }
- this->fixedHeader = reinterpret_cast(const_cast(dataPtr));
- sourceIdRaw = static_cast(&fixedHeader->variableFieldsStart);
- cfdp::WidthInBytes widthEntityIds = getLenEntityIds();
- cfdp::WidthInBytes widthSeqNum = getLenSeqNum();
- seqNumRaw = static_cast(sourceIdRaw) + static_cast(widthEntityIds);
- destIdRaw = static_cast(seqNumRaw) + static_cast(widthSeqNum);
- this->maxSize = maxSize;
- return HasReturnvaluesIF::RETURN_OK;
-}
-
-size_t HeaderDeserializer::getHeaderSize() const {
- if (fixedHeader != nullptr) {
- return getLenEntityIds() * 2 + getLenSeqNum() + 4;
- }
- return 0;
-}
-
-size_t HeaderDeserializer::getPduDataFieldLen() const {
- uint16_t pduFiedlLen = (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL;
- return pduFiedlLen;
-}
-
-size_t HeaderDeserializer::getWholePduSize() const {
- return getPduDataFieldLen() + getHeaderSize();
-}
-
-cfdp::PduType HeaderDeserializer::getPduType() const {
- return static_cast((fixedHeader->firstByte >> 4) & 0x01);
-}
-
-cfdp::Direction HeaderDeserializer::getDirection() const {
- return static_cast((fixedHeader->firstByte >> 3) & 0x01);
-}
-
-cfdp::TransmissionModes HeaderDeserializer::getTransmissionMode() const {
- return static_cast((fixedHeader->firstByte >> 2) & 0x01);
-}
-
-bool HeaderDeserializer::getCrcFlag() const { return (fixedHeader->firstByte >> 1) & 0x01; }
-
-bool HeaderDeserializer::getLargeFileFlag() const { return fixedHeader->firstByte & 0x01; }
-
-cfdp::SegmentationControl HeaderDeserializer::getSegmentationControl() const {
- return static_cast((fixedHeader->fourthByte >> 7) & 0x01);
-}
-
-cfdp::WidthInBytes HeaderDeserializer::getLenEntityIds() const {
- return static_cast((fixedHeader->fourthByte >> 4) & 0x07);
-}
-
-cfdp::WidthInBytes HeaderDeserializer::getLenSeqNum() const {
- return static_cast(fixedHeader->fourthByte & 0x07);
-}
-
-cfdp::SegmentMetadataFlag HeaderDeserializer::getSegmentMetadataFlag() const {
- return static_cast((fixedHeader->fourthByte >> 3) & 0x01);
-}
-
-void HeaderDeserializer::getSourceId(cfdp::EntityId &sourceId) const {
- assignVarLenField(dynamic_cast(&sourceId), getLenEntityIds(),
- this->sourceIdRaw);
-}
-
-void HeaderDeserializer::getDestId(cfdp::EntityId &destId) const {
- assignVarLenField(dynamic_cast(&destId), getLenEntityIds(), this->destIdRaw);
-}
-
-void HeaderDeserializer::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const {
- assignVarLenField(dynamic_cast(&seqNum), getLenSeqNum(), this->seqNumRaw);
-}
-
-void HeaderDeserializer::assignVarLenField(cfdp::VarLenField *field, cfdp::WidthInBytes width,
- void *sourcePtr) const {
- switch (width) {
- case (cfdp::WidthInBytes::ONE_BYTE): {
- uint8_t *fieldTyped = static_cast(sourcePtr);
- field->setValue(width, *fieldTyped);
- break;
- }
- case (cfdp::WidthInBytes::TWO_BYTES): {
- uint16_t fieldTyped = 0;
- size_t deserSize = 0;
- SerializeAdapter::deSerialize(&fieldTyped, static_cast(sourcePtr), &deserSize,
- SerializeIF::Endianness::NETWORK);
- field->setValue(width, fieldTyped);
- break;
- }
- case (cfdp::WidthInBytes::FOUR_BYTES): {
- uint32_t fieldTyped = 0;
- size_t deserSize = 0;
- SerializeAdapter::deSerialize(&fieldTyped, static_cast(sourcePtr), &deserSize,
- SerializeIF::Endianness::NETWORK);
- field->setValue(width, fieldTyped);
- break;
- }
- }
-}
-
-size_t HeaderDeserializer::getMaxSize() const { return maxSize; }
-
-bool HeaderDeserializer::hasSegmentMetadataFlag() const {
- if (this->getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT) {
- return true;
- }
- return false;
-}
diff --git a/src/fsfw/cfdp/pdu/HeaderDeserializer.h b/src/fsfw/cfdp/pdu/HeaderDeserializer.h
deleted file mode 100644
index ed033697..00000000
--- a/src/fsfw/cfdp/pdu/HeaderDeserializer.h
+++ /dev/null
@@ -1,90 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_HEADERDESERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_HEADERDESERIALIZER_H_
-
-#include
-#include
-
-#include "PduConfig.h"
-#include "PduHeaderIF.h"
-#include "fsfw/serialize/SerializeIF.h"
-#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h"
-
-struct PduHeaderFixedStruct {
- uint8_t firstByte;
- uint8_t pduDataFieldLenH;
- uint8_t pduDataFieldLenL;
- uint8_t fourthByte;
- uint8_t variableFieldsStart;
-};
-
-/**
- * @brief This class is used to deserialize a PDU header from raw memory.
- * @details
- * This is a zero-copy implementation and #parseData needs to be called to ensure the data is
- * valid.
- */
-class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF {
- public:
- /**
- * Initialize a PDU header from raw data. This is a zero-copy implementation and #parseData
- * needs to be called to ensure the data is valid
- * @param pduBuf
- * @param maxSize
- */
- HeaderDeserializer(const uint8_t* pduBuf, size_t maxSize);
-
- /**
- * This needs to be called before accessing the PDU fields to avoid segmentation faults.
- * @return
- * - RETURN_OK on parse success
- * - RETURN_FAILED Invalid raw data
- * - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected
- */
- virtual ReturnValue_t parseData();
- size_t getHeaderSize() const;
-
- size_t getPduDataFieldLen() const override;
- size_t getWholePduSize() const override;
-
- cfdp::PduType getPduType() const override;
- cfdp::Direction getDirection() const override;
- cfdp::TransmissionModes getTransmissionMode() const override;
- bool getCrcFlag() const override;
- bool getLargeFileFlag() const override;
- cfdp::SegmentationControl getSegmentationControl() const override;
- cfdp::WidthInBytes getLenEntityIds() const override;
- cfdp::WidthInBytes getLenSeqNum() const override;
- cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override;
- bool hasSegmentMetadataFlag() const override;
-
- void getSourceId(cfdp::EntityId& sourceId) const override;
- void getDestId(cfdp::EntityId& destId) const override;
- void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const override;
-
- ReturnValue_t deserResult = HasReturnvaluesIF::RETURN_OK;
-
- /**
- * Can also be used to reset the pointer to a nullptr, but the getter functions will not
- * perform nullptr checks!
- * @param dataPtr
- * @param maxSize
- * @param args
- * @return
- */
- ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) override;
-
- size_t getMaxSize() const;
-
- protected:
- PduHeaderFixedStruct* fixedHeader = nullptr;
- const uint8_t* rawPtr = nullptr;
- size_t maxSize = 0;
-
- private:
- void assignVarLenField(cfdp::VarLenField* field, cfdp::WidthInBytes width, void* sourcePtr) const;
- void* sourceIdRaw = nullptr;
- void* seqNumRaw = nullptr;
- void* destIdRaw = nullptr;
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_HEADERDESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp
new file mode 100644
index 00000000..9edf2394
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp
@@ -0,0 +1,160 @@
+#include
+
+#include
+
+#include "PduHeaderReader.h"
+
+PduHeaderReader::PduHeaderReader(const uint8_t *pduBuf, size_t maxSize) {
+ setReadOnlyData(pduBuf, maxSize);
+}
+
+ReturnValue_t PduHeaderReader::parseData() {
+ if (pointers.rawPtr == nullptr) {
+ return returnvalue::FAILED;
+ }
+ if (maxSize < 7) {
+ return SerializeIF::STREAM_TOO_SHORT;
+ }
+ pointers.fixedHeader =
+ reinterpret_cast(const_cast(pointers.rawPtr));
+ sourceIdRaw = static_cast(&pointers.fixedHeader->variableFieldsStart);
+ cfdp::WidthInBytes widthEntityIds = getLenEntityIds();
+ cfdp::WidthInBytes widthSeqNum = getLenSeqNum();
+ seqNumRaw = static_cast(sourceIdRaw) + static_cast(widthEntityIds);
+ destIdRaw = static_cast(seqNumRaw) + static_cast(widthSeqNum);
+ if (getWholePduSize() > PduHeaderReader::getHeaderSize()) {
+ pointers.dataFieldStart = reinterpret_cast(destIdRaw) + widthEntityIds;
+ } else {
+ pointers.dataFieldStart = nullptr;
+ }
+ return returnvalue::OK;
+}
+
+ReturnValue_t PduHeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) {
+ if (dataPtr == nullptr) {
+ return returnvalue::FAILED;
+ }
+ if (maxSize_ < 7) {
+ return SerializeIF::STREAM_TOO_SHORT;
+ }
+ pointers.rawPtr = dataPtr;
+ maxSize = maxSize_;
+ return returnvalue::OK;
+}
+
+size_t PduHeaderReader::getHeaderSize() const {
+ if (pointers.fixedHeader != nullptr) {
+ return getLenEntityIds() * 2 + getLenSeqNum() + 4;
+ }
+ return 0;
+}
+
+size_t PduHeaderReader::getPduDataFieldLen() const {
+ return (pointers.fixedHeader->pduDataFieldLenH << 8) | pointers.fixedHeader->pduDataFieldLenL;
+}
+
+size_t PduHeaderReader::getWholePduSize() const {
+ return getPduDataFieldLen() + PduHeaderReader::getHeaderSize();
+}
+
+cfdp::PduType PduHeaderReader::getPduType() const {
+ return static_cast((pointers.fixedHeader->firstByte >> 4) & 0x01);
+}
+
+cfdp::Direction PduHeaderReader::getDirection() const {
+ return static_cast((pointers.fixedHeader->firstByte >> 3) & 0x01);
+}
+
+cfdp::TransmissionMode PduHeaderReader::getTransmissionMode() const {
+ return static_cast((pointers.fixedHeader->firstByte >> 2) & 0x01);
+}
+
+bool PduHeaderReader::getCrcFlag() const { return (pointers.fixedHeader->firstByte >> 1) & 0x01; }
+
+bool PduHeaderReader::getLargeFileFlag() const { return pointers.fixedHeader->firstByte & 0x01; }
+
+cfdp::SegmentationControl PduHeaderReader::getSegmentationControl() const {
+ return static_cast((pointers.fixedHeader->fourthByte >> 7) & 0x01);
+}
+
+cfdp::WidthInBytes PduHeaderReader::getLenEntityIds() const {
+ return static_cast((pointers.fixedHeader->fourthByte >> 4) & 0x07);
+}
+
+cfdp::WidthInBytes PduHeaderReader::getLenSeqNum() const {
+ return static_cast(pointers.fixedHeader->fourthByte & 0x07);
+}
+
+cfdp::SegmentMetadataFlag PduHeaderReader::getSegmentMetadataFlag() const {
+ return static_cast((pointers.fixedHeader->fourthByte >> 3) & 0x01);
+}
+
+void PduHeaderReader::getSourceId(cfdp::EntityId &sourceId) const {
+ assignVarLenField(dynamic_cast(&sourceId), getLenEntityIds(),
+ this->sourceIdRaw);
+}
+
+void PduHeaderReader::getDestId(cfdp::EntityId &destId) const {
+ assignVarLenField(dynamic_cast(&destId), getLenEntityIds(), this->destIdRaw);
+}
+
+void PduHeaderReader::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const {
+ assignVarLenField(dynamic_cast(&seqNum), getLenSeqNum(), this->seqNumRaw);
+}
+
+void PduHeaderReader::assignVarLenField(cfdp::VarLenField *field, cfdp::WidthInBytes width,
+ void *sourcePtr) const {
+ switch (width) {
+ case (cfdp::WidthInBytes::ONE_BYTE): {
+ auto *fieldTyped = static_cast(sourcePtr);
+ field->setValue(width, *fieldTyped);
+ break;
+ }
+ case (cfdp::WidthInBytes::TWO_BYTES): {
+ uint16_t fieldTyped = 0;
+ size_t deserSize = 0;
+ SerializeAdapter::deSerialize(&fieldTyped, static_cast(sourcePtr), &deserSize,
+ SerializeIF::Endianness::NETWORK);
+ field->setValue(width, fieldTyped);
+ break;
+ }
+ case (cfdp::WidthInBytes::FOUR_BYTES): {
+ uint32_t fieldTyped = 0;
+ size_t deserSize = 0;
+ SerializeAdapter::deSerialize(&fieldTyped, static_cast(sourcePtr), &deserSize,
+ SerializeIF::Endianness::NETWORK);
+ field->setValue(width, fieldTyped);
+ break;
+ }
+ }
+}
+
+size_t PduHeaderReader::getMaxSize() const { return maxSize; }
+
+bool PduHeaderReader::hasSegmentMetadataFlag() const {
+ if (this->getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT) {
+ return true;
+ }
+ return false;
+}
+
+ReturnValue_t PduHeaderReader::setReadOnlyData(const uint8_t *dataPtr, size_t maxSize_) {
+ return setData(const_cast(dataPtr), maxSize_, nullptr);
+}
+bool PduHeaderReader::isNull() const {
+ return pointers.rawPtr == nullptr or pointers.fixedHeader == nullptr;
+}
+
+PduHeaderReader::operator bool() const { return not isNull(); }
+
+void PduHeaderReader::fillConfig(PduConfig &cfg) const {
+ cfg.largeFile = getLargeFileFlag();
+ cfg.crcFlag = getCrcFlag();
+ cfg.mode = getTransmissionMode();
+ cfg.direction = getDirection();
+ getTransactionSeqNum(cfg.seqNum);
+ getSourceId(cfg.sourceId);
+ getDestId(cfg.destId);
+}
+
+const uint8_t *PduHeaderReader::getPduDataField() const { return pointers.dataFieldStart; }
diff --git a/src/fsfw/cfdp/pdu/HeaderSerializer.cpp b/src/fsfw/cfdp/pdu/HeaderSerializer.cpp
deleted file mode 100644
index 041fb714..00000000
--- a/src/fsfw/cfdp/pdu/HeaderSerializer.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-#include "HeaderSerializer.h"
-
-#include "HeaderDeserializer.h"
-
-HeaderSerializer::HeaderSerializer(PduConfig &pduConf, cfdp::PduType pduType,
- size_t initPduDataFieldLen,
- cfdp::SegmentMetadataFlag segmentMetadataFlag,
- cfdp::SegmentationControl segCtrl)
- : pduType(pduType),
- segmentMetadataFlag(segmentMetadataFlag),
- segmentationCtrl(segCtrl),
- pduDataFieldLen(initPduDataFieldLen),
- pduConf(pduConf) {}
-
-ReturnValue_t HeaderSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const {
- if (buffer == nullptr or size == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
- }
- if (maxSize < this->getSerializedSize()) {
- return BUFFER_TOO_SHORT;
- }
- **buffer = cfdp::VERSION_BITS | this->pduType << 4 | pduConf.direction << 3 | pduConf.mode << 2 |
- pduConf.crcFlag << 1 | pduConf.largeFile;
- *buffer += 1;
- **buffer = (pduDataFieldLen & 0xff00) >> 8;
- *buffer += 1;
- **buffer = pduDataFieldLen & 0x00ff;
- *buffer += 1;
- **buffer = segmentationCtrl << 7 | pduConf.sourceId.getWidth() << 4 | segmentMetadataFlag << 3 |
- pduConf.seqNum.getWidth();
- *buffer += 1;
- *size += 4;
- ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
-
- return HasReturnvaluesIF::RETURN_OK;
-}
-
-size_t HeaderSerializer::getSerializedSize() const {
- size_t shit = pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4;
- return shit;
-}
-
-ReturnValue_t HeaderSerializer::deSerialize(const uint8_t **buffer, size_t *size,
- Endianness streamEndianness) {
- // We could implement this, but I prefer dedicated classes
- return HasReturnvaluesIF::RETURN_FAILED;
-}
-
-size_t HeaderSerializer::getWholePduSize() const {
- // Return size of header plus the PDU data field length
- return pduDataFieldLen + HeaderSerializer::getSerializedSize();
-}
-
-size_t HeaderSerializer::getPduDataFieldLen() const { return pduDataFieldLen; }
-
-void HeaderSerializer::setPduDataFieldLen(size_t pduDataFieldLen) {
- this->pduDataFieldLen = pduDataFieldLen;
-}
-
-void HeaderSerializer::setPduType(cfdp::PduType pduType) { this->pduType = pduType; }
-
-void HeaderSerializer::setSegmentMetadataFlag(cfdp::SegmentMetadataFlag segmentMetadataFlag) {
- this->segmentMetadataFlag = segmentMetadataFlag;
-}
-
-cfdp::PduType HeaderSerializer::getPduType() const { return pduType; }
-
-cfdp::Direction HeaderSerializer::getDirection() const { return pduConf.direction; }
-
-cfdp::TransmissionModes HeaderSerializer::getTransmissionMode() const { return pduConf.mode; }
-
-bool HeaderSerializer::getCrcFlag() const { return pduConf.crcFlag; }
-
-bool HeaderSerializer::getLargeFileFlag() const { return pduConf.largeFile; }
-
-cfdp::SegmentationControl HeaderSerializer::getSegmentationControl() const {
- return segmentationCtrl;
-}
-
-cfdp::WidthInBytes HeaderSerializer::getLenEntityIds() const { return pduConf.sourceId.getWidth(); }
-
-cfdp::WidthInBytes HeaderSerializer::getLenSeqNum() const { return pduConf.seqNum.getWidth(); }
-
-cfdp::SegmentMetadataFlag HeaderSerializer::getSegmentMetadataFlag() const {
- return segmentMetadataFlag;
-}
-
-void HeaderSerializer::getSourceId(cfdp::EntityId &sourceId) const { sourceId = pduConf.sourceId; }
-
-void HeaderSerializer::getDestId(cfdp::EntityId &destId) const { destId = pduConf.destId; }
-
-void HeaderSerializer::setSegmentationControl(cfdp::SegmentationControl segmentationControl) {
- this->segmentationCtrl = segmentationControl;
-}
-
-void HeaderSerializer::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const {
- seqNum = pduConf.seqNum;
-}
-
-bool HeaderSerializer::hasSegmentMetadataFlag() const {
- if (this->segmentMetadataFlag == cfdp::SegmentMetadataFlag::PRESENT) {
- return true;
- }
- return false;
-}
diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp
new file mode 100644
index 00000000..40747751
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp
@@ -0,0 +1,25 @@
+#include "KeepAlivePduCreator.h"
+
+KeepAlivePduCreator::KeepAlivePduCreator(PduConfig &conf, cfdp::FileSize &progress)
+ : FileDirectiveCreator(conf, cfdp::FileDirective::KEEP_ALIVE, 4), progress(progress) {
+ updateDirectiveFieldLen();
+}
+
+size_t KeepAlivePduCreator::getSerializedSize() const {
+ return FileDirectiveCreator::getWholePduSize();
+}
+
+void KeepAlivePduCreator::updateDirectiveFieldLen() {
+ if (this->getLargeFileFlag()) {
+ this->setDirectiveDataFieldLen(8);
+ }
+}
+
+ReturnValue_t KeepAlivePduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const {
+ ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ return progress.serialize(this->getLargeFileFlag(), buffer, size, maxSize, streamEndianness);
+}
diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduCreator.h b/src/fsfw/cfdp/pdu/KeepAlivePduCreator.h
new file mode 100644
index 00000000..aa4bf0fd
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/KeepAlivePduCreator.h
@@ -0,0 +1,22 @@
+#ifndef FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_
+#define FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_
+
+#include "fsfw/cfdp/FileSize.h"
+#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
+
+class KeepAlivePduCreator : public FileDirectiveCreator {
+ public:
+ KeepAlivePduCreator(PduConfig& conf, cfdp::FileSize& progress);
+
+ void updateDirectiveFieldLen();
+
+ [[nodiscard]] size_t getSerializedSize() const override;
+
+ ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
+ Endianness streamEndianness) const override;
+
+ private:
+ cfdp::FileSize& progress;
+};
+
+#endif /* FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp
deleted file mode 100644
index 15f80549..00000000
--- a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "KeepAlivePduDeserializer.h"
-
-KeepAlivePduDeserializer::KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize,
- cfdp::FileSize& progress)
- : FileDirectiveDeserializer(pduBuf, maxSize), progress(progress) {}
-
-ReturnValue_t KeepAlivePduDeserializer::parseData() {
- ReturnValue_t result = FileDirectiveDeserializer::parseData();
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
- size_t remLen = FileDirectiveDeserializer::getWholePduSize() - currentIdx;
- const uint8_t* buffer = rawPtr + currentIdx;
- return progress.deSerialize(&buffer, &remLen, getEndianness());
-}
-
-cfdp::FileSize& KeepAlivePduDeserializer::getProgress() { return progress; }
diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h
deleted file mode 100644
index e8b83ad6..00000000
--- a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUDESERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUDESERIALIZER_H_
-
-#include "fsfw/cfdp/FileSize.h"
-#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
-
-class KeepAlivePduDeserializer : public FileDirectiveDeserializer {
- public:
- KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize, cfdp::FileSize& progress);
-
- ReturnValue_t parseData() override;
-
- cfdp::FileSize& getProgress();
-
- private:
- cfdp::FileSize& progress;
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUDESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduReader.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduReader.cpp
new file mode 100644
index 00000000..d3362cf9
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/KeepAlivePduReader.cpp
@@ -0,0 +1,18 @@
+#include "KeepAlivePduReader.h"
+
+KeepAlivePduReader::KeepAlivePduReader(const uint8_t* pduBuf, size_t maxSize,
+ cfdp::FileSize& progress)
+ : FileDirectiveReader(pduBuf, maxSize), progress(progress) {}
+
+ReturnValue_t KeepAlivePduReader::parseData() {
+ ReturnValue_t result = FileDirectiveReader::parseData();
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ size_t currentIdx = FileDirectiveReader::getHeaderSize();
+ size_t remLen = FileDirectiveReader::getWholePduSize() - currentIdx;
+ const uint8_t* buffer = pointers.rawPtr + currentIdx;
+ return progress.deSerialize(&buffer, &remLen, getEndianness());
+}
+
+cfdp::FileSize& KeepAlivePduReader::getProgress() { return progress; }
diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduReader.h b/src/fsfw/cfdp/pdu/KeepAlivePduReader.h
new file mode 100644
index 00000000..38e061f1
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/KeepAlivePduReader.h
@@ -0,0 +1,19 @@
+#ifndef FSFW_CFDP_PDU_KEEPALIVEREADER_H_
+#define FSFW_CFDP_PDU_KEEPALIVEREADER_H_
+
+#include "fsfw/cfdp/FileSize.h"
+#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
+
+class KeepAlivePduReader : public FileDirectiveReader {
+ public:
+ KeepAlivePduReader(const uint8_t* pduBuf, size_t maxSize, cfdp::FileSize& progress);
+
+ ReturnValue_t parseData() override;
+
+ cfdp::FileSize& getProgress();
+
+ private:
+ cfdp::FileSize& progress;
+};
+
+#endif /* FSFW_CFDP_PDU_KEEPALIVEPDUREADER_H_ */
diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp
deleted file mode 100644
index e635ce06..00000000
--- a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "KeepAlivePduSerializer.h"
-
-KeepAlivePduSerializer::KeepAlivePduSerializer(PduConfig &conf, cfdp::FileSize &progress)
- : FileDirectiveSerializer(conf, cfdp::FileDirectives::KEEP_ALIVE, 4), progress(progress) {
- updateDirectiveFieldLen();
-}
-
-size_t KeepAlivePduSerializer::getSerializedSize() const {
- return FileDirectiveSerializer::getWholePduSize();
-}
-
-void KeepAlivePduSerializer::updateDirectiveFieldLen() {
- if (this->getLargeFileFlag()) {
- this->setDirectiveDataFieldLen(8);
- }
-}
-
-ReturnValue_t KeepAlivePduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const {
- ReturnValue_t result =
- FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- return progress.serialize(this->getLargeFileFlag(), buffer, size, maxSize, streamEndianness);
-}
diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h
deleted file mode 100644
index d2499a79..00000000
--- a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_
-
-#include "fsfw/cfdp/FileSize.h"
-#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
-
-class KeepAlivePduSerializer : public FileDirectiveSerializer {
- public:
- KeepAlivePduSerializer(PduConfig& conf, cfdp::FileSize& progress);
-
- void updateDirectiveFieldLen();
-
- size_t getSerializedSize() const override;
-
- ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
- Endianness streamEndianness) const override;
-
- private:
- cfdp::FileSize& progress;
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/MetadataInfo.cpp b/src/fsfw/cfdp/pdu/MetadataInfo.cpp
index a2ca6972..d88bdd87 100644
--- a/src/fsfw/cfdp/pdu/MetadataInfo.cpp
+++ b/src/fsfw/cfdp/pdu/MetadataInfo.cpp
@@ -1,54 +1,57 @@
#include "MetadataInfo.h"
MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType,
- cfdp::FileSize& fileSize, cfdp::Lv& sourceFileName,
- cfdp::Lv& destFileName)
- : closureRequested(closureRequested),
- checksumType(checksumType),
- fileSize(fileSize),
- sourceFileName(sourceFileName),
- destFileName(destFileName) {}
+ cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName,
+ cfdp::StringLv& destFileName)
+ : MetadataInfo(fileSize, sourceFileName, destFileName) {
+ this->closureRequested = closureRequested;
+ this->checksumType = checksumType;
+}
-void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray, size_t* optionsLen,
- size_t* maxOptionsLen) {
- this->optionsArray = optionsArray;
- if (maxOptionsLen != nullptr) {
- this->maxOptionsLen = *maxOptionsLen;
+MetadataInfo::MetadataInfo(cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName,
+ cfdp::StringLv& destFileName)
+ : fileSize(fileSize), sourceFileName(sourceFileName), destFileName(destFileName) {}
+
+void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray_, std::optional optionsLen_,
+ std::optional maxOptionsLen_) {
+ this->optionsArray = optionsArray_;
+ if (maxOptionsLen_) {
+ this->maxOptionsLen = maxOptionsLen_.value();
}
- if (optionsLen != nullptr) {
- this->optionsLen = *optionsLen;
+ if (optionsLen_) {
+ this->optionsLen = optionsLen_.value();
}
}
cfdp::ChecksumType MetadataInfo::getChecksumType() const { return checksumType; }
-void MetadataInfo::setChecksumType(cfdp::ChecksumType checksumType) {
- this->checksumType = checksumType;
+void MetadataInfo::setChecksumType(cfdp::ChecksumType checksumType_) {
+ checksumType = checksumType_;
}
bool MetadataInfo::isClosureRequested() const { return closureRequested; }
-void MetadataInfo::setClosureRequested(bool closureRequested) {
- this->closureRequested = closureRequested;
+void MetadataInfo::setClosureRequested(bool closureRequested_) {
+ closureRequested = closureRequested_;
}
-cfdp::Lv& MetadataInfo::getDestFileName() { return destFileName; }
+cfdp::StringLv& MetadataInfo::getDestFileName() { return destFileName; }
cfdp::FileSize& MetadataInfo::getFileSize() { return fileSize; }
-ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray, size_t* optionsLen,
+ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray_, size_t* optionsLen_,
size_t* maxOptsLen) {
- if (optionsArray == nullptr or this->optionsArray == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ if (optionsArray_ == nullptr or optionsArray == nullptr) {
+ return returnvalue::FAILED;
}
- *optionsArray = this->optionsArray;
- if (optionsLen != nullptr) {
- *optionsLen = this->optionsLen;
+ *optionsArray_ = optionsArray;
+ if (optionsLen_ != nullptr) {
+ *optionsLen_ = this->optionsLen;
}
if (maxOptsLen != nullptr) {
*maxOptsLen = this->maxOptionsLen;
}
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
bool MetadataInfo::hasOptions() const {
@@ -81,18 +84,20 @@ size_t MetadataInfo::getSerializedSize(bool fssLarge) {
return size;
}
-void MetadataInfo::setDestFileName(cfdp::Lv& destFileName) { this->destFileName = destFileName; }
+void MetadataInfo::setDestFileName(cfdp::StringLv& destFileName_) {
+ this->destFileName = destFileName_;
+}
-void MetadataInfo::setSourceFileName(cfdp::Lv& sourceFileName) {
- this->sourceFileName = sourceFileName;
+void MetadataInfo::setSourceFileName(cfdp::StringLv& sourceFileName_) {
+ this->sourceFileName = sourceFileName_;
}
size_t MetadataInfo::getMaxOptionsLen() const { return maxOptionsLen; }
-void MetadataInfo::setMaxOptionsLen(size_t maxOptionsLen) { this->maxOptionsLen = maxOptionsLen; }
+void MetadataInfo::setMaxOptionsLen(size_t maxOptionsLen_) { this->maxOptionsLen = maxOptionsLen_; }
size_t MetadataInfo::getOptionsLen() const { return optionsLen; }
-void MetadataInfo::setOptionsLen(size_t optionsLen) { this->optionsLen = optionsLen; }
+void MetadataInfo::setOptionsLen(size_t optionsLen_) { this->optionsLen = optionsLen_; }
-cfdp::Lv& MetadataInfo::getSourceFileName() { return sourceFileName; }
+cfdp::StringLv& MetadataInfo::getSourceFileName() { return sourceFileName; }
diff --git a/src/fsfw/cfdp/pdu/MetadataInfo.h b/src/fsfw/cfdp/pdu/MetadataInfo.h
index 9b90138c..95f4544a 100644
--- a/src/fsfw/cfdp/pdu/MetadataInfo.h
+++ b/src/fsfw/cfdp/pdu/MetadataInfo.h
@@ -1,45 +1,51 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAINFO_H_
#define FSFW_SRC_FSFW_CFDP_PDU_METADATAINFO_H_
+#include
+
#include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/definitions.h"
#include "fsfw/cfdp/tlv/Lv.h"
+#include "fsfw/cfdp/tlv/StringLv.h"
#include "fsfw/cfdp/tlv/Tlv.h"
class MetadataInfo {
public:
+ MetadataInfo(cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName,
+ cfdp::StringLv& destFileName);
MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType, cfdp::FileSize& fileSize,
- cfdp::Lv& sourceFileName, cfdp::Lv& destFileName);
+ cfdp::StringLv& sourceFileName, cfdp::StringLv& destFileName);
size_t getSerializedSize(bool fssLarge = false);
- void setOptionsArray(cfdp::Tlv** optionsArray, size_t* optionsLen, size_t* maxOptionsLen);
- cfdp::ChecksumType getChecksumType() const;
+ void setOptionsArray(cfdp::Tlv** optionsArray, std::optional optionsLen,
+ std::optional maxOptionsLen);
+ [[nodiscard]] cfdp::ChecksumType getChecksumType() const;
void setChecksumType(cfdp::ChecksumType checksumType);
- bool isClosureRequested() const;
+ [[nodiscard]] bool isClosureRequested() const;
void setClosureRequested(bool closureRequested = false);
- void setDestFileName(cfdp::Lv& destFileName);
- void setSourceFileName(cfdp::Lv& sourceFileName);
+ void setDestFileName(cfdp::StringLv& destFileName);
+ void setSourceFileName(cfdp::StringLv& sourceFileName);
- cfdp::Lv& getDestFileName();
- cfdp::Lv& getSourceFileName();
+ cfdp::StringLv& getDestFileName();
+ cfdp::StringLv& getSourceFileName();
cfdp::FileSize& getFileSize();
- bool hasOptions() const;
- bool canHoldOptions() const;
+ [[nodiscard]] bool hasOptions() const;
+ [[nodiscard]] bool canHoldOptions() const;
ReturnValue_t getOptions(cfdp::Tlv*** optionsArray, size_t* optionsLen, size_t* maxOptsLen);
void setOptionsLen(size_t optionsLen);
- size_t getOptionsLen() const;
+ [[nodiscard]] size_t getOptionsLen() const;
void setMaxOptionsLen(size_t maxOptionsLen);
- size_t getMaxOptionsLen() const;
+ [[nodiscard]] size_t getMaxOptionsLen() const;
private:
bool closureRequested = false;
- cfdp::ChecksumType checksumType;
+ cfdp::ChecksumType checksumType = cfdp::ChecksumType::NULL_CHECKSUM;
cfdp::FileSize& fileSize;
- cfdp::Lv& sourceFileName;
- cfdp::Lv& destFileName;
+ cfdp::StringLv& sourceFileName;
+ cfdp::StringLv& destFileName;
cfdp::Tlv** optionsArray = nullptr;
size_t optionsLen = 0;
diff --git a/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp b/src/fsfw/cfdp/pdu/MetadataPduCreator.cpp
similarity index 51%
rename from src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp
rename to src/fsfw/cfdp/pdu/MetadataPduCreator.cpp
index f5c4de0a..536a48f4 100644
--- a/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp
+++ b/src/fsfw/cfdp/pdu/MetadataPduCreator.cpp
@@ -1,23 +1,22 @@
-#include "MetadataPduSerializer.h"
+#include "MetadataPduCreator.h"
-MetadataPduSerializer::MetadataPduSerializer(PduConfig &conf, MetadataInfo &info)
- : FileDirectiveSerializer(conf, cfdp::FileDirectives::METADATA, 5), info(info) {
+MetadataPduCreator::MetadataPduCreator(PduConfig &conf, MetadataInfo &info)
+ : FileDirectiveCreator(conf, cfdp::FileDirective::METADATA, 5), info(info) {
updateDirectiveFieldLen();
}
-void MetadataPduSerializer::updateDirectiveFieldLen() {
+void MetadataPduCreator::updateDirectiveFieldLen() {
setDirectiveDataFieldLen(info.getSerializedSize(getLargeFileFlag()));
}
-size_t MetadataPduSerializer::getSerializedSize() const {
- return FileDirectiveSerializer::getWholePduSize();
+size_t MetadataPduCreator::getSerializedSize() const {
+ return FileDirectiveCreator::getWholePduSize();
}
-ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const {
- ReturnValue_t result =
- FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ReturnValue_t MetadataPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const {
+ ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
return result;
}
if (*size + 1 >= maxSize) {
@@ -27,15 +26,15 @@ ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, s
*buffer += 1;
*size += 1;
result = info.getFileSize().serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = info.getSourceFileName().serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = info.getDestFileName().serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
@@ -45,7 +44,7 @@ ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, s
info.getOptions(&optsArray, &optsLen, nullptr);
for (size_t idx = 0; idx < optsLen; idx++) {
result = optsArray[idx]->serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
}
diff --git a/src/fsfw/cfdp/pdu/MetadataPduCreator.h b/src/fsfw/cfdp/pdu/MetadataPduCreator.h
new file mode 100644
index 00000000..4486a79c
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/MetadataPduCreator.h
@@ -0,0 +1,23 @@
+#ifndef FSFW_CFDP_PDU_METADATAPDUCREATOR_H_
+#define FSFW_CFDP_PDU_METADATAPDUCREATOR_H_
+
+#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
+#include "fsfw/cfdp/pdu/MetadataInfo.h"
+
+class MetadataPduCreator : public FileDirectiveCreator {
+ public:
+ MetadataPduCreator(PduConfig& conf, MetadataInfo& info);
+
+ void updateDirectiveFieldLen();
+
+ [[nodiscard]] size_t getSerializedSize() const override;
+
+ ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
+ Endianness streamEndianness) const override;
+ using FileDirectiveCreator::serialize;
+
+ private:
+ MetadataInfo& info;
+};
+
+#endif /* FSFW_CFDP_PDU_METADATAPDUCREATOR_H_ */
diff --git a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.h b/src/fsfw/cfdp/pdu/MetadataPduDeserializer.h
deleted file mode 100644
index 1a8f9315..00000000
--- a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_
-
-#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
-#include "fsfw/cfdp/pdu/MetadataInfo.h"
-
-class MetadataPduDeserializer : public FileDirectiveDeserializer {
- public:
- MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info);
-
- ReturnValue_t parseData() override;
-
- private:
- MetadataInfo& info;
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp
similarity index 58%
rename from src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp
rename to src/fsfw/cfdp/pdu/MetadataPduReader.cpp
index 161eb63a..66025140 100644
--- a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp
+++ b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp
@@ -1,17 +1,16 @@
-#include "MetadataPduDeserializer.h"
+#include "MetadataPduReader.h"
-MetadataPduDeserializer::MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize,
- MetadataInfo& info)
- : FileDirectiveDeserializer(pduBuf, maxSize), info(info) {}
+MetadataPduReader::MetadataPduReader(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info)
+ : FileDirectiveReader(pduBuf, maxSize), info(info) {}
-ReturnValue_t MetadataPduDeserializer::parseData() {
- ReturnValue_t result = FileDirectiveDeserializer::parseData();
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ReturnValue_t MetadataPduReader::parseData() {
+ ReturnValue_t result = FileDirectiveReader::parseData();
+ if (result != returnvalue::OK) {
return result;
}
- size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
- const uint8_t* buf = rawPtr + currentIdx;
- size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx;
+ size_t currentIdx = FileDirectiveReader::getHeaderSize();
+ const uint8_t* buf = pointers.rawPtr + currentIdx;
+ size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx;
if (remSize < 1) {
return SerializeIF::STREAM_TOO_SHORT;
}
@@ -21,15 +20,15 @@ ReturnValue_t MetadataPduDeserializer::parseData() {
buf += 1;
auto endianness = getEndianness();
result = info.getFileSize().deSerialize(&buf, &remSize, endianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = info.getSourceFileName().deSerialize(&buf, &remSize, endianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = info.getDestFileName().deSerialize(&buf, &remSize, endianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
@@ -47,7 +46,7 @@ ReturnValue_t MetadataPduDeserializer::parseData() {
return cfdp::METADATA_CANT_PARSE_OPTIONS;
}
result = optionsArray[optsIdx]->deSerialize(&buf, &remSize, endianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
optsIdx++;
diff --git a/src/fsfw/cfdp/pdu/MetadataPduReader.h b/src/fsfw/cfdp/pdu/MetadataPduReader.h
new file mode 100644
index 00000000..3e8c0f30
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/MetadataPduReader.h
@@ -0,0 +1,17 @@
+#ifndef FSFW_CFDP_PDU_METADATAPDUREADER_H_
+#define FSFW_CFDP_PDU_METADATAPDUREADER_H_
+
+#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
+#include "fsfw/cfdp/pdu/MetadataInfo.h"
+
+class MetadataPduReader : public FileDirectiveReader {
+ public:
+ MetadataPduReader(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info);
+
+ ReturnValue_t parseData() override;
+
+ private:
+ MetadataInfo& info;
+};
+
+#endif /* FSFW_CFDP_PDU_METADATAPDUREADER_H_ */
diff --git a/src/fsfw/cfdp/pdu/MetadataPduSerializer.h b/src/fsfw/cfdp/pdu/MetadataPduSerializer.h
deleted file mode 100644
index cacf8a52..00000000
--- a/src/fsfw/cfdp/pdu/MetadataPduSerializer.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_
-
-#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
-#include "fsfw/cfdp/pdu/MetadataInfo.h"
-
-class MetadataPduSerializer : public FileDirectiveSerializer {
- public:
- MetadataPduSerializer(PduConfig& conf, MetadataInfo& info);
-
- void updateDirectiveFieldLen();
-
- size_t getSerializedSize() const override;
-
- ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
- Endianness streamEndianness) const override;
-
- private:
- MetadataInfo& info;
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/NakInfo.cpp b/src/fsfw/cfdp/pdu/NakInfo.cpp
index 795004a9..14d06cb0 100644
--- a/src/fsfw/cfdp/pdu/NakInfo.cpp
+++ b/src/fsfw/cfdp/pdu/NakInfo.cpp
@@ -26,7 +26,7 @@ bool NakInfo::hasSegmentRequests() const {
}
bool NakInfo::canHoldSegmentRequests() const {
- if (this->segmentRequests != nullptr and maxSegmentRequestsLen > 0) {
+ if (segmentRequests != nullptr and maxSegmentRequestsLen > 0) {
return true;
}
return false;
diff --git a/src/fsfw/cfdp/pdu/NakPduSerializer.cpp b/src/fsfw/cfdp/pdu/NakPduCreator.cpp
similarity index 50%
rename from src/fsfw/cfdp/pdu/NakPduSerializer.cpp
rename to src/fsfw/cfdp/pdu/NakPduCreator.cpp
index 95f1bc98..11f3aba9 100644
--- a/src/fsfw/cfdp/pdu/NakPduSerializer.cpp
+++ b/src/fsfw/cfdp/pdu/NakPduCreator.cpp
@@ -1,31 +1,28 @@
-#include "NakPduSerializer.h"
+#include "NakPduCreator.h"
-NakPduSerializer::NakPduSerializer(PduConfig &pduConf, NakInfo &nakInfo)
- : FileDirectiveSerializer(pduConf, cfdp::FileDirectives::NAK, 0), nakInfo(nakInfo) {
+NakPduCreator::NakPduCreator(PduConfig &pduConf, NakInfo &nakInfo)
+ : FileDirectiveCreator(pduConf, cfdp::FileDirective::NAK, 0), nakInfo(nakInfo) {
updateDirectiveFieldLen();
}
-void NakPduSerializer::updateDirectiveFieldLen() {
+void NakPduCreator::updateDirectiveFieldLen() {
this->setDirectiveDataFieldLen(nakInfo.getSerializedSize(getLargeFileFlag()));
}
-size_t NakPduSerializer::getSerializedSize() const {
- return FileDirectiveSerializer::getWholePduSize();
-}
+size_t NakPduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); }
-ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const {
- ReturnValue_t result =
- FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ReturnValue_t NakPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const {
+ ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
return result;
}
result = nakInfo.getStartOfScope().serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = nakInfo.getEndOfScope().serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
if (nakInfo.hasSegmentRequests()) {
@@ -34,11 +31,11 @@ ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t
nakInfo.getSegmentRequests(&segmentRequests, &segmentRequestLen, nullptr);
for (size_t idx = 0; idx < segmentRequestLen; idx++) {
result = segmentRequests[idx].first.serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = segmentRequests[idx].second.serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
}
diff --git a/src/fsfw/cfdp/pdu/NakPduSerializer.h b/src/fsfw/cfdp/pdu/NakPduCreator.h
similarity index 65%
rename from src/fsfw/cfdp/pdu/NakPduSerializer.h
rename to src/fsfw/cfdp/pdu/NakPduCreator.h
index 4009884b..bfcff78d 100644
--- a/src/fsfw/cfdp/pdu/NakPduSerializer.h
+++ b/src/fsfw/cfdp/pdu/NakPduCreator.h
@@ -1,14 +1,14 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_
+#ifndef FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_
+#define FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_
#include
#include "NakInfo.h"
#include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/definitions.h"
-#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
+#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
-class NakPduSerializer : public FileDirectiveSerializer {
+class NakPduCreator : public FileDirectiveCreator {
public:
/**
*
@@ -18,9 +18,9 @@ class NakPduSerializer : public FileDirectiveSerializer {
* @param [in] segmentRequests Pointer to the start of a list of segment requests
* @param segmentRequestLen Length of the segment request list to be serialized
*/
- NakPduSerializer(PduConfig& PduConf, NakInfo& nakInfo);
+ NakPduCreator(PduConfig& PduConf, NakInfo& nakInfo);
- size_t getSerializedSize() const override;
+ [[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
@@ -35,4 +35,4 @@ class NakPduSerializer : public FileDirectiveSerializer {
NakInfo& nakInfo;
};
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_ */
+#endif /* FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/NakPduDeserializer.h b/src/fsfw/cfdp/pdu/NakPduDeserializer.h
deleted file mode 100644
index f0f43158..00000000
--- a/src/fsfw/cfdp/pdu/NakPduDeserializer.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_
-
-#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
-#include "fsfw/cfdp/pdu/NakInfo.h"
-
-class NakPduDeserializer : public FileDirectiveDeserializer {
- public:
- NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info);
-
- /**
- * This needs to be called before accessing the PDU fields to avoid segmentation faults.
- * @return
- */
- virtual ReturnValue_t parseData() override;
-
- private:
- NakInfo& nakInfo;
-};
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp b/src/fsfw/cfdp/pdu/NakPduReader.cpp
similarity index 61%
rename from src/fsfw/cfdp/pdu/NakPduDeserializer.cpp
rename to src/fsfw/cfdp/pdu/NakPduReader.cpp
index 9d5f074c..c67774c0 100644
--- a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp
+++ b/src/fsfw/cfdp/pdu/NakPduReader.cpp
@@ -1,26 +1,26 @@
-#include "NakPduDeserializer.h"
+#include "NakPduReader.h"
-NakPduDeserializer::NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info)
- : FileDirectiveDeserializer(pduBuf, maxSize), nakInfo(info) {}
+NakPduReader::NakPduReader(const uint8_t* pduBuf, size_t maxSize, NakInfo& info)
+ : FileDirectiveReader(pduBuf, maxSize), nakInfo(info) {}
-ReturnValue_t NakPduDeserializer::parseData() {
- ReturnValue_t result = FileDirectiveDeserializer::parseData();
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ReturnValue_t NakPduReader::parseData() {
+ ReturnValue_t result = FileDirectiveReader::parseData();
+ if (result != returnvalue::OK) {
return result;
}
- size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
- const uint8_t* buffer = rawPtr + currentIdx;
- size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx;
+ size_t currentIdx = FileDirectiveReader::getHeaderSize();
+ const uint8_t* buffer = pointers.rawPtr + currentIdx;
+ size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx;
if (remSize < 1) {
return SerializeIF::STREAM_TOO_SHORT;
}
result =
nakInfo.getStartOfScope().deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = nakInfo.getEndOfScope().deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
nakInfo.setSegmentRequestLen(0);
@@ -39,12 +39,12 @@ ReturnValue_t NakPduDeserializer::parseData() {
}
result =
segReqs[idx].first.deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result =
segReqs[idx].second.deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
idx++;
diff --git a/src/fsfw/cfdp/pdu/NakPduReader.h b/src/fsfw/cfdp/pdu/NakPduReader.h
new file mode 100644
index 00000000..7e08229d
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/NakPduReader.h
@@ -0,0 +1,21 @@
+#ifndef FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_
+#define FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_
+
+#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
+#include "fsfw/cfdp/pdu/NakInfo.h"
+
+class NakPduReader : public FileDirectiveReader {
+ public:
+ NakPduReader(const uint8_t* pduBuf, size_t maxSize, NakInfo& info);
+
+ /**
+ * This needs to be called before accessing the PDU fields to avoid segmentation faults.
+ * @return
+ */
+ ReturnValue_t parseData() override;
+
+ private:
+ NakInfo& nakInfo;
+};
+
+#endif /* FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/PduConfig.cpp b/src/fsfw/cfdp/pdu/PduConfig.cpp
index d495f864..ccb20f51 100644
--- a/src/fsfw/cfdp/pdu/PduConfig.cpp
+++ b/src/fsfw/cfdp/pdu/PduConfig.cpp
@@ -1,12 +1,14 @@
#include "PduConfig.h"
-PduConfig::PduConfig(cfdp::TransmissionModes mode, cfdp::TransactionSeqNum seqNum,
- cfdp::EntityId sourceId, cfdp::EntityId destId, bool crcFlag, bool largeFile,
+#include
+
+PduConfig::PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionMode mode,
+ cfdp::TransactionSeqNum seqNum, bool crcFlag, bool largeFile,
cfdp::Direction direction)
: mode(mode),
- seqNum(seqNum),
- sourceId(sourceId),
- destId(destId),
+ seqNum(std::move(seqNum)),
+ sourceId(std::move(sourceId)),
+ destId(std::move(destId)),
crcFlag(crcFlag),
largeFile(largeFile),
direction(direction) {}
diff --git a/src/fsfw/cfdp/pdu/PduConfig.h b/src/fsfw/cfdp/pdu/PduConfig.h
index e5b52e52..70f37e38 100644
--- a/src/fsfw/cfdp/pdu/PduConfig.h
+++ b/src/fsfw/cfdp/pdu/PduConfig.h
@@ -1,36 +1,23 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_
#define FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_
-#include "VarLenField.h"
-
-namespace cfdp {
-
-struct EntityId : public VarLenField {
- public:
- EntityId() : VarLenField() {}
- EntityId(cfdp::WidthInBytes width, size_t entityId) : VarLenField(width, entityId) {}
-};
-
-struct TransactionSeqNum : public VarLenField {
- public:
- TransactionSeqNum() : VarLenField() {}
- TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {}
-};
-
-} // namespace cfdp
+#include "fsfw/cfdp/VarLenFields.h"
+#include "fsfw/cfdp/definitions.h"
class PduConfig {
public:
- PduConfig(cfdp::TransmissionModes mode, cfdp::TransactionSeqNum seqNum, cfdp::EntityId sourceId,
- cfdp::EntityId destId, bool crcFlag = false, bool largeFile = false,
+ PduConfig() = default;
+ PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionMode mode,
+ cfdp::TransactionSeqNum seqNum, bool crcFlag = false, bool largeFile = false,
cfdp::Direction direction = cfdp::Direction::TOWARDS_RECEIVER);
- cfdp::TransmissionModes mode;
+
+ cfdp::TransmissionMode mode = cfdp::TransmissionMode::ACKNOWLEDGED;
cfdp::TransactionSeqNum seqNum;
cfdp::EntityId sourceId;
cfdp::EntityId destId;
- bool crcFlag;
- bool largeFile;
- cfdp::Direction direction;
+ bool crcFlag = false;
+ bool largeFile = false;
+ cfdp::Direction direction = cfdp::Direction::TOWARDS_RECEIVER;
};
#endif /* FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_ */
diff --git a/src/fsfw/cfdp/pdu/PduHeaderIF.h b/src/fsfw/cfdp/pdu/PduHeaderIF.h
index f05d95a4..341b0335 100644
--- a/src/fsfw/cfdp/pdu/PduHeaderIF.h
+++ b/src/fsfw/cfdp/pdu/PduHeaderIF.h
@@ -3,8 +3,8 @@
#include
-#include "../definitions.h"
#include "PduConfig.h"
+#include "fsfw/cfdp/definitions.h"
/**
* @brief Generic interface to access all fields of a PDU header
@@ -13,20 +13,20 @@
*/
class PduHeaderIF {
public:
- virtual ~PduHeaderIF(){};
+ virtual ~PduHeaderIF() = default;
- virtual size_t getWholePduSize() const = 0;
- virtual size_t getPduDataFieldLen() const = 0;
- virtual cfdp::PduType getPduType() const = 0;
- virtual cfdp::Direction getDirection() const = 0;
- virtual cfdp::TransmissionModes getTransmissionMode() const = 0;
- virtual bool getCrcFlag() const = 0;
- virtual bool getLargeFileFlag() const = 0;
- virtual cfdp::SegmentationControl getSegmentationControl() const = 0;
- virtual cfdp::WidthInBytes getLenEntityIds() const = 0;
- virtual cfdp::WidthInBytes getLenSeqNum() const = 0;
- virtual cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const = 0;
- virtual bool hasSegmentMetadataFlag() const = 0;
+ [[nodiscard]] virtual size_t getWholePduSize() const = 0;
+ [[nodiscard]] virtual size_t getPduDataFieldLen() const = 0;
+ [[nodiscard]] virtual cfdp::PduType getPduType() const = 0;
+ [[nodiscard]] virtual cfdp::Direction getDirection() const = 0;
+ [[nodiscard]] virtual cfdp::TransmissionMode getTransmissionMode() const = 0;
+ [[nodiscard]] virtual bool getCrcFlag() const = 0;
+ [[nodiscard]] virtual bool getLargeFileFlag() const = 0;
+ [[nodiscard]] virtual cfdp::SegmentationControl getSegmentationControl() const = 0;
+ [[nodiscard]] virtual cfdp::WidthInBytes getLenEntityIds() const = 0;
+ [[nodiscard]] virtual cfdp::WidthInBytes getLenSeqNum() const = 0;
+ [[nodiscard]] virtual cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const = 0;
+ [[nodiscard]] virtual bool hasSegmentMetadataFlag() const = 0;
virtual void getSourceId(cfdp::EntityId& sourceId) const = 0;
virtual void getDestId(cfdp::EntityId& destId) const = 0;
virtual void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const = 0;
diff --git a/src/fsfw/cfdp/pdu/PduHeaderReader.h b/src/fsfw/cfdp/pdu/PduHeaderReader.h
new file mode 100644
index 00000000..a2e122cd
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/PduHeaderReader.h
@@ -0,0 +1,114 @@
+#ifndef FSFW_SRC_FSFW_CFDP_PDU_HEADERDESERIALIZER_H_
+#define FSFW_SRC_FSFW_CFDP_PDU_HEADERDESERIALIZER_H_
+
+#include
+#include
+
+#include "PduConfig.h"
+#include "PduHeaderIF.h"
+#include "fsfw/serialize/SerializeIF.h"
+#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h"
+
+struct PduHeaderFixedStruct {
+ uint8_t firstByte;
+ uint8_t pduDataFieldLenH;
+ uint8_t pduDataFieldLenL;
+ uint8_t fourthByte;
+ uint8_t variableFieldsStart;
+};
+
+/**
+ * @brief This class is used to deserialize a PDU header from raw memory.
+ * @details
+ * This is a zero-copy implementation and #parseData needs to be called to ensure the data is
+ * valid.
+ */
+class PduHeaderReader : public RedirectableDataPointerIF, public PduHeaderIF {
+ public:
+ PduHeaderReader() = default;
+ /**
+ * Initialize a PDU header from raw data. This is a zero-copy implementation and #parseData
+ * needs to be called to ensure the data is valid
+ * @param pduBuf
+ * @param maxSize
+ */
+ PduHeaderReader(const uint8_t* pduBuf, size_t maxSize);
+
+ /**
+ * This needs to be called before accessing the PDU fields to avoid segmentation faults.
+ * @return
+ * - returnvalue::OK on parse success
+ * - returnvalue::FAILED Invalid raw data
+ * - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected
+ */
+ virtual ReturnValue_t parseData();
+ explicit operator bool() const;
+ [[nodiscard]] bool isNull() const;
+
+ /**
+ * Fill the provided PDU configuration from the fields detected by this reader.
+ * @param cfg
+ */
+ void fillConfig(PduConfig& cfg) const;
+
+ [[nodiscard]] virtual size_t getHeaderSize() const;
+
+ [[nodiscard]] size_t getPduDataFieldLen() const override;
+ [[nodiscard]] size_t getWholePduSize() const override;
+
+ [[nodiscard]] cfdp::PduType getPduType() const override;
+ [[nodiscard]] cfdp::Direction getDirection() const override;
+ [[nodiscard]] cfdp::TransmissionMode getTransmissionMode() const override;
+ [[nodiscard]] bool getCrcFlag() const override;
+ [[nodiscard]] bool getLargeFileFlag() const override;
+ [[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override;
+ [[nodiscard]] cfdp::WidthInBytes getLenEntityIds() const override;
+ [[nodiscard]] cfdp::WidthInBytes getLenSeqNum() const override;
+ [[nodiscard]] cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override;
+ [[nodiscard]] bool hasSegmentMetadataFlag() const override;
+
+ void getSourceId(cfdp::EntityId& sourceId) const override;
+ void getDestId(cfdp::EntityId& destId) const override;
+ void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const override;
+
+ ReturnValue_t deserResult = returnvalue::OK;
+
+ [[nodiscard]] size_t getMaxSize() const;
+ [[nodiscard]] const uint8_t* getPduDataField() const;
+
+ /**
+ * Can also be used to reset the pointer to a nullptr, but the getter functions will not
+ * perform nullptr checks!
+ * @param dataPtr
+ * @param maxSize
+ * @param args
+ * @return
+ */
+ ReturnValue_t setReadOnlyData(const uint8_t* dataPtr, size_t maxSize);
+
+ protected:
+ struct Pointers {
+ PduHeaderFixedStruct* fixedHeader = nullptr;
+ const uint8_t* dataFieldStart = nullptr;
+ const uint8_t* rawPtr = nullptr;
+ };
+
+ Pointers pointers;
+ size_t maxSize = 0;
+
+ private:
+ /**
+ * This is a reader class and setting mutable data is forbidden. Use @setReadOnlyData instead.
+ * @param dataPtr
+ * @param maxSize
+ * @param args
+ * @return
+ */
+ ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) override;
+ void assignVarLenField(cfdp::VarLenField* field, cfdp::WidthInBytes width, void* sourcePtr) const;
+ void* sourceIdRaw = nullptr;
+ void* seqNumRaw = nullptr;
+ void* destIdRaw = nullptr;
+};
+
+#endif /* FSFW_SRC_FSFW_CFDP_PDU_HEADERDESERIALIZER_H_ */
diff --git a/src/fsfw/cfdp/pdu/PromptPduCreator.cpp b/src/fsfw/cfdp/pdu/PromptPduCreator.cpp
new file mode 100644
index 00000000..f4141fdb
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/PromptPduCreator.cpp
@@ -0,0 +1,24 @@
+#include "PromptPduCreator.h"
+
+PromptPduCreator::PromptPduCreator(PduConfig &conf, cfdp::PromptResponseRequired responseRequired)
+ : FileDirectiveCreator(conf, cfdp::FileDirective::PROMPT, 1),
+ responseRequired(responseRequired) {}
+
+size_t PromptPduCreator::getSerializedSize() const {
+ return FileDirectiveCreator::getWholePduSize();
+}
+
+ReturnValue_t PromptPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const {
+ ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ if (*size + 1 > maxSize) {
+ return SerializeIF::BUFFER_TOO_SHORT;
+ }
+ **buffer = responseRequired << 7;
+ *buffer += 1;
+ *size += 1;
+ return result;
+}
diff --git a/src/fsfw/cfdp/pdu/PromptPduSerializer.h b/src/fsfw/cfdp/pdu/PromptPduCreator.h
similarity index 61%
rename from src/fsfw/cfdp/pdu/PromptPduSerializer.h
rename to src/fsfw/cfdp/pdu/PromptPduCreator.h
index 51500224..ccecab6e 100644
--- a/src/fsfw/cfdp/pdu/PromptPduSerializer.h
+++ b/src/fsfw/cfdp/pdu/PromptPduCreator.h
@@ -1,13 +1,13 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUSERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUSERIALIZER_H_
-#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
+#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
-class PromptPduSerializer : public FileDirectiveSerializer {
+class PromptPduCreator : public FileDirectiveCreator {
public:
- PromptPduSerializer(PduConfig& conf, cfdp::PromptResponseRequired responseRequired);
+ PromptPduCreator(PduConfig& conf, cfdp::PromptResponseRequired responseRequired);
- size_t getSerializedSize() const override;
+ [[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
diff --git a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp b/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp
deleted file mode 100644
index 6a6f5505..00000000
--- a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "PromptPduDeserializer.h"
-
-PromptPduDeserializer::PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize)
- : FileDirectiveDeserializer(pduBuf, maxSize) {}
-
-cfdp::PromptResponseRequired PromptPduDeserializer::getPromptResponseRequired() const {
- return responseRequired;
-}
-
-ReturnValue_t PromptPduDeserializer::parseData() {
- ReturnValue_t result = FileDirectiveDeserializer::parseData();
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
- if (FileDirectiveDeserializer::getWholePduSize() - currentIdx < 1) {
- return SerializeIF::STREAM_TOO_SHORT;
- }
- responseRequired = static_cast((rawPtr[currentIdx] >> 7) & 0x01);
- return HasReturnvaluesIF::RETURN_OK;
-}
diff --git a/src/fsfw/cfdp/pdu/PromptPduReader.cpp b/src/fsfw/cfdp/pdu/PromptPduReader.cpp
new file mode 100644
index 00000000..f554c3c9
--- /dev/null
+++ b/src/fsfw/cfdp/pdu/PromptPduReader.cpp
@@ -0,0 +1,21 @@
+#include "PromptPduReader.h"
+
+PromptPduReader::PromptPduReader(const uint8_t *pduBuf, size_t maxSize)
+ : FileDirectiveReader(pduBuf, maxSize) {}
+
+cfdp::PromptResponseRequired PromptPduReader::getPromptResponseRequired() const {
+ return responseRequired;
+}
+
+ReturnValue_t PromptPduReader::parseData() {
+ ReturnValue_t result = FileDirectiveReader::parseData();
+ if (result != returnvalue::OK) {
+ return result;
+ }
+ if (FileDirectiveReader::getWholePduSize() <= FileDirectiveReader::getHeaderSize()) {
+ return SerializeIF::STREAM_TOO_SHORT;
+ }
+ responseRequired = static_cast(
+ (pointers.rawPtr[FileDirectiveReader::getHeaderSize()] >> 7) & 0x01);
+ return returnvalue::OK;
+}
diff --git a/src/fsfw/cfdp/pdu/PromptPduDeserializer.h b/src/fsfw/cfdp/pdu/PromptPduReader.h
similarity index 57%
rename from src/fsfw/cfdp/pdu/PromptPduDeserializer.h
rename to src/fsfw/cfdp/pdu/PromptPduReader.h
index 9441f364..2afcb20e 100644
--- a/src/fsfw/cfdp/pdu/PromptPduDeserializer.h
+++ b/src/fsfw/cfdp/pdu/PromptPduReader.h
@@ -1,13 +1,13 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUDESERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUDESERIALIZER_H_
-#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
+#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
-class PromptPduDeserializer : public FileDirectiveDeserializer {
+class PromptPduReader : public FileDirectiveReader {
public:
- PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize);
+ PromptPduReader(const uint8_t *pduBuf, size_t maxSize);
- cfdp::PromptResponseRequired getPromptResponseRequired() const;
+ [[nodiscard]] cfdp::PromptResponseRequired getPromptResponseRequired() const;
ReturnValue_t parseData() override;
private:
diff --git a/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp b/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp
deleted file mode 100644
index a7287563..00000000
--- a/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "PromptPduSerializer.h"
-
-PromptPduSerializer::PromptPduSerializer(PduConfig &conf,
- cfdp::PromptResponseRequired responseRequired)
- : FileDirectiveSerializer(conf, cfdp::FileDirectives::PROMPT, 1),
- responseRequired(responseRequired) {}
-
-size_t PromptPduSerializer::getSerializedSize() const {
- return FileDirectiveSerializer::getWholePduSize();
-}
-
-ReturnValue_t PromptPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const {
- ReturnValue_t result =
- FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- if (*size + 1 > maxSize) {
- return SerializeIF::BUFFER_TOO_SHORT;
- }
- **buffer = this->responseRequired << 7;
- *buffer += 1;
- *size += 1;
- return result;
-}
diff --git a/src/fsfw/cfdp/pdu/VarLenField.h b/src/fsfw/cfdp/pdu/VarLenField.h
deleted file mode 100644
index 590c2dd5..00000000
--- a/src/fsfw/cfdp/pdu/VarLenField.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_
-#define FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_
-
-#include
-#include
-
-#include "../definitions.h"
-#include "fsfw/serialize/SerializeIF.h"
-
-namespace cfdp {
-
-class VarLenField : public SerializeIF {
- public:
- union LengthFieldLen {
- uint8_t oneByte;
- uint16_t twoBytes;
- uint32_t fourBytes;
- uint64_t eightBytes;
- };
-
- VarLenField();
- VarLenField(cfdp::WidthInBytes width, size_t value);
-
- ReturnValue_t setValue(cfdp::WidthInBytes, size_t value);
-
- ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const override;
-
- size_t getSerializedSize() const override;
-
- ReturnValue_t deSerialize(cfdp::WidthInBytes width, const uint8_t **buffer, size_t *size,
- Endianness streamEndianness);
-
- cfdp::WidthInBytes getWidth() const;
- size_t getValue() const;
-
- private:
- ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
- Endianness streamEndianness) override;
-
- cfdp::WidthInBytes width;
- LengthFieldLen value;
-};
-
-} // namespace cfdp
-
-#endif /* FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_ */
diff --git a/src/fsfw/cfdp/tlv/CMakeLists.txt b/src/fsfw/cfdp/tlv/CMakeLists.txt
index cdf7b44a..617b1b0f 100644
--- a/src/fsfw/cfdp/tlv/CMakeLists.txt
+++ b/src/fsfw/cfdp/tlv/CMakeLists.txt
@@ -5,6 +5,7 @@ target_sources(
FilestoreResponseTlv.cpp
Lv.cpp
Tlv.cpp
+ StringLv.cpp
FlowLabelTlv.cpp
MessageToUserTlv.cpp
FaultHandlerOverrideTlv.cpp)
diff --git a/src/fsfw/cfdp/tlv/EntityIdTlv.cpp b/src/fsfw/cfdp/tlv/EntityIdTlv.cpp
index 87f55db8..d4c4d6a8 100644
--- a/src/fsfw/cfdp/tlv/EntityIdTlv.cpp
+++ b/src/fsfw/cfdp/tlv/EntityIdTlv.cpp
@@ -11,7 +11,7 @@ ReturnValue_t EntityIdTlv::serialize(uint8_t **buffer, size_t *size, size_t maxS
if (maxSize < this->getSerializedSize()) {
return BUFFER_TOO_SHORT;
}
- **buffer = cfdp::TlvTypes::ENTITY_ID;
+ **buffer = cfdp::TlvType::ENTITY_ID;
*size += 1;
*buffer += 1;
size_t serLen = entityId.getSerializedSize();
@@ -28,8 +28,8 @@ ReturnValue_t EntityIdTlv::deSerialize(const uint8_t **buffer, size_t *size,
if (*size < 3) {
return STREAM_TOO_SHORT;
}
- cfdp::TlvTypes type = static_cast(**buffer);
- if (type != cfdp::TlvTypes::ENTITY_ID) {
+ cfdp::TlvType type = static_cast(**buffer);
+ if (type != cfdp::TlvType::ENTITY_ID) {
return cfdp::INVALID_TLV_TYPE;
}
*buffer += 1;
@@ -54,6 +54,6 @@ ReturnValue_t EntityIdTlv::deSerialize(cfdp::Tlv &tlv, Endianness endianness) {
uint8_t EntityIdTlv::getLengthField() const { return 1 + entityId.getSerializedSize(); }
-cfdp::TlvTypes EntityIdTlv::getType() const { return cfdp::TlvTypes::ENTITY_ID; }
+cfdp::TlvType EntityIdTlv::getType() const { return cfdp::TlvType::ENTITY_ID; }
cfdp::EntityId &EntityIdTlv::getEntityId() { return entityId; }
diff --git a/src/fsfw/cfdp/tlv/EntityIdTlv.h b/src/fsfw/cfdp/tlv/EntityIdTlv.h
index 1443cc17..ac310899 100644
--- a/src/fsfw/cfdp/tlv/EntityIdTlv.h
+++ b/src/fsfw/cfdp/tlv/EntityIdTlv.h
@@ -27,7 +27,7 @@ class EntityIdTlv : public TlvIF {
Endianness streamEndianness) override;
uint8_t getLengthField() const override;
- cfdp::TlvTypes getType() const override;
+ cfdp::TlvType getType() const override;
cfdp::EntityId& getEntityId();
diff --git a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp
index f5f777ea..90b71361 100644
--- a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp
+++ b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp
@@ -4,7 +4,7 @@ FaultHandlerOverrideTlv::FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCo
cfdp::FaultHandlerCode handlerCode)
: conditionCode(conditionCode), handlerCode(handlerCode) {}
-FaultHandlerOverrideTlv::FaultHandlerOverrideTlv() {}
+FaultHandlerOverrideTlv::FaultHandlerOverrideTlv() = default;
uint8_t FaultHandlerOverrideTlv::getLengthField() const { return 1; }
@@ -22,7 +22,7 @@ ReturnValue_t FaultHandlerOverrideTlv::serialize(uint8_t **buffer, size_t *size,
**buffer = this->conditionCode << 4 | this->handlerCode;
*buffer += 1;
*size += 1;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
size_t FaultHandlerOverrideTlv::getSerializedSize() const { return getLengthField() + 2; }
@@ -32,15 +32,15 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_
if (*size < 3) {
return SerializeIF::STREAM_TOO_SHORT;
}
- auto detectedType = static_cast(**buffer);
- if (detectedType != cfdp::TlvTypes::FAULT_HANDLER) {
+ auto detectedType = static_cast(**buffer);
+ if (detectedType != cfdp::TlvType::FAULT_HANDLER) {
return cfdp::INVALID_TLV_TYPE;
}
*buffer += 1;
*size -= 1;
size_t detectedSize = **buffer;
if (detectedSize != getLengthField()) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
*buffer += 1;
*size += 1;
@@ -48,7 +48,7 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_
this->handlerCode = static_cast(**buffer & 0x0f);
*buffer += 1;
*size += 1;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
-cfdp::TlvTypes FaultHandlerOverrideTlv::getType() const { return cfdp::TlvTypes::FAULT_HANDLER; }
+cfdp::TlvType FaultHandlerOverrideTlv::getType() const { return cfdp::TlvType::FAULT_HANDLER; }
diff --git a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h
index 9f2adbb3..9f5cd486 100644
--- a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h
+++ b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h
@@ -3,18 +3,6 @@
#include "TlvIF.h"
-namespace cfdp {
-
-enum FaultHandlerCode {
- RESERVED = 0b0000,
- NOTICE_OF_CANCELLATION = 0b0001,
- NOTICE_OF_SUSPENSION = 0b0010,
- IGNORE_ERROR = 0b0011,
- ABANDON_TRANSACTION = 0b0100
-};
-
-}
-
class FaultHandlerOverrideTlv : public TlvIF {
public:
FaultHandlerOverrideTlv();
@@ -23,12 +11,12 @@ class FaultHandlerOverrideTlv : public TlvIF {
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const override;
- size_t getSerializedSize() const override;
+ [[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override;
- uint8_t getLengthField() const override;
- cfdp::TlvTypes getType() const override;
+ [[nodiscard]] uint8_t getLengthField() const override;
+ [[nodiscard]] cfdp::TlvType getType() const override;
private:
cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD;
diff --git a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp
index 9ad7c645..1022a7d1 100644
--- a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp
+++ b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp
@@ -3,10 +3,10 @@
#include "fsfw/FSFW.h"
FilestoreRequestTlv::FilestoreRequestTlv(cfdp::FilestoreActionCode actionCode,
- cfdp::Lv &firstFileName)
+ cfdp::StringLv &firstFileName)
: FilestoreTlvBase(actionCode, firstFileName) {}
-FilestoreRequestTlv::FilestoreRequestTlv(cfdp::Lv &firstFileName)
+FilestoreRequestTlv::FilestoreRequestTlv(cfdp::StringLv &firstFileName)
: FilestoreTlvBase(cfdp::FilestoreActionCode::INVALID, firstFileName) {}
void FilestoreRequestTlv::setSecondFileName(cfdp::Lv *secondFileName) {
@@ -16,11 +16,11 @@ void FilestoreRequestTlv::setSecondFileName(cfdp::Lv *secondFileName) {
ReturnValue_t FilestoreRequestTlv::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const {
ReturnValue_t result = commonSerialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = firstFileName.serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
if (requiresSecondFileName()) {
@@ -30,13 +30,13 @@ ReturnValue_t FilestoreRequestTlv::serialize(uint8_t **buffer, size_t *size, siz
}
secondFileName->serialize(buffer, size, maxSize, streamEndianness);
}
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t FilestoreRequestTlv::deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) {
ReturnValue_t result = commonDeserialize(buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
return deSerializeFromValue(buffer, size, streamEndianness);
@@ -63,17 +63,17 @@ ReturnValue_t FilestoreRequestTlv::deSerializeFromValue(const uint8_t **buffer,
*buffer += 1;
*size -= 1;
ReturnValue_t result = firstFileName.deSerialize(buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
if (requiresSecondFileName()) {
if (secondFileName == nullptr) {
secondFileNameMissing();
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
result = secondFileName->deSerialize(buffer, size, streamEndianness);
}
return result;
}
-cfdp::TlvTypes FilestoreRequestTlv::getType() const { return cfdp::TlvTypes::FILESTORE_REQUEST; }
+cfdp::TlvType FilestoreRequestTlv::getType() const { return cfdp::TlvType::FILESTORE_REQUEST; }
diff --git a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h
index 5acb0ef4..02e639b8 100644
--- a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h
+++ b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h
@@ -9,9 +9,9 @@
class FilestoreRequestTlv : public cfdp::FilestoreTlvBase {
public:
- FilestoreRequestTlv(cfdp::FilestoreActionCode actionCode, cfdp::Lv &firstFileName);
+ FilestoreRequestTlv(cfdp::FilestoreActionCode actionCode, cfdp::StringLv &firstFileName);
- FilestoreRequestTlv(cfdp::Lv &firstFileName);
+ explicit FilestoreRequestTlv(cfdp::StringLv &firstFileName);
void setSecondFileName(cfdp::Lv *secondFileName);
@@ -29,8 +29,8 @@ class FilestoreRequestTlv : public cfdp::FilestoreTlvBase {
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override;
- uint8_t getLengthField() const override;
- cfdp::TlvTypes getType() const override;
+ [[nodiscard]] uint8_t getLengthField() const override;
+ [[nodiscard]] cfdp::TlvType getType() const override;
private:
cfdp::Lv *secondFileName = nullptr;
diff --git a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp
index 36945725..38b56077 100644
--- a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp
+++ b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp
@@ -1,10 +1,10 @@
#include "FilestoreResponseTlv.h"
FilestoreResponseTlv::FilestoreResponseTlv(cfdp::FilestoreActionCode actionCode, uint8_t statusCode,
- cfdp::Lv &firstFileName, cfdp::Lv *fsMsg)
+ cfdp::StringLv &firstFileName, cfdp::Lv *fsMsg)
: FilestoreTlvBase(actionCode, firstFileName), statusCode(statusCode), filestoreMsg(fsMsg) {}
-FilestoreResponseTlv::FilestoreResponseTlv(cfdp::Lv &firstFileName, cfdp::Lv *fsMsg)
+FilestoreResponseTlv::FilestoreResponseTlv(cfdp::StringLv &firstFileName, cfdp::Lv *fsMsg)
: FilestoreTlvBase(firstFileName), statusCode(0), filestoreMsg(fsMsg) {}
uint8_t FilestoreResponseTlv::getLengthField() const {
@@ -20,23 +20,23 @@ uint8_t FilestoreResponseTlv::getLengthField() const {
return 1 + firstFileName.getSerializedSize() + optFieldsLen;
}
-void FilestoreResponseTlv::setSecondFileName(cfdp::Lv *secondFileName) {
- this->secondFileName = secondFileName;
+void FilestoreResponseTlv::setSecondFileName(cfdp::StringLv *secondFileName_) {
+ this->secondFileName = secondFileName_;
}
-void FilestoreResponseTlv::setFilestoreMessage(cfdp::Lv *filestoreMsg) {
- this->filestoreMsg = filestoreMsg;
+void FilestoreResponseTlv::setFilestoreMessage(cfdp::Lv *filestoreMsg_) {
+ this->filestoreMsg = filestoreMsg_;
}
ReturnValue_t FilestoreResponseTlv::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const {
ReturnValue_t result =
commonSerialize(buffer, size, maxSize, streamEndianness, true, this->statusCode);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = firstFileName.serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
if (requiresSecondFileName()) {
@@ -61,7 +61,7 @@ ReturnValue_t FilestoreResponseTlv::serialize(uint8_t **buffer, size_t *size, si
ReturnValue_t FilestoreResponseTlv::deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) {
ReturnValue_t result = commonDeserialize(buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
return deSerializeFromValue(buffer, size, streamEndianness);
@@ -75,7 +75,7 @@ ReturnValue_t FilestoreResponseTlv::deSerializeFromValue(const uint8_t **buffer,
*buffer += 1;
*size -= 1;
ReturnValue_t result = firstFileName.deSerialize(buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
if (requiresSecondFileName()) {
@@ -83,7 +83,7 @@ ReturnValue_t FilestoreResponseTlv::deSerializeFromValue(const uint8_t **buffer,
return cfdp::FILESTORE_REQUIRES_SECOND_FILE;
}
result = secondFileName->deSerialize(buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
}
@@ -98,7 +98,7 @@ ReturnValue_t FilestoreResponseTlv::deSerializeFromValue(const uint8_t **buffer,
*size -= 1;
*buffer += 1;
// Ignore empty filestore message
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
return filestoreMsg->deSerialize(buffer, size, streamEndianness);
}
@@ -112,4 +112,4 @@ ReturnValue_t FilestoreResponseTlv::deSerialize(const cfdp::Tlv &tlv, Endianness
uint8_t FilestoreResponseTlv::getStatusCode() const { return statusCode; }
-cfdp::TlvTypes FilestoreResponseTlv::getType() const { return cfdp::TlvTypes::FILESTORE_RESPONSE; }
+cfdp::TlvType FilestoreResponseTlv::getType() const { return cfdp::TlvType::FILESTORE_RESPONSE; }
diff --git a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h
index 7b68ba57..110f1bb4 100644
--- a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h
+++ b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h
@@ -4,17 +4,18 @@
#include "Lv.h"
#include "TlvIF.h"
#include "fsfw/cfdp/tlv/FilestoreTlvBase.h"
+#include "fsfw/cfdp/tlv/StringLv.h"
#include "fsfw/cfdp/tlv/Tlv.h"
class FilestoreResponseTlv : public cfdp::FilestoreTlvBase {
public:
- FilestoreResponseTlv(cfdp::Lv& firstFileName, cfdp::Lv* fsMsg);
+ FilestoreResponseTlv(cfdp::StringLv& firstFileName, cfdp::Lv* fsMsg);
FilestoreResponseTlv(cfdp::FilestoreActionCode actionCode, uint8_t statusCode,
- cfdp::Lv& firstFileName, cfdp::Lv* fsMsg);
+ cfdp::StringLv& firstFileName, cfdp::Lv* fsMsg);
- uint8_t getStatusCode() const;
- void setSecondFileName(cfdp::Lv* secondFileName);
+ [[nodiscard]] uint8_t getStatusCode() const;
+ void setSecondFileName(cfdp::StringLv* secondFileName);
void setFilestoreMessage(cfdp::Lv* filestoreMsg);
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
@@ -31,12 +32,12 @@ class FilestoreResponseTlv : public cfdp::FilestoreTlvBase {
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
- uint8_t getLengthField() const override;
- cfdp::TlvTypes getType() const override;
+ [[nodiscard]] uint8_t getLengthField() const override;
+ [[nodiscard]] cfdp::TlvType getType() const override;
private:
uint8_t statusCode;
- cfdp::Lv* secondFileName = nullptr;
+ cfdp::StringLv* secondFileName = nullptr;
cfdp::Lv* filestoreMsg = nullptr;
ReturnValue_t deSerializeFromValue(const uint8_t** buffer, size_t* size,
diff --git a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h
index 04012cda..a5974087 100644
--- a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h
+++ b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h
@@ -11,6 +11,7 @@
#include
#include
+#include "StringLv.h"
#include "fsfw/FSFW.h"
namespace cfdp {
@@ -65,15 +66,15 @@ static constexpr uint8_t FSR_DENY_DIR_NOT_ALLOWED = 0b0010;
class FilestoreTlvBase : public TlvIF {
public:
- FilestoreTlvBase(cfdp::Lv& firstFileName) : firstFileName(firstFileName){};
- FilestoreTlvBase(FilestoreActionCode actionCode, cfdp::Lv& firstFileName)
+ explicit FilestoreTlvBase(cfdp::StringLv& firstFileName) : firstFileName(firstFileName){};
+ FilestoreTlvBase(FilestoreActionCode actionCode, cfdp::StringLv& firstFileName)
: actionCode(actionCode), firstFileName(firstFileName){};
ReturnValue_t commonSerialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness, bool isResponse = false,
uint8_t responseStatusCode = 0) const {
if (buffer == nullptr or size == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
if (maxSize < 3) {
return SerializeIF::BUFFER_TOO_SHORT;
@@ -90,18 +91,18 @@ class FilestoreTlvBase : public TlvIF {
}
*buffer += 1;
*size += 1;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t commonDeserialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) {
if (buffer == nullptr or size == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
if (*size < 3) {
return SerializeIF::STREAM_TOO_SHORT;
}
- cfdp::TlvTypes type = static_cast(**buffer);
+ auto type = static_cast(**buffer);
if (type != getType()) {
return cfdp::INVALID_TLV_TYPE;
}
@@ -114,10 +115,10 @@ class FilestoreTlvBase : public TlvIF {
if (remainingLength == 0) {
return SerializeIF::STREAM_TOO_SHORT;
}
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
- bool requiresSecondFileName() const {
+ [[nodiscard]] bool requiresSecondFileName() const {
using namespace cfdp;
if (actionCode == FilestoreActionCode::RENAME_FILE or
actionCode == FilestoreActionCode::APPEND_FILE or
@@ -141,9 +142,9 @@ class FilestoreTlvBase : public TlvIF {
#endif
}
- FilestoreActionCode getActionCode() const { return actionCode; }
+ [[nodiscard]] FilestoreActionCode getActionCode() const { return actionCode; }
- void setActionCode(FilestoreActionCode actionCode) { this->actionCode = actionCode; }
+ void setActionCode(FilestoreActionCode actionCode_) { this->actionCode = actionCode_; }
cfdp::Lv& getFirstFileName() { return firstFileName; }
@@ -152,7 +153,7 @@ class FilestoreTlvBase : public TlvIF {
size_t serSize = 0;
uint8_t* valueStart = buffer + 2;
ReturnValue_t result = this->serialize(&buffer, &serSize, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
tlv.setValue(valueStart, serSize - 2);
@@ -160,11 +161,11 @@ class FilestoreTlvBase : public TlvIF {
return result;
}
- size_t getSerializedSize() const override { return getLengthField() + 2; }
+ [[nodiscard]] size_t getSerializedSize() const override { return getLengthField() + 2; }
protected:
FilestoreActionCode actionCode = FilestoreActionCode::INVALID;
- cfdp::Lv& firstFileName;
+ cfdp::StringLv& firstFileName;
};
} // namespace cfdp
diff --git a/src/fsfw/cfdp/tlv/FlowLabelTlv.cpp b/src/fsfw/cfdp/tlv/FlowLabelTlv.cpp
index 938af9f4..5f225669 100644
--- a/src/fsfw/cfdp/tlv/FlowLabelTlv.cpp
+++ b/src/fsfw/cfdp/tlv/FlowLabelTlv.cpp
@@ -1,4 +1,4 @@
#include "FlowLabelTlv.h"
FlowLabelTlv::FlowLabelTlv(uint8_t* value, size_t size)
- : Tlv(cfdp::TlvTypes::FLOW_LABEL, value, size) {}
+ : Tlv(cfdp::TlvType::FLOW_LABEL, value, size) {}
diff --git a/src/fsfw/cfdp/tlv/Lv.cpp b/src/fsfw/cfdp/tlv/Lv.cpp
index 1bb16301..e7fa414a 100644
--- a/src/fsfw/cfdp/tlv/Lv.cpp
+++ b/src/fsfw/cfdp/tlv/Lv.cpp
@@ -6,6 +6,12 @@ cfdp::Lv::Lv(const uint8_t* value, size_t size) : value(value, size, true) {
}
}
+cfdp::Lv::Lv(const std::vector& data) : value(data.data(), data.size(), true) {
+ if (!data.empty()) {
+ zeroLen = false;
+ }
+}
+
cfdp::Lv::Lv() : value(static_cast(nullptr), 0, true) {}
cfdp::Lv::Lv(const Lv& other)
@@ -17,11 +23,11 @@ cfdp::Lv::Lv(const Lv& other)
cfdp::Lv& cfdp::Lv::operator=(const Lv& other) {
size_t otherSize = 0;
- uint8_t* value = const_cast(other.getValue(&otherSize));
- if (value == nullptr or otherSize == 0) {
+ auto* otherVal = const_cast(other.getValue(&otherSize));
+ if (otherVal == nullptr or otherSize == 0) {
this->zeroLen = true;
}
- this->value.setBuffer(value, otherSize);
+ this->value.setConstBuffer(otherVal, otherSize);
return *this;
}
@@ -31,13 +37,13 @@ ReturnValue_t cfdp::Lv::serialize(uint8_t** buffer, size_t* size, size_t maxSize
return BUFFER_TOO_SHORT;
}
if (buffer == nullptr or size == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
if (zeroLen) {
**buffer = 0;
*size += 1;
*buffer += 1;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
return value.serialize(buffer, size, maxSize, streamEndianness);
}
@@ -54,7 +60,7 @@ size_t cfdp::Lv::getSerializedSize() const {
ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) {
if (buffer == nullptr or size == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
if (*size < 1) {
return SerializeIF::STREAM_TOO_SHORT;
@@ -64,16 +70,16 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size,
zeroLen = true;
*buffer += 1;
*size -= 1;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
} else if (*size < lengthField + 1) {
return SerializeIF::STREAM_TOO_SHORT;
}
zeroLen = false;
// Zero-copy implementation
- value.setBuffer(const_cast(*buffer + 1), lengthField);
+ value.setConstBuffer(*buffer + 1, lengthField);
*buffer += 1 + lengthField;
*size -= 1 + lengthField;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
const uint8_t* cfdp::Lv::getValue(size_t* size) const {
diff --git a/src/fsfw/cfdp/tlv/Lv.h b/src/fsfw/cfdp/tlv/Lv.h
index 29764433..efabfdef 100644
--- a/src/fsfw/cfdp/tlv/Lv.h
+++ b/src/fsfw/cfdp/tlv/Lv.h
@@ -1,5 +1,7 @@
-#ifndef FSFW_SRC_FSFW_CFDP_LV_H_
-#define FSFW_SRC_FSFW_CFDP_LV_H_
+#ifndef FSFW_CFDP_LV_H_
+#define FSFW_CFDP_LV_H_
+
+#include
#include "fsfw/serialize/SerialBufferAdapter.h"
@@ -12,18 +14,17 @@ namespace cfdp {
*/
class Lv : public SerializeIF {
public:
+ explicit Lv(const std::vector& data);
Lv(const uint8_t* value, size_t size);
Lv();
- // Delete copy ctor and assingment ctor for now because this class contains a reference to
- // data
Lv(const Lv&);
Lv& operator=(const Lv&);
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
- size_t getSerializedSize() const override;
+ [[nodiscard]] size_t getSerializedSize() const override;
/**
* @brief Deserialize a LV field from a raw buffer
@@ -50,4 +51,4 @@ class Lv : public SerializeIF {
} // namespace cfdp
-#endif /* FSFW_SRC_FSFW_CFDP_LV_H_ */
+#endif /* FSFW_CFDP_LV_H_ */
diff --git a/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp b/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp
index 9034552b..9a3e55ff 100644
--- a/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp
+++ b/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp
@@ -1,6 +1,9 @@
#include "MessageToUserTlv.h"
-MessageToUserTlv::MessageToUserTlv(uint8_t *value, size_t size)
- : Tlv(cfdp::TlvTypes::MSG_TO_USER, value, size) {}
+MessageToUserTlv::MessageToUserTlv(uint8_t* value, size_t size)
+ : Tlv(cfdp::TlvType::MSG_TO_USER, value, size) {}
MessageToUserTlv::MessageToUserTlv() : Tlv() {}
+
+MessageToUserTlv::MessageToUserTlv(const std::vector& data)
+ : Tlv(cfdp::TlvType::MSG_TO_USER, data.data(), data.size()) {}
diff --git a/src/fsfw/cfdp/tlv/MessageToUserTlv.h b/src/fsfw/cfdp/tlv/MessageToUserTlv.h
index 1d00bf31..e7f63ed2 100644
--- a/src/fsfw/cfdp/tlv/MessageToUserTlv.h
+++ b/src/fsfw/cfdp/tlv/MessageToUserTlv.h
@@ -1,12 +1,15 @@
#ifndef FSFW_SRC_FSFW_CFDP_TLV_MESSAGETOUSERTLV_H_
#define FSFW_SRC_FSFW_CFDP_TLV_MESSAGETOUSERTLV_H_
+#include
+
#include "Tlv.h"
class MessageToUserTlv : public cfdp::Tlv {
public:
MessageToUserTlv();
MessageToUserTlv(uint8_t* value, size_t size);
+ explicit MessageToUserTlv(const std::vector& data);
private:
};
diff --git a/src/fsfw/cfdp/tlv/StringLv.cpp b/src/fsfw/cfdp/tlv/StringLv.cpp
new file mode 100644
index 00000000..60c278a7
--- /dev/null
+++ b/src/fsfw/cfdp/tlv/StringLv.cpp
@@ -0,0 +1,9 @@
+#include "StringLv.h"
+
+cfdp::StringLv::StringLv(const std::string& fileName)
+ : Lv(reinterpret_cast(fileName.data()), fileName.size()) {}
+
+cfdp::StringLv::StringLv(const char* filename, size_t len)
+ : Lv(reinterpret_cast(filename), len) {}
+
+cfdp::StringLv::StringLv() : Lv() {}
diff --git a/src/fsfw/cfdp/tlv/StringLv.h b/src/fsfw/cfdp/tlv/StringLv.h
new file mode 100644
index 00000000..6c200b8b
--- /dev/null
+++ b/src/fsfw/cfdp/tlv/StringLv.h
@@ -0,0 +1,22 @@
+#ifndef FSFW_CFDP_STRINGLV_H
+#define FSFW_CFDP_STRINGLV_H
+
+#include
+
+#include "Lv.h"
+
+namespace cfdp {
+
+class StringLv : public Lv {
+ public:
+ StringLv();
+ explicit StringLv(const std::string& fileName);
+ explicit StringLv(const char* filename, size_t len);
+
+ // Delete the move constructor to avoid passing in a temporary
+ StringLv(const std::string&&) = delete;
+};
+
+} // namespace cfdp
+
+#endif // FSFW_CFDP_STRINGLV_H
diff --git a/src/fsfw/cfdp/tlv/Tlv.cpp b/src/fsfw/cfdp/tlv/Tlv.cpp
index f37ff8d5..c3fce612 100644
--- a/src/fsfw/cfdp/tlv/Tlv.cpp
+++ b/src/fsfw/cfdp/tlv/Tlv.cpp
@@ -1,6 +1,6 @@
#include "Tlv.h"
-cfdp::Tlv::Tlv(TlvTypes type, const uint8_t *value, size_t size)
+cfdp::Tlv::Tlv(TlvType type, const uint8_t *value, size_t size)
: type(type), value(value, size, true) {
if (size > 0) {
zeroLen = false;
@@ -12,12 +12,12 @@ cfdp::Tlv::Tlv() : value(static_cast(nullptr), 0, true) {}
ReturnValue_t cfdp::Tlv::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const {
if (buffer == nullptr or size == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
if (*size + 2 > maxSize) {
return BUFFER_TOO_SHORT;
}
- if (type == TlvTypes::INVALID_TLV) {
+ if (type == TlvType::INVALID_TLV) {
return INVALID_TLV_TYPE;
}
**buffer = type;
@@ -28,10 +28,10 @@ ReturnValue_t cfdp::Tlv::serialize(uint8_t **buffer, size_t *size, size_t maxSiz
**buffer = 0;
*size += 1;
*buffer += 1;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
if (value.getConstBuffer() == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
return value.serialize(buffer, size, maxSize, streamEndianness);
}
@@ -48,7 +48,7 @@ size_t cfdp::Tlv::getSerializedSize() const {
ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) {
if (buffer == nullptr or size == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
if (*size < 2) {
return STREAM_TOO_SHORT;
@@ -59,7 +59,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size,
return INVALID_TLV_TYPE;
}
- type = static_cast(rawType);
+ type = static_cast(rawType);
*buffer += 1;
*size -= 1;
@@ -68,22 +68,22 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size,
zeroLen = true;
*buffer += 1;
*size -= 1;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
if (lengthField + 1 > *size) {
return SerializeIF::STREAM_TOO_SHORT;
}
zeroLen = false;
// Zero-copy implementation
- value.setBuffer(const_cast(*buffer + 1), lengthField);
+ value.setConstBuffer(*buffer + 1, lengthField);
*buffer += 1 + lengthField;
*size -= 1 + lengthField;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
const uint8_t *cfdp::Tlv::getValue() const { return value.getConstBuffer(); }
-cfdp::TlvTypes cfdp::Tlv::getType() const { return type; }
+cfdp::TlvType cfdp::Tlv::getType() const { return type; }
bool cfdp::Tlv::checkType(uint8_t rawType) {
if (rawType != 0x03 and rawType <= 6) {
@@ -96,9 +96,9 @@ void cfdp::Tlv::setValue(uint8_t *value, size_t len) {
if (len > 0) {
zeroLen = false;
}
- this->value.setBuffer(value, len);
+ this->value.setConstBuffer(value, len);
}
uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; }
-void cfdp::Tlv::setType(TlvTypes type) { this->type = type; }
+void cfdp::Tlv::setType(TlvType type) { this->type = type; }
diff --git a/src/fsfw/cfdp/tlv/Tlv.h b/src/fsfw/cfdp/tlv/Tlv.h
index a67c6dd1..786a3b79 100644
--- a/src/fsfw/cfdp/tlv/Tlv.h
+++ b/src/fsfw/cfdp/tlv/Tlv.h
@@ -13,7 +13,7 @@ namespace cfdp {
*/
class Tlv : public TlvIF {
public:
- Tlv(TlvTypes type, const uint8_t *value, size_t size);
+ Tlv(TlvType type, const uint8_t *value, size_t size);
Tlv();
/**
@@ -23,39 +23,39 @@ class Tlv : public TlvIF {
* @param maxSize
* @param streamEndianness
* @return
- * - RETURN_OK on success
+ * - returnvalue::OK on success
* - INVALID_TLV_TYPE
* - SerializeIF returncode on wrong serialization parameters
*/
- virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
- Endianness streamEndianness) const override;
+ ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
+ Endianness streamEndianness) const override;
- virtual size_t getSerializedSize() const override;
+ [[nodiscard]] size_t getSerializedSize() const override;
/**
* @brief Deserialize a LV field from a raw buffer. Zero-copy implementation
* @param buffer Raw buffer including the size field
* @param size
* @param streamEndianness
- * - RETURN_OK on success
+ * - returnvalue::OK on success
* - INVALID_TLV_TYPE
* - SerializeIF returncode on wrong deserialization parameters
*/
- virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
- Endianness streamEndianness) override;
+ ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
+ Endianness streamEndianness) override;
void setValue(uint8_t *value, size_t len);
- const uint8_t *getValue() const;
- void setType(TlvTypes type);
- TlvTypes getType() const override;
- uint8_t getLengthField() const override;
+ [[nodiscard]] const uint8_t *getValue() const;
+ void setType(TlvType type);
+ [[nodiscard]] TlvType getType() const override;
+ [[nodiscard]] uint8_t getLengthField() const override;
private:
bool checkType(uint8_t rawType);
bool zeroLen = true;
- TlvTypes type = TlvTypes::INVALID_TLV;
+ TlvType type = TlvType::INVALID_TLV;
SerialBufferAdapter value;
};
diff --git a/src/fsfw/cfdp/tlv/TlvIF.h b/src/fsfw/cfdp/tlv/TlvIF.h
index 9a02b241..317d970a 100644
--- a/src/fsfw/cfdp/tlv/TlvIF.h
+++ b/src/fsfw/cfdp/tlv/TlvIF.h
@@ -8,7 +8,7 @@ class TlvIF : public SerializeIF {
virtual ~TlvIF(){};
virtual uint8_t getLengthField() const = 0;
- virtual cfdp::TlvTypes getType() const = 0;
+ virtual cfdp::TlvType getType() const = 0;
};
#endif /* FSFW_SRC_FSFW_CFDP_TLVIF_H_ */
diff --git a/src/fsfw/container/ArrayList.h b/src/fsfw/container/ArrayList.h
index 11f40039..92834558 100644
--- a/src/fsfw/container/ArrayList.h
+++ b/src/fsfw/container/ArrayList.h
@@ -1,9 +1,10 @@
#ifndef FSFW_CONTAINER_ARRAYLIST_H_
#define FSFW_CONTAINER_ARRAYLIST_H_
-#include "../returnvalues/HasReturnvaluesIF.h"
+#include "../returnvalues/returnvalue.h"
#include "../serialize/SerializeAdapter.h"
#include "../serialize/SerializeIF.h"
+#include "definitions.h"
/**
* @brief A List that stores its values in an array.
@@ -19,9 +20,6 @@ class ArrayList {
friend class SerialArrayListAdapter;
public:
- static const uint8_t INTERFACE_ID = CLASS_ID::ARRAY_LIST;
- static const ReturnValue_t FULL = MAKE_RETURN_CODE(0x01);
-
/**
* This is the allocating constructor.
* It allocates an array of the specified size.
@@ -183,15 +181,15 @@ class ArrayList {
* @param entry
* @return
* -@c FULL if the List is full
- * -@c RETURN_OK else
+ * -@c returnvalue::OK else
*/
ReturnValue_t insert(T entry) {
if (size >= maxSize_) {
- return FULL;
+ return containers::LIST_FULL;
}
entries[size] = entry;
++size;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
/**
diff --git a/src/fsfw/container/DynamicFIFO.h b/src/fsfw/container/DynamicFIFO.h
index 96f55938..5d1d46e7 100644
--- a/src/fsfw/container/DynamicFIFO.h
+++ b/src/fsfw/container/DynamicFIFO.h
@@ -18,7 +18,8 @@
template
class DynamicFIFO : public FIFOBase {
public:
- DynamicFIFO(size_t maxCapacity) : FIFOBase(nullptr, maxCapacity), fifoVector(maxCapacity) {
+ explicit DynamicFIFO(size_t maxCapacity)
+ : FIFOBase(nullptr, maxCapacity), fifoVector(maxCapacity) {
// trying to pass the pointer of the uninitialized vector
// to the FIFOBase constructor directly lead to a super evil bug.
// So we do it like this now.
diff --git a/src/fsfw/container/FIFOBase.h b/src/fsfw/container/FIFOBase.h
index 25c75515..b215dae4 100644
--- a/src/fsfw/container/FIFOBase.h
+++ b/src/fsfw/container/FIFOBase.h
@@ -4,7 +4,7 @@
#include
#include
-#include "../returnvalues/HasReturnvaluesIF.h"
+#include "../returnvalues/returnvalue.h"
template
class FIFOBase {
@@ -15,29 +15,29 @@ class FIFOBase {
/** Default ctor, takes pointer to first entry of underlying container
* and maximum capacity */
- FIFOBase(T* values, const size_t maxCapacity);
+ FIFOBase(T* values, size_t maxCapacity);
/**
* Insert value into FIFO
* @param value
- * @return RETURN_OK on success, FULL if full
+ * @return returnvalue::OK on success, FULL if full
*/
ReturnValue_t insert(T value);
/**
* Retrieve item from FIFO. This removes the item from the FIFO.
* @param value Must point to a valid T
- * @return RETURN_OK on success, EMPTY if empty and FAILED if nullptr check failed
+ * @return returnvalue::OK on success, EMPTY if empty and FAILED if nullptr check failed
*/
ReturnValue_t retrieve(T* value);
/**
* Retrieve item from FIFO without removing it from FIFO.
* @param value Must point to a valid T
- * @return RETURN_OK on success, EMPTY if empty and FAILED if nullptr check failed
+ * @return returnvalue::OK on success, EMPTY if empty and FAILED if nullptr check failed
*/
ReturnValue_t peek(T* value);
/**
* Remove item from FIFO.
- * @return RETURN_OK on success, EMPTY if empty
+ * @return returnvalue::OK on success, EMPTY if empty
*/
ReturnValue_t pop();
@@ -60,7 +60,7 @@ class FIFOBase {
* Get maximal capacity of fifo
* @return size_t with max capacity of this fifo
*/
- size_t getMaxCapacity() const;
+ [[nodiscard]] size_t getMaxCapacity() const;
protected:
void setContainer(T* data);
diff --git a/src/fsfw/container/FIFOBase.tpp b/src/fsfw/container/FIFOBase.tpp
index 91804b6c..63727869 100644
--- a/src/fsfw/container/FIFOBase.tpp
+++ b/src/fsfw/container/FIFOBase.tpp
@@ -17,7 +17,7 @@ inline ReturnValue_t FIFOBase::insert(T value) {
values[writeIndex] = value;
writeIndex = next(writeIndex);
++currentSize;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
};
@@ -27,12 +27,12 @@ inline ReturnValue_t FIFOBase::retrieve(T* value) {
return EMPTY;
} else {
if (value == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
*value = values[readIndex];
readIndex = next(readIndex);
--currentSize;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
};
@@ -42,10 +42,10 @@ inline ReturnValue_t FIFOBase::peek(T* value) {
return EMPTY;
} else {
if (value == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
*value = values[readIndex];
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
};
diff --git a/src/fsfw/container/FixedArrayList.h b/src/fsfw/container/FixedArrayList.h
index fc8be393..dde8eb16 100644
--- a/src/fsfw/container/FixedArrayList.h
+++ b/src/fsfw/container/FixedArrayList.h
@@ -12,6 +12,7 @@ template
class FixedArrayList : public ArrayList {
static_assert(MAX_SIZE <= std::numeric_limits::max(),
"count_t is not large enough to hold MAX_SIZE");
+ static_assert(MAX_SIZE > 0, "MAX_SIZE is 0");
private:
T data[MAX_SIZE];
@@ -20,15 +21,19 @@ class FixedArrayList : public ArrayList {
FixedArrayList() : ArrayList(data, MAX_SIZE) {}
FixedArrayList(const FixedArrayList& other) : ArrayList(data, MAX_SIZE) {
- memcpy(this->data, other.data, sizeof(this->data));
this->entries = data;
this->size = other.size;
+ for (size_t idx = 0; idx < this->size; idx++) {
+ data[idx] = other.data[idx];
+ }
}
FixedArrayList& operator=(FixedArrayList other) {
- memcpy(this->data, other.data, sizeof(this->data));
this->entries = data;
this->size = other.size;
+ for (size_t idx = 0; idx < this->size; idx++) {
+ data[idx] = other.data[idx];
+ }
return *this;
}
diff --git a/src/fsfw/container/FixedMap.h b/src/fsfw/container/FixedMap.h
index 48822cd5..ce90d814 100644
--- a/src/fsfw/container/FixedMap.h
+++ b/src/fsfw/container/FixedMap.h
@@ -4,8 +4,8 @@
#include
#include
-#include "../returnvalues/HasReturnvaluesIF.h"
#include "ArrayList.h"
+#include "definitions.h"
/**
* @brief Map implementation for maps with a pre-defined size.
@@ -24,11 +24,6 @@ class FixedMap : public SerializeIF {
"derived class from SerializeIF to be serialize-able");
public:
- static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP;
- static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01);
- static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x02);
- static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03);
-
private:
static const key_t EMPTY_SLOT = -1;
ArrayList, uint32_t> theMap;
@@ -75,11 +70,11 @@ class FixedMap : public SerializeIF {
uint32_t size() const { return _size; }
ReturnValue_t insert(key_t key, T value, Iterator* storedValue = nullptr) {
- if (exists(key) == HasReturnvaluesIF::RETURN_OK) {
- return KEY_ALREADY_EXISTS;
+ if (exists(key) == returnvalue::OK) {
+ return containers::KEY_ALREADY_EXISTS;
}
if (_size == theMap.maxSize()) {
- return MAP_FULL;
+ return containers::MAP_FULL;
}
theMap[_size].first = key;
theMap[_size].second = value;
@@ -87,15 +82,15 @@ class FixedMap : public SerializeIF {
*storedValue = Iterator(&theMap[_size]);
}
++_size;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t insert(std::pair pair) { return insert(pair.first, pair.second); }
ReturnValue_t exists(key_t key) const {
- ReturnValue_t result = KEY_DOES_NOT_EXIST;
+ ReturnValue_t result = containers::KEY_DOES_NOT_EXIST;
if (findIndex(key) < _size) {
- result = HasReturnvaluesIF::RETURN_OK;
+ result = returnvalue::OK;
}
return result;
}
@@ -103,29 +98,29 @@ class FixedMap : public SerializeIF {
ReturnValue_t erase(Iterator* iter) {
uint32_t i;
if ((i = findIndex((*iter).value->first)) >= _size) {
- return KEY_DOES_NOT_EXIST;
+ return containers::KEY_DOES_NOT_EXIST;
}
theMap[i] = theMap[_size - 1];
--_size;
--((*iter).value);
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t erase(key_t key) {
uint32_t i;
if ((i = findIndex(key)) >= _size) {
- return KEY_DOES_NOT_EXIST;
+ return containers::KEY_DOES_NOT_EXIST;
}
theMap[i] = theMap[_size - 1];
--_size;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
T* findValue(key_t key) const { return &theMap[findIndex(key)].second; }
Iterator find(key_t key) const {
ReturnValue_t result = exists(key);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return end();
}
return Iterator(&theMap[findIndex(key)]);
@@ -133,11 +128,11 @@ class FixedMap : public SerializeIF {
ReturnValue_t find(key_t key, T** value) const {
ReturnValue_t result = exists(key);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
*value = &theMap[findIndex(key)].second;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
bool empty() {
@@ -165,7 +160,7 @@ class FixedMap : public SerializeIF {
ReturnValue_t result =
SerializeAdapter::serialize(&this->_size, buffer, size, maxSize, streamEndianness);
uint32_t i = 0;
- while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->_size)) {
+ while ((result == returnvalue::OK) && (i < this->_size)) {
result =
SerializeAdapter::serialize(&theMap[i].first, buffer, size, maxSize, streamEndianness);
result =
@@ -195,7 +190,7 @@ class FixedMap : public SerializeIF {
return SerializeIF::TOO_MANY_ELEMENTS;
}
uint32_t i = 0;
- while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->_size)) {
+ while ((result == returnvalue::OK) && (i < this->_size)) {
result = SerializeAdapter::deSerialize(&theMap[i].first, buffer, size, streamEndianness);
result = SerializeAdapter::deSerialize(&theMap[i].second, buffer, size, streamEndianness);
++i;
diff --git a/src/fsfw/container/FixedOrderedMultimap.h b/src/fsfw/container/FixedOrderedMultimap.h
index 3ef8f8f1..73b010ed 100644
--- a/src/fsfw/container/FixedOrderedMultimap.h
+++ b/src/fsfw/container/FixedOrderedMultimap.h
@@ -100,7 +100,7 @@ class FixedOrderedMultimap {
* @param[in] value Value of the new element
* @param[in/out] (optional) storedValue On success this points to the new value, otherwise a
* nullptr
- * @return RETURN_OK if insert was successful, MAP_FULL if no space is available
+ * @return returnvalue::OK if insert was successful, MAP_FULL if no space is available
*/
ReturnValue_t insert(key_t key, T value, Iterator* storedValue = nullptr);
@@ -108,14 +108,14 @@ class FixedOrderedMultimap {
* Used to insert new pair instead of single values
*
* @param pair Pair to be inserted
- * @return RETURN_OK if insert was successful, MAP_FULL if no space is available
+ * @return returnvalue::OK if insert was successful, MAP_FULL if no space is available
*/
ReturnValue_t insert(std::pair pair);
/***
* Can be used to check if a certain key is in the map
* @param key Key to be checked
- * @return RETURN_OK if the key exists KEY_DOES_NOT_EXIST otherwise
+ * @return returnvalue::OK if the key exists KEY_DOES_NOT_EXIST otherwise
*/
ReturnValue_t exists(key_t key) const;
@@ -127,14 +127,14 @@ class FixedOrderedMultimap {
*
* @warning The iterator needs to be valid and dereferenceable
* @param[in/out] iter Pointer to iterator to the element that needs to be ereased
- * @return RETURN_OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this
+ * @return returnvalue::OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this
*/
ReturnValue_t erase(Iterator* iter);
/***
* Used to erase by key
* @param key Key to be erased
- * @return RETURN_OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this
+ * @return returnvalue::OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this
*/
ReturnValue_t erase(key_t key);
@@ -148,7 +148,7 @@ class FixedOrderedMultimap {
*/
Iterator find(key_t key) const {
ReturnValue_t result = exists(key);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return end();
}
return Iterator(&theMap[findFirstIndex(key)]);
@@ -160,7 +160,7 @@ class FixedOrderedMultimap {
*
* @param key Key to search for
* @param value Found value
- * @return RETURN_OK if it points to the value,
+ * @return returnvalue::OK if it points to the value,
* KEY_DOES_NOT_EXIST if the key is not in the map
*/
ReturnValue_t find(key_t key, T** value) const;
diff --git a/src/fsfw/container/FixedOrderedMultimap.tpp b/src/fsfw/container/FixedOrderedMultimap.tpp
index fd58bc44..cfdb5331 100644
--- a/src/fsfw/container/FixedOrderedMultimap.tpp
+++ b/src/fsfw/container/FixedOrderedMultimap.tpp
@@ -16,7 +16,7 @@ inline ReturnValue_t FixedOrderedMultimap::insert(key_t k
if (storedValue != nullptr) {
*storedValue = Iterator(&theMap[position]);
}
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
template
inline ReturnValue_t FixedOrderedMultimap::insert(std::pair pair) {
@@ -27,7 +27,7 @@ template
inline ReturnValue_t FixedOrderedMultimap::exists(key_t key) const {
ReturnValue_t result = KEY_DOES_NOT_EXIST;
if (findFirstIndex(key) < _size) {
- result = HasReturnvaluesIF::RETURN_OK;
+ result = returnvalue::OK;
}
return result;
}
@@ -44,7 +44,7 @@ inline ReturnValue_t FixedOrderedMultimap::erase(Iterator
} else {
*iter = begin();
}
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
template
@@ -57,17 +57,17 @@ inline ReturnValue_t FixedOrderedMultimap::erase(key_t ke
removeFromPosition(i);
i = findFirstIndex(key, i);
} while (i < _size);
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
template
inline ReturnValue_t FixedOrderedMultimap::find(key_t key, T **value) const {
ReturnValue_t result = exists(key);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
*value = &theMap[findFirstIndex(key)].second;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
template
diff --git a/src/fsfw/container/IndexedRingMemoryArray.h b/src/fsfw/container/IndexedRingMemoryArray.h
index b76e7d56..127ed5d7 100644
--- a/src/fsfw/container/IndexedRingMemoryArray.h
+++ b/src/fsfw/container/IndexedRingMemoryArray.h
@@ -4,7 +4,7 @@
#include
#include "../globalfunctions/CRC.h"
-#include "../returnvalues/HasReturnvaluesIF.h"
+#include "../returnvalues/returnvalue.h"
#include "../serialize/SerialArrayListAdapter.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "ArrayList.h"
@@ -52,15 +52,15 @@ class Index : public SerializeIF {
Endianness streamEndianness) const {
ReturnValue_t result =
SerializeAdapter::serialize(&blockStartAddress, buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = indexType.serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::serialize(&this->size, buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result =
@@ -71,19 +71,19 @@ class Index : public SerializeIF {
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) {
ReturnValue_t result =
SerializeAdapter::deSerialize(&blockStartAddress, buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = indexType.deSerialize(buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&this->size, buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&this->storedPackets, buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
return result;
@@ -449,13 +449,13 @@ class IndexedRingMemoryArray : public SerializeIF, public ArrayList, ui
// Check Next Block
if (!isNextBlockWritable()) {
// The Index is full and does not overwrite old
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
// Next block can be written, update Metadata
currentWriteBlock = getNextWrite();
currentWriteBlock->setSize(0);
currentWriteBlock->setStoredPackets(0);
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
/**
@@ -475,21 +475,21 @@ class IndexedRingMemoryArray : public SerializeIF, public ArrayList, ui
additionalInfo->serialize(buffer, size, maxSize, streamEndianness);
}
ReturnValue_t result = currentWriteBlock->serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::serialize(&this->size, buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
uint32_t i = 0;
- while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) {
+ while ((result == returnvalue::OK) && (i < this->size)) {
result =
SerializeAdapter::serialize(&this->entries[i], buffer, size, maxSize, streamEndianness);
++i;
}
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
uint16_t crc = Calculate_CRC(crcBuffer, (*size - oldSize));
@@ -523,44 +523,44 @@ class IndexedRingMemoryArray : public SerializeIF, public ArrayList, ui
*/
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) {
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
+ ReturnValue_t result = returnvalue::OK;
if (additionalInfo != NULL) {
result = additionalInfo->deSerialize(buffer, size, streamEndianness);
}
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
Index tempIndex;
result = tempIndex.deSerialize(buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
uint32_t tempSize = 0;
result = SerializeAdapter::deSerialize(&tempSize, buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
if (this->size != tempSize) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
uint32_t i = 0;
- while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) {
+ while ((result == returnvalue::OK) && (i < this->size)) {
result = SerializeAdapter::deSerialize(&this->entries[i], buffer, size, streamEndianness);
++i;
}
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
typename IndexedRingMemoryArray::Iterator cmp(&tempIndex);
for (typename IndexedRingMemoryArray::Iterator it = this->begin(); it != this->end(); ++it) {
if (*(cmp.value) == *(it.value)) {
currentWriteBlock = it;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
}
// Reached if current write block iterator is not found
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
uint32_t getIndexAddress() const { return indexAddress; }
diff --git a/src/fsfw/container/PlacementFactory.h b/src/fsfw/container/PlacementFactory.h
index 936be59d..668e71b8 100644
--- a/src/fsfw/container/PlacementFactory.h
+++ b/src/fsfw/container/PlacementFactory.h
@@ -40,7 +40,7 @@ class PlacementFactory {
store_address_t tempId;
uint8_t* pData = nullptr;
ReturnValue_t result = dataBackend->getFreeElement(&tempId, sizeof(T), &pData);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return nullptr;
}
T* temp = new (pData) T(std::forward(args)...);
@@ -51,12 +51,12 @@ class PlacementFactory {
* This must be called by the user.
*
* @param thisElement Element to be destroyed
- * @return RETURN_OK if the element was destroyed, different errors on failure
+ * @return returnvalue::OK if the element was destroyed, different errors on failure
*/
template
ReturnValue_t destroy(T* thisElement) {
if (thisElement == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
// Need to call destructor first, in case something was allocated by the object (shouldn't do
// that, however).
diff --git a/src/fsfw/container/RingBufferBase.h b/src/fsfw/container/RingBufferBase.h
index 98207698..e86f0ee1 100644
--- a/src/fsfw/container/RingBufferBase.h
+++ b/src/fsfw/container/RingBufferBase.h
@@ -3,7 +3,7 @@
#include
-#include "../returnvalues/HasReturnvaluesIF.h"
+#include "../returnvalues/returnvalue.h"
template
class RingBufferBase {
@@ -58,18 +58,18 @@ class RingBufferBase {
ReturnValue_t readData(uint32_t amount, uint8_t n = 0) {
if (getAvailableReadData(n) >= amount) {
incrementRead(amount, n);
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
} else {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
ReturnValue_t writeData(uint32_t amount) {
if (availableWriteSpace() >= amount or overwriteOld) {
incrementWrite(amount);
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
} else {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
diff --git a/src/fsfw/container/SimpleRingBuffer.cpp b/src/fsfw/container/SimpleRingBuffer.cpp
index bcf3cf20..a006df46 100644
--- a/src/fsfw/container/SimpleRingBuffer.cpp
+++ b/src/fsfw/container/SimpleRingBuffer.cpp
@@ -2,6 +2,9 @@
#include
+#include "fsfw/FSFW.h"
+#include "fsfw/serviceinterface.h"
+
SimpleRingBuffer::SimpleRingBuffer(const size_t size, bool overwriteOld, size_t maxExcessBytes)
: RingBufferBase<>(0, size, overwriteOld), maxExcessBytes(maxExcessBytes) {
if (maxExcessBytes > size) {
@@ -29,14 +32,14 @@ ReturnValue_t SimpleRingBuffer::getFreeElement(uint8_t** writePointer, size_t am
size_t amountTillWrap = writeTillWrap();
if (amountTillWrap < amount) {
if ((amount - amountTillWrap + excessBytes) > maxExcessBytes) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
excessBytes = amount - amountTillWrap;
}
*writePointer = &buffer[write];
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
} else {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
@@ -48,6 +51,19 @@ void SimpleRingBuffer::confirmBytesWritten(size_t amount) {
}
ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) {
+ if (data == nullptr) {
+ return returnvalue::FAILED;
+ }
+ if (amount > getMaxSize()) {
+#if FSFW_VERBOSE_LEVEL >= 1
+#if FSFW_CPP_OSTREAM_ENABLED == 1
+ sif::error << "SimpleRingBuffer::writeData: Amount of data too large" << std::endl;
+#else
+ sif::printError("SimpleRingBuffer::writeData: Amount of data too large\n");
+#endif
+#endif
+ return returnvalue::FAILED;
+ }
if (availableWriteSpace() >= amount or overwriteOld) {
size_t amountTillWrap = writeTillWrap();
if (amountTillWrap >= amount) {
@@ -58,9 +74,9 @@ ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) {
memcpy(buffer, data + amountTillWrap, amount - amountTillWrap);
}
incrementWrite(amount);
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
} else {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
@@ -73,7 +89,7 @@ ReturnValue_t SimpleRingBuffer::readData(uint8_t* data, size_t amount, bool incr
// more data available than amount specified.
amount = availableData;
} else {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
if (trueAmount != nullptr) {
@@ -89,7 +105,7 @@ ReturnValue_t SimpleRingBuffer::readData(uint8_t* data, size_t amount, bool incr
if (incrementReadPtr) {
deleteData(amount, readRemaining);
}
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
size_t SimpleRingBuffer::getExcessBytes() const { return excessBytes; }
@@ -108,12 +124,12 @@ ReturnValue_t SimpleRingBuffer::deleteData(size_t amount, bool deleteRemaining,
if (deleteRemaining) {
amount = availableData;
} else {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
if (trueAmount != nullptr) {
*trueAmount = amount;
}
incrementRead(amount, READ_PTR);
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
diff --git a/src/fsfw/container/SimpleRingBuffer.h b/src/fsfw/container/SimpleRingBuffer.h
index b9762451..a9892c0c 100644
--- a/src/fsfw/container/SimpleRingBuffer.h
+++ b/src/fsfw/container/SimpleRingBuffer.h
@@ -47,8 +47,8 @@ class SimpleRingBuffer : public RingBufferBase<> {
* Write to circular buffer and increment write pointer by amount.
* @param data
* @param amount
- * @return -@c RETURN_OK if write operation was successful
- * -@c RETURN_FAILED if
+ * @return -@c returnvalue::OK if write operation was successful
+ * -@c returnvalue::FAILED if
*/
ReturnValue_t writeData(const uint8_t* data, size_t amount);
@@ -95,8 +95,8 @@ class SimpleRingBuffer : public RingBufferBase<> {
* If readRemaining was set to true, the true amount read will be assigned
* to the passed value.
* @return
- * - @c RETURN_OK if data was read successfully
- * - @c RETURN_FAILED if not enough data was available and readRemaining
+ * - @c returnvalue::OK if data was read successfully
+ * - @c returnvalue::FAILED if not enough data was available and readRemaining
* was set to false.
*/
ReturnValue_t readData(uint8_t* data, size_t amount, bool incrementReadPtr = false,
diff --git a/src/fsfw/container/definitions.h b/src/fsfw/container/definitions.h
new file mode 100644
index 00000000..b50ea45d
--- /dev/null
+++ b/src/fsfw/container/definitions.h
@@ -0,0 +1,14 @@
+#ifndef FSFW_CONTAINER_DEFINITIONS_H_
+#define FSFW_CONTAINER_DEFINITIONS_H_
+
+#include "fsfw/retval.h"
+
+namespace containers {
+static const ReturnValue_t KEY_ALREADY_EXISTS = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x01);
+static const ReturnValue_t MAP_FULL = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x02);
+static const ReturnValue_t KEY_DOES_NOT_EXIST = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x03);
+
+static const ReturnValue_t LIST_FULL = returnvalue::makeCode(CLASS_ID::ARRAY_LIST, 0x01);
+} // namespace containers
+
+#endif /* FSFW_CONTAINER_DEFINITIONS_H_ */
diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp
index 953dacb4..a9d19ef2 100644
--- a/src/fsfw/controller/ControllerBase.cpp
+++ b/src/fsfw/controller/ControllerBase.cpp
@@ -20,15 +20,15 @@ ControllerBase::~ControllerBase() { QueueFactory::instance()->deleteMessageQueue
ReturnValue_t ControllerBase::initialize() {
ReturnValue_t result = SystemObject::initialize();
- if (result != RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
MessageQueueId_t parentQueue = 0;
if (parentId != objects::NO_OBJECT) {
- SubsystemBase* parent = ObjectManager::instance()->get(parentId);
+ auto* parent = ObjectManager::instance()->get(parentId);
if (parent == nullptr) {
- return RETURN_FAILED;
+ return returnvalue::FAILED;
}
parentQueue = parent->getCommandQueue();
@@ -36,36 +36,36 @@ ReturnValue_t ControllerBase::initialize() {
}
result = healthHelper.initialize(parentQueue);
- if (result != RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = modeHelper.initialize(parentQueue);
- if (result != RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
- return RETURN_OK;
+ return returnvalue::OK;
}
MessageQueueId_t ControllerBase::getCommandQueue() const { return commandQueue->getId(); }
void ControllerBase::handleQueue() {
CommandMessage command;
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
- for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
+ ReturnValue_t result;
+ for (result = commandQueue->receiveMessage(&command); result == returnvalue::OK;
result = commandQueue->receiveMessage(&command)) {
result = modeHelper.handleModeCommand(&command);
- if (result == RETURN_OK) {
+ if (result == returnvalue::OK) {
continue;
}
result = healthHelper.handleHealthCommand(&command);
- if (result == RETURN_OK) {
+ if (result == returnvalue::OK) {
continue;
}
result = handleCommandMessage(&command);
- if (result == RETURN_OK) {
+ if (result == returnvalue::OK) {
continue;
}
command.setToUnknownCommand();
@@ -73,20 +73,20 @@ void ControllerBase::handleQueue() {
}
}
-void ControllerBase::startTransition(Mode_t mode, Submode_t submode) {
+void ControllerBase::startTransition(Mode_t mode_, Submode_t submode_) {
changeHK(this->mode, this->submode, false);
triggerEvent(CHANGING_MODE, mode, submode);
- this->mode = mode;
- this->submode = submode;
+ mode = mode_;
+ submode = submode_;
modeHelper.modeChanged(mode, submode);
modeChanged(mode, submode);
announceMode(false);
changeHK(this->mode, this->submode, true);
}
-void ControllerBase::getMode(Mode_t* mode, Submode_t* submode) {
- *mode = this->mode;
- *submode = this->submode;
+void ControllerBase::getMode(Mode_t* mode_, Submode_t* submode_) {
+ *mode_ = this->mode;
+ *submode_ = this->submode;
}
void ControllerBase::setToExternalControl() { healthHelper.setHealth(EXTERNAL_CONTROL); }
@@ -96,17 +96,17 @@ void ControllerBase::announceMode(bool recursive) { triggerEvent(MODE_INFO, mode
ReturnValue_t ControllerBase::performOperation(uint8_t opCode) {
handleQueue();
performControlOperation();
- return RETURN_OK;
+ return returnvalue::OK;
}
-void ControllerBase::modeChanged(Mode_t mode, Submode_t submode) { return; }
+void ControllerBase::modeChanged(Mode_t mode_, Submode_t submode_) {}
ReturnValue_t ControllerBase::setHealth(HealthState health) {
switch (health) {
case HEALTHY:
case EXTERNAL_CONTROL:
healthHelper.setHealth(health);
- return RETURN_OK;
+ return returnvalue::OK;
default:
return INVALID_HEALTH_STATE;
}
@@ -115,6 +115,6 @@ ReturnValue_t ControllerBase::setHealth(HealthState health) {
HasHealthIF::HealthState ControllerBase::getHealth() { return healthHelper.getHealth(); }
void ControllerBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; }
-void ControllerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) {}
+void ControllerBase::changeHK(Mode_t mode_, Submode_t submode_, bool enable) {}
-ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return HasReturnvaluesIF::RETURN_OK; }
+ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return returnvalue::OK; }
diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h
index 227b859b..56c28585 100644
--- a/src/fsfw/controller/ControllerBase.h
+++ b/src/fsfw/controller/ControllerBase.h
@@ -18,27 +18,26 @@
class ControllerBase : public HasModesIF,
public HasHealthIF,
public ExecutableObjectIF,
- public SystemObject,
- public HasReturnvaluesIF {
+ public SystemObject {
public:
static const Mode_t MODE_NORMAL = 2;
ControllerBase(object_id_t setObjectId, object_id_t parentId, size_t commandQueueDepth = 3);
- virtual ~ControllerBase();
+ ~ControllerBase() override;
/** SystemObject override */
- virtual ReturnValue_t initialize() override;
+ ReturnValue_t initialize() override;
- virtual MessageQueueId_t getCommandQueue() const override;
+ [[nodiscard]] MessageQueueId_t getCommandQueue() const override;
/** HasHealthIF overrides */
- virtual ReturnValue_t setHealth(HealthState health) override;
- virtual HasHealthIF::HealthState getHealth() override;
+ ReturnValue_t setHealth(HealthState health) override;
+ HasHealthIF::HealthState getHealth() override;
/** ExecutableObjectIF overrides */
- virtual ReturnValue_t performOperation(uint8_t opCode) override;
- virtual void setTaskIF(PeriodicTaskIF *task) override;
- virtual ReturnValue_t initializeAfterTaskCreation() override;
+ ReturnValue_t performOperation(uint8_t opCode) override;
+ void setTaskIF(PeriodicTaskIF *task) override;
+ ReturnValue_t initializeAfterTaskCreation() override;
protected:
/**
@@ -54,8 +53,8 @@ class ControllerBase : public HasModesIF,
*/
virtual void performControlOperation() = 0;
- virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
- uint32_t *msToReachTheMode) override = 0;
+ ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
+ uint32_t *msToReachTheMode) override = 0;
const object_id_t parentId;
@@ -80,10 +79,10 @@ class ControllerBase : public HasModesIF,
/** Mode helpers */
virtual void modeChanged(Mode_t mode, Submode_t submode);
- virtual void startTransition(Mode_t mode, Submode_t submode) override;
- virtual void getMode(Mode_t *mode, Submode_t *submode) override;
- virtual void setToExternalControl() override;
- virtual void announceMode(bool recursive);
+ void startTransition(Mode_t mode, Submode_t submode) override;
+ void getMode(Mode_t *mode, Submode_t *submode) override;
+ void setToExternalControl() override;
+ void announceMode(bool recursive) override;
/** HK helpers */
virtual void changeHK(Mode_t mode, Submode_t submode, bool enable);
};
diff --git a/src/fsfw/controller/ExtendedControllerBase.cpp b/src/fsfw/controller/ExtendedControllerBase.cpp
index 0dfd9dc7..4d5c90c8 100644
--- a/src/fsfw/controller/ExtendedControllerBase.cpp
+++ b/src/fsfw/controller/ExtendedControllerBase.cpp
@@ -6,13 +6,13 @@ ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, object_id_t
poolManager(this, commandQueue),
actionHelper(this, commandQueue) {}
-ExtendedControllerBase::~ExtendedControllerBase() {}
+ExtendedControllerBase::~ExtendedControllerBase() = default;
ReturnValue_t ExtendedControllerBase::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy,
const uint8_t *data, size_t size) {
/* Needs to be overriden and implemented by child class. */
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
object_id_t ExtendedControllerBase::getObjectId() const { return SystemObject::getObjectId(); }
@@ -23,7 +23,7 @@ uint32_t ExtendedControllerBase::getPeriodicOperationFrequency() const {
ReturnValue_t ExtendedControllerBase::handleCommandMessage(CommandMessage *message) {
ReturnValue_t result = actionHelper.handleActionMessage(message);
- if (result == HasReturnvaluesIF::RETURN_OK) {
+ if (result == returnvalue::OK) {
return result;
}
return poolManager.handleHousekeepingMessage(message);
@@ -31,31 +31,31 @@ ReturnValue_t ExtendedControllerBase::handleCommandMessage(CommandMessage *messa
void ExtendedControllerBase::handleQueue() {
CommandMessage command;
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
- for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
+ ReturnValue_t result;
+ for (result = commandQueue->receiveMessage(&command); result == returnvalue::OK;
result = commandQueue->receiveMessage(&command)) {
result = actionHelper.handleActionMessage(&command);
- if (result == RETURN_OK) {
+ if (result == returnvalue::OK) {
continue;
}
result = modeHelper.handleModeCommand(&command);
- if (result == RETURN_OK) {
+ if (result == returnvalue::OK) {
continue;
}
result = healthHelper.handleHealthCommand(&command);
- if (result == RETURN_OK) {
+ if (result == returnvalue::OK) {
continue;
}
result = poolManager.handleHousekeepingMessage(&command);
- if (result == RETURN_OK) {
+ if (result == returnvalue::OK) {
continue;
}
result = handleCommandMessage(&command);
- if (result == RETURN_OK) {
+ if (result == returnvalue::OK) {
continue;
}
command.setToUnknownCommand();
@@ -65,11 +65,11 @@ void ExtendedControllerBase::handleQueue() {
ReturnValue_t ExtendedControllerBase::initialize() {
ReturnValue_t result = ControllerBase::initialize();
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
result = actionHelper.initialize(commandQueue);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
@@ -86,7 +86,7 @@ ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) {
/* We do this after performing control operation because variables will be set changed
in this function. */
poolManager.performHkOperation();
- return RETURN_OK;
+ return returnvalue::OK;
}
MessageQueueId_t ExtendedControllerBase::getCommandQueue() const { return commandQueue->getId(); }
diff --git a/src/fsfw/controller/ExtendedControllerBase.h b/src/fsfw/controller/ExtendedControllerBase.h
index f1802b54..75845f02 100644
--- a/src/fsfw/controller/ExtendedControllerBase.h
+++ b/src/fsfw/controller/ExtendedControllerBase.h
@@ -18,16 +18,16 @@ class ExtendedControllerBase : public ControllerBase,
public HasLocalDataPoolIF {
public:
ExtendedControllerBase(object_id_t objectId, object_id_t parentId, size_t commandQueueDepth = 3);
- virtual ~ExtendedControllerBase();
+ ~ExtendedControllerBase() override;
/* SystemObjectIF overrides */
- virtual ReturnValue_t initialize() override;
+ ReturnValue_t initialize() override;
- virtual MessageQueueId_t getCommandQueue() const override;
+ [[nodiscard]] MessageQueueId_t getCommandQueue() const override;
/* ExecutableObjectIF overrides */
- virtual ReturnValue_t performOperation(uint8_t opCode) override;
- virtual ReturnValue_t initializeAfterTaskCreation() override;
+ ReturnValue_t performOperation(uint8_t opCode) override;
+ ReturnValue_t initializeAfterTaskCreation() override;
protected:
LocalDataPoolManager poolManager;
@@ -39,34 +39,32 @@ class ExtendedControllerBase : public ControllerBase,
* @param message
* @return
*/
- virtual ReturnValue_t handleCommandMessage(CommandMessage* message) = 0;
+ ReturnValue_t handleCommandMessage(CommandMessage* message) override = 0;
/**
* Periodic helper from ControllerBase, implemented by child class.
*/
- virtual void performControlOperation() = 0;
+ void performControlOperation() override = 0;
// Handle the four messages mentioned above
void handleQueue() override;
- // HasActionsIF overrides
- virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
- const uint8_t* data, size_t size) override;
+ /* HasActionsIF overrides */
+ ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
+ const uint8_t* data, size_t size) override;
- // HasLocalDatapoolIF overrides
- virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
- LocalDataPoolManager& poolManager) override = 0;
- virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override = 0;
+ /* HasLocalDatapoolIF overrides */
+ LocalDataPoolManager* getHkManagerHandle() override;
+ [[nodiscard]] object_id_t getObjectId() const override;
+ [[nodiscard]] uint32_t getPeriodicOperationFrequency() const override;
+
+ ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
+ LocalDataPoolManager& poolManager) override = 0;
+ LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override = 0;
// Mode abstract functions
- virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
- uint32_t* msToReachTheMode) override = 0;
-
- virtual LocalDataPoolManager* getHkManagerHandle() override;
- virtual object_id_t getObjectId() const override;
- virtual uint32_t getPeriodicOperationFrequency() const override;
-
-
+ ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
+ uint32_t* msToReachTheMode) override = 0;
};
#endif /* FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_ */
diff --git a/src/fsfw/coordinates/Sgp4Propagator.cpp b/src/fsfw/coordinates/Sgp4Propagator.cpp
index 4a43842c..e79ffef5 100644
--- a/src/fsfw/coordinates/Sgp4Propagator.cpp
+++ b/src/fsfw/coordinates/Sgp4Propagator.cpp
@@ -152,7 +152,7 @@ ReturnValue_t Sgp4Propagator::initialize(const uint8_t* line1, const uint8_t* li
return MAKE_RETURN_CODE(result);
} else {
initialized = true;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
}
@@ -195,6 +195,6 @@ ReturnValue_t Sgp4Propagator::propagate(double* position, double* velocity, time
if (result != 0) {
return MAKE_RETURN_CODE(result || 0xB0);
} else {
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
}
diff --git a/src/fsfw/coordinates/Sgp4Propagator.h b/src/fsfw/coordinates/Sgp4Propagator.h
index 0edaf459..5cbeb3f2 100644
--- a/src/fsfw/coordinates/Sgp4Propagator.h
+++ b/src/fsfw/coordinates/Sgp4Propagator.h
@@ -7,7 +7,7 @@
#ifndef PLATFORM_WIN
#include
#endif
-#include "fsfw/returnvalues/HasReturnvaluesIF.h"
+#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw_contrib/sgp4/sgp4unit.h"
class Sgp4Propagator {
diff --git a/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h b/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h
index 22ff12e4..71d14e60 100644
--- a/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h
+++ b/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h
@@ -9,12 +9,12 @@
#define CCSDSRETURNVALUESIF_H_
#include "dllConf.h"
-#include "fsfw/returnvalues/HasReturnvaluesIF.h"
+#include "fsfw/returnvalues/returnvalue.h"
/**
* This is a helper class to collect special return values that come up during CCSDS Handling.
* @ingroup ccsds_handling
*/
-class CCSDSReturnValuesIF : public HasReturnvaluesIF {
+class CCSDSReturnValuesIF {
public:
static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER_IF; //!< Basic ID of the interface.
diff --git a/src/fsfw/datalinklayer/DataLinkLayer.cpp b/src/fsfw/datalinklayer/DataLinkLayer.cpp
index ca607478..6fe3e664 100644
--- a/src/fsfw/datalinklayer/DataLinkLayer.cpp
+++ b/src/fsfw/datalinklayer/DataLinkLayer.cpp
@@ -28,7 +28,7 @@ ReturnValue_t DataLinkLayer::frameDelimitingAndFillRemoval() {
TcTransferFrame frame_candidate(frameBuffer);
this->currentFrame = frame_candidate; // should work with shallow copy.
- return RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t DataLinkLayer::frameValidationCheck() {
@@ -59,14 +59,14 @@ ReturnValue_t DataLinkLayer::frameValidationCheck() {
if (USE_CRC) {
return this->frameCheckCRC();
}
- return RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t DataLinkLayer::frameCheckCRC() {
uint16_t checkValue =
CRC::crc16ccitt(this->currentFrame.getFullFrame(), this->currentFrame.getFullSize());
if (checkValue == 0) {
- return RETURN_OK;
+ return returnvalue::OK;
} else {
return CRC_FAILED;
}
@@ -74,7 +74,7 @@ ReturnValue_t DataLinkLayer::frameCheckCRC() {
ReturnValue_t DataLinkLayer::allFramesReception() {
ReturnValue_t status = this->frameDelimitingAndFillRemoval();
- if (status != RETURN_OK) {
+ if (status != returnvalue::OK) {
return status;
}
return this->frameValidationCheck();
@@ -90,7 +90,7 @@ ReturnValue_t DataLinkLayer::virtualChannelDemultiplexing() {
virtualChannelIterator iter = virtualChannels.find(vcId);
if (iter == virtualChannels.end()) {
// Do not report because passive board will get this error all the time.
- return RETURN_OK;
+ return returnvalue::OK;
} else {
return (iter->second)->frameAcceptanceAndReportingMechanism(¤tFrame, clcw);
}
@@ -99,7 +99,7 @@ ReturnValue_t DataLinkLayer::virtualChannelDemultiplexing() {
ReturnValue_t DataLinkLayer::processFrame(uint16_t length) {
receivedDataLength = length;
ReturnValue_t status = allFramesReception();
- if (status != RETURN_OK) {
+ if (status != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataLinkLayer::processFrame: frame reception failed. "
"Error code: "
@@ -117,14 +117,14 @@ ReturnValue_t DataLinkLayer::addVirtualChannel(uint8_t virtualChannelId,
std::pair returnValue = virtualChannels.insert(
std::pair(virtualChannelId, object));
if (returnValue.second == true) {
- return RETURN_OK;
+ return returnvalue::OK;
} else {
- return RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
ReturnValue_t DataLinkLayer::initialize() {
- ReturnValue_t returnValue = RETURN_FAILED;
+ ReturnValue_t returnValue = returnvalue::FAILED;
// Set Virtual Channel ID to first virtual channel instance in this DataLinkLayer instance to
// avoid faulty information (e.g. 0) in the VCID.
if (virtualChannels.begin() != virtualChannels.end()) {
@@ -133,13 +133,13 @@ ReturnValue_t DataLinkLayer::initialize() {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataLinkLayer::initialize: No VC assigned to this DLL instance! " << std::endl;
#endif
- return RETURN_FAILED;
+ return returnvalue::FAILED;
}
for (virtualChannelIterator iterator = virtualChannels.begin(); iterator != virtualChannels.end();
iterator++) {
returnValue = iterator->second->initialize();
- if (returnValue != RETURN_OK) break;
+ if (returnValue != returnvalue::OK) break;
}
return returnValue;
}
diff --git a/src/fsfw/datalinklayer/DataLinkLayer.h b/src/fsfw/datalinklayer/DataLinkLayer.h
index 8735feb6..64d2f96b 100644
--- a/src/fsfw/datalinklayer/DataLinkLayer.h
+++ b/src/fsfw/datalinklayer/DataLinkLayer.h
@@ -51,7 +51,7 @@ class DataLinkLayer : public CCSDSReturnValuesIF {
* This method tries to process a frame that is placed in #frameBuffer.
* The procedures described in the Standard are performed.
* @param length Length of the incoming frame candidate.
- * @return @c RETURN_OK on successful handling, otherwise the return codes of the higher
+ * @return @c returnvalue::OK on successful handling, otherwise the return codes of the higher
* methods.
*/
ReturnValue_t processFrame(uint16_t length);
@@ -61,12 +61,12 @@ class DataLinkLayer : public CCSDSReturnValuesIF {
* handle Frames directed to this VC.
* @param virtualChannelId Id of the VC. Shall be smaller than 64.
* @param object Reference to the object that handles the Frame.
- * @return @c RETURN_OK on success, @c RETURN_FAILED otherwise.
+ * @return @c returnvalue::OK on success, @c returnvalue::FAILED otherwise.
*/
ReturnValue_t addVirtualChannel(uint8_t virtualChannelId, VirtualChannelReceptionIF* object);
/**
* The initialization method calls the @c initialize routine of all virtual channels.
- * @return The return code of the first failed VC initialization or @c RETURN_OK.
+ * @return The return code of the first failed VC initialization or @c returnvalue::OK.
*/
ReturnValue_t initialize();
@@ -91,19 +91,19 @@ class DataLinkLayer : public CCSDSReturnValuesIF {
virtualChannels; //!< Map of all virtual channels assigned.
/**
* Method that performs all possible frame validity checks (as specified).
- * @return Various error codes or @c RETURN_OK on success.
+ * @return Various error codes or @c returnvalue::OK on success.
*/
ReturnValue_t frameValidationCheck();
/**
* First method to call.
* Removes start sequence bytes and checks if the complete frame was received.
* SHOULDDO: Maybe handling the start sequence must be done more variable.
- * @return @c RETURN_OK or @c TOO_SHORT.
+ * @return @c returnvalue::OK or @c TOO_SHORT.
*/
ReturnValue_t frameDelimitingAndFillRemoval();
/**
* Small helper method to check the CRC of the Frame.
- * @return @c RETURN_OK or @c CRC_FAILED.
+ * @return @c returnvalue::OK or @c CRC_FAILED.
*/
ReturnValue_t frameCheckCRC();
/**
diff --git a/src/fsfw/datalinklayer/Farm1StateOpen.cpp b/src/fsfw/datalinklayer/Farm1StateOpen.cpp
index cf3339a7..b27f609c 100644
--- a/src/fsfw/datalinklayer/Farm1StateOpen.cpp
+++ b/src/fsfw/datalinklayer/Farm1StateOpen.cpp
@@ -11,7 +11,7 @@ ReturnValue_t Farm1StateOpen::handleADFrame(TcTransferFrame* frame, ClcwIF* clcw
if (diff == 0) {
myVC->vR++;
clcw->setRetransmitFlag(false);
- return RETURN_OK;
+ return returnvalue::OK;
} else if (diff < myVC->positiveWindow && diff > 0) {
clcw->setRetransmitFlag(true);
return NS_POSITIVE_W;
diff --git a/src/fsfw/datalinklayer/Farm1StateOpen.h b/src/fsfw/datalinklayer/Farm1StateOpen.h
index 0bca931d..a1c553ff 100644
--- a/src/fsfw/datalinklayer/Farm1StateOpen.h
+++ b/src/fsfw/datalinklayer/Farm1StateOpen.h
@@ -37,8 +37,8 @@ class Farm1StateOpen : public Farm1StateIF {
* change to Farm1StateLockout.
* @param frame The frame to handle.
* @param clcw Any changes to the CLCW shall be done with the help of this interface.
- * @return If the Sequence Number is ok, it returns #RETURN_OK. Otherwise either #NS_POSITIVE_W,
- * #NS_NEGATIVE_W or NS_LOCKOUT is returned.
+ * @return If the Sequence Number is ok, it returns returnvalue::OK. Otherwise either
+ * #NS_POSITIVE_W, #NS_NEGATIVE_W or NS_LOCKOUT is returned.
*/
ReturnValue_t handleADFrame(TcTransferFrame* frame, ClcwIF* clcw);
/**
diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.cpp b/src/fsfw/datalinklayer/MapPacketExtraction.cpp
index 57aa2f08..f2a6c550 100644
--- a/src/fsfw/datalinklayer/MapPacketExtraction.cpp
+++ b/src/fsfw/datalinklayer/MapPacketExtraction.cpp
@@ -6,7 +6,7 @@
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
-#include "fsfw/tmtcpacket/SpacePacketBase.h"
+#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
@@ -31,7 +31,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
if (packetLength <= MAX_PACKET_SIZE) {
memcpy(packetBuffer, frame->getDataField(), packetLength);
bufferPosition = &packetBuffer[packetLength];
- status = RETURN_OK;
+ status = returnvalue::OK;
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MapPacketExtraction::extractPackets. Packet too large! Size: "
@@ -52,7 +52,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
status = sendCompletePacket(packetBuffer, packetLength);
clearBuffers();
}
- status = RETURN_OK;
+ status = returnvalue::OK;
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MapPacketExtraction::extractPackets. Packet too large! Size: "
@@ -88,14 +88,19 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame)
uint32_t totalLength = frame->getDataLength();
if (totalLength > MAX_PACKET_SIZE) return CONTENT_TOO_LARGE;
uint8_t* position = frame->getDataField();
- while ((totalLength > SpacePacketBase::MINIMUM_SIZE)) {
- SpacePacketBase packet(position);
- uint32_t packetSize = packet.getFullSize();
+ while ((totalLength > ccsds::HEADER_LEN)) {
+ SpacePacketReader packet(position, totalLength);
+ status = packet.checkSize();
+ if(status != returnvalue::OK) {
+ // TODO: Better error handling
+ status = DATA_CORRUPTED;
+ }
+ uint32_t packetSize = packet.getFullPacketLen();
if (packetSize <= totalLength) {
- status = sendCompletePacket(packet.getWholeData(), packet.getFullSize());
- totalLength -= packet.getFullSize();
- position += packet.getFullSize();
- status = RETURN_OK;
+ status = sendCompletePacket(packet.getFullData(), packet.getFullPacketLen());
+ totalLength -= packet.getFullPacketLen();
+ position += packet.getFullPacketLen();
+ status = returnvalue::OK;
} else {
status = DATA_CORRUPTED;
totalLength = 0;
@@ -107,10 +112,10 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame)
return status;
}
-ReturnValue_t MapPacketExtraction::sendCompletePacket(uint8_t* data, uint32_t size) {
+ReturnValue_t MapPacketExtraction::sendCompletePacket(const uint8_t* data, uint32_t size) {
store_address_t store_id;
ReturnValue_t status = this->packetStore->addData(&store_id, data, size);
- if (status == RETURN_OK) {
+ if (status == returnvalue::OK) {
TmTcMessage message(store_id);
status = MessageQueueSenderIF::sendMessage(tcQueueId, &message);
}
@@ -130,9 +135,9 @@ ReturnValue_t MapPacketExtraction::initialize() {
ObjectManager::instance()->get(packetDestination);
if ((packetStore != NULL) && (distributor != NULL)) {
tcQueueId = distributor->getRequestQueue();
- return RETURN_OK;
+ return returnvalue::OK;
} else {
- return RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.h b/src/fsfw/datalinklayer/MapPacketExtraction.h
index c2673b2e..3aa92aeb 100644
--- a/src/fsfw/datalinklayer/MapPacketExtraction.h
+++ b/src/fsfw/datalinklayer/MapPacketExtraction.h
@@ -5,7 +5,7 @@
#include "dllConf.h"
#include "fsfw/ipc/MessageQueueSenderIF.h"
#include "fsfw/objectmanager/ObjectManagerIF.h"
-#include "fsfw/returnvalues/HasReturnvaluesIF.h"
+#include "fsfw/returnvalues/returnvalue.h"
class StorageManagerIF;
@@ -36,7 +36,7 @@ class MapPacketExtraction : public MapPacketExtractionIF {
* Method that is called if the segmentation flag is @c NO_SEGMENTATION.
* The method extracts one or more packets within the frame and forwards them to the OBSW.
* @param frame The TC Transfer Frame to work on.
- * @return @c RETURN_OK if all Packets were extracted. If something is entirely wrong,
+ * @return @c returnvalue::OK if all Packets were extracted. If something is entirely wrong,
* @c DATA_CORRUPTED is returned, if some bytes are left over @c RESIDUAL_DATA.
*/
ReturnValue_t unpackBlockingPackets(TcTransferFrame* frame);
@@ -47,7 +47,7 @@ class MapPacketExtraction : public MapPacketExtractionIF {
* @param size Complete total size of the packet.
* @return Return Code of the Packet Store or the Message Queue.
*/
- ReturnValue_t sendCompletePacket(uint8_t* data, uint32_t size);
+ ReturnValue_t sendCompletePacket(const uint8_t* data, uint32_t size);
/**
* Helper method to reset the internal buffer.
*/
@@ -63,7 +63,7 @@ class MapPacketExtraction : public MapPacketExtractionIF {
ReturnValue_t extractPackets(TcTransferFrame* frame);
/**
* The #packetStore and the default destination of #tcQueue are initialized here.
- * @return @c RETURN_OK on success, @c RETURN_FAILED otherwise.
+ * @return @c returnvalue::OK on success, @c returnvalue::FAILED otherwise.
*/
ReturnValue_t initialize();
/**
diff --git a/src/fsfw/datalinklayer/VirtualChannelReception.cpp b/src/fsfw/datalinklayer/VirtualChannelReception.cpp
index 258bc1e6..4c44cf01 100644
--- a/src/fsfw/datalinklayer/VirtualChannelReception.cpp
+++ b/src/fsfw/datalinklayer/VirtualChannelReception.cpp
@@ -57,18 +57,18 @@ ReturnValue_t VirtualChannelReception::doFARM(TcTransferFrame* frame, ClcwIF* cl
ReturnValue_t VirtualChannelReception::frameAcceptanceAndReportingMechanism(TcTransferFrame* frame,
ClcwIF* clcw) {
- ReturnValue_t result = RETURN_OK;
+ ReturnValue_t result = returnvalue::OK;
result = doFARM(frame, &internalClcw);
internalClcw.setReceiverFrameSequenceNumber(vR);
internalClcw.setFarmBCount(farmBCounter);
clcw->setWhole(internalClcw.getAsWhole());
switch (result) {
- case RETURN_OK:
+ case returnvalue::OK:
return mapDemultiplexing(frame);
case BC_IS_SET_VR_COMMAND:
case BC_IS_UNLOCK_COMMAND:
// Need to catch these codes to avoid error reporting later.
- return RETURN_OK;
+ return returnvalue::OK;
default:
break;
}
@@ -79,15 +79,15 @@ ReturnValue_t VirtualChannelReception::addMapChannel(uint8_t mapId, MapPacketExt
std::pair returnValue =
mapChannels.insert(std::pair(mapId, object));
if (returnValue.second == true) {
- return RETURN_OK;
+ return returnvalue::OK;
} else {
- return RETURN_FAILED;
+ return returnvalue::FAILED;
}
}
ReturnValue_t VirtualChannelReception::handleBDFrame(TcTransferFrame* frame, ClcwIF* clcw) {
farmBCounter++;
- return RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t VirtualChannelReception::handleBCFrame(TcTransferFrame* frame, ClcwIF* clcw) {
@@ -107,18 +107,18 @@ ReturnValue_t VirtualChannelReception::handleBCFrame(TcTransferFrame* frame, Clc
uint8_t VirtualChannelReception::getChannelId() const { return channelId; }
ReturnValue_t VirtualChannelReception::initialize() {
- ReturnValue_t returnValue = RETURN_FAILED;
+ ReturnValue_t returnValue = returnvalue::FAILED;
if ((slidingWindowWidth > 254) || (slidingWindowWidth % 2 != 0)) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "VirtualChannelReception::initialize: Illegal sliding window width: "
<< (int)slidingWindowWidth << std::endl;
#endif
- return RETURN_FAILED;
+ return returnvalue::FAILED;
}
for (mapChannelIterator iterator = mapChannels.begin(); iterator != mapChannels.end();
iterator++) {
returnValue = iterator->second->initialize();
- if (returnValue != RETURN_OK) break;
+ if (returnValue != returnvalue::OK) break;
}
return returnValue;
}
diff --git a/src/fsfw/datalinklayer/VirtualChannelReception.h b/src/fsfw/datalinklayer/VirtualChannelReception.h
index 6dc17dd8..429ae9de 100644
--- a/src/fsfw/datalinklayer/VirtualChannelReception.h
+++ b/src/fsfw/datalinklayer/VirtualChannelReception.h
@@ -77,7 +77,7 @@ class VirtualChannelReception : public VirtualChannelReceptionIF, public CCSDSRe
* required.
* @param frame The Tc Transfer Frame to handle.
* @param clcw Any changes on the CLCW shall be done with this method.
- * @return Always returns @c RETURN_OK.
+ * @return Always returns @c returnvalue::OK.
*/
ReturnValue_t handleBDFrame(TcTransferFrame* frame, ClcwIF* clcw);
/**
@@ -102,13 +102,14 @@ class VirtualChannelReception : public VirtualChannelReceptionIF, public CCSDSRe
* Helper method to simplify adding a mapChannel during construction.
* @param mapId The mapId of the object to add.
* @param object Pointer to the MapPacketExtraction object itself.
- * @return @c RETURN_OK if the channel was successfully inserted, @c RETURN_FAILED otherwise.
+ * @return @c returnvalue::OK if the channel was successfully inserted, @c returnvalue::FAILED
+ * otherwise.
*/
ReturnValue_t addMapChannel(uint8_t mapId, MapPacketExtractionIF* object);
/**
* The initialization routine checks the set #slidingWindowWidth and initializes all MAP
* channels.
- * @return @c RETURN_OK on successful initialization, @c RETURN_FAILED otherwise.
+ * @return @c returnvalue::OK on successful initialization, @c returnvalue::FAILED otherwise.
*/
ReturnValue_t initialize();
/**
diff --git a/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h b/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h
index 3426f21c..9239ee0e 100644
--- a/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h
+++ b/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h
@@ -11,7 +11,7 @@
#include "ClcwIF.h"
#include "TcTransferFrame.h"
#include "dllConf.h"
-#include "fsfw/returnvalues/HasReturnvaluesIF.h"
+#include "fsfw/returnvalues/returnvalue.h"
/**
* This is the interface for Virtual Channel reception classes.
@@ -33,13 +33,13 @@ class VirtualChannelReceptionIF {
* Handling the Frame includes forwarding to higher-level procedures.
* @param frame The Tc Transfer Frame that was received and checked.
* @param clcw Any changes to the CLCW value are forwarded by using this parameter.
- * @return The return Value shall indicate successful processing with @c RETURN_OK.
+ * @return The return Value shall indicate successful processing with @c returnvalue::OK.
*/
virtual ReturnValue_t frameAcceptanceAndReportingMechanism(TcTransferFrame* frame,
ClcwIF* clcw) = 0;
/**
* If any other System Objects are required for operation they shall be initialized here.
- * @return @c RETURN_OK for successful initialization.
+ * @return @c returnvalue::OK for successful initialization.
*/
virtual ReturnValue_t initialize() = 0;
/**
diff --git a/src/fsfw/datapool/DataSetIF.h b/src/fsfw/datapool/DataSetIF.h
index 492bcf29..3d4be351 100644
--- a/src/fsfw/datapool/DataSetIF.h
+++ b/src/fsfw/datapool/DataSetIF.h
@@ -1,7 +1,7 @@
#ifndef FSFW_DATAPOOL_DATASETIF_H_
#define FSFW_DATAPOOL_DATASETIF_H_
-#include "../returnvalues/HasReturnvaluesIF.h"
+#include "../returnvalues/returnvalue.h"
#include "../timemanager/Clock.h"
class PoolVariableIF;
diff --git a/src/fsfw/datapool/PoolDataSetBase.cpp b/src/fsfw/datapool/PoolDataSetBase.cpp
index b31f4725..0df21d2a 100644
--- a/src/fsfw/datapool/PoolDataSetBase.cpp
+++ b/src/fsfw/datapool/PoolDataSetBase.cpp
@@ -14,7 +14,7 @@ PoolDataSetBase::~PoolDataSetBase() {}
ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) {
if (registeredVariables == nullptr) {
/* Underlying container invalid */
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
if (state != States::STATE_SET_UNINITIALISED) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
@@ -42,17 +42,17 @@ ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) {
}
registeredVariables[fillCount] = variable;
fillCount++;
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) {
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
+ ReturnValue_t result = returnvalue::OK;
ReturnValue_t error = result;
if (state == States::STATE_SET_UNINITIALISED) {
lockDataPool(timeoutType, lockTimeout);
for (uint16_t count = 0; count < fillCount; count++) {
result = readVariable(count);
- if (result != RETURN_OK) {
+ if (result != returnvalue::OK) {
error = result;
}
}
@@ -71,7 +71,7 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t l
result = SET_WAS_ALREADY_READ;
}
- if (error != HasReturnvaluesIF::RETURN_OK) {
+ if (error != returnvalue::OK) {
result = error;
}
return result;
@@ -80,10 +80,10 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t l
uint16_t PoolDataSetBase::getFillCount() const { return fillCount; }
ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
+ ReturnValue_t result = returnvalue::OK;
if (registeredVariables[count] == nullptr) {
/* Configuration error. */
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
/* These checks are often performed by the respective variable implementation too, but I guess
@@ -98,7 +98,7 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
result = ReadCommitIFAttorney::readWithoutLock(registeredVariables[count]);
}
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
result = INVALID_PARAMETER_DEFINITION;
}
}
@@ -108,7 +108,7 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
ReturnValue_t PoolDataSetBase::commit(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) {
if (state == States::STATE_SET_WAS_READ) {
handleAlreadyReadDatasetCommit(timeoutType, lockTimeout);
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
} else {
return handleUnreadDatasetCommit(timeoutType, lockTimeout);
}
@@ -134,7 +134,7 @@ void PoolDataSetBase::handleAlreadyReadDatasetCommit(MutexIF::TimeoutType timeou
ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(MutexIF::TimeoutType timeoutType,
uint32_t lockTimeout) {
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
+ ReturnValue_t result = returnvalue::OK;
lockDataPool(timeoutType, lockTimeout);
for (uint16_t count = 0; count < fillCount; count++) {
if ((registeredVariables[count]->getReadWriteMode() == PoolVariableIF::VAR_WRITE) and
@@ -165,17 +165,17 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(MutexIF::TimeoutType ti
ReturnValue_t PoolDataSetBase::lockDataPool(MutexIF::TimeoutType timeoutType,
uint32_t lockTimeout) {
- return HasReturnvaluesIF::RETURN_OK;
+ return returnvalue::OK;
}
-ReturnValue_t PoolDataSetBase::unlockDataPool() { return HasReturnvaluesIF::RETURN_OK; }
+ReturnValue_t PoolDataSetBase::unlockDataPool() { return returnvalue::OK; }
ReturnValue_t PoolDataSetBase::serialize(uint8_t** buffer, size_t* size, const size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
- ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
+ ReturnValue_t result = returnvalue::FAILED;
for (uint16_t count = 0; count < fillCount; count++) {
result = registeredVariables[count]->serialize(buffer, size, maxSize, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
}
@@ -184,10 +184,10 @@ ReturnValue_t PoolDataSetBase::serialize(uint8_t** buffer, size_t* size, const s
ReturnValue_t PoolDataSetBase::deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) {
- ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
+ ReturnValue_t result = returnvalue::FAILED;
for (uint16_t count = 0; count < fillCount; count++) {
result = registeredVariables[count]->deSerialize(buffer, size, streamEndianness);
- if (result != HasReturnvaluesIF::RETURN_OK) {
+ if (result != returnvalue::OK) {
return result;
}
}
diff --git a/src/fsfw/datapool/PoolDataSetBase.h b/src/fsfw/datapool/PoolDataSetBase.h
index dc6ec135..3e7e30c5 100644
--- a/src/fsfw/datapool/PoolDataSetBase.h
+++ b/src/fsfw/datapool/PoolDataSetBase.h
@@ -29,20 +29,20 @@
* @author Bastian Baetz
* @ingroup data_pool
*/
-class PoolDataSetBase : public PoolDataSetIF, public SerializeIF, public HasReturnvaluesIF {
+class PoolDataSetBase : public PoolDataSetIF, public SerializeIF {
public:
/**
* @brief Creates an empty dataset. Use registerVariable or
* supply a pointer to this dataset to PoolVariable
* initializations to register pool variables.
*/
- PoolDataSetBase(PoolVariableIF** registeredVariablesArray, const size_t maxFillCount);
+ PoolDataSetBase(PoolVariableIF** registeredVariablesArray, size_t maxFillCount);
/* Forbidden for now */
PoolDataSetBase(const PoolDataSetBase& otherSet) = delete;
const PoolDataSetBase& operator=(const PoolDataSetBase& otherSet) = delete;
- virtual ~PoolDataSetBase();
+ ~PoolDataSetBase() override;
/**
* @brief The read call initializes reading out all registered variables.
@@ -58,7 +58,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF, public HasRetu
* freed afterwards. It is mandatory to call commit after a read call,
* even if the read operation is not successful!
* @return
- * - @c RETURN_OK if all variables were read successfully.
+ * - @c returnvalue::OK if all variables were read successfully.
* - @c INVALID_PARAMETER_DEFINITION if a pool entry does not exist or there
* is a type conflict.
* - @c SET_WAS_ALREADY_READ if read() is called twice without calling
@@ -80,7 +80,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF, public HasRetu
* commit() can only be called after read(). If the set only contains
* variables which are write only, commit() can be called without a
* preceding read() call. Every read call must be followed by a commit call!
- * @return - @c RETURN_OK if all variables were read successfully.
+ * @return - @c returnvalue::OK if all variables were read successfully.
* - @c COMMITING_WITHOUT_READING if set was not read yet and
* contains non write-only variables
*/
@@ -97,7 +97,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF, public HasRetu
/**
* Provides the means to lock the underlying data structure to ensure
* thread-safety. Default implementation is empty
- * @return Always returns -@c RETURN_OK
+ * @return Always returns -@c returnvalue::OK
*/
virtual ReturnValue_t lockDataPool(
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
@@ -105,7 +105,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF, public HasRetu
/**
* Provides the means to unlock the underlying data structure to ensure
* thread-safety. Default implementation is empty
- * @return Always returns -@c RETURN_OK
+ * @return Always returns -@c returnvalue::OK
*/
virtual ReturnValue_t unlockDataPool() override;
diff --git a/src/fsfw/datapool/PoolEntry.cpp b/src/fsfw/datapool/PoolEntry.cpp
index fd110e6c..9138a705 100644
--- a/src/fsfw/datapool/PoolEntry.cpp
+++ b/src/fsfw/datapool/PoolEntry.cpp
@@ -7,24 +7,26 @@
#include "fsfw/serviceinterface/ServiceInterface.h"
template
-PoolEntry::PoolEntry(std::initializer_list initValue, bool setValid)
- : length(static_cast(initValue.size())), valid(setValid) {
- this->address = new T[this->length];
- if (initValue.size() == 0) {
- std::memset(this->address, 0, this->getByteSize());
- } else {
- std::copy(initValue.begin(), initValue.end(), this->address);
+PoolEntry::PoolEntry(uint8_t len, bool setValid) : length(len), valid(setValid) {
+ this->address = new T[this->length]();
+ std::memset(this->address, 0, this->getByteSize());
+}
+
+template
+PoolEntry::PoolEntry(std::initializer_list initValues, bool setValid)
+ : length(static_cast(initValues.size())), valid(setValid) {
+ this->address = new T[this->length]();
+ if (initValues.size() > 0) {
+ std::copy(initValues.begin(), initValues.end(), this->address);
}
}
template
-PoolEntry::PoolEntry(T* initValue, uint8_t setLength, bool setValid)
+PoolEntry::PoolEntry(const T* initValue, uint8_t setLength, bool setValid)
: length(setLength), valid(setValid) {
- this->address = new T[this->length];
+ this->address = new T[this->length]();
if (initValue != nullptr) {
std::memcpy(this->address, initValue, this->getByteSize());
- } else {
- std::memset(this->address, 0, this->getByteSize());
}
}
diff --git a/src/fsfw/datapool/PoolEntry.h b/src/fsfw/datapool/PoolEntry.h
index d3d80f09..4010f78d 100644
--- a/src/fsfw/datapool/PoolEntry.h
+++ b/src/fsfw/datapool/PoolEntry.h
@@ -33,6 +33,9 @@ class PoolEntry : public PoolEntryIF {
"instead! The ECSS standard defines a boolean as a one bit "
"field. Therefore it is preferred to store a boolean as an "
"uint8_t");
+
+ PoolEntry(uint8_t len = 1, bool setValid = false);
+
/**
* @brief In the classe's constructor, space is allocated on the heap and
* potential initialization values are copied to that space.
@@ -49,7 +52,7 @@ class PoolEntry : public PoolEntryIF {
* @param setValid
* Sets the initialization flag. It is invalid by default.
*/
- PoolEntry(std::initializer_list initValue = {0}, bool setValid = false);
+ PoolEntry(std::initializer_list initValue, bool setValid = false);
/**
* @brief In the classe's constructor, space is allocated on the heap and
@@ -62,7 +65,7 @@ class PoolEntry : public PoolEntryIF {
* @param setValid
* Sets the initialization flag. It is invalid by default.
*/
- PoolEntry(T* initValue, uint8_t setLength = 1, bool setValid = false);
+ PoolEntry(const T* initValue, uint8_t setLength = 1, bool setValid = false);
//! Explicitely deleted copy ctor, copying is not allowed.
PoolEntry(const PoolEntry&) = delete;
diff --git a/src/fsfw/datapool/PoolReadGuard.h b/src/fsfw/datapool/PoolReadGuard.h
index 24d98933..f9bf35fe 100644
--- a/src/fsfw/datapool/PoolReadGuard.h
+++ b/src/fsfw/datapool/PoolReadGuard.h
@@ -17,7 +17,7 @@ class PoolReadGuard {
: readObject(readObject), mutexTimeout(mutexTimeout) {
if (readObject != nullptr) {
readResult = readObject->read(timeoutType, mutexTimeout);
- if (readResult != HasReturnvaluesIF::RETURN_OK) {
+ if (readResult != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PoolReadHelper: Read failed!" << std::endl;
@@ -47,7 +47,7 @@ class PoolReadGuard {
private:
ReadCommitIF* readObject = nullptr;
- ReturnValue_t readResult = HasReturnvaluesIF::RETURN_OK;
+ ReturnValue_t readResult = returnvalue::OK;
bool noCommit = false;
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t mutexTimeout = 20;
diff --git a/src/fsfw/datapool/PoolVariableIF.h b/src/fsfw/datapool/PoolVariableIF.h
index 95cf898e..69074310 100644
--- a/src/fsfw/datapool/PoolVariableIF.h
+++ b/src/fsfw/datapool/PoolVariableIF.h
@@ -1,7 +1,7 @@
#ifndef FSFW_DATAPOOL_POOLVARIABLEIF_H_
#define FSFW_DATAPOOL_POOLVARIABLEIF_H_
-#include "../returnvalues/HasReturnvaluesIF.h"
+#include "../returnvalues/returnvalue.h"
#include "../serialize/SerializeIF.h"
#include "ReadCommitIF.h"
diff --git a/src/fsfw/datapool/ReadCommitIF.h b/src/fsfw/datapool/ReadCommitIF.h
index 08554be1..ca074dec 100644
--- a/src/fsfw/datapool/ReadCommitIF.h
+++ b/src/fsfw/datapool/ReadCommitIF.h
@@ -2,7 +2,7 @@
#define FSFW_DATAPOOL_READCOMMITIF_H_
#include "../ipc/MutexIF.h"
-#include "../returnvalues/HasReturnvaluesIF.h"
+#include "../returnvalues/returnvalue.h"
/**
* @brief Common interface for all software objects which employ read-commit
diff --git a/src/fsfw/datapool/ReadCommitIFAttorney.h b/src/fsfw/datapool/ReadCommitIFAttorney.h
index ea39ffe5..cca76c97 100644
--- a/src/fsfw/datapool/ReadCommitIFAttorney.h
+++ b/src/fsfw/datapool/ReadCommitIFAttorney.h
@@ -2,7 +2,7 @@
#define FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_
#include
-#include
+#include
/**
* @brief This class determines which members are allowed to access protected members
@@ -12,14 +12,14 @@ class ReadCommitIFAttorney {
private:
static ReturnValue_t readWithoutLock(ReadCommitIF* readCommitIF) {
if (readCommitIF == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
return readCommitIF->readWithoutLock();
}
static ReturnValue_t commitWithoutLock(ReadCommitIF* readCommitIF) {
if (readCommitIF == nullptr) {
- return HasReturnvaluesIF::RETURN_FAILED;
+ return returnvalue::FAILED;
}
return readCommitIF->commitWithoutLock();
}
diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h
index a2925a46..488e0cd4 100644
--- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h
+++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h
@@ -3,11 +3,11 @@
#include