Compare commits

..

1 Commits

Author SHA1 Message Date
9986b91ac7 Merge branch 'develop' into mueller/spi-speed-mode-getter 2022-05-11 16:28:41 +02:00
180 changed files with 2344 additions and 3631 deletions

8
.gitignore vendored
View File

@ -1,14 +1,6 @@
# PyCharm and CLion
/.idea/*
!/.idea/runConfigurations
!/.idea/cmake.xml
!/.idea/codeStyles
# Eclipse
.cproject .cproject
.project .project
.settings .settings
.metadata .metadata
/build* /build*
/cmake-build*

View File

@ -1,14 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<clangFormatSettings>
<option name="ENABLED" value="true" />
</clangFormatSettings>
<codeStyleSettings language="CMake">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="0" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>

View File

@ -1,5 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View File

@ -12,19 +12,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Changes ## Changes
- Renamed auto-formatting script to `auto-formatter.sh` and made it more robust.
If `cmake-format` is installed, it will also auto-format the `CMakeLists.txt` files now.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/625
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/626
- Bump C++ required version to C++17. Every project which uses the FSFW and every modern - Bump C++ required version to C++17. Every project which uses the FSFW and every modern
compiler supports it compiler supports it
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/622 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. - New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572
- HAL Devicehandlers: Periodic printout is run-time configurable now - HAL Devicehandlers: Periodic printout is run-time configurable now
- `oneShotAction` flag in the `TestTask` class is not static anymore - `oneShotAction` flag in the `TestTask` class is not static anymore
- HAL Linux Uart: Baudrate and bits per word are enums now, avoiding misconfigurations
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/585
- Major update for version handling, using `git describe` to fetch version information with git. - 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 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/601
- Place `Version` class outside of `fsfw` namespace. It is generic
- Add helper functions provided by [`cmake-modules`](https://github.com/bilke/cmake-modules) - Add helper functions provided by [`cmake-modules`](https://github.com/bilke/cmake-modules)
manually now. Those should not change too often and only a small subset is needed manually now. Those should not change too often and only a small subset is needed
- Separate folder for easier update and for distinction - Separate folder for easier update and for distinction
@ -40,72 +45,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
creation call. It allows passing context information and an arbitrary user argument into 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 the message queue. Also streamlined and simplified `MessageQueue` implementation for all OSALs
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/583 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/583
- Clock:
### Task Module Refactoring - `timeval` to `TimeOfDay_t`
- Added Mutex for gmtime calls: (compare http://www.opengate.at/blog/2020/01/timeless/)
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/636 - Moved the statics used by Clock in ClockCommon.cpp to this file
- Better check for leap seconds
**Refactoring general task code** - Added Unittests for Clock (only getter)
- There was a lot of duplicate/boilerplate code inside the individual task IF OSAL implementations.
Remove it by introducing base classes `PeriodicTaskBase` and `FixedTimeslotTaskBase`.
**Refactor PeriodicTaskIF**
- Convert `virtual ReturnValue_t addComponent(object_id_t object)` to
`virtual ReturnValue_t addComponent(object_id_t object, uint8_t opCode = 0)`, allowing to pass
the operation code passed to `performOperation`. Updated API taking
an `ExecutableObjectIF` accordingly
**Refactor FixedTimeslotTaskIF**
- Add additional `addSlot` function which takes an `ExecutableObjectIF` pointer and its Object ID
**Refactor FixedSequenceSlot**
- Introduce typedef `CustomCheckFunc` for `ReturnValue_t (*customCheckFunction)(const SlotList&)`.
- Convert `ReturnValue_t (*customCheckFunction)(const SlotList&)` to
`ReturnValue_t (*customCheckFunction)(const SlotList&, void*)`, allowing arbitrary user arguments
for the custom checker
**Linux Task Module**
- Use composition instead of inheritance for the `PeriodicPosixTask` and make the `PosixTask` a
member of the class
### HAL
- HAL Linux Uart: Baudrate and bits per word are enums now, avoiding misconfigurations
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/585
- 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
- HAL Linux Uart: Baudrate and bits per word are enums now, avoiding misconfigurations
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/585
- Linux HAL: Add wiretapping option for I2C. Enabled with `FSFW_HAL_I2C_WIRETAPPING` defined to 1
### Time
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/584 and
https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/593
- `timeval` to `TimeOfDay_t`
- Added Mutex for gmtime calls: (compare http://www.opengate.at/blog/2020/01/timeless/)
- Moved the statics used by Clock in ClockCommon.cpp to this file
- Better check for leap seconds
- Added Unittests for Clock (only getter)
### Power
- `PowerSwitchIF`: Remove `const` specifier from `sendSwitchCommand` and `sendFuseOnCommand` and
also specify a `ReturnValue_t` return type
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/590
- Extend `PowerSwitcher` module to optionally check current state when calling `turnOn` or
`turnOff`. Tis can be helpful to avoid commanding switches which do not need commanding
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/590
## Removed ## Removed
@ -115,39 +60,24 @@ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/593
## Additions ## Additions
- 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
- Basic `clion` support: Update `.gitignore` and add some basic run configurations
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/625
- LTO support: Allow using LTO/IPO by setting `FSFW_ENABLE_LTO=1`. CMake is able to detect whether
the user compiler supports IPO/LPO. LTO is on by default now. Most modern compilers support it,
can make good use of it and it usually makes the code faster and/or smaller.
After some more research:
Enabling LTO will actually cause the compiler to only produce thin LTO by adding
`-flto -fno-fat-lto-objects` to the compiler options. I am not sure this is an ideal choice
because if an application linking against the FSFW does not use LTO, there can be compile
issues (e.g. observed when compiling the FSFW tests without LTO). This is a known issue as
can be seen in the multiple CMake issues for it:
- https://gitlab.kitware.com/cmake/cmake/-/issues/22913,
- https://gitlab.kitware.com/cmake/cmake/-/issues/16808,
- https://gitlab.kitware.com/cmake/cmake/-/issues/21696
Easiest solution for now: Keep this option OFF by default.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/616
- Dedicated Version class and constant `fsfw::FSFW_VERSION` containing version information - Dedicated Version class and constant `fsfw::FSFW_VERSION` containing version information
inside `fsfw/version.h` inside `fsfw/version.h`
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/559 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/559
- Added generic PUS TC Scheduler Service 11. It depends on the new added Emebeded Template Library
(ETL) dependency.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/594
- Added ETL dependency and improved library dependency management - Added ETL dependency and improved library dependency management
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/592 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/592
- Add a `DummyPowerSwitcher` module which can be useful for test setups when no PCDU is available
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/590
- New typedef for switcher type
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/590
- `Subsystem`: New API to add table and sequence entries - `Subsystem`: New API to add table and sequence entries
## HAL
- SPI: Cache the SPI device in the communication interface. Architecturally, this makes a
lot more sense because each ComIF should be responsible for one SPI bus.
- SPI: Move the empty transfer to update the line polarity to separate function. This means
it is not automatically called when calling the setter function for SPI speed and mode.
The user should call this function after locking the CS mutex if multiple SPI devices with
differing speeds and modes are attached to one bus.
- SPI: Getter functions for SPI speed and mode.
- I2C: Add wiretapping option for I2C. Enabled with `FSFW_HAL_I2C_WIRETAPPING` defined to 1.
## Fixed ## Fixed
- TCP TMTC Server: `MutexGuard` was not created properly in - TCP TMTC Server: `MutexGuard` was not created properly in

View File

@ -1,111 +1,48 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
set(MSG_PREFIX "fsfw |")
# Add the cmake folder so the FindSphinx module is found
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules/bilke")
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules/rpavlik")
# ##############################################################################
# Version file handling #
# ##############################################################################
set(FSFW_VERSION_IF_GIT_FAILS 4)
set(FSFW_SUBVERSION_IF_GIT_FAILS 0)
set(FSFW_REVISION_IF_GIT_FAILS 0)
set(FSFW_GIT_VER_HANDLING_OK FALSE)
# Version handling
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
message(STATUS "${MSG_PREFIX} Determining version information with git")
include(FsfwHelpers)
determine_version_with_git("--exclude" "docker_*")
if(GIT_INFO)
set(FSFW_GIT_INFO
${GIT_INFO}
CACHE STRING "Version information retrieved with git describe")
list(GET FSFW_GIT_INFO 1 FSFW_VERSION)
list(GET FSFW_GIT_INFO 2 FSFW_SUBVERSION)
list(GET FSFW_GIT_INFO 3 FSFW_REVISION)
list(GET FSFW_GIT_INFO 4 FSFW_VCS_INFO)
if(NOT FSFW_VERSION)
set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS})
endif()
if(NOT FSFW_SUBVERSION)
set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS})
endif()
if(NOT FSFW_REVISION)
set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS})
endif()
set(FSFW_GIT_VER_HANDLING_OK TRUE)
else()
set(FSFW_GIT_VER_HANDLING_OK FALSE)
endif()
endif()
if(NOT FSFW_GIT_VER_HANDLING_OK)
set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS})
set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS})
set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS})
endif()
set(LIB_FSFW_NAME fsfw) set(LIB_FSFW_NAME fsfw)
project(${LIB_FSFW_NAME} project(${LIB_FSFW_NAME})
VERSION ${FSFW_VERSION}.${FSFW_SUBVERSION}.${FSFW_REVISION})
if(NOT CMAKE_CXX_STANDARD) if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
elseif(${CMAKE_CXX_STANDARD} LESS 17) elseif(${CMAKE_CXX_STANDARD} LESS 17)
message( message(FATAL_ERROR "Compiling the FSFW requires a minimum of C++17 support")
FATAL_ERROR
"${MSG_PREFIX} Compiling the FSFW requires a minimum of C++17 support")
endif() endif()
set(FSFW_SOURCES_DIR "${CMAKE_SOURCE_DIR}/src/fsfw") set(FSFW_VERSION_IF_GIT_FAILS 4)
set(FSFW_SUBVERSION_IF_GIT_FAILS 0)
set(FSFW_REVISION_IF_GIT_FAILS 0)
set(FSFW_ETL_LIB_NAME etl) # Add the cmake folder so the FindSphinx module is found
set(FSFW_ETL_LIB_MAJOR_VERSION list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
20 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules")
CACHE STRING "ETL library major version requirement") set(MSG_PREFIX "fsfw |")
set(FSFW_ETL_LIB_VERSION
${FSFW_ETL_LIB_MAJOR_VERSION}.28.0 set(FSFW_ETL_LIB_MAJOR_VERSION 20 CACHE STRING
CACHE STRING "ETL library exact version requirement") "ETL library major version requirement"
)
set(FSFW_ETL_LIB_VERSION ${FSFW_ETL_LIB_MAJOR_VERSION}.27.3 CACHE STRING
"ETL library exact version requirement"
)
set(FSFW_ETL_LINK_TARGET etl::etl) set(FSFW_ETL_LINK_TARGET etl::etl)
set(FSFW_CATCH2_LIB_MAJOR_VERSION set(FSFW_CATCH2_LIB_MAJOR_VERSION 3 CACHE STRING
3 "Catch2 library major version requirement"
CACHE STRING "Catch2 library major version requirement") )
set(FSFW_CATCH2_LIB_VERSION set(FSFW_CATCH2_LIB_VERSION v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5 CACHE STRING
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5 "Catch2 library exact version requirement"
CACHE STRING "Catch2 library exact version requirement") )
# Keep this off by default for now. See PR: set(FSFW_ETL_LIB_NAME etl)
# https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/616 for information which
# keeping this on by default is problematic
option(
FSFW_ENABLE_IPO
"Enable interprocedural optimization or link-time optimization if available"
OFF)
if(FSFW_ENABLE_IPO)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
if(NOT IPO_SUPPORTED)
message(STATUS "FSFW | IPO/LTO not supported: ${IPO_ERROR}")
endif()
endif()
option(FSFW_GENERATE_SECTIONS option(FSFW_GENERATE_SECTIONS
"Generate function and data sections. Required to remove unused code" ON) "Generate function and data sections. Required to remove unused code" ON
)
if(FSFW_GENERATE_SECTIONS) if(FSFW_GENERATE_SECTIONS)
option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON)
endif() endif()
option(FSFW_BUILD_UNITTESTS option(FSFW_BUILD_UNITTESTS "Build unittest binary in addition to static library" OFF)
"Build unittest binary in addition to static library" 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) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF)
if(FSFW_BUILD_UNITTESTS) if(FSFW_BUILD_UNITTESTS)
option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON) option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON)
@ -129,80 +66,95 @@ option(FSFW_ADD_TMSTORAGE "Compile with tm storage components" OFF)
# Contrib sources # Contrib sources
option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF) option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF)
set(FSFW_TEST_TGT fsfw-tests) set(FSFW_TEST_TGT fsfw-tests)
set(FSFW_DUMMY_TGT fsfw-dummy) set(FSFW_DUMMY_TGT fsfw-dummy)
add_library(${LIB_FSFW_NAME}) add_library(${LIB_FSFW_NAME})
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set(FSFW_GIT_VER_HANDLING_OK FALSE)
set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION # Version handling
TRUE) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
message(STATUS "${MSG_PREFIX} Determining version information with git")
include(FsfwHelpers)
determine_version_with_git("--exclude" "docker_*")
if(GIT_INFO)
set(FSFW_GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe")
list(GET FSFW_GIT_INFO 1 FSFW_VERSION)
list(GET FSFW_GIT_INFO 2 FSFW_SUBVERSION)
list(GET FSFW_GIT_INFO 3 FSFW_REVISION)
list(GET FSFW_GIT_INFO 4 FSFW_VERSION_CST_GIT_SHA1)
if(NOT FSFW_VERSION)
set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS})
endif()
if(NOT FSFW_SUBVERSION)
set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS})
endif()
if(NOT FSFW_REVISION)
set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS})
endif()
set(FSFW_GIT_VER_HANDLING_OK TRUE)
else()
set(FSFW_GIT_VER_HANDLING_OK FALSE)
endif()
endif()
if(NOT FSFW_GIT_VER_HANDLING_OK)
set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS})
set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS})
set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS})
endif() endif()
if(FSFW_BUILD_UNITTESTS) if(FSFW_BUILD_UNITTESTS)
message( message(STATUS "${MSG_PREFIX} Building the FSFW unittests in addition to the static library")
STATUS
"${MSG_PREFIX} Building the FSFW unittests in addition to the static library"
)
# Check whether the user has already installed Catch2 first # 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} CONFIG QUIET)
# Not installed, so use FetchContent to download and provide Catch2 # Not installed, so use FetchContent to download and provide Catch2
if(NOT Catch2_FOUND) if(NOT Catch2_FOUND)
message( message(STATUS "${MSG_PREFIX} Catch2 installation not found. Downloading Catch2 library with FetchContent")
STATUS
"${MSG_PREFIX} Catch2 installation not found. Downloading Catch2 library with FetchContent"
)
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
Catch2 Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG ${FSFW_CATCH2_LIB_VERSION}) GIT_TAG ${FSFW_CATCH2_LIB_VERSION}
)
list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2) list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2)
endif() endif()
set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg) 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/FSFWConfig.h.in FSFWConfig.h)
configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in tests/TestsConfig.h)
tests/TestsConfig.h)
project(${FSFW_TEST_TGT} CXX C) project(${FSFW_TEST_TGT} CXX C)
add_executable(${FSFW_TEST_TGT}) add_executable(${FSFW_TEST_TGT})
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION
TRUE)
endif()
if(FSFW_TESTS_GEN_COV) if(FSFW_TESTS_GEN_COV)
message(STATUS "${MSG_PREFIX} Generating coverage data for the library") message(STATUS "${MSG_PREFIX} Generating coverage data for the library")
message(STATUS "${MSG_PREFIX} Targets linking against ${LIB_FSFW_NAME} " message(STATUS "${MSG_PREFIX} Targets linking against ${LIB_FSFW_NAME} "
"will be compiled with coverage data as well") "will be compiled with coverage data as well"
)
set(CMAKE_BUILD_TYPE "Debug") set(CMAKE_BUILD_TYPE "Debug")
include(CodeCoverage) include(CodeCoverage)
endif() endif()
endif() endif()
message( message(STATUS "Finding and/or providing etl library with version ${FSFW_ETL_LIB_MAJOR_VERSION}")
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 # Check whether the user has already installed ETL first
find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET) find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET)
# Not installed, so use FetchContent to download and provide etl # Not installed, so use FetchContent to download and provide etl
if(NOT ${FSFW_ETL_LIB_NAME}_FOUND) if(NOT ${FSFW_ETL_LIB_NAME}_FOUND)
message( message(STATUS
STATUS "No ETL installation was found with find_package. Installing and providing "
"${MSG_PREFIX} No ETL installation was found with find_package. Installing and providing " "etl with FindPackage"
"etl with FindPackage") )
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_NAME}
GIT_REPOSITORY https://github.com/ETLCPP/etl GIT_REPOSITORY https://github.com/ETLCPP/etl
GIT_TAG ${FSFW_ETL_LIB_VERSION}) GIT_TAG ${FSFW_ETL_LIB_VERSION}
)
list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME}) list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME})
endif() endif()
@ -215,8 +167,8 @@ if(FSFW_FETCH_CONTENT_TARGETS)
add_library(${FSFW_ETL_LINK_TARGET} ALIAS ${FSFW_ETL_LIB_NAME}) add_library(${FSFW_ETL_LINK_TARGET} ALIAS ${FSFW_ETL_LIB_NAME})
endif() endif()
if(TARGET Catch2) if(TARGET Catch2)
# Fixes regression -preview4, to be confirmed in later releases Related # Fixes regression -preview4, to be confirmed in later releases
# GitHub issue: https://github.com/catchorg/Catch2/issues/2417 # Related GitHub issue: https://github.com/catchorg/Catch2/issues/2417
set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "") set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "")
endif() endif()
endif() endif()
@ -226,30 +178,33 @@ set(FSFW_CORE_INC_PATH "inc")
set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos) set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos)
# For configure files # For configure files
target_include_directories(${LIB_FSFW_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(${LIB_FSFW_NAME} PRIVATE
target_include_directories(${LIB_FSFW_NAME} ${CMAKE_CURRENT_BINARY_DIR}
INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) )
target_include_directories(${LIB_FSFW_NAME} INTERFACE
${CMAKE_CURRENT_BINARY_DIR}
)
# Backwards comptability # Backwards comptability
if(OS_FSFW AND NOT FSFW_OSAL) if(OS_FSFW AND NOT FSFW_OSAL)
message( message(WARNING "${MSG_PREFIX} Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW")
WARNING
"${MSG_PREFIX} Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW")
set(FSFW_OSAL OS_FSFW) set(FSFW_OSAL OS_FSFW)
endif() endif()
if(NOT FSFW_OSAL) if(NOT FSFW_OSAL)
message(STATUS "No OS for FSFW via FSFW_OSAL set. Assuming host OS") message(STATUS "${MSG_PREFIX} No OS for FSFW via FSFW_OSAL set. Assuming host OS")
# Assume host OS and autodetermine from OS_FSFW # Assume host OS and autodetermine from OS_FSFW
if(UNIX) if(UNIX)
set(FSFW_OSAL set(FSFW_OSAL "linux"
"linux" CACHE STRING
CACHE STRING "OS abstraction layer used in the FSFW") "OS abstraction layer used in the FSFW"
)
elseif(WIN32) elseif(WIN32)
set(FSFW_OSAL set(FSFW_OSAL "host"
"host" CACHE STRING "OS abstraction layer used in the FSFW"
CACHE STRING "OS abstraction layer used in the FSFW") )
endif() endif()
endif() endif()
set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST) set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST)
@ -263,13 +218,14 @@ elseif(FSFW_OSAL MATCHES linux)
elseif(FSFW_OSAL MATCHES freertos) elseif(FSFW_OSAL MATCHES freertos)
set(FSFW_OS_NAME "FreeRTOS") set(FSFW_OS_NAME "FreeRTOS")
set(FSFW_OSAL_FREERTOS ON) set(FSFW_OSAL_FREERTOS ON)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${LIB_OS_NAME}) target_link_libraries(${LIB_FSFW_NAME} PRIVATE
${LIB_OS_NAME}
)
elseif(FSFW_OSAL STREQUAL rtems) elseif(FSFW_OSAL STREQUAL rtems)
set(FSFW_OS_NAME "RTEMS") set(FSFW_OS_NAME "RTEMS")
set(FSFW_OSAL_RTEMS ON) set(FSFW_OSAL_RTEMS ON)
else() else()
message( message(WARNING
WARNING
"${MSG_PREFIX} Invalid operating system for FSFW specified! Setting to host.." "${MSG_PREFIX} Invalid operating system for FSFW specified! Setting to host.."
) )
set(FSFW_OS_NAME "Host") set(FSFW_OS_NAME "Host")
@ -279,9 +235,7 @@ endif()
configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h) configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h)
configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h) configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h)
message( message(STATUS "${MSG_PREFIX} Compiling FSFW for the ${FSFW_OS_NAME} operating system")
STATUS "${MSG_PREFIX} Compiling FSFW for the ${FSFW_OS_NAME} operating system"
)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(tests) add_subdirectory(tests)
@ -299,86 +253,95 @@ if(FSFW_BUILD_UNITTESTS)
include(CodeCoverage) include(CodeCoverage)
# Remove quotes. # Remove quotes.
separate_arguments(COVERAGE_COMPILER_FLAGS NATIVE_COMMAND separate_arguments(COVERAGE_COMPILER_FLAGS
"${COVERAGE_COMPILER_FLAGS}") NATIVE_COMMAND "${COVERAGE_COMPILER_FLAGS}"
)
# Add compile options manually, we don't want coverage for Catch2 # Add compile options manually, we don't want coverage for Catch2
target_compile_options(${FSFW_TEST_TGT} target_compile_options(${FSFW_TEST_TGT} PRIVATE
PRIVATE "${COVERAGE_COMPILER_FLAGS}") "${COVERAGE_COMPILER_FLAGS}"
target_compile_options(${LIB_FSFW_NAME} )
PRIVATE "${COVERAGE_COMPILER_FLAGS}") target_compile_options(${LIB_FSFW_NAME} PRIVATE
"${COVERAGE_COMPILER_FLAGS}"
)
# Exclude directories here # Exclude directories here
if(WIN32) if(WIN32)
set(GCOVR_ADDITIONAL_ARGS "--exclude-throw-branches" set(GCOVR_ADDITIONAL_ARGS
"--exclude-unreachable-branches") "--exclude-throw-branches"
set(COVERAGE_EXCLUDES "/c/msys64/mingw64/*" "*/fsfw_hal/*") "--exclude-unreachable-branches"
)
set(COVERAGE_EXCLUDES
"/c/msys64/mingw64/*" "*/fsfw_hal/*"
)
elseif(UNIX) elseif(UNIX)
set(COVERAGE_EXCLUDES set(COVERAGE_EXCLUDES
"/usr/include/*" "/usr/include/*" "/usr/bin/*" "Catch2/*"
"/usr/bin/*" "/usr/local/include/*" "*/fsfw_tests/*"
"Catch2/*" "*/catch2-src/*" "*/fsfw_hal/*"
"/usr/local/include/*" )
"*/fsfw_tests/*"
"*/catch2-src/*"
"*/fsfw_hal/*")
endif() endif()
target_link_options(${FSFW_TEST_TGT} PRIVATE -fprofile-arcs target_link_options(${FSFW_TEST_TGT} PRIVATE
-ftest-coverage) -fprofile-arcs
target_link_options(${LIB_FSFW_NAME} PRIVATE -fprofile-arcs -ftest-coverage
-ftest-coverage) )
# Need to specify this as an interface, otherwise there will the compile target_link_options(${LIB_FSFW_NAME} PRIVATE
# issues -fprofile-arcs
target_link_options(${LIB_FSFW_NAME} INTERFACE -fprofile-arcs -ftest-coverage
-ftest-coverage) )
# Need to specify this as an interface, otherwise there will the compile issues
target_link_options(${LIB_FSFW_NAME} INTERFACE
-fprofile-arcs
-ftest-coverage
)
if(WIN32) if(WIN32)
setup_target_for_coverage_gcovr_html( setup_target_for_coverage_gcovr_html(
NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} NAME ${FSFW_TEST_TGT}_coverage
DEPENDENCIES ${FSFW_TEST_TGT}) EXECUTABLE ${FSFW_TEST_TGT}
DEPENDENCIES ${FSFW_TEST_TGT}
)
else() else()
setup_target_for_coverage_lcov( setup_target_for_coverage_lcov(
NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} NAME ${FSFW_TEST_TGT}_coverage
DEPENDENCIES ${FSFW_TEST_TGT}) EXECUTABLE ${FSFW_TEST_TGT}
DEPENDENCIES ${FSFW_TEST_TGT}
)
endif() endif()
endif() endif()
endif() endif()
target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2 target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2 ${LIB_FSFW_NAME})
${LIB_FSFW_NAME})
endif() endif()
# The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it. If # The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it.
# this is not given, we include the default configuration and emit a warning. # If this is not given, we include the default configuration and emit a warning.
if(NOT FSFW_CONFIG_PATH) if(NOT FSFW_CONFIG_PATH)
set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig) set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig)
if(NOT FSFW_BUILD_DOCS) if(NOT FSFW_BUILD_DOCS)
message( message(WARNING "${MSG_PREFIX} Flight Software Framework configuration path not set")
WARNING message(WARNING "${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..")
"${MSG_PREFIX} Flight Software Framework configuration path not set")
message(
WARNING
"${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..")
endif() endif()
add_subdirectory(${DEF_CONF_PATH}) add_subdirectory(${DEF_CONF_PATH})
set(FSFW_CONFIG_PATH ${DEF_CONF_PATH}) set(FSFW_CONFIG_PATH ${DEF_CONF_PATH})
endif() endif()
# FSFW might be part of a possibly complicated folder structure, so we extract # FSFW might be part of a possibly complicated folder structure, so we
# the absolute path of the fsfwconfig folder. # extract the absolute path of the fsfwconfig folder.
if(IS_ABSOLUTE ${FSFW_CONFIG_PATH}) if(IS_ABSOLUTE ${FSFW_CONFIG_PATH})
set(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH}) set(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH})
else() else()
get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH} REALPATH get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE
BASE_DIR ${CMAKE_SOURCE_DIR}) ${FSFW_CONFIG_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR}
)
endif() endif()
foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATHS}) foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATHS})
if(IS_ABSOLUTE ${INCLUDE_PATH}) if(IS_ABSOLUTE ${INCLUDE_PATH})
set(CURR_ABS_INC_PATH "${INCLUDE_PATH}") set(CURR_ABS_INC_PATH "${INCLUDE_PATH}")
else() else()
get_filename_component(CURR_ABS_INC_PATH ${INCLUDE_PATH} REALPATH BASE_DIR get_filename_component(CURR_ABS_INC_PATH
${CMAKE_SOURCE_DIR}) ${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR})
endif() endif()
if(CMAKE_VERBOSE) if(CMAKE_VERBOSE)
@ -411,19 +374,23 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
-Wcast-qual # Warn if the constness is cast away -Wcast-qual # Warn if the constness is cast away
-Wstringop-overflow=4 -Wstringop-overflow=4
# -Wstack-protector # Emits a few false positives for low level access # -Wstack-protector # Emits a few false positives for low level access
# -Wconversion # Creates many false positives -Warith-conversion # Use # -Wconversion # Creates many false positives
# with Wconversion to find more implicit conversions -fanalyzer # Should # -Warith-conversion # Use with Wconversion to find more implicit conversions
# be used to look through problems # -fanalyzer # Should be used to look through problems
) )
endif() endif()
if(FSFW_GENERATE_SECTIONS) if(FSFW_GENERATE_SECTIONS)
target_compile_options(${LIB_FSFW_NAME} PRIVATE "-ffunction-sections" target_compile_options(${LIB_FSFW_NAME} PRIVATE
"-fdata-sections") "-ffunction-sections"
"-fdata-sections"
)
endif() endif()
if(FSFW_REMOVE_UNUSED_CODE) if(FSFW_REMOVE_UNUSED_CODE)
target_link_options(${LIB_FSFW_NAME} PRIVATE "Wl,--gc-sections") target_link_options(${LIB_FSFW_NAME} PRIVATE
"Wl,--gc-sections"
)
endif() endif()
if(FSFW_WARNING_SHADOW_LOCAL_GCC) if(FSFW_WARNING_SHADOW_LOCAL_GCC)
@ -437,31 +404,42 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif() endif()
# Required include paths to compile the FSFW # Required include paths to compile the FSFW
target_include_directories( target_include_directories(${LIB_FSFW_NAME} INTERFACE
${LIB_FSFW_NAME} INTERFACE ${CMAKE_SOURCE_DIR} ${FSFW_CONFIG_PATH_ABSOLUTE} ${CMAKE_SOURCE_DIR}
${FSFW_CORE_INC_PATH} ${FSFW_ADD_INC_PATHS_ABS}) ${FSFW_CONFIG_PATH_ABSOLUTE}
${FSFW_CORE_INC_PATH}
${FSFW_ADD_INC_PATHS_ABS}
)
# Includes path required to compile FSFW itself as well We assume that the # Includes path required to compile FSFW itself as well
# fsfwconfig folder uses include relative to the project root here! # We assume that the fsfwconfig folder uses include relative to the project
target_include_directories( # root here!
${LIB_FSFW_NAME} PRIVATE ${CMAKE_SOURCE_DIR} ${FSFW_CONFIG_PATH_ABSOLUTE} target_include_directories(${LIB_FSFW_NAME} PRIVATE
${FSFW_CORE_INC_PATH} ${FSFW_ADD_INC_PATHS_ABS}) ${CMAKE_SOURCE_DIR}
${FSFW_CONFIG_PATH_ABSOLUTE}
${FSFW_CORE_INC_PATH}
${FSFW_ADD_INC_PATHS_ABS}
)
target_compile_options(${LIB_FSFW_NAME} PRIVATE ${FSFW_WARNING_FLAGS} target_compile_options(${LIB_FSFW_NAME} PRIVATE
${COMPILER_FLAGS}) ${FSFW_WARNING_FLAGS}
${COMPILER_FLAGS}
)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ETL_LINK_TARGET} target_link_libraries(${LIB_FSFW_NAME} PRIVATE
${FSFW_ADDITIONAL_LINK_LIBS}) ${FSFW_ETL_LINK_TARGET}
${FSFW_ADDITIONAL_LINK_LIBS}
)
string( string(CONCAT POST_BUILD_COMMENT
CONCAT
POST_BUILD_COMMENT
"######################################################################\n" "######################################################################\n"
"Built FSFW v${FSFW_VERSION}.${FSFW_SUBVERSION}.${FSFW_REVISION}, " "Built FSFW v${FSFW_VERSION}.${FSFW_SUBVERSION}.${FSFW_REVISION}, "
"Target OSAL: ${FSFW_OS_NAME}\n" "Target OSAL: ${FSFW_OS_NAME}\n"
"######################################################################\n") "######################################################################\n"
)
add_custom_command( add_custom_command(
TARGET ${LIB_FSFW_NAME} TARGET ${LIB_FSFW_NAME}
POST_BUILD POST_BUILD
COMMENT ${POST_BUILD_COMMENT}) COMMENT ${POST_BUILD_COMMENT}
)

View File

View File

@ -99,7 +99,7 @@ add and link against the FSFW library in general.
4. Link against the FSFW library 4. Link against the FSFW library
```sh ```cmake
target_link_libraries(${YourProjectName} PRIVATE fsfw) target_link_libraries(${YourProjectName} PRIVATE fsfw)
``` ```
@ -131,7 +131,7 @@ default. This can be disabled by setting the `FSFW_TESTS_COV_GEN` option to `OFF
You can use the following commands inside the `fsfw` folder to set up the build system You can use the following commands inside the `fsfw` folder to set up the build system
```sh ```sh
mkdir build-tests && cd build-tests mkdir build-Unittest && cd build-Unittest
cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug .. cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug ..
``` ```

View File

@ -14,7 +14,7 @@ pipeline {
stage('Configure') { stage('Configure') {
steps { steps {
dir(BUILDDIR) { dir(BUILDDIR) {
sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON -DFSFW_CICD_BUILD=ON ..' sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..'
} }
} }
} }

View File

@ -0,0 +1,141 @@
# - Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time,
# to find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
# check if this is a submodule
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
if (IS_ABSOLUTE ${GIT_DIR_RELATIVE})
set(GIT_DIR ${GIT_DIR_RELATIVE})
else()
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
endif()
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${GIT_DIR}/HEAD")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(COMMAND
${GIT_EXECUTABLE}
describe
${hash}
${ARGN}
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_get_tag _var)
git_describe(out --tags ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()

View File

@ -8,12 +8,10 @@
# http://academic.cleardefinition.com # http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC # Iowa State University HCI Graduate Program/VRAC
# #
# Copyright 2009-2012, Iowa State University # Copyright Iowa State University 2009-2010.
# Copyright 2011-2015, Contributors
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at # (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt) # http://www.boost.org/LICENSE_1_0.txt)
# SPDX-License-Identifier: BSL-1.0
set(HEAD_HASH) set(HEAD_HASH)
@ -25,12 +23,9 @@ if(HEAD_CONTENTS MATCHES "ref")
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}") if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else() elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) set(HEAD_HASH "${HEAD_REF}")
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif() endif()
else() else()
# detached HEAD # detached HEAD
@ -38,6 +33,6 @@ else()
endif() endif()
if(NOT HEAD_HASH) if(NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH) string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif() endif()

View File

@ -1,7 +1,5 @@
The files in the `bilke` folder were manually copy and pasted from the The files in these folder were manually copy and pasted from the
[cmake-modules repository](https://github.com/bilke/cmake-modules). It was decided to do [cmake-modules repository](https://github.com/bilke/cmake-modules). It was decided to do
this because only a small subset of its provided functions are needed. this because only a small subset of its provided functions are needed.
The files in the `rpavlik` folder were manually copy and pasted from the The license file in included here as well.
[cmake-modules repository](https://github.com/rpavlik/cmake-modules). It was decided to do
this because only a small subset of its provided functions are needed.

View File

@ -1,284 +0,0 @@
# - Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_describe_working_tree(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the working tree (--dirty option),
# and adjusting the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# git_local_changes(<var>)
#
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes.
# Uses the return code of "git diff-index --quiet HEAD --".
# Does not regard untracked files.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2020 Ryan Pavlik <ryan.pavlik@gmail.com> <abiryan@ryand.net>
# http://academic.cleardefinition.com
#
# Copyright 2009-2013, Iowa State University.
# Copyright 2013-2020, Ryan Pavlik
# Copyright 2013-2020, Contributors
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time,
# to find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
# Function _git_find_closest_git_dir finds the next closest .git directory
# that is part of any directory in the path defined by _start_dir.
# The result is returned in the parent scope variable whose name is passed
# as variable _git_dir_var. If no .git directory can be found, the
# function returns an empty string via _git_dir_var.
#
# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and
# neither foo nor bar contain a file/directory .git. This wil return
# C:/bla/.git
#
function(_git_find_closest_git_dir _start_dir _git_dir_var)
set(cur_dir "${_start_dir}")
set(git_dir "${_start_dir}/.git")
while(NOT EXISTS "${git_dir}")
# .git dir not found, search parent directories
set(git_previous_parent "${cur_dir}")
get_filename_component(cur_dir "${cur_dir}" DIRECTORY)
if(cur_dir STREQUAL git_previous_parent)
# We have reached the root directory, we are not in git
set(${_git_dir_var}
""
PARENT_SCOPE)
return()
endif()
set(git_dir "${cur_dir}/.git")
endwhile()
set(${_git_dir_var}
"${git_dir}"
PARENT_SCOPE)
endfunction()
function(get_git_head_revision _refspecvar _hashvar)
_git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)
if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR")
set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE)
else()
set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE)
endif()
if(NOT "${GIT_DIR}" STREQUAL "")
file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}"
"${GIT_DIR}")
if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)
# We've gone above the CMake root dir.
set(GIT_DIR "")
endif()
endif()
if("${GIT_DIR}" STREQUAL "")
set(${_refspecvar}
"GITDIR-NOTFOUND"
PARENT_SCOPE)
set(${_hashvar}
"GITDIR-NOTFOUND"
PARENT_SCOPE)
return()
endif()
# Check if the current source dir is a git submodule or a worktree.
# In both cases .git is a file instead of a directory.
#
if(NOT IS_DIRECTORY ${GIT_DIR})
# The following git command will return a non empty string that
# points to the super project working tree if the current
# source dir is inside a git submodule.
# Otherwise the command will return an empty string.
#
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse
--show-superproject-working-tree
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT "${out}" STREQUAL "")
# If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE
${submodule})
string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE)
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE}
ABSOLUTE)
set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
else()
# GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree
file(READ ${GIT_DIR} worktree_ref)
# The .git directory contains a path to the worktree information directory
# inside the parent git repo of the worktree.
#
string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir
${worktree_ref})
string(STRIP ${git_worktree_dir} git_worktree_dir)
_git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR)
set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD")
endif()
else()
set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${HEAD_SOURCE_FILE}")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake" @ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar}
"${HEAD_REF}"
PARENT_SCOPE)
set(${_hashvar}
"${HEAD_HASH}"
PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var}
"HEAD-HASH-NOTFOUND"
PARENT_SCOPE)
return()
endif()
# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var}
"${out}"
PARENT_SCOPE)
endfunction()
function(git_describe_working_tree _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var}
"${out}"
PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var}
"${out}"
PARENT_SCOPE)
endfunction()
function(git_local_changes _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var}
"HEAD-HASH-NOTFOUND"
PARENT_SCOPE)
return()
endif()
execute_process(
COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD --
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(res EQUAL 0)
set(${_var}
"CLEAN"
PARENT_SCOPE)
else()
set(${_var}
"DIRTY"
PARENT_SCOPE)
endif()
endfunction()

View File

@ -1,26 +0,0 @@
Copyright (c) <year> <owner>. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute, execute,
and transmit the Software, and to prepare derivative works of the Software,
and to permit third-parties to whom the Software is furnished to do so, all
subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer, must
be included in all copies of the Software, in whole or in part, and all derivative
works of the Software, unless such copies or derivative works are solely in
the form of machine-executable object code generated by a source language
processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@ -252,7 +252,6 @@ ReturnValue_t GyroHandlerL3GD20H::initializeLocalDataPool(localpool::DataPool &l
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Y, new PoolEntry<float>({0.0})); localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Y, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Z, new PoolEntry<float>({0.0})); localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Z, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::TEMPERATURE, new PoolEntry<float>({0.0})); localDataPoolMap.emplace(L3GD20H::TEMPERATURE, new PoolEntry<float>({0.0}));
poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 10.0, false);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -475,7 +475,6 @@ ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &lo
localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Y, new PoolEntry<float>({0.0})); localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Y, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Z, new PoolEntry<float>({0.0})); localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Z, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, new PoolEntry<float>({0.0})); localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, new PoolEntry<float>({0.0}));
poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 10.0, false);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -312,7 +312,6 @@ ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &loc
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_X, new PoolEntry<float>({0.0})); localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_X, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Y, new PoolEntry<float>({0.0})); localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Y, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Z, new PoolEntry<float>({0.0})); localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Z, new PoolEntry<float>({0.0}));
poolManager.subscribeForPeriodicPacket(primaryDataset.getSid(), false, 10.0, false);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -32,8 +32,6 @@ ReturnValue_t CommandExecutor::execute() {
} else if (state == States::PENDING) { } else if (state == States::PENDING) {
return COMMAND_PENDING; return COMMAND_PENDING;
} }
// Reset data in read vector
std::memset(readVec.data(), 0, readVec.size());
currentCmdFile = popen(currentCmd.c_str(), "r"); currentCmdFile = popen(currentCmd.c_str(), "r");
if (currentCmdFile == nullptr) { if (currentCmdFile == nullptr) {
lastError = errno; lastError = errno;
@ -207,5 +205,3 @@ ReturnValue_t CommandExecutor::executeBlocking() {
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
const std::vector<char>& CommandExecutor::getReadVector() const { return readVec; }

View File

@ -109,8 +109,6 @@ class CommandExecutor {
*/ */
void reset(); void reset();
const std::vector<char>& getReadVector() const;
private: private:
std::string currentCmd; std::string currentCmd;
bool blocking = true; bool blocking = true;

View File

@ -20,9 +20,7 @@ LinuxLibgpioIF::~LinuxLibgpioIF() {
ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) { ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) {
ReturnValue_t result; ReturnValue_t result;
if (gpioCookie == nullptr) { if (gpioCookie == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LinuxLibgpioIF::addGpios: Invalid cookie" << std::endl; sif::error << "LinuxLibgpioIF::addGpios: Invalid cookie" << std::endl;
#endif
return RETURN_FAILED; return RETURN_FAILED;
} }
@ -98,10 +96,8 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLabel(gpioId_t gpioId,
std::string& label = gpioByLabel.label; std::string& label = gpioByLabel.label;
struct gpiod_chip* chip = gpiod_chip_open_by_label(label.c_str()); struct gpiod_chip* chip = gpiod_chip_open_by_label(label.c_str());
if (chip == nullptr) { if (chip == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::configureGpioByLabel: Failed to open gpio from gpio " sif::warning << "LinuxLibgpioIF::configureGpioByLabel: Failed to open gpio from gpio "
<< "group with label " << label << ". Gpio ID: " << gpioId << std::endl; << "group with label " << label << ". Gpio ID: " << gpioId << std::endl;
#endif
return RETURN_FAILED; return RETURN_FAILED;
} }
std::string failOutput = "label: " + label; std::string failOutput = "label: " + label;
@ -112,10 +108,8 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByChip(gpioId_t gpioId, GpiodRegularB
std::string& chipname = gpioByChip.chipname; std::string& chipname = gpioByChip.chipname;
struct gpiod_chip* chip = gpiod_chip_open_by_name(chipname.c_str()); struct gpiod_chip* chip = gpiod_chip_open_by_name(chipname.c_str());
if (chip == nullptr) { if (chip == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::configureGpioByChip: Failed to open chip " << chipname sif::warning << "LinuxLibgpioIF::configureGpioByChip: Failed to open chip " << chipname
<< ". Gpio ID: " << gpioId << std::endl; << ". Gpio ID: " << gpioId << std::endl;
#endif
return RETURN_FAILED; return RETURN_FAILED;
} }
std::string failOutput = "chipname: " + chipname; std::string failOutput = "chipname: " + chipname;
@ -139,10 +133,8 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLineName(gpioId_t gpioId,
struct gpiod_chip* chip = gpiod_chip_open_by_name(chipname); struct gpiod_chip* chip = gpiod_chip_open_by_name(chipname);
if (chip == nullptr) { if (chip == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::configureGpioByLineName: Failed to open chip " << chipname sif::warning << "LinuxLibgpioIF::configureGpioByLineName: Failed to open chip " << chipname
<< ". <Gpio ID: " << gpioId << std::endl; << ". <Gpio ID: " << gpioId << std::endl;
#endif
return RETURN_FAILED; return RETURN_FAILED;
} }
std::string failOutput = "line name: " + lineName; std::string failOutput = "line name: " + lineName;
@ -161,12 +153,10 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
lineNum = regularGpio.lineNum; lineNum = regularGpio.lineNum;
lineHandle = gpiod_chip_get_line(chip, lineNum); lineHandle = gpiod_chip_get_line(chip, lineNum);
if (!lineHandle) { if (!lineHandle) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::configureRegularGpio: Failed to open line " << std::endl; sif::warning << "LinuxLibgpioIF::configureRegularGpio: Failed to open line " << std::endl;
sif::warning << "GPIO ID: " << gpioId << ", line number: " << lineNum << ", " << failOutput sif::warning << "GPIO ID: " << gpioId << ", line number: " << lineNum << ", " << failOutput
<< std::endl; << std::endl;
sif::warning << "Check if Linux GPIO configuration has changed. " << std::endl; sif::warning << "Check if Linux GPIO configuration has changed. " << std::endl;
#endif
gpiod_chip_close(chip); gpiod_chip_close(chip);
return RETURN_FAILED; return RETURN_FAILED;
} }
@ -185,9 +175,7 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
break; break;
} }
default: { default: {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified" << std::endl; sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified" << std::endl;
#endif
return GPIO_INVALID_INSTANCE; return GPIO_INVALID_INSTANCE;
} }
@ -216,9 +204,7 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) { ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
gpioMapIter = gpioMap.find(gpioId); gpioMapIter = gpioMap.find(gpioId);
if (gpioMapIter == gpioMap.end()) { if (gpioMapIter == gpioMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::pullHigh: Unknown GPIO ID " << gpioId << std::endl; sif::warning << "LinuxLibgpioIF::pullHigh: Unknown GPIO ID " << gpioId << std::endl;
#endif
return UNKNOWN_GPIO_ID; return UNKNOWN_GPIO_ID;
} }

View File

@ -1,43 +0,0 @@
#pragma once
#include "fsfw/ipc/MutexIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw_hal/common/gpio/GpioIF.h"
class ManualCsLockWrapper : public HasReturnvaluesIF {
public:
ManualCsLockWrapper(MutexIF* lock, GpioIF* gpioIF, SpiCookie* cookie,
MutexIF::TimeoutType type = MutexIF::TimeoutType::BLOCKING,
uint32_t timeoutMs = 0)
: lock(lock), gpioIF(gpioIF), cookie(cookie), type(type), timeoutMs(timeoutMs) {
if (cookie == nullptr) {
// TODO: Error? Or maybe throw exception..
return;
}
cookie->setCsLockManual(true);
lockResult = lock->lockMutex(type, timeoutMs);
if (lockResult != RETURN_OK) {
return;
}
gpioResult = gpioIF->pullLow(cookie->getChipSelectPin());
}
~ManualCsLockWrapper() {
if (gpioResult == RETURN_OK) {
gpioIF->pullHigh(cookie->getChipSelectPin());
}
cookie->setCsLockManual(false);
if (lockResult == RETURN_OK) {
lock->unlockMutex();
}
}
ReturnValue_t lockResult;
ReturnValue_t gpioResult;
private:
MutexIF* lock;
GpioIF* gpioIF;
SpiCookie* cookie;
MutexIF::TimeoutType type;
uint32_t timeoutMs = 0;
};

View File

@ -194,28 +194,22 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
bool fullDuplex = spiCookie->isFullDuplex(); bool fullDuplex = spiCookie->isFullDuplex();
gpioId_t gpioId = spiCookie->getChipSelectPin(); gpioId_t gpioId = spiCookie->getChipSelectPin();
bool csLockManual = spiCookie->getCsLockManual();
MutexIF::TimeoutType csType; /* Pull SPI CS low. For now, no support for active high given */
dur_millis_t csTimeout = 0; if (gpioId != gpio::NO_GPIO) {
// Pull SPI CS low. For now, no support for active high given result = csMutex->lockMutex(timeoutType, timeoutMs);
if (gpioId != gpio::NO_GPIO and not csLockManual) {
spiCookie->getMutexParams(csType, csTimeout);
result = csMutex->lockMutex(csType, csTimeout);
if (result != RETURN_OK) { if (result != RETURN_OK) {
#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "SpiComIF::sendMessage: Failed to lock mutex with code " sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl;
<< "0x" << std::hex << std::setfill('0') << std::setw(4) << result << std::dec
<< std::endl;
#else #else
sif::printError("SpiComIF::sendMessage: Failed to lock mutex with code %d\n", result); sif::printError("SpiComIF::sendMessage: Failed to lock mutex\n");
#endif #endif
#endif #endif
return result; return result;
} }
updateLinePolarity(fileDescriptor); updateLinePolarity(fileDescriptor);
result = gpioComIF->pullLow(gpioId); ReturnValue_t result = gpioComIF->pullLow(gpioId);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -255,7 +249,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
} }
} }
if (gpioId != gpio::NO_GPIO and not csLockManual) { if (gpioId != gpio::NO_GPIO) {
gpioComIF->pullHigh(gpioId); gpioComIF->pullHigh(gpioId);
result = csMutex->unlockMutex(); result = csMutex->unlockMutex();
if (result != RETURN_OK) { if (result != RETURN_OK) {
@ -298,22 +292,12 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
return result; return result;
} }
bool csLockManual = spiCookie->getCsLockManual();
gpioId_t gpioId = spiCookie->getChipSelectPin(); gpioId_t gpioId = spiCookie->getChipSelectPin();
MutexIF::TimeoutType csType; if (gpioId != gpio::NO_GPIO) {
dur_millis_t csTimeout = 0; result = csMutex->lockMutex(timeoutType, timeoutMs);
if (gpioId != gpio::NO_GPIO and not csLockManual) {
spiCookie->getMutexParams(csType, csTimeout);
result = csMutex->lockMutex(csType, csTimeout);
if (result != RETURN_OK) { if (result != RETURN_OK) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "SpiComIF::sendMessage: Failed to lock mutex with code " sif::error << "SpiComIF::getSendSuccess: Failed to lock mutex" << std::endl;
<< "0x" << std::hex << std::setfill('0') << std::setw(4) << result << std::dec
<< std::endl;
#else
sif::printError("SpiComIF::sendMessage: Failed to lock mutex with code %d\n", result);
#endif
#endif #endif
return result; return result;
} }
@ -331,7 +315,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
result = HALF_DUPLEX_TRANSFER_FAILED; result = HALF_DUPLEX_TRANSFER_FAILED;
} }
if (gpioId != gpio::NO_GPIO and not csLockManual) { if (gpioId != gpio::NO_GPIO) {
gpioComIF->pullHigh(gpioId); gpioComIF->pullHigh(gpioId);
result = csMutex->unlockMutex(); result = csMutex->unlockMutex();
if (result != RETURN_OK) { if (result != RETURN_OK) {
@ -362,7 +346,15 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
MutexIF* SpiComIF::getCsMutex() { return csMutex; } MutexIF* SpiComIF::getMutex(MutexIF::TimeoutType* timeoutType, uint32_t* timeoutMs) {
if (timeoutType != nullptr) {
*timeoutType = this->timeoutType;
}
if (timeoutMs != nullptr) {
*timeoutMs = this->timeoutMs;
}
return csMutex;
}
void SpiComIF::performSpiWiretapping(SpiCookie* spiCookie) { void SpiComIF::performSpiWiretapping(SpiCookie* spiCookie) {
if (spiCookie == nullptr) { if (spiCookie == nullptr) {
@ -425,7 +417,9 @@ void SpiComIF::getSpiSpeedAndMode(int spiFd, spi::SpiModes& mode, uint32_t& spee
} }
} }
const std::string& SpiComIF::getSpiDev() const { return dev; } const std::string& SpiComIF::getSpiDev() const {
return dev;
}
void SpiComIF::updateLinePolarity(int spiFd) { void SpiComIF::updateLinePolarity(int spiFd) {
clockUpdateTransfer.len = 0; clockUpdateTransfer.len = 0;

View File

@ -22,15 +22,15 @@ class SpiCookie;
*/ */
class SpiComIF : public DeviceCommunicationIF, public SystemObject { class SpiComIF : public DeviceCommunicationIF, public SystemObject {
public: public:
static constexpr uint8_t CLASS_ID = CLASS_ID::HAL_SPI; static constexpr uint8_t spiRetvalId = CLASS_ID::HAL_SPI;
static constexpr ReturnValue_t OPENING_FILE_FAILED = static constexpr ReturnValue_t OPENING_FILE_FAILED =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); HasReturnvaluesIF::makeReturnCode(spiRetvalId, 0);
/* Full duplex (ioctl) transfer failure */ /* Full duplex (ioctl) transfer failure */
static constexpr ReturnValue_t FULL_DUPLEX_TRANSFER_FAILED = static constexpr ReturnValue_t FULL_DUPLEX_TRANSFER_FAILED =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); HasReturnvaluesIF::makeReturnCode(spiRetvalId, 1);
/* Half duplex (read/write) transfer failure */ /* Half duplex (read/write) transfer failure */
static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED = static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); HasReturnvaluesIF::makeReturnCode(spiRetvalId, 2);
SpiComIF(object_id_t objectId, std::string devname, GpioIF* gpioComIF); SpiComIF(object_id_t objectId, std::string devname, GpioIF* gpioComIF);
@ -44,8 +44,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject {
* @brief This function returns the mutex which can be used to protect the spi bus when * @brief This function returns the mutex which can be used to protect the spi bus when
* the chip select must be driven from outside of the com if. * the chip select must be driven from outside of the com if.
*/ */
MutexIF* getCsMutex(); MutexIF* getMutex(MutexIF::TimeoutType* timeoutType = nullptr, uint32_t* timeoutMs = nullptr);
void setMutexParams(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs);
/** /**
* Perform a regular send operation using Linux iotcl. This is public so it can be used * Perform a regular send operation using Linux iotcl. This is public so it can be used
@ -60,7 +59,6 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject {
GpioIF* getGpioInterface(); GpioIF* getGpioInterface();
void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed);
void getSpiSpeedAndMode(int spiFd, spi::SpiModes& mode, uint32_t& speed) const;
/** /**
* This updates the SPI clock default polarity. Only setting the mode does not update * This updates the SPI clock default polarity. Only setting the mode does not update
@ -72,6 +70,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject {
* @param spiFd * @param spiFd
*/ */
void updateLinePolarity(int spiFd); void updateLinePolarity(int spiFd);
void getSpiSpeedAndMode(int spiFd, spi::SpiModes& mode, uint32_t& speed) const;
const std::string& getSpiDev() const; const std::string& getSpiDev() const;
void performSpiWiretapping(SpiCookie* spiCookie); void performSpiWiretapping(SpiCookie* spiCookie);
@ -91,8 +90,8 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject {
* pulled high * pulled high
*/ */
MutexIF* csMutex = nullptr; MutexIF* csMutex = nullptr;
// MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
// uint32_t timeoutMs = DEFAULT_MUTEX_TIMEOUT; uint32_t timeoutMs = 20;
spi_ioc_transfer clockUpdateTransfer = {}; spi_ioc_transfer clockUpdateTransfer = {};
using SpiDeviceMap = std::unordered_map<address_t, SpiInstance>; using SpiDeviceMap = std::unordered_map<address_t, SpiInstance>;

View File

@ -104,17 +104,3 @@ void SpiCookie::getCallback(spi::send_callback_function_t* callback, void** args
*callback = this->sendCallback; *callback = this->sendCallback;
*args = this->callbackArgs; *args = this->callbackArgs;
} }
void SpiCookie::setCsLockManual(bool enable) { manualCsLock = enable; }
bool SpiCookie::getCsLockManual() const { return manualCsLock; }
void SpiCookie::getMutexParams(MutexIF::TimeoutType& csTimeoutType, dur_millis_t& csTimeout) const {
csTimeoutType = this->csTimeoutType;
csTimeout = this->csTimeout;
}
void SpiCookie::setMutexParams(MutexIF::TimeoutType csTimeoutType, dur_millis_t csTimeout) {
this->csTimeoutType = csTimeoutType;
this->csTimeout = csTimeout;
}

View File

@ -2,8 +2,6 @@
#define LINUX_SPI_SPICOOKIE_H_ #define LINUX_SPI_SPICOOKIE_H_
#include <fsfw/devicehandlers/CookieIF.h> #include <fsfw/devicehandlers/CookieIF.h>
#include <fsfw/ipc/MutexIF.h>
#include <fsfw/timemanager/clockDefinitions.h>
#include <linux/spi/spidev.h> #include <linux/spi/spidev.h>
#include "../../common/gpio/gpioDefinitions.h" #include "../../common/gpio/gpioDefinitions.h"
@ -22,8 +20,6 @@
*/ */
class SpiCookie : public CookieIF { class SpiCookie : public CookieIF {
public: public:
static constexpr dur_millis_t DEFAULT_MUTEX_TIMEOUT = 20;
/** /**
* Each SPI device will have a corresponding cookie. The cookie is used by the communication * Each SPI device will have a corresponding cookie. The cookie is used by the communication
* interface and contains device specific information like the largest expected size to be * interface and contains device specific information like the largest expected size to be
@ -141,42 +137,9 @@ class SpiCookie : public CookieIF {
*/ */
void activateCsDeselect(bool deselectCs, uint16_t delayUsecs); void activateCsDeselect(bool deselectCs, uint16_t delayUsecs);
void getMutexParams(MutexIF::TimeoutType& csTimeoutType, dur_millis_t& csTimeout) const;
void setMutexParams(MutexIF::TimeoutType csTimeoutType, dur_millis_t csTimeout);
void setCsLockManual(bool enable);
bool getCsLockManual() const;
spi_ioc_transfer* getTransferStructHandle(); spi_ioc_transfer* getTransferStructHandle();
private: private:
address_t spiAddress;
gpioId_t chipSelectPin;
spi::SpiComIfModes comIfMode;
// Required for regular mode
const size_t maxSize;
spi::SpiModes spiMode;
/**
* If this is set to true, the SPI ComIF will not perform any mutex locking for the
* CS mechanism. The user is responsible to locking and unlocking the mutex for the
* whole duration of the transfers.
*/
bool manualCsLock = false;
uint32_t spiSpeed;
bool halfDuplex = false;
MutexIF::TimeoutType csTimeoutType = MutexIF::TimeoutType::WAITING;
dur_millis_t csTimeout = DEFAULT_MUTEX_TIMEOUT;
// Required for callback mode
spi::send_callback_function_t sendCallback = nullptr;
void* callbackArgs = nullptr;
struct spi_ioc_transfer spiTransferStruct = {};
UncommonParameters uncommonParameters;
/** /**
* Internal constructor which initializes every field * Internal constructor which initializes every field
* @param spiAddress * @param spiAddress
@ -191,6 +154,24 @@ class SpiCookie : public CookieIF {
SpiCookie(spi::SpiComIfModes comIfMode, address_t spiAddress, gpioId_t chipSelect, SpiCookie(spi::SpiComIfModes comIfMode, address_t spiAddress, gpioId_t chipSelect,
const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed, const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed,
spi::send_callback_function_t callback, void* args); spi::send_callback_function_t callback, void* args);
address_t spiAddress;
gpioId_t chipSelectPin;
spi::SpiComIfModes comIfMode;
// Required for regular mode
const size_t maxSize;
spi::SpiModes spiMode;
uint32_t spiSpeed;
bool halfDuplex = false;
// Required for callback mode
spi::send_callback_function_t sendCallback = nullptr;
void* callbackArgs = nullptr;
struct spi_ioc_transfer spiTransferStruct = {};
UncommonParameters uncommonParameters;
}; };
#endif /* LINUX_SPI_SPICOOKIE_H_ */ #endif /* LINUX_SPI_SPICOOKIE_H_ */

View File

@ -10,10 +10,6 @@
#include "stm32h7xx_hal.h" #include "stm32h7xx_hal.h"
#include "stm32h7xx_hal_spi.h" #include "stm32h7xx_hal_spi.h"
#ifndef STM_USE_PERIPHERAL_TX_BUFFER_MPU_PROTECTION
#define STM_USE_PERIPHERAL_TX_BUFFER_MPU_PROTECTION 1
#endif
enum class TransferStates { IDLE, WAIT, SUCCESS, FAILURE }; enum class TransferStates { IDLE, WAIT, SUCCESS, FAILURE };
class GyroL3GD20H { class GyroL3GD20H {

8
scripts/apply-clang-format.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
if [[ ! -f README.md ]]; then
cd ..
fi
find ./src -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
find ./hal -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
find ./tests -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i

View File

@ -1,30 +0,0 @@
#!/bin/bash
if [[ ! -f README.md ]]; then
cd ..
fi
folder_list=(
"./src"
"./hal"
"./tests"
)
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
else
echo "No ${cmake_fmt} tool found, not formatting CMake files"
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
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

View File

@ -1,6 +1,9 @@
target_include_directories(${LIB_FSFW_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(${LIB_FSFW_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_include_directories(${LIB_FSFW_NAME} target_include_directories(${LIB_FSFW_NAME} INTERFACE
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) ${CMAKE_CURRENT_SOURCE_DIR}
)
add_subdirectory(fsfw) add_subdirectory(fsfw)

View File

@ -1,4 +1,6 @@
target_sources(${LIB_FSFW_NAME} PRIVATE version.cpp) target_sources(${LIB_FSFW_NAME} PRIVATE
version.cpp
)
# Core # Core
@ -35,7 +37,7 @@ add_subdirectory(tmtcservices)
# Optional # Optional
if(FSFW_ADD_MONITORING) if(FSFW_ADD_MONITORING)
add_subdirectory(monitoring) add_subdirectory(monitoring)
endif() endif()
if(FSFW_ADD_PUS) if(FSFW_ADD_PUS)
add_subdirectory(pus) add_subdirectory(pus)

View File

@ -6,6 +6,6 @@ static constexpr int FSFW_VERSION_MAJOR = @FSFW_VERSION@;
static constexpr int FSFW_VERSION_MINOR = @FSFW_SUBVERSION@; static constexpr int FSFW_VERSION_MINOR = @FSFW_SUBVERSION@;
static constexpr int FSFW_VERSION_REVISION = @FSFW_REVISION@; static constexpr int FSFW_VERSION_REVISION = @FSFW_REVISION@;
// Also contains CST (Commits since tag) information // Also contains CST (Commits since tag) information
static const char FSFW_VCS_INFO[] = "@FSFW_VCS_INFO@"; static const char FSFW_VERSION_CST_GIT_SHA1[] = "@FSFW_VERSION_CST_GIT_SHA1@";
#endif /* FSFW_VERSION_H_ */ #endif /* FSFW_VERSION_H_ */

View File

@ -1,3 +1,7 @@
target_sources( target_sources(${LIB_FSFW_NAME}
${LIB_FSFW_NAME} PRIVATE ActionHelper.cpp ActionMessage.cpp PRIVATE
CommandActionHelper.cpp SimpleActionHelper.cpp) ActionHelper.cpp
ActionMessage.cpp
CommandActionHelper.cpp
SimpleActionHelper.cpp
)

View File

@ -1,4 +1,7 @@
target_sources(${LIB_FSFW_NAME} PRIVATE CFDPHandler.cpp CFDPMessage.cpp) target_sources(${LIB_FSFW_NAME} PRIVATE
CFDPHandler.cpp
CFDPMessage.cpp
)
add_subdirectory(pdu) add_subdirectory(pdu)
add_subdirectory(tlv) add_subdirectory(tlv)

View File

@ -1,11 +1,11 @@
target_sources( target_sources(${LIB_FSFW_NAME} PRIVATE
${LIB_FSFW_NAME} PduConfig.cpp
PRIVATE PduConfig.cpp
VarLenField.cpp VarLenField.cpp
HeaderSerializer.cpp HeaderSerializer.cpp
HeaderDeserializer.cpp HeaderDeserializer.cpp
FileDirectiveDeserializer.cpp FileDirectiveDeserializer.cpp
FileDirectiveSerializer.cpp FileDirectiveSerializer.cpp
AckInfo.cpp AckInfo.cpp
AckPduSerializer.cpp AckPduSerializer.cpp
AckPduDeserializer.cpp AckPduDeserializer.cpp
@ -25,6 +25,8 @@ target_sources(
KeepAlivePduDeserializer.cpp KeepAlivePduDeserializer.cpp
PromptPduSerializer.cpp PromptPduSerializer.cpp
PromptPduDeserializer.cpp PromptPduDeserializer.cpp
FileDataSerializer.cpp FileDataSerializer.cpp
FileDataDeserializer.cpp FileDataDeserializer.cpp
FileDataInfo.cpp) FileDataInfo.cpp
)

View File

@ -1,10 +1,10 @@
target_sources( target_sources(${LIB_FSFW_NAME} PRIVATE
${LIB_FSFW_NAME} EntityIdTlv.cpp
PRIVATE EntityIdTlv.cpp
FilestoreRequestTlv.cpp FilestoreRequestTlv.cpp
FilestoreResponseTlv.cpp FilestoreResponseTlv.cpp
Lv.cpp Lv.cpp
Tlv.cpp Tlv.cpp
FlowLabelTlv.cpp FlowLabelTlv.cpp
MessageToUserTlv.cpp MessageToUserTlv.cpp
FaultHandlerOverrideTlv.cpp) FaultHandlerOverrideTlv.cpp
)

View File

@ -1,2 +1,5 @@
target_sources(${LIB_FSFW_NAME} PRIVATE SharedRingBuffer.cpp target_sources(${LIB_FSFW_NAME}
SimpleRingBuffer.cpp) PRIVATE
SharedRingBuffer.cpp
SimpleRingBuffer.cpp
)

View File

@ -5,11 +5,11 @@
#error Include FIFOBase.h before FIFOBase.tpp! #error Include FIFOBase.h before FIFOBase.tpp!
#endif #endif
template <typename T> template<typename T>
inline FIFOBase<T>::FIFOBase(T* values, const size_t maxCapacity) inline FIFOBase<T>::FIFOBase(T* values, const size_t maxCapacity):
: maxCapacity(maxCapacity), values(values){}; maxCapacity(maxCapacity), values(values){};
template <typename T> template<typename T>
inline ReturnValue_t FIFOBase<T>::insert(T value) { inline ReturnValue_t FIFOBase<T>::insert(T value) {
if (full()) { if (full()) {
return FULL; return FULL;
@ -21,12 +21,12 @@ inline ReturnValue_t FIFOBase<T>::insert(T value) {
} }
}; };
template <typename T> template<typename T>
inline ReturnValue_t FIFOBase<T>::retrieve(T* value) { inline ReturnValue_t FIFOBase<T>::retrieve(T* value) {
if (empty()) { if (empty()) {
return EMPTY; return EMPTY;
} else { } else {
if (value == nullptr) { if (value == nullptr){
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
*value = values[readIndex]; *value = values[readIndex];
@ -36,12 +36,12 @@ inline ReturnValue_t FIFOBase<T>::retrieve(T* value) {
} }
}; };
template <typename T> template<typename T>
inline ReturnValue_t FIFOBase<T>::peek(T* value) { inline ReturnValue_t FIFOBase<T>::peek(T* value) {
if (empty()) { if(empty()) {
return EMPTY; return EMPTY;
} else { } else {
if (value == nullptr) { if (value == nullptr){
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
*value = values[readIndex]; *value = values[readIndex];
@ -49,28 +49,28 @@ inline ReturnValue_t FIFOBase<T>::peek(T* value) {
} }
}; };
template <typename T> template<typename T>
inline ReturnValue_t FIFOBase<T>::pop() { inline ReturnValue_t FIFOBase<T>::pop() {
T value; T value;
return this->retrieve(&value); return this->retrieve(&value);
}; };
template <typename T> template<typename T>
inline bool FIFOBase<T>::empty() { inline bool FIFOBase<T>::empty() {
return (currentSize == 0); return (currentSize == 0);
}; };
template <typename T> template<typename T>
inline bool FIFOBase<T>::full() { inline bool FIFOBase<T>::full() {
return (currentSize == maxCapacity); return (currentSize == maxCapacity);
} }
template <typename T> template<typename T>
inline size_t FIFOBase<T>::size() { inline size_t FIFOBase<T>::size() {
return currentSize; return currentSize;
} }
template <typename T> template<typename T>
inline size_t FIFOBase<T>::next(size_t current) { inline size_t FIFOBase<T>::next(size_t current) {
++current; ++current;
if (current == maxCapacity) { if (current == maxCapacity) {
@ -79,13 +79,14 @@ inline size_t FIFOBase<T>::next(size_t current) {
return current; return current;
} }
template <typename T> template<typename T>
inline size_t FIFOBase<T>::getMaxCapacity() const { inline size_t FIFOBase<T>::getMaxCapacity() const {
return maxCapacity; return maxCapacity;
} }
template <typename T>
inline void FIFOBase<T>::setContainer(T* data) { template<typename T>
inline void FIFOBase<T>::setContainer(T *data) {
this->values = data; this->values = data;
} }

View File

@ -1,15 +1,15 @@
#ifndef FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ #ifndef FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_
#define FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ #define FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_
template <typename key_t, typename T, typename KEY_COMPARE>
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(key_t key, T value, template<typename key_t, typename T, typename KEY_COMPARE>
Iterator *storedValue) { inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(key_t key, T value, Iterator *storedValue) {
if (_size == theMap.maxSize()) { if (_size == theMap.maxSize()) {
return MAP_FULL; return MAP_FULL;
} }
size_t position = findNicePlace(key); size_t position = findNicePlace(key);
memmove(static_cast<void *>(&theMap[position + 1]), static_cast<void *>(&theMap[position]), memmove(static_cast<void*>(&theMap[position + 1]),static_cast<void*>(&theMap[position]),
(_size - position) * sizeof(std::pair<key_t, T>)); (_size - position) * sizeof(std::pair<key_t,T>));
theMap[position].first = key; theMap[position].first = key;
theMap[position].second = value; theMap[position].second = value;
++_size; ++_size;
@ -18,12 +18,12 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(key_t k
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
template <typename key_t, typename T, typename KEY_COMPARE> template<typename key_t, typename T, typename KEY_COMPARE>
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(std::pair<key_t, T> pair) { inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(std::pair<key_t, T> pair) {
return insert(pair.first, pair.second); return insert(pair.first, pair.second);
} }
template <typename key_t, typename T, typename KEY_COMPARE> template<typename key_t, typename T, typename KEY_COMPARE>
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::exists(key_t key) const { inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::exists(key_t key) const {
ReturnValue_t result = KEY_DOES_NOT_EXIST; ReturnValue_t result = KEY_DOES_NOT_EXIST;
if (findFirstIndex(key) < _size) { if (findFirstIndex(key) < _size) {
@ -32,7 +32,7 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::exists(key_t k
return result; return result;
} }
template <typename key_t, typename T, typename KEY_COMPARE> template<typename key_t, typename T, typename KEY_COMPARE>
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(Iterator *iter) { inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(Iterator *iter) {
size_t i; size_t i;
if ((i = findFirstIndex((*iter).value->first)) >= _size) { if ((i = findFirstIndex((*iter).value->first)) >= _size) {
@ -47,7 +47,7 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(Iterator
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
template <typename key_t, typename T, typename KEY_COMPARE> template<typename key_t, typename T, typename KEY_COMPARE>
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(key_t key) { inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(key_t key) {
size_t i; size_t i;
if ((i = findFirstIndex(key)) >= _size) { if ((i = findFirstIndex(key)) >= _size) {
@ -60,7 +60,7 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(key_t ke
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
template <typename key_t, typename T, typename KEY_COMPARE> template<typename key_t, typename T, typename KEY_COMPARE>
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::find(key_t key, T **value) const { inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::find(key_t key, T **value) const {
ReturnValue_t result = exists(key); ReturnValue_t result = exists(key);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
@ -70,9 +70,8 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::find(key_t key
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
template <typename key_t, typename T, typename KEY_COMPARE> template<typename key_t, typename T, typename KEY_COMPARE>
inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findFirstIndex(key_t key, inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findFirstIndex(key_t key, size_t startAt) const {
size_t startAt) const {
if (startAt >= _size) { if (startAt >= _size) {
return startAt + 1; return startAt + 1;
} }
@ -85,7 +84,7 @@ inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findFirstIndex(key_t
return i; return i;
} }
template <typename key_t, typename T, typename KEY_COMPARE> template<typename key_t, typename T, typename KEY_COMPARE>
inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findNicePlace(key_t key) const { inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findNicePlace(key_t key) const {
size_t i = 0; size_t i = 0;
for (i = 0; i < _size; ++i) { for (i = 0; i < _size; ++i) {
@ -96,14 +95,15 @@ inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findNicePlace(key_t k
return i; return i;
} }
template <typename key_t, typename T, typename KEY_COMPARE> template<typename key_t, typename T, typename KEY_COMPARE>
inline void FixedOrderedMultimap<key_t, T, KEY_COMPARE>::removeFromPosition(size_t position) { inline void FixedOrderedMultimap<key_t, T, KEY_COMPARE>::removeFromPosition(size_t position) {
if (_size <= position) { if (_size <= position) {
return; return;
} }
memmove(static_cast<void *>(&theMap[position]), static_cast<void *>(&theMap[position + 1]), memmove(static_cast<void*>(&theMap[position]), static_cast<void*>(&theMap[position + 1]),
(_size - position - 1) * sizeof(std::pair<key_t, T>)); (_size - position - 1) * sizeof(std::pair<key_t,T>));
--_size; --_size;
} }
#endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ */ #endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ */

View File

@ -1,2 +1,4 @@
target_sources(${LIB_FSFW_NAME} PRIVATE ControllerBase.cpp target_sources(${LIB_FSFW_NAME} PRIVATE
ExtendedControllerBase.cpp) ControllerBase.cpp
ExtendedControllerBase.cpp
)

View File

@ -1,2 +1,5 @@
target_sources(${LIB_FSFW_NAME} PRIVATE CoordinateTransformations.cpp target_sources(${LIB_FSFW_NAME}
Sgp4Propagator.cpp) PRIVATE
CoordinateTransformations.cpp
Sgp4Propagator.cpp
)

View File

@ -1,6 +1,6 @@
target_sources( target_sources(${LIB_FSFW_NAME}
${LIB_FSFW_NAME} PRIVATE
PRIVATE Clcw.cpp Clcw.cpp
DataLinkLayer.cpp DataLinkLayer.cpp
Farm1StateLockout.cpp Farm1StateLockout.cpp
Farm1StateOpen.cpp Farm1StateOpen.cpp
@ -8,4 +8,5 @@ target_sources(
MapPacketExtraction.cpp MapPacketExtraction.cpp
TcTransferFrame.cpp TcTransferFrame.cpp
TcTransferFrameLocal.cpp TcTransferFrameLocal.cpp
VirtualChannelReception.cpp) VirtualChannelReception.cpp
)

View File

@ -1 +1,4 @@
target_sources(${LIB_FSFW_NAME} PRIVATE PoolDataSetBase.cpp PoolEntry.cpp) target_sources(${LIB_FSFW_NAME} PRIVATE
PoolDataSetBase.cpp
PoolEntry.cpp
)

View File

@ -1,6 +1,10 @@
target_sources( target_sources(${LIB_FSFW_NAME}
${LIB_FSFW_NAME} PRIVATE
PRIVATE LocalDataPoolManager.cpp LocalDataSet.cpp LocalPoolDataSetBase.cpp LocalDataPoolManager.cpp
LocalPoolObjectBase.cpp SharedLocalDataSet.cpp) LocalDataSet.cpp
LocalPoolDataSetBase.cpp
LocalPoolObjectBase.cpp
SharedLocalDataSet.cpp
)
add_subdirectory(internal) add_subdirectory(internal)

View File

@ -577,10 +577,6 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me
CommandMessage reply; CommandMessage reply;
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
if (result == WRONG_HK_PACKET_TYPE) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "handleHousekeepingMessage",
WRONG_HK_PACKET_TYPE);
}
HousekeepingMessage::setHkRequestFailureReply(&reply, sid, result); HousekeepingMessage::setHkRequestFailureReply(&reply, sid, result);
} else { } else {
HousekeepingMessage::setHkRequestSuccessReply(&reply, sid); HousekeepingMessage::setHkRequestSuccessReply(&reply, sid);
@ -700,9 +696,9 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
/* Configuration error */ /* Configuration error */
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalDataPoolManager::performPeriodicHkOperation: HK generation failed." << std::endl; sif::warning << "LocalDataPoolManager::performHkOperation: HK generation failed." << std::endl;
#else #else
sif::printWarning("LocalDataPoolManager::performPeriodicHkOperation: HK generation failed.\n"); sif::printWarning("LocalDataPoolManager::performHkOperation: HK generation failed.\n");
#endif #endif
} }
} }
@ -838,8 +834,6 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType,
errorPrint = "Dataset not found"; errorPrint = "Dataset not found";
} else if (error == POOLOBJECT_NOT_FOUND) { } else if (error == POOLOBJECT_NOT_FOUND) {
errorPrint = "Pool Object not found"; errorPrint = "Pool Object not found";
} else if (error == WRONG_HK_PACKET_TYPE) {
errorPrint = "Wrong Packet Type";
} else if (error == HasReturnvaluesIF::RETURN_FAILED) { } else if (error == HasReturnvaluesIF::RETURN_FAILED) {
if (outputType == sif::OutputTypes::OUT_WARNING) { if (outputType == sif::OutputTypes::OUT_WARNING) {
errorPrint = "Generic Warning"; errorPrint = "Generic Warning";

View File

@ -5,31 +5,33 @@
#error Include LocalPoolVariable.h before LocalPoolVariable.tpp! #error Include LocalPoolVariable.h before LocalPoolVariable.tpp!
#endif #endif
template <typename T> template<typename T>
inline LocalPoolVariable<T>::LocalPoolVariable(HasLocalDataPoolIF* hkOwner, lp_id_t poolId, inline LocalPoolVariable<T>::LocalPoolVariable(HasLocalDataPoolIF* hkOwner,
DataSetIF* dataSet, pool_rwm_t setReadWriteMode) lp_id_t poolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode):
: LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {} LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
template <typename T> template<typename T>
inline LocalPoolVariable<T>::LocalPoolVariable(object_id_t poolOwner, lp_id_t poolId, inline LocalPoolVariable<T>::LocalPoolVariable(object_id_t poolOwner,
DataSetIF* dataSet, pool_rwm_t setReadWriteMode) lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
: LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {} LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
template <typename T>
inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode)
: LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet,
setReadWriteMode) {}
template <typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::read(MutexIF::TimeoutType timeoutType, inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId,
uint32_t timeoutMs) { DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
if (hkManager == nullptr) { LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId,
dataSet, setReadWriteMode){}
template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::read(
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
if(hkManager == nullptr) {
return readWithoutLock(); return readWithoutLock();
} }
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager); MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs); ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = readWithoutLock(); result = readWithoutLock();
@ -37,21 +39,23 @@ inline ReturnValue_t LocalPoolVariable<T>::read(MutexIF::TimeoutType timeoutType
return result; return result;
} }
template <typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() { inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
if (readWriteMode == pool_rwm_t::VAR_WRITE) { if(readWriteMode == pool_rwm_t::VAR_WRITE) {
object_id_t targetObjectId = hkManager->getCreatorObjectId(); object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, true, reportReadCommitError("LocalPoolVector",
targetObjectId, localPoolId); PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
localPoolId);
return PoolVariableIF::INVALID_READ_WRITE_MODE; return PoolVariableIF::INVALID_READ_WRITE_MODE;
} }
PoolEntry<T>* poolEntry = nullptr; PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); &poolEntry);
if (result != RETURN_OK) { if(result != RETURN_OK) {
object_id_t ownerObjectId = hkManager->getCreatorObjectId(); object_id_t ownerObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId); reportReadCommitError("LocalPoolVariable", result,
false, ownerObjectId, localPoolId);
return result; return result;
} }
@ -60,22 +64,22 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
return RETURN_OK; return RETURN_OK;
} }
template <typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::commit(bool setValid, MutexIF::TimeoutType timeoutType, inline ReturnValue_t LocalPoolVariable<T>::commit(bool setValid,
uint32_t timeoutMs) { MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
this->setValid(setValid); this->setValid(setValid);
return commit(timeoutType, timeoutMs); return commit(timeoutType, timeoutMs);
} }
template <typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::commit(MutexIF::TimeoutType timeoutType, inline ReturnValue_t LocalPoolVariable<T>::commit(
uint32_t timeoutMs) { MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
if (hkManager == nullptr) { if(hkManager == nullptr) {
return commitWithoutLock(); return commitWithoutLock();
} }
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager); MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs); ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = commitWithoutLock(); result = commitWithoutLock();
@ -83,21 +87,23 @@ inline ReturnValue_t LocalPoolVariable<T>::commit(MutexIF::TimeoutType timeoutTy
return result; return result;
} }
template <typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() { inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
if (readWriteMode == pool_rwm_t::VAR_READ) { if(readWriteMode == pool_rwm_t::VAR_READ) {
object_id_t targetObjectId = hkManager->getCreatorObjectId(); object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, false, reportReadCommitError("LocalPoolVector",
targetObjectId, localPoolId); PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
localPoolId);
return PoolVariableIF::INVALID_READ_WRITE_MODE; return PoolVariableIF::INVALID_READ_WRITE_MODE;
} }
PoolEntry<T>* poolEntry = nullptr; PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); &poolEntry);
if (result != RETURN_OK) { if(result != RETURN_OK) {
object_id_t ownerObjectId = hkManager->getCreatorObjectId(); object_id_t ownerObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId); reportReadCommitError("LocalPoolVariable", result,
false, ownerObjectId, localPoolId);
return result; return result;
} }
@ -106,88 +112,98 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
return RETURN_OK; return RETURN_OK;
} }
template <typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::serialize( inline ReturnValue_t LocalPoolVariable<T>::serialize(uint8_t** buffer,
uint8_t** buffer, size_t* size, const size_t max_size, size_t* size, const size_t max_size,
SerializeIF::Endianness streamEndianness) const { SerializeIF::Endianness streamEndianness) const {
return SerializeAdapter::serialize(&value, buffer, size, max_size, streamEndianness); return SerializeAdapter::serialize(&value,
buffer, size ,max_size, streamEndianness);
} }
template <typename T> template<typename T>
inline size_t LocalPoolVariable<T>::getSerializedSize() const { inline size_t LocalPoolVariable<T>::getSerializedSize() const {
return SerializeAdapter::getSerializedSize(&value); return SerializeAdapter::getSerializedSize(&value);
} }
template <typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::deSerialize(const uint8_t** buffer, size_t* size, inline ReturnValue_t LocalPoolVariable<T>::deSerialize(const uint8_t** buffer,
SerializeIF::Endianness streamEndianness) { size_t* size, SerializeIF::Endianness streamEndianness) {
return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness); return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
template <typename T> template<typename T>
inline std::ostream& operator<<(std::ostream& out, const LocalPoolVariable<T>& var) { inline std::ostream& operator<< (std::ostream &out,
const LocalPoolVariable<T> &var) {
out << var.value; out << var.value;
return out; return out;
} }
#endif #endif
template <typename T> template<typename T>
inline LocalPoolVariable<T>::operator T() const { inline LocalPoolVariable<T>::operator T() const {
return value; return value;
} }
template <typename T> template<typename T>
inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator=(const T& newValue) { inline LocalPoolVariable<T> & LocalPoolVariable<T>::operator=(
const T& newValue) {
value = newValue; value = newValue;
return *this; return *this;
} }
template <typename T> template<typename T>
inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator=( inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator =(
const LocalPoolVariable<T>& newPoolVariable) { const LocalPoolVariable<T>& newPoolVariable) {
value = newPoolVariable.value; value = newPoolVariable.value;
return *this; return *this;
} }
template <typename T> template<typename T>
inline bool LocalPoolVariable<T>::operator==(const LocalPoolVariable<T>& other) const { inline bool LocalPoolVariable<T>::operator ==(
const LocalPoolVariable<T> &other) const {
return this->value == other.value; return this->value == other.value;
} }
template <typename T> template<typename T>
inline bool LocalPoolVariable<T>::operator==(const T& other) const { inline bool LocalPoolVariable<T>::operator ==(const T &other) const {
return this->value == other; return this->value == other;
} }
template <typename T>
inline bool LocalPoolVariable<T>::operator!=(const LocalPoolVariable<T>& other) const { template<typename T>
return not(*this == other); inline bool LocalPoolVariable<T>::operator !=(
const LocalPoolVariable<T> &other) const {
return not (*this == other);
} }
template <typename T> template<typename T>
inline bool LocalPoolVariable<T>::operator!=(const T& other) const { inline bool LocalPoolVariable<T>::operator !=(const T &other) const {
return not(*this == other); return not (*this == other);
} }
template <typename T>
inline bool LocalPoolVariable<T>::operator<(const LocalPoolVariable<T>& other) const { template<typename T>
inline bool LocalPoolVariable<T>::operator <(
const LocalPoolVariable<T> &other) const {
return this->value < other.value; return this->value < other.value;
} }
template <typename T> template<typename T>
inline bool LocalPoolVariable<T>::operator<(const T& other) const { inline bool LocalPoolVariable<T>::operator <(const T &other) const {
return this->value < other; return this->value < other;
} }
template <typename T>
inline bool LocalPoolVariable<T>::operator>(const LocalPoolVariable<T>& other) const { template<typename T>
return not(*this < other); inline bool LocalPoolVariable<T>::operator >(
const LocalPoolVariable<T> &other) const {
return not (*this < other);
} }
template <typename T> template<typename T>
inline bool LocalPoolVariable<T>::operator>(const T& other) const { inline bool LocalPoolVariable<T>::operator >(const T &other) const {
return not(*this < other); return not (*this < other);
} }
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ */ #endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ */

View File

@ -5,47 +5,48 @@
#error Include LocalPoolVector.h before LocalPoolVector.tpp! #error Include LocalPoolVector.h before LocalPoolVector.tpp!
#endif #endif
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(HasLocalDataPoolIF* hkOwner, lp_id_t poolId, inline LocalPoolVector<T, vectorSize>::LocalPoolVector(
DataSetIF* dataSet, HasLocalDataPoolIF* hkOwner, lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode) pool_rwm_t setReadWriteMode):
: LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {} LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner, lp_id_t poolId, inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner,
DataSetIF* dataSet, lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
pool_rwm_t setReadWriteMode) LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
: LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId, DataSetIF* dataSet, inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId,
pool_rwm_t setReadWriteMode) DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
: LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet, LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId,
setReadWriteMode) {} dataSet, setReadWriteMode) {}
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(MutexIF::TimeoutType timeoutType, inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
uint32_t timeoutMs) { MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs); MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
return readWithoutLock(); return readWithoutLock();
} }
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() { inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
if (readWriteMode == pool_rwm_t::VAR_WRITE) { if(readWriteMode == pool_rwm_t::VAR_WRITE) {
object_id_t targetObjectId = hkManager->getCreatorObjectId(); object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, true, reportReadCommitError("LocalPoolVector",
targetObjectId, localPoolId); PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
localPoolId);
return PoolVariableIF::INVALID_READ_WRITE_MODE; return PoolVariableIF::INVALID_READ_WRITE_MODE;
} }
PoolEntry<T>* poolEntry = nullptr; PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); &poolEntry);
memset(this->value, 0, vectorSize * sizeof(T)); memset(this->value, 0, vectorSize * sizeof(T));
if (result != RETURN_OK) { if(result != RETURN_OK) {
object_id_t targetObjectId = hkManager->getCreatorObjectId(); object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", result, true, targetObjectId, localPoolId); reportReadCommitError("LocalPoolVector", result, true, targetObjectId,
localPoolId);
return result; return result;
} }
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize()); std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
@ -53,35 +54,36 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
return RETURN_OK; return RETURN_OK;
} }
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid, inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
MutexIF::TimeoutType timeoutType, MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
uint32_t timeoutMs) {
this->setValid(valid); this->setValid(valid);
return commit(timeoutType, timeoutMs); return commit(timeoutType, timeoutMs);
} }
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(MutexIF::TimeoutType timeoutType, inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
uint32_t timeoutMs) { MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs); MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
return commitWithoutLock(); return commitWithoutLock();
} }
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() { inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
if (readWriteMode == pool_rwm_t::VAR_READ) { if(readWriteMode == pool_rwm_t::VAR_READ) {
object_id_t targetObjectId = hkManager->getCreatorObjectId(); object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, false, reportReadCommitError("LocalPoolVector",
targetObjectId, localPoolId); PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
localPoolId);
return PoolVariableIF::INVALID_READ_WRITE_MODE; return PoolVariableIF::INVALID_READ_WRITE_MODE;
} }
PoolEntry<T>* poolEntry = nullptr; PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); &poolEntry);
if (result != RETURN_OK) { if(result != RETURN_OK) {
object_id_t targetObjectId = hkManager->getCreatorObjectId(); object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", result, false, targetObjectId, localPoolId); reportReadCommitError("LocalPoolVector", result, false, targetObjectId,
localPoolId);
return result; return result;
} }
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize()); std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
@ -89,51 +91,48 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
return RETURN_OK; return RETURN_OK;
} }
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline T& LocalPoolVector<T, vectorSize>::operator[](size_t i) { inline T& LocalPoolVector<T, vectorSize>::operator [](size_t i) {
if (i < vectorSize) { if(i < vectorSize) {
return value[i]; return value[i];
} }
// If this happens, I have to set some value. I consider this // If this happens, I have to set some value. I consider this
// a configuration error, but I wont exit here. // a configuration error, but I wont exit here.
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVector: Invalid index. Setting or returning" sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
" last value!" " last value!" << std::endl;
<< std::endl;
#else #else
sif::printWarning( sif::printWarning("LocalPoolVector: Invalid index. Setting or returning"
"LocalPoolVector: Invalid index. Setting or returning"
" last value!\n"); " last value!\n");
#endif #endif
return value[vectorSize - 1]; return value[vectorSize - 1];
} }
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline const T& LocalPoolVector<T, vectorSize>::operator[](size_t i) const { inline const T& LocalPoolVector<T, vectorSize>::operator [](size_t i) const {
if (i < vectorSize) { if(i < vectorSize) {
return value[i]; return value[i];
} }
// If this happens, I have to set some value. I consider this // If this happens, I have to set some value. I consider this
// a configuration error, but I wont exit here. // a configuration error, but I wont exit here.
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVector: Invalid index. Setting or returning" sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
" last value!" " last value!" << std::endl;
<< std::endl;
#else #else
sif::printWarning( sif::printWarning("LocalPoolVector: Invalid index. Setting or returning"
"LocalPoolVector: Invalid index. Setting or returning"
" last value!\n"); " last value!\n");
#endif #endif
return value[vectorSize - 1]; return value[vectorSize - 1];
} }
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize( inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(uint8_t** buffer,
uint8_t** buffer, size_t* size, size_t maxSize, size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const { SerializeIF::Endianness streamEndianness) const {
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
for (uint16_t i = 0; i < vectorSize; i++) { for (uint16_t i = 0; i < vectorSize; i++) {
result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness); result = SerializeAdapter::serialize(&(value[i]), buffer, size,
maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
break; break;
} }
@ -141,17 +140,19 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(
return result; return result;
} }
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const { inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const {
return vectorSize * SerializeAdapter::getSerializedSize(value); return vectorSize * SerializeAdapter::getSerializedSize(value);
} }
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize( inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) { const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
for (uint16_t i = 0; i < vectorSize; i++) { for (uint16_t i = 0; i < vectorSize; i++) {
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, streamEndianness); result = SerializeAdapter::deSerialize(&(value[i]), buffer, size,
streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
break; break;
} }
@ -160,12 +161,13 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
template <typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline std::ostream& operator<<(std::ostream& out, const LocalPoolVector<T, vectorSize>& var) { inline std::ostream& operator<< (std::ostream &out,
const LocalPoolVector<T, vectorSize> &var) {
out << "Vector: ["; out << "Vector: [";
for (int i = 0; i < vectorSize; i++) { for(int i = 0;i < vectorSize; i++) {
out << var.value[i]; out << var.value[i];
if (i < vectorSize - 1) { if(i < vectorSize - 1) {
out << ", "; out << ", ";
} }
} }

View File

@ -1,2 +1,5 @@
target_sources(${LIB_FSFW_NAME} PRIVATE HasLocalDpIFUserAttorney.cpp target_sources(${LIB_FSFW_NAME}
HasLocalDpIFManagerAttorney.cpp) PRIVATE
HasLocalDpIFUserAttorney.cpp
HasLocalDpIFManagerAttorney.cpp
)

View File

@ -1,10 +1,11 @@
target_sources( target_sources(${LIB_FSFW_NAME}
${LIB_FSFW_NAME} PRIVATE
PRIVATE AssemblyBase.cpp AssemblyBase.cpp
ChildHandlerBase.cpp ChildHandlerBase.cpp
ChildHandlerFDIR.cpp ChildHandlerFDIR.cpp
DeviceHandlerBase.cpp DeviceHandlerBase.cpp
DeviceHandlerFailureIsolation.cpp DeviceHandlerFailureIsolation.cpp
DeviceHandlerMessage.cpp DeviceHandlerMessage.cpp
DeviceTmReportingWrapper.cpp DeviceTmReportingWrapper.cpp
HealthDevice.cpp) HealthDevice.cpp
)

View File

@ -572,9 +572,6 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
mode = newMode; mode = newMode;
modeChanged(); modeChanged();
setNormalDatapoolEntriesInvalid(); setNormalDatapoolEntriesInvalid();
if (newMode == MODE_OFF) {
disableCommandsAndReplies();
}
if (!isTransitionalMode()) { if (!isTransitionalMode()) {
modeHelper.modeChanged(newMode, newSubmode); modeHelper.modeChanged(newMode, newSubmode);
announceMode(false); announceMode(false);
@ -1570,21 +1567,3 @@ void DeviceHandlerBase::setParent(object_id_t parent) { this->parent = parent; }
void DeviceHandlerBase::setPowerSwitcher(PowerSwitchIF* switcher) { void DeviceHandlerBase::setPowerSwitcher(PowerSwitchIF* switcher) {
this->powerSwitcher = switcher; this->powerSwitcher = switcher;
} }
void DeviceHandlerBase::disableCommandsAndReplies() {
for (auto& command : deviceCommandMap) {
if (command.second.isExecuting) {
command.second.isExecuting = false;
}
}
for (auto& reply : deviceReplyMap) {
if (!reply.second.periodic) {
if (reply.second.countdown != nullptr) {
reply.second.countdown->timeOut();
} else {
reply.second.delayCycles = 0;
}
reply.second.active = false;
}
}
}

View File

@ -7,7 +7,6 @@
#include "DeviceHandlerFailureIsolation.h" #include "DeviceHandlerFailureIsolation.h"
#include "DeviceHandlerIF.h" #include "DeviceHandlerIF.h"
#include "DeviceHandlerThermalSet.h" #include "DeviceHandlerThermalSet.h"
#include "DhbCfgHelpers.h"
#include "fsfw/action/ActionHelper.h" #include "fsfw/action/ActionHelper.h"
#include "fsfw/action/HasActionsIF.h" #include "fsfw/action/HasActionsIF.h"
#include "fsfw/datapool/PoolVariableIF.h" #include "fsfw/datapool/PoolVariableIF.h"
@ -489,9 +488,9 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* @return - @c RETURN_OK when the command was successfully inserted, * @return - @c RETURN_OK when the command was successfully inserted,
* - @c RETURN_FAILED else. * - @c RETURN_FAILED else.
*/ */
ReturnValue_t insertInCommandMap( ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand,
DeviceCommandId_t deviceCommand, bool useAlternativeReply = false, bool useAlternativeReply = false,
DeviceCommandId_t alternativeReplyId = DeviceHandlerIF::NO_COMMAND_ID); DeviceCommandId_t alternativeReplyId = 0);
/** /**
* Enables a periodic reply for a given command. It sets to delay cycles to the specified * Enables a periodic reply for a given command. It sets to delay cycles to the specified
@ -784,18 +783,11 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* This is used to keep track of pending replies. * This is used to keep track of pending replies.
*/ */
struct DeviceReplyInfo { struct DeviceReplyInfo {
//! For Command-Reply combinations:
//! The maximum number of cycles the handler should wait for a reply //! The maximum number of cycles the handler should wait for a reply
//! to this command. //! to this command.
//!
//! Reply Only:
//! For periodic replies, this variable will be the number of delay cycles between the replies.
//! For the non-periodic variant, this variable is not used as there is no meaningful
//! definition for delay
uint16_t maxDelayCycles; uint16_t maxDelayCycles;
//! This variable will be set to #maxDelayCycles if a reply is expected. //! The currently remaining cycles the handler should wait for a reply,
//! For non-periodic replies without a command, this variable is unused. //! 0 means there is no reply expected
//! A runtime value of 0 means there is no reply is currently expected.
uint16_t delayCycles; uint16_t delayCycles;
size_t replyLen = 0; //!< Expected size of the reply. size_t replyLen = 0; //!< Expected size of the reply.
//! if this is !=0, the delayCycles will not be reset to 0 but to //! if this is !=0, the delayCycles will not be reset to 0 but to
@ -1326,11 +1318,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
void printWarningOrError(sif::OutputTypes errorType, const char *functionName, void printWarningOrError(sif::OutputTypes errorType, const char *functionName,
ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED, ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED,
const char *errorPrint = nullptr); const char *errorPrint = nullptr);
/**
* @brief Disables all commands and replies when device is set to MODE_OFF
*/
void disableCommandsAndReplies();
}; };
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */ #endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */

View File

@ -1,72 +0,0 @@
#ifndef FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_
#define FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_
/**
* @brief This is the base class for configuration related to both DHB commands, replies and their
* combination
*/
struct CfgBase {
public:
explicit CfgBase(DeviceCommandId_t cmdAndOrReplyId) : cmdAndOrReplyId(cmdAndOrReplyId){};
DeviceCommandId_t cmdAndOrReplyId;
};
/**
* @brief Configuration class for commands
*/
struct CmdCfg {
public:
explicit CmdCfg(DeviceCommandId_t cmdId) : baseCfg(cmdId){};
CfgBase baseCfg;
//! This can be used if a command can trigger multiple replies
std::pair<bool, DeviceCommandId_t> alternativeReply = {false, DeviceHandlerIF::NO_COMMAND_ID};
};
/**
* @brief Configuration class for replies
*/
struct ReplyCfg {
public:
ReplyCfg(DeviceCommandId_t replyId, uint16_t maxDelayCycles)
: baseCfg(replyId), maxDelayCycles(maxDelayCycles){};
ReplyCfg(DeviceCommandId_t replyId, uint16_t maxDelayCycles, LocalPoolDataSetBase* set)
: ReplyCfg(replyId, maxDelayCycles) {
dataSet = set;
};
CfgBase baseCfg;
//! A data set can be mapped to a reply ID. This allows to omit the #getDataSetHandle
//! override in a user device handler as this pointer will be passed as long as the device
//! command ID is equal to the set ID.
LocalPoolDataSetBase* dataSet = nullptr;
//! For Command-Reply combinations:
//! The maximum number of cycles the handler should wait for a reply
//! to this command.
//!
//! Reply Only:
//! For periodic replies, this variable will be the number of delay cycles between the replies.
//! For the non-periodic variant, this variable is not used as there is no meaningful
//! definition for delay
uint16_t maxDelayCycles = 0;
//! First parameter: Specify whether reply is arriving periodically
//! Second parameter: Specify whether periodic reply should be enabled immediately
std::pair<bool, bool> periodicCfg = {false, false};
//! If a reply needs to be requested with a specific length, the length can be specified here
size_t replyLen = 0;
//! It is also possible to use a time based instead of a cycle based mechanism to specify
//! how long a reply takes. For non-periodic replies without a command, this variable is not used.
Countdown* countdown = nullptr;
};
/**
* @brief Configuration class for commands and replies
*/
struct CmdReplyCfg {
public:
CmdReplyCfg(CmdCfg cmdCfg, ReplyCfg replyCfg) : cmdCfg(cmdCfg), replyCfg(replyCfg) {}
CmdCfg cmdCfg;
ReplyCfg replyCfg;
};
#endif /* FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_ */

View File

@ -1,3 +1,6 @@
target_sources(${LIB_FSFW_NAME} PRIVATE EventManager.cpp EventMessage.cpp) target_sources(${LIB_FSFW_NAME} PRIVATE
EventManager.cpp
EventMessage.cpp
)
add_subdirectory(eventmatching) add_subdirectory(eventmatching)

View File

@ -1,3 +1,7 @@
target_sources( target_sources(${LIB_FSFW_NAME}
${LIB_FSFW_NAME} PRIVATE EventIdRangeMatcher.cpp EventMatchTree.cpp PRIVATE
ReporterRangeMatcher.cpp SeverityRangeMatcher.cpp) EventIdRangeMatcher.cpp
EventMatchTree.cpp
ReporterRangeMatcher.cpp
SeverityRangeMatcher.cpp
)

View File

@ -27,7 +27,6 @@ enum : uint8_t {
PUS_SERVICE_6 = 86, PUS_SERVICE_6 = 86,
PUS_SERVICE_8 = 88, PUS_SERVICE_8 = 88,
PUS_SERVICE_9 = 89, PUS_SERVICE_9 = 89,
PUS_SERVICE_11 = 91,
PUS_SERVICE_17 = 97, PUS_SERVICE_17 = 97,
PUS_SERVICE_23 = 103, PUS_SERVICE_23 = 103,
MGM_LIS3MDL = 106, MGM_LIS3MDL = 106,

View File

@ -1,3 +1,6 @@
target_sources( target_sources(${LIB_FSFW_NAME}
${LIB_FSFW_NAME} PRIVATE EventCorrelation.cpp FailureIsolationBase.cpp PRIVATE
FaultCounter.cpp) EventCorrelation.cpp
FailureIsolationBase.cpp
FaultCounter.cpp
)

View File

@ -1,6 +1,5 @@
target_sources( target_sources(${LIB_FSFW_NAME} PRIVATE
${LIB_FSFW_NAME} arrayprinter.cpp
PRIVATE arrayprinter.cpp
AsciiConverter.cpp AsciiConverter.cpp
CRC.cpp CRC.cpp
DleEncoder.cpp DleEncoder.cpp
@ -8,6 +7,7 @@ target_sources(
PeriodicOperationDivider.cpp PeriodicOperationDivider.cpp
timevalOperations.cpp timevalOperations.cpp
Type.cpp Type.cpp
bitutility.cpp) bitutility.cpp
)
add_subdirectory(math) add_subdirectory(math)

View File

@ -1,5 +1,6 @@
#include "DleParser.h" #include "DleParser.h"
#include <fsfw/globalfunctions/DleEncoder.h>
#include <fsfw/serviceinterface/ServiceInterface.h> #include <fsfw/serviceinterface/ServiceInterface.h>
#include <cstdio> #include <cstdio>

View File

@ -1,4 +1,5 @@
#pragma once #ifndef MISSION_DEVICES_DLEPARSER_H_
#define MISSION_DEVICES_DLEPARSER_H_
#include <fsfw/container/SimpleRingBuffer.h> #include <fsfw/container/SimpleRingBuffer.h>
#include <fsfw/globalfunctions/DleEncoder.h> #include <fsfw/globalfunctions/DleEncoder.h>
@ -122,3 +123,5 @@ class DleParser : public HasReturnvaluesIF {
Context ctx; Context ctx;
bool startFound = false; bool startFound = false;
}; };
#endif /* MISSION_DEVICES_DLEPARSER_H_ */

View File

@ -1 +1,4 @@
target_sources(${LIB_FSFW_NAME} PRIVATE QuaternionOperations.cpp) target_sources(${LIB_FSFW_NAME}
PRIVATE
QuaternionOperations.cpp
)

View File

@ -1,2 +1,6 @@
target_sources(${LIB_FSFW_NAME} PRIVATE HealthHelper.cpp HealthMessage.cpp target_sources(${LIB_FSFW_NAME}
HealthTable.cpp) PRIVATE
HealthHelper.cpp
HealthMessage.cpp
HealthTable.cpp
)

View File

@ -16,15 +16,10 @@ class HasHealthIF {
}; };
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_HEALTH_IF; static const uint8_t INTERFACE_ID = CLASS_ID::HAS_HEALTH_IF;
static constexpr ReturnValue_t OBJECT_NOT_HEALTHY = static const ReturnValue_t OBJECT_NOT_HEALTHY = MAKE_RETURN_CODE(1);
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); static const ReturnValue_t INVALID_HEALTH_STATE = MAKE_RETURN_CODE(2);
static constexpr ReturnValue_t INVALID_HEALTH_STATE =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2);
static constexpr ReturnValue_t IS_EXTERNALLY_CONTROLLED =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3);
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_MANAGER_1; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_MANAGER_1;
//! P1: New Health, P2: Old Health
static const Event HEALTH_INFO = MAKE_EVENT(6, severity::INFO); static const Event HEALTH_INFO = MAKE_EVENT(6, severity::INFO);
static const Event CHILD_CHANGED_HEALTH = MAKE_EVENT(7, severity::INFO); static const Event CHILD_CHANGED_HEALTH = MAKE_EVENT(7, severity::INFO);
static const Event CHILD_PROBLEMS = MAKE_EVENT(8, severity::LOW); static const Event CHILD_PROBLEMS = MAKE_EVENT(8, severity::LOW);

View File

@ -1,2 +1,5 @@
target_sources(${LIB_FSFW_NAME} PRIVATE HousekeepingMessage.cpp target_sources(${LIB_FSFW_NAME}
PeriodicHousekeepingHelper.cpp) PRIVATE
HousekeepingMessage.cpp
PeriodicHousekeepingHelper.cpp
)

View File

@ -1 +1,4 @@
target_sources(${LIB_FSFW_NAME} PRIVATE InternalErrorReporter.cpp) target_sources(${LIB_FSFW_NAME}
PRIVATE
InternalErrorReporter.cpp
)

View File

@ -1,3 +1,6 @@
target_sources( target_sources(${LIB_FSFW_NAME} PRIVATE
${LIB_FSFW_NAME} PRIVATE CommandMessage.cpp CommandMessageCleaner.cpp CommandMessage.cpp
MessageQueueMessage.cpp MessageQueueBase.cpp) CommandMessageCleaner.cpp
MessageQueueMessage.cpp
MessageQueueBase.cpp
)

View File

@ -34,7 +34,7 @@ class CommandMessageIF {
static const Command_t CMD_NONE = MAKE_COMMAND_ID(0); static const Command_t CMD_NONE = MAKE_COMMAND_ID(0);
static const Command_t REPLY_COMMAND_OK = MAKE_COMMAND_ID(1); static const Command_t REPLY_COMMAND_OK = MAKE_COMMAND_ID(1);
//! Reply indicating that the current command was rejected, //! Reply indicating that the current command was rejected,
//! Parameter 1 should contain the error code //! par1 should contain the error code
static const Command_t REPLY_REJECTED = MAKE_COMMAND_ID(2); static const Command_t REPLY_REJECTED = MAKE_COMMAND_ID(2);
virtual ~CommandMessageIF(){}; virtual ~CommandMessageIF(){};

View File

@ -1,2 +1,5 @@
target_sources(${LIB_FSFW_NAME} PRIVATE MemoryHelper.cpp MemoryMessage.cpp target_sources(${LIB_FSFW_NAME} PRIVATE
GenericFileSystemMessage.cpp) MemoryHelper.cpp
MemoryMessage.cpp
GenericFileSystemMessage.cpp
)

View File

@ -1 +1,5 @@
target_sources(${LIB_FSFW_NAME} PRIVATE ModeHelper.cpp ModeMessage.cpp) target_sources(${LIB_FSFW_NAME}
PRIVATE
ModeHelper.cpp
ModeMessage.cpp
)

View File

@ -1,2 +1,5 @@
target_sources(${LIB_FSFW_NAME} PRIVATE LimitViolationReporter.cpp target_sources(${LIB_FSFW_NAME}
MonitoringMessage.cpp) PRIVATE
LimitViolationReporter.cpp
MonitoringMessage.cpp
)

View File

@ -1 +1,5 @@
target_sources(${LIB_FSFW_NAME} PRIVATE ObjectManager.cpp SystemObject.cpp) target_sources(${LIB_FSFW_NAME}
PRIVATE
ObjectManager.cpp
SystemObject.cpp
)

View File

@ -14,7 +14,6 @@ enum framework_objects : object_id_t {
PUS_SERVICE_5_EVENT_REPORTING = 0x53000005, PUS_SERVICE_5_EVENT_REPORTING = 0x53000005,
PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008, PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008,
PUS_SERVICE_9_TIME_MGMT = 0x53000009, PUS_SERVICE_9_TIME_MGMT = 0x53000009,
PUS_SERVICE_11_TC_SCHEDULER = 0x53000011,
PUS_SERVICE_17_TEST = 0x53000017, PUS_SERVICE_17_TEST = 0x53000017,
PUS_SERVICE_20_PARAMETERS = 0x53000020, PUS_SERVICE_20_PARAMETERS = 0x53000020,
PUS_SERVICE_200_MODE_MGMT = 0x53000200, PUS_SERVICE_200_MODE_MGMT = 0x53000200,

View File

@ -7,25 +7,25 @@ elseif(FSFW_OSAL MATCHES "linux")
add_subdirectory(linux) add_subdirectory(linux)
elseif(FSFW_OSAL MATCHES "host") elseif(FSFW_OSAL MATCHES "host")
add_subdirectory(host) add_subdirectory(host)
if(WIN32) if (WIN32)
add_subdirectory(windows) add_subdirectory(windows)
elseif(UNIX) elseif(UNIX)
# We still need to pull in some Linux specific sources # We still need to pull in some Linux specific sources
target_sources(${LIB_FSFW_NAME} PUBLIC linux/tcpipHelpers.cpp) target_sources(${LIB_FSFW_NAME} PUBLIC
endif() linux/tcpipHelpers.cpp
)
endif ()
else() else()
message( message(WARNING "The OS_FSFW variable was not set. Assuming host OS..")
WARNING
"${MSG_PREFIX} The FSFW_OSAL variable was not set. Assuming host OS..")
# Not set. Assumuing this is a host build, try to determine host OS # Not set. Assumuing this is a host build, try to determine host OS
if(WIN32) if (WIN32)
add_subdirectory(host) add_subdirectory(host)
add_subdirectory(windows) add_subdirectory(windows)
elseif(UNIX) elseif (UNIX)
add_subdirectory(linux) add_subdirectory(linux)
else() else ()
# MacOS or other OSes have not been tested yet / are not supported. # MacOS or other OSes have not been tested yet / are not supported.
message(FATAL_ERROR "The host OS could not be determined! Aborting.") message(FATAL_ERROR "The host OS could not be determined! Aborting.")
endif() endif()

View File

@ -1,10 +1,17 @@
if(DEFINED WIN32 OR DEFINED UNIX) if(DEFINED WIN32 OR DEFINED UNIX)
target_sources( target_sources(${LIB_FSFW_NAME} PRIVATE
${LIB_FSFW_NAME} tcpipCommon.cpp
PRIVATE tcpipCommon.cpp TcpIpBase.cpp UdpTcPollingTask.cpp TcpIpBase.cpp
UdpTmTcBridge.cpp TcpTmTcServer.cpp TcpTmTcBridge.cpp) UdpTcPollingTask.cpp
UdpTmTcBridge.cpp
TcpTmTcServer.cpp
TcpTmTcBridge.cpp
)
endif() endif()
if(WIN32) if(WIN32)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE wsock32 ws2_32) target_link_libraries(${LIB_FSFW_NAME} PRIVATE
wsock32
ws2_32
)
endif() endif()

View File

@ -109,8 +109,8 @@ TcpTmTcServer::~TcpTmTcServer() { closeSocket(listenerTcpSocket); }
using namespace tcpip; using namespace tcpip;
// If a connection is accepted, the corresponding socket will be assigned to the new socket // If a connection is accepted, the corresponding socket will be assigned to the new socket
socket_t connSocket = 0; socket_t connSocket = 0;
sockaddr clientSockAddr = {}; // sockaddr clientSockAddr = {};
socklen_t connectorSockAddrLen = 0; // socklen_t connectorSockAddrLen = 0;
int retval = 0; int retval = 0;
// Listen for connection requests permanently for lifetime of program // Listen for connection requests permanently for lifetime of program
@ -121,7 +121,8 @@ TcpTmTcServer::~TcpTmTcServer() { closeSocket(listenerTcpSocket); }
continue; continue;
} }
connSocket = accept(listenerTcpSocket, &clientSockAddr, &connectorSockAddrLen); // connSocket = accept(listenerTcpSocket, &clientSockAddr, &connectorSockAddrLen);
connSocket = accept(listenerTcpSocket, nullptr, nullptr);
if (connSocket == INVALID_SOCKET) { if (connSocket == INVALID_SOCKET) {
handleError(Protocol::TCP, ErrorSources::ACCEPT_CALL, 500); handleError(Protocol::TCP, ErrorSources::ACCEPT_CALL, 500);
@ -136,7 +137,6 @@ TcpTmTcServer::~TcpTmTcServer() { closeSocket(listenerTcpSocket); }
if (retval != 0) { if (retval != 0) {
handleError(Protocol::TCP, ErrorSources::SHUTDOWN_CALL); handleError(Protocol::TCP, ErrorSources::SHUTDOWN_CALL);
} }
closeSocket(connSocket); closeSocket(connSocket);
connSocket = 0; connSocket = 0;
} }

View File

@ -1,6 +1,6 @@
target_sources( target_sources(${LIB_FSFW_NAME}
${LIB_FSFW_NAME} PRIVATE
PRIVATE Clock.cpp Clock.cpp
FixedTimeslotTask.cpp FixedTimeslotTask.cpp
BinarySemaphore.cpp BinarySemaphore.cpp
BinSemaphUsingTask.cpp BinSemaphUsingTask.cpp
@ -15,16 +15,18 @@ target_sources(
TaskFactory.cpp TaskFactory.cpp
Timekeeper.cpp Timekeeper.cpp
TaskManagement.cpp TaskManagement.cpp
QueueMapManager.cpp) QueueMapManager.cpp
)
# FreeRTOS is required to link the FSFW now. It is recommended to compile # FreeRTOS is required to link the FSFW now. It is recommended to compile
# FreeRTOS as a static library and set LIB_OS_NAME to the target name of the # FreeRTOS as a static library and set LIB_OS_NAME to the target name of the
# library. # library.
if(NOT LIB_OS_NAME) if(NOT LIB_OS_NAME)
message( message(STATUS
STATUS
"LIB_OS_NAME is empty. Make sure to include the FreeRTOS header path properly." "LIB_OS_NAME is empty. Make sure to include the FreeRTOS header path properly."
) )
else() else()
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${LIB_OS_NAME}) target_link_libraries(${LIB_FSFW_NAME} PRIVATE
${LIB_OS_NAME}
)
endif() endif()

View File

@ -1,23 +1,27 @@
#include "fsfw/osal/freertos/FixedTimeslotTask.h" #include "fsfw/osal/freertos/FixedTimeslotTask.h"
#include "fsfw/serviceinterface.h" #include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
uint32_t FixedTimeslotTask::deadlineMissedCount = 0;
const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = configMINIMAL_STACK_SIZE; const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = configMINIMAL_STACK_SIZE;
FixedTimeslotTask::FixedTimeslotTask(TaskName name, TaskPriority setPriority, FixedTimeslotTask::FixedTimeslotTask(TaskName name, TaskPriority setPriority,
TaskStackSize setStack, TaskPeriod period, TaskStackSize setStack, TaskPeriod overallPeriod,
TaskDeadlineMissedFunction dlmFunc_) void (*setDeadlineMissedFunc)())
: FixedTimeslotTaskBase(period, dlmFunc_), started(false), handle(nullptr) { : started(false), handle(nullptr), pst(overallPeriod * 1000) {
configSTACK_DEPTH_TYPE stackSize = setStack / sizeof(configSTACK_DEPTH_TYPE); configSTACK_DEPTH_TYPE stackSize = setStack / sizeof(configSTACK_DEPTH_TYPE);
xTaskCreate(taskEntryPoint, name, stackSize, this, setPriority, &handle); xTaskCreate(taskEntryPoint, name, stackSize, this, setPriority, &handle);
// All additional attributes are applied to the object.
this->deadlineMissedFunc = setDeadlineMissedFunc;
} }
FixedTimeslotTask::~FixedTimeslotTask() = default; FixedTimeslotTask::~FixedTimeslotTask() {}
void FixedTimeslotTask::taskEntryPoint(void* argument) { void FixedTimeslotTask::taskEntryPoint(void* argument) {
// The argument is re-interpreted as FixedTimeslotTask. The Task object is // The argument is re-interpreted as FixedTimeslotTask. The Task object is
// global, so it is found from any place. // global, so it is found from any place.
auto* originalTask(reinterpret_cast<FixedTimeslotTask*>(argument)); FixedTimeslotTask* originalTask(reinterpret_cast<FixedTimeslotTask*>(argument));
/* Task should not start until explicitly requested, /* Task should not start until explicitly requested,
* but in FreeRTOS, tasks start as soon as they are created if the scheduler * but in FreeRTOS, tasks start as soon as they are created if the scheduler
* is running but not if the scheduler is not running. * is running but not if the scheduler is not running.
@ -28,18 +32,26 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) {
* can continue */ * can continue */
if (not originalTask->started) { if (not originalTask->started) {
vTaskSuspend(nullptr); vTaskSuspend(NULL);
} }
originalTask->taskFunctionality(); originalTask->taskFunctionality();
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Polling task " << originalTask->handle << " returned from taskFunctionality." sif::debug << "Polling task " << originalTask->handle << " returned from taskFunctionality."
<< std::endl; << std::endl;
#else
sif::printDebug("Polling task returned from taskFunctionality\n");
#endif #endif
} }
void FixedTimeslotTask::missedDeadlineCounter() {
FixedTimeslotTask::deadlineMissedCount++;
if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PST missed " << FixedTimeslotTask::deadlineMissedCount << " deadlines"
<< std::endl;
#endif
}
}
ReturnValue_t FixedTimeslotTask::startTask() { ReturnValue_t FixedTimeslotTask::startTask() {
started = true; started = true;
@ -51,12 +63,31 @@ ReturnValue_t FixedTimeslotTask::startTask() {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
[[noreturn]] void FixedTimeslotTask::taskFunctionality() { ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs,
int8_t executionStep) {
ExecutableObjectIF* handler = ObjectManager::instance()->get<ExecutableObjectIF>(componentId);
if (handler != nullptr) {
pst.addSlot(componentId, slotTimeMs, executionStep, handler, this);
return HasReturnvaluesIF::RETURN_OK;
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst"
<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
uint32_t FixedTimeslotTask::getPeriodMs() const { return pst.getLengthMs(); }
ReturnValue_t FixedTimeslotTask::checkSequence() const { return pst.checkSequence(); }
void FixedTimeslotTask::taskFunctionality() {
// A local iterator for the Polling Sequence Table is created to find the // A local iterator for the Polling Sequence Table is created to find the
// start time for the first entry. // start time for the first entry.
auto slotListIter = pollingSeqTable.current; auto slotListIter = pst.current;
pollingSeqTable.intializeSequenceAfterTaskCreation(); pst.intializeSequenceAfterTaskCreation();
// The start time for the first entry is read. // The start time for the first entry is read.
uint32_t intervalMs = slotListIter->pollingTimeMs; uint32_t intervalMs = slotListIter->pollingTimeMs;
@ -77,10 +108,10 @@ ReturnValue_t FixedTimeslotTask::startTask() {
/* Enter the loop that defines the task behavior. */ /* Enter the loop that defines the task behavior. */
for (;;) { for (;;) {
// The component for this slot is executed and the next one is chosen. // The component for this slot is executed and the next one is chosen.
this->pollingSeqTable.executeAndAdvance(); this->pst.executeAndAdvance();
if (not pollingSeqTable.slotFollowsImmediately()) { if (not pst.slotFollowsImmediately()) {
// Get the interval till execution of the next slot. // Get the interval till execution of the next slot.
intervalMs = this->pollingSeqTable.getIntervalToPreviousSlotMs(); intervalMs = this->pst.getIntervalToPreviousSlotMs();
interval = pdMS_TO_TICKS(intervalMs); interval = pdMS_TO_TICKS(intervalMs);
#if (tskKERNEL_VERSION_MAJOR == 10 && tskKERNEL_VERSION_MINOR >= 4) || tskKERNEL_VERSION_MAJOR > 10 #if (tskKERNEL_VERSION_MAJOR == 10 && tskKERNEL_VERSION_MINOR >= 4) || tskKERNEL_VERSION_MAJOR > 10
@ -101,8 +132,8 @@ ReturnValue_t FixedTimeslotTask::startTask() {
} }
void FixedTimeslotTask::handleMissedDeadline() { void FixedTimeslotTask::handleMissedDeadline() {
if (dlmFunc != nullptr) { if (deadlineMissedFunc != nullptr) {
dlmFunc(); this->deadlineMissedFunc();
} }
} }

View File

@ -4,11 +4,11 @@
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "FreeRTOSTaskIF.h" #include "FreeRTOSTaskIF.h"
#include "fsfw/tasks/FixedSlotSequence.h" #include "fsfw/tasks/FixedSlotSequence.h"
#include "fsfw/tasks/FixedTimeslotTaskBase.h" #include "fsfw/tasks/FixedTimeslotTaskIF.h"
#include "fsfw/tasks/definitions.h" #include "fsfw/tasks/Typedef.h"
#include "task.h" #include "task.h"
class FixedTimeslotTask : public FixedTimeslotTaskBase, public FreeRTOSTaskIF { class FixedTimeslotTask : public FixedTimeslotTaskIF, public FreeRTOSTaskIF {
public: public:
/** /**
* Keep in mind that you need to call before vTaskStartScheduler()! * Keep in mind that you need to call before vTaskStartScheduler()!
@ -23,7 +23,7 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase, public FreeRTOSTaskIF {
* @return Pointer to the newly created task. * @return Pointer to the newly created task.
*/ */
FixedTimeslotTask(TaskName name, TaskPriority setPriority, TaskStackSize setStack, FixedTimeslotTask(TaskName name, TaskPriority setPriority, TaskStackSize setStack,
TaskPeriod overallPeriod, TaskDeadlineMissedFunction dlmFunc); TaskPeriod overallPeriod, void (*setDeadlineMissedFunc)());
/** /**
* @brief The destructor of the class. * @brief The destructor of the class.
@ -32,9 +32,26 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase, public FreeRTOSTaskIF {
* initialization for the PST and the device handlers. This is done by * initialization for the PST and the device handlers. This is done by
* calling the PST's destructor. * calling the PST's destructor.
*/ */
~FixedTimeslotTask() override; virtual ~FixedTimeslotTask(void);
ReturnValue_t startTask() override; ReturnValue_t startTask(void);
/**
* This static function can be used as #deadlineMissedFunc.
* It counts missedDeadlines and prints the number of missed deadlines
* every 10th time.
*/
static void missedDeadlineCounter();
/**
* A helper variable to count missed deadlines.
*/
static uint32_t deadlineMissedCount;
ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs,
int8_t executionStep) override;
uint32_t getPeriodMs() const override;
ReturnValue_t checkSequence() const override;
ReturnValue_t sleepFor(uint32_t ms) override; ReturnValue_t sleepFor(uint32_t ms) override;
@ -44,6 +61,17 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase, public FreeRTOSTaskIF {
bool started; bool started;
TaskHandle_t handle; TaskHandle_t handle;
FixedSlotSequence pst;
/**
* @brief This attribute holds a function pointer that is executed when
* a deadline was missed.
* @details
* Another function may be announced to determine the actions to perform
* when a deadline was missed. Currently, only one function for missing
* any deadline is allowed. If not used, it shall be declared NULL.
*/
void (*deadlineMissedFunc)(void);
/** /**
* @brief This is the entry point for a new task. * @brief This is the entry point for a new task.
* @details * @details
@ -60,7 +88,7 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase, public FreeRTOSTaskIF {
* It links the functionalities provided by FixedSlotSequence with the * It links the functionalities provided by FixedSlotSequence with the
* OS's System Calls to keep the timing of the periods. * OS's System Calls to keep the timing of the periods.
*/ */
[[noreturn]] void taskFunctionality(); void taskFunctionality(void);
void handleMissedDeadline(); void handleMissedDeadline();
}; };

View File

@ -6,11 +6,11 @@
class FreeRTOSTaskIF { class FreeRTOSTaskIF {
public: public:
virtual ~FreeRTOSTaskIF() = default; virtual ~FreeRTOSTaskIF() {}
virtual TaskHandle_t getTaskHandle() = 0; virtual TaskHandle_t getTaskHandle() = 0;
protected: protected:
static bool checkMissedDeadline(const TickType_t xLastWakeTime, const TickType_t interval) { bool checkMissedDeadline(const TickType_t xLastWakeTime, const TickType_t interval) {
/* Check whether deadline was missed while also taking overflows /* Check whether deadline was missed while also taking overflows
* into account. Drawing this on paper with a timeline helps to understand * into account. Drawing this on paper with a timeline helps to understand
* it. */ * it. */

View File

@ -5,28 +5,27 @@
#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/ExecutableObjectIF.h"
PeriodicTask::PeriodicTask(const char* name, TaskPriority setPriority, TaskStackSize setStack, PeriodicTask::PeriodicTask(const char* name, TaskPriority setPriority, TaskStackSize setStack,
TaskPeriod setPeriod, TaskDeadlineMissedFunction dlmFunc_) TaskPeriod setPeriod, TaskDeadlineMissedFunction deadlineMissedFunc)
: PeriodicTaskBase(setPeriod, dlmFunc_), started(false), handle(nullptr) { : started(false), handle(NULL), period(setPeriod), deadlineMissedFunc(deadlineMissedFunc) {
configSTACK_DEPTH_TYPE stackSize = setStack / sizeof(configSTACK_DEPTH_TYPE); configSTACK_DEPTH_TYPE stackSize = setStack / sizeof(configSTACK_DEPTH_TYPE);
BaseType_t status = xTaskCreate(taskEntryPoint, name, stackSize, this, setPriority, &handle); BaseType_t status = xTaskCreate(taskEntryPoint, name, stackSize, this, setPriority, &handle);
if (status != pdPASS) { if (status != pdPASS) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "PeriodicTask::PeriodicTask Insufficient heap memory remaining. Status: " sif::debug << "PeriodicTask Insufficient heap memory remaining. "
"Status: "
<< status << std::endl; << status << std::endl;
#else
sif::printDebug("PeriodicTask::PeriodicTask: Insufficient heap memory remaining. Status: %d\n",
status);
#endif #endif
} }
} }
// Do not delete objects, we were responsible for ptrs only. PeriodicTask::~PeriodicTask(void) {
PeriodicTask::~PeriodicTask() = default; // Do not delete objects, we were responsible for ptrs only.
}
void PeriodicTask::taskEntryPoint(void* argument) { void PeriodicTask::taskEntryPoint(void* argument) {
// The argument is re-interpreted as PeriodicTask. The Task object is // The argument is re-interpreted as PeriodicTask. The Task object is
// global, so it is found from any place. // global, so it is found from any place.
auto* originalTask(reinterpret_cast<PeriodicTask*>(argument)); PeriodicTask* originalTask(reinterpret_cast<PeriodicTask*>(argument));
/* Task should not start until explicitly requested, /* Task should not start until explicitly requested,
* but in FreeRTOS, tasks start as soon as they are created if the scheduler * but in FreeRTOS, tasks start as soon as they are created if the scheduler
* is running but not if the scheduler is not running. * is running but not if the scheduler is not running.
@ -37,7 +36,7 @@ void PeriodicTask::taskEntryPoint(void* argument) {
* can continue */ * can continue */
if (not originalTask->started) { if (not originalTask->started) {
vTaskSuspend(nullptr); vTaskSuspend(NULL);
} }
originalTask->taskFunctionality(); originalTask->taskFunctionality();
@ -63,11 +62,13 @@ ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
[[noreturn]] void PeriodicTask::taskFunctionality() { void PeriodicTask::taskFunctionality() {
TickType_t xLastWakeTime; TickType_t xLastWakeTime;
const TickType_t xPeriod = pdMS_TO_TICKS(this->period * 1000.); const TickType_t xPeriod = pdMS_TO_TICKS(this->period * 1000.);
initObjsAfterTaskCreation(); for (auto const& object : objectList) {
object->initializeAfterTaskCreation();
}
/* The xLastWakeTime variable needs to be initialized with the current tick /* The xLastWakeTime variable needs to be initialized with the current tick
count. Note that this is the only time the variable is written to count. Note that this is the only time the variable is written to
@ -76,8 +77,8 @@ ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) {
xLastWakeTime = xTaskGetTickCount(); xLastWakeTime = xTaskGetTickCount();
/* Enter the loop that defines the task behavior. */ /* Enter the loop that defines the task behavior. */
for (;;) { for (;;) {
for (auto const& objectPair : objectList) { for (auto const& object : objectList) {
objectPair.first->performOperation(objectPair.second); object->performOperation();
} }
#if (tskKERNEL_VERSION_MAJOR == 10 && tskKERNEL_VERSION_MINOR >= 4) || tskKERNEL_VERSION_MAJOR > 10 #if (tskKERNEL_VERSION_MAJOR == 10 && tskKERNEL_VERSION_MINOR >= 4) || tskKERNEL_VERSION_MAJOR > 10
@ -94,10 +95,32 @@ ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) {
} }
} }
ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
ExecutableObjectIF* newObject = ObjectManager::instance()->get<ExecutableObjectIF>(object);
return addComponent(newObject);
}
ReturnValue_t PeriodicTask::addComponent(ExecutableObjectIF* object) {
if (object == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
"it implement ExecutableObjectIF"
<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
objectList.push_back(object);
object->setTaskIF(this);
return HasReturnvaluesIF::RETURN_OK;
}
uint32_t PeriodicTask::getPeriodMs() const { return period * 1000; }
TaskHandle_t PeriodicTask::getTaskHandle() { return handle; } TaskHandle_t PeriodicTask::getTaskHandle() { return handle; }
void PeriodicTask::handleMissedDeadline() { void PeriodicTask::handleMissedDeadline() {
if (dlmFunc != nullptr) { if (deadlineMissedFunc != nullptr) {
dlmFunc(); this->deadlineMissedFunc();
} }
} }

View File

@ -6,8 +6,8 @@
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "FreeRTOSTaskIF.h" #include "FreeRTOSTaskIF.h"
#include "fsfw/objectmanager/ObjectManagerIF.h" #include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/tasks/PeriodicTaskBase.h" #include "fsfw/tasks/PeriodicTaskIF.h"
#include "fsfw/tasks/definitions.h" #include "fsfw/tasks/Typedef.h"
#include "task.h" #include "task.h"
class ExecutableObjectIF; class ExecutableObjectIF;
@ -17,7 +17,7 @@ class ExecutableObjectIF;
* periodic activities of multiple objects. * periodic activities of multiple objects.
* @ingroup task_handling * @ingroup task_handling
*/ */
class PeriodicTask : public PeriodicTaskBase, public FreeRTOSTaskIF { class PeriodicTask : public PeriodicTaskIF, public FreeRTOSTaskIF {
public: public:
/** /**
* Keep in Mind that you need to call before this vTaskStartScheduler()! * Keep in Mind that you need to call before this vTaskStartScheduler()!
@ -43,7 +43,7 @@ class PeriodicTask : public PeriodicTaskBase, public FreeRTOSTaskIF {
* @brief Currently, the executed object's lifetime is not coupled with * @brief Currently, the executed object's lifetime is not coupled with
* the task object's lifetime, so the destructor is empty. * the task object's lifetime, so the destructor is empty.
*/ */
~PeriodicTask() override; virtual ~PeriodicTask(void);
/** /**
* @brief The method to start the task. * @brief The method to start the task.
@ -53,6 +53,27 @@ class PeriodicTask : public PeriodicTaskBase, public FreeRTOSTaskIF {
* to the system call. * to the system call.
*/ */
ReturnValue_t startTask() override; ReturnValue_t startTask() override;
/**
* Adds an object to the list of objects to be executed.
* The objects are executed in the order added.
* @param object Id of the object to add.
* @return
* -@c RETURN_OK on success
* -@c RETURN_FAILED if the object could not be added.
*/
ReturnValue_t addComponent(object_id_t object) override;
/**
* Adds an object to the list of objects to be executed.
* The objects are executed in the order added.
* @param object Id of the object to add.
* @return
* -@c RETURN_OK on success
* -@c RETURN_FAILED if the object could not be added.
*/
ReturnValue_t addComponent(ExecutableObjectIF* object) override;
uint32_t getPeriodMs() const override;
ReturnValue_t sleepFor(uint32_t ms) override; ReturnValue_t sleepFor(uint32_t ms) override;
@ -62,6 +83,28 @@ class PeriodicTask : public PeriodicTaskBase, public FreeRTOSTaskIF {
bool started; bool started;
TaskHandle_t handle; TaskHandle_t handle;
//! Typedef for the List of objects.
typedef std::vector<ExecutableObjectIF*> ObjectList;
/**
* @brief This attribute holds a list of objects to be executed.
*/
ObjectList objectList;
/**
* @brief The period of the task.
* @details
* The period determines the frequency of the task's execution.
* It is expressed in clock ticks.
*/
TaskPeriod period;
/**
* @brief The pointer to the deadline-missed function.
* @details
* This pointer stores the function that is executed if the task's deadline
* is missed so each may react individually on a timing failure.
* The pointer may be NULL, then nothing happens on missing the deadline.
* The deadline is equal to the next execution of the periodic task.
*/
void (*deadlineMissedFunc)(void);
/** /**
* @brief This is the function executed in the new task's context. * @brief This is the function executed in the new task's context.
* @details * @details
@ -82,7 +125,7 @@ class PeriodicTask : public PeriodicTaskBase, public FreeRTOSTaskIF {
* the next period. * the next period.
* On missing the deadline, the deadlineMissedFunction is executed. * On missing the deadline, the deadlineMissedFunction is executed.
*/ */
[[noreturn]] void taskFunctionality(); void taskFunctionality(void);
void handleMissedDeadline(); void handleMissedDeadline();
}; };

View File

@ -1,6 +1,5 @@
target_sources( target_sources(${LIB_FSFW_NAME} PRIVATE
${LIB_FSFW_NAME} Clock.cpp
PRIVATE Clock.cpp
FixedTimeslotTask.cpp FixedTimeslotTask.cpp
MessageQueue.cpp MessageQueue.cpp
Mutex.cpp Mutex.cpp
@ -10,14 +9,19 @@ target_sources(
QueueMapManager.cpp QueueMapManager.cpp
SemaphoreFactory.cpp SemaphoreFactory.cpp
TaskFactory.cpp TaskFactory.cpp
taskHelpers.cpp) taskHelpers.cpp
)
if(UNIX) if(UNIX)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(${LIB_FSFW_NAME} PRIVATE
${CMAKE_THREAD_LIBS_INIT}
)
if(NOT APPLE) if(NOT APPLE)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE rt) target_link_libraries(${LIB_FSFW_NAME} PRIVATE
rt
)
endif() endif()
endif() endif()

View File

@ -3,7 +3,9 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include "fsfw/ipc/MutexFactory.h"
#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/osal/host/FixedTimeslotTask.h"
#include "fsfw/osal/host/Mutex.h" #include "fsfw/osal/host/Mutex.h"
#include "fsfw/osal/host/taskHelpers.h" #include "fsfw/osal/host/taskHelpers.h"
#include "fsfw/platform.h" #include "fsfw/platform.h"
@ -20,8 +22,12 @@
FixedTimeslotTask::FixedTimeslotTask(const char* name, TaskPriority setPriority, FixedTimeslotTask::FixedTimeslotTask(const char* name, TaskPriority setPriority,
TaskStackSize setStack, TaskPeriod setPeriod, TaskStackSize setStack, TaskPeriod setPeriod,
TaskDeadlineMissedFunction dlmFunc_) void (*setDeadlineMissedFunc)())
: FixedTimeslotTaskBase(setPeriod, dlmFunc_), started(false), taskName(name) { : started(false),
pollingSeqTable(setPeriod * 1000),
taskName(name),
period(setPeriod),
deadlineMissedFunc(setDeadlineMissedFunc) {
// It is propably possible to set task priorities by using the native // It is propably possible to set task priorities by using the native
// task handles for Windows / Linux // task handles for Windows / Linux
mainThread = std::thread(&FixedTimeslotTask::taskEntryPoint, this, this); mainThread = std::thread(&FixedTimeslotTask::taskEntryPoint, this, this);
@ -33,7 +39,7 @@ FixedTimeslotTask::FixedTimeslotTask(const char* name, TaskPriority setPriority,
tasks::insertTaskName(mainThread.get_id(), taskName); tasks::insertTaskName(mainThread.get_id(), taskName);
} }
FixedTimeslotTask::~FixedTimeslotTask() { FixedTimeslotTask::~FixedTimeslotTask(void) {
// Do not delete objects, we were responsible for ptrs only. // Do not delete objects, we were responsible for ptrs only.
terminateThread = true; terminateThread = true;
if (mainThread.joinable()) { if (mainThread.joinable()) {
@ -42,7 +48,7 @@ FixedTimeslotTask::~FixedTimeslotTask() {
} }
void FixedTimeslotTask::taskEntryPoint(void* argument) { void FixedTimeslotTask::taskEntryPoint(void* argument) {
auto* originalTask(reinterpret_cast<FixedTimeslotTask*>(argument)); FixedTimeslotTask* originalTask(reinterpret_cast<FixedTimeslotTask*>(argument));
if (not originalTask->started) { if (not originalTask->started) {
// we have to suspend/block here until the task is started. // we have to suspend/block here until the task is started.
@ -75,9 +81,7 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
} }
void FixedTimeslotTask::taskFunctionality() { void FixedTimeslotTask::taskFunctionality() {
ReturnValue_t result = pollingSeqTable.intializeSequenceAfterTaskCreation(); pollingSeqTable.intializeSequenceAfterTaskCreation();
// Ignore returnvalue for now
static_cast<void>(result);
// A local iterator for the Polling Sequence Table is created to // A local iterator for the Polling Sequence Table is created to
// find the start time for the first entry. // find the start time for the first entry.
@ -102,15 +106,37 @@ void FixedTimeslotTask::taskFunctionality() {
// we need to wait before executing the current slot // we need to wait before executing the current slot
// this gives us the time to wait: // this gives us the time to wait:
interval = chron_ms(this->pollingSeqTable.getIntervalToPreviousSlotMs()); interval = chron_ms(this->pollingSeqTable.getIntervalToPreviousSlotMs());
if (not delayForInterval(&currentStartTime, interval)) { delayForInterval(&currentStartTime, interval);
if (dlmFunc != nullptr) { // TODO deadline missed check
dlmFunc();
}
}
} }
} }
} }
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs,
int8_t executionStep) {
ExecutableObjectIF* executableObject =
ObjectManager::instance()->get<ExecutableObjectIF>(componentId);
if (executableObject != nullptr) {
pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep, executableObject, this);
return HasReturnvaluesIF::RETURN_OK;
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Component " << std::hex << "0x" << componentId
<< "not found, "
"not adding it to PST.."
<< std::dec << std::endl;
#else
sif::printError("Component 0x%08x not found, not adding it to PST..\n",
static_cast<unsigned int>(componentId));
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t FixedTimeslotTask::checkSequence() const { return pollingSeqTable.checkSequence(); }
uint32_t FixedTimeslotTask::getPeriodMs() const { return period * 1000; }
bool FixedTimeslotTask::delayForInterval(chron_ms* previousWakeTimeMs, const chron_ms interval) { bool FixedTimeslotTask::delayForInterval(chron_ms* previousWakeTimeMs, const chron_ms interval) {
bool shouldDelay = false; bool shouldDelay = false;
// Get current wakeup time // Get current wakeup time

View File

@ -6,10 +6,10 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include "fsfw/objectmanager/ObjectManagerIF.h" #include "../../objectmanager/ObjectManagerIF.h"
#include "fsfw/tasks/FixedSlotSequence.h" #include "../../tasks/FixedSlotSequence.h"
#include "fsfw/tasks/FixedTimeslotTaskBase.h" #include "../../tasks/FixedTimeslotTaskIF.h"
#include "fsfw/tasks/definitions.h" #include "../../tasks/Typedef.h"
class ExecutableObjectIF; class ExecutableObjectIF;
@ -19,7 +19,7 @@ class ExecutableObjectIF;
* @details * @details
* @ingroup task_handling * @ingroup task_handling
*/ */
class FixedTimeslotTask : public FixedTimeslotTaskBase { class FixedTimeslotTask : public FixedTimeslotTaskIF {
public: public:
/** /**
* @brief Standard constructor of the class. * @brief Standard constructor of the class.
@ -39,7 +39,7 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase {
* @brief Currently, the executed object's lifetime is not coupled with * @brief Currently, the executed object's lifetime is not coupled with
* the task object's lifetime, so the destructor is empty. * the task object's lifetime, so the destructor is empty.
*/ */
~FixedTimeslotTask() override; virtual ~FixedTimeslotTask(void);
/** /**
* @brief The method to start the task. * @brief The method to start the task.
@ -48,22 +48,56 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase {
* The address of the task object is passed as an argument * The address of the task object is passed as an argument
* to the system call. * to the system call.
*/ */
ReturnValue_t startTask() override; ReturnValue_t startTask(void);
ReturnValue_t sleepFor(uint32_t ms) override; /**
* Add timeslot to the polling sequence table.
* @param componentId
* @param slotTimeMs
* @param executionStep
* @return
*/
ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep);
ReturnValue_t checkSequence() const override;
uint32_t getPeriodMs() const;
ReturnValue_t sleepFor(uint32_t ms);
protected: protected:
using chron_ms = std::chrono::milliseconds; using chron_ms = std::chrono::milliseconds;
bool started; bool started;
//!< Typedef for the List of objects.
typedef std::vector<ExecutableObjectIF*> ObjectList;
std::thread mainThread; std::thread mainThread;
std::atomic<bool> terminateThread{false}; std::atomic<bool> terminateThread{false};
//! Polling sequence table which contains the object to execute
//! and information like the timeslots and the passed execution step.
FixedSlotSequence pollingSeqTable;
std::condition_variable initCondition; std::condition_variable initCondition;
std::mutex initMutex; std::mutex initMutex;
std::string taskName; std::string taskName;
/**
* @brief The period of the task.
* @details
* The period determines the frequency of the task's execution.
* It is expressed in clock ticks.
*/
TaskPeriod period;
/**
* @brief The pointer to the deadline-missed function.
* @details
* This pointer stores the function that is executed if the task's deadline
* is missed. So, each may react individually on a timing failure.
* The pointer may be NULL, then nothing happens on missing the deadline.
* The deadline is equal to the next execution of the periodic task.
*/
void (*deadlineMissedFunc)(void);
/** /**
* @brief This is the function executed in the new task's context. * @brief This is the function executed in the new task's context.
* @details * @details
@ -83,9 +117,9 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase {
* the checkAndRestartPeriod system call blocks the task until the next * the checkAndRestartPeriod system call blocks the task until the next
* period. On missing the deadline, the deadlineMissedFunction is executed. * period. On missing the deadline, the deadlineMissedFunction is executed.
*/ */
void taskFunctionality(); void taskFunctionality(void);
static bool delayForInterval(chron_ms* previousWakeTimeMs, chron_ms interval); bool delayForInterval(chron_ms* previousWakeTimeMs, const chron_ms interval);
}; };
#endif /* FRAMEWORK_OSAL_HOST_FIXEDTIMESLOTTASK_H_ */ #endif /* FRAMEWORK_OSAL_HOST_FIXEDTIMESLOTTASK_H_ */

View File

@ -3,10 +3,13 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include "fsfw/ipc/MutexFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/osal/host/Mutex.h" #include "fsfw/osal/host/Mutex.h"
#include "fsfw/osal/host/taskHelpers.h" #include "fsfw/osal/host/taskHelpers.h"
#include "fsfw/platform.h" #include "fsfw/platform.h"
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#if defined(PLATFORM_WIN) #if defined(PLATFORM_WIN)
#include <processthreadsapi.h> #include <processthreadsapi.h>
@ -17,8 +20,8 @@
#endif #endif
PeriodicTask::PeriodicTask(const char* name, TaskPriority setPriority, TaskStackSize setStack, PeriodicTask::PeriodicTask(const char* name, TaskPriority setPriority, TaskStackSize setStack,
TaskPeriod setPeriod, TaskDeadlineMissedFunction dlmFunc_) TaskPeriod setPeriod, void (*setDeadlineMissedFunc)())
: PeriodicTaskBase(setPeriod, dlmFunc_), started(false), taskName(name) { : started(false), taskName(name), period(setPeriod), deadlineMissedFunc(setDeadlineMissedFunc) {
// It is probably possible to set task priorities by using the native // It is probably possible to set task priorities by using the native
// task handles for Windows / Linux // task handles for Windows / Linux
mainThread = std::thread(&PeriodicTask::taskEntryPoint, this, this); mainThread = std::thread(&PeriodicTask::taskEntryPoint, this, this);
@ -30,7 +33,7 @@ PeriodicTask::PeriodicTask(const char* name, TaskPriority setPriority, TaskStack
tasks::insertTaskName(mainThread.get_id(), taskName); tasks::insertTaskName(mainThread.get_id(), taskName);
} }
PeriodicTask::~PeriodicTask() { PeriodicTask::~PeriodicTask(void) {
// Do not delete objects, we were responsible for ptrs only. // Do not delete objects, we were responsible for ptrs only.
terminateThread = true; terminateThread = true;
if (mainThread.joinable()) { if (mainThread.joinable()) {
@ -39,7 +42,7 @@ PeriodicTask::~PeriodicTask() {
} }
void PeriodicTask::taskEntryPoint(void* argument) { void PeriodicTask::taskEntryPoint(void* argument) {
auto* originalTask(reinterpret_cast<PeriodicTask*>(argument)); PeriodicTask* originalTask(reinterpret_cast<PeriodicTask*>(argument));
if (not originalTask->started) { if (not originalTask->started) {
// we have to suspend/block here until the task is started. // we have to suspend/block here until the task is started.
@ -72,27 +75,47 @@ ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) {
} }
void PeriodicTask::taskFunctionality() { void PeriodicTask::taskFunctionality() {
initObjsAfterTaskCreation(); for (const auto& object : objectList) {
object->initializeAfterTaskCreation();
}
std::chrono::milliseconds periodChrono(static_cast<uint32_t>(period * 1000)); std::chrono::milliseconds periodChrono(static_cast<uint32_t>(period * 1000));
auto currentStartTime{std::chrono::duration_cast<std::chrono::milliseconds>( auto currentStartTime{std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())}; std::chrono::system_clock::now().time_since_epoch())};
auto nextStartTime{currentStartTime};
/* Enter the loop that defines the task behavior. */ /* Enter the loop that defines the task behavior. */
for (;;) { for (;;) {
if (terminateThread.load()) { if (terminateThread.load()) {
break; break;
} }
for (const auto& objectPair : objectList) { for (const auto& object : objectList) {
objectPair.first->performOperation(objectPair.second); object->performOperation();
} }
if (not delayForInterval(&currentStartTime, periodChrono)) { if (not delayForInterval(&currentStartTime, periodChrono)) {
if (dlmFunc != nullptr) { if (deadlineMissedFunc != nullptr) {
this->dlmFunc(); this->deadlineMissedFunc();
} }
} }
} }
} }
ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
ExecutableObjectIF* newObject = ObjectManager::instance()->get<ExecutableObjectIF>(object);
return addComponent(newObject);
}
ReturnValue_t PeriodicTask::addComponent(ExecutableObjectIF* object) {
if (object == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
object->setTaskIF(this);
objectList.push_back(object);
return HasReturnvaluesIF::RETURN_OK;
}
uint32_t PeriodicTask::getPeriodMs() const { return period * 1000; }
bool PeriodicTask::delayForInterval(chron_ms* previousWakeTimeMs, const chron_ms interval) { bool PeriodicTask::delayForInterval(chron_ms* previousWakeTimeMs, const chron_ms interval) {
bool shouldDelay = false; bool shouldDelay = false;
// Get current wakeup time // Get current wakeup time

View File

@ -6,9 +6,9 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include "fsfw/objectmanager/ObjectManagerIF.h" #include "../../objectmanager/ObjectManagerIF.h"
#include "fsfw/tasks/PeriodicTaskBase.h" #include "../../tasks/PeriodicTaskIF.h"
#include "fsfw/tasks/definitions.h" #include "../../tasks/Typedef.h"
class ExecutableObjectIF; class ExecutableObjectIF;
@ -19,7 +19,7 @@ class ExecutableObjectIF;
* *
* @ingroup task_handling * @ingroup task_handling
*/ */
class PeriodicTask : public PeriodicTaskBase { class PeriodicTask : public PeriodicTaskIF {
public: public:
/** /**
* @brief Standard constructor of the class. * @brief Standard constructor of the class.
@ -34,12 +34,12 @@ class PeriodicTask : public PeriodicTaskBase {
* assigned. * assigned.
*/ */
PeriodicTask(const char* name, TaskPriority setPriority, TaskStackSize setStack, PeriodicTask(const char* name, TaskPriority setPriority, TaskStackSize setStack,
TaskPeriod setPeriod, TaskDeadlineMissedFunction dlmFunc); TaskPeriod setPeriod, void (*setDeadlineMissedFunc)());
/** /**
* @brief Currently, the executed object's lifetime is not coupled with * @brief Currently, the executed object's lifetime is not coupled with
* the task object's lifetime, so the destructor is empty. * the task object's lifetime, so the destructor is empty.
*/ */
~PeriodicTask() override; virtual ~PeriodicTask(void);
/** /**
* @brief The method to start the task. * @brief The method to start the task.
@ -48,20 +48,63 @@ class PeriodicTask : public PeriodicTaskBase {
* The address of the task object is passed as an argument * The address of the task object is passed as an argument
* to the system call. * to the system call.
*/ */
ReturnValue_t startTask() override; ReturnValue_t startTask(void);
/**
* Adds an object to the list of objects to be executed.
* The objects are executed in the order added.
* @param object Id of the object to add.
* @return
* -@c RETURN_OK on success
* -@c RETURN_FAILED if the object could not be added.
*/
ReturnValue_t addComponent(object_id_t object);
ReturnValue_t sleepFor(uint32_t ms) override; /**
* Adds an object to the list of objects to be executed.
* The objects are executed in the order added.
* @param object pointer to the object to add.
* @return
* -@c RETURN_OK on success
* -@c RETURN_FAILED if the object could not be added.
*/
ReturnValue_t addComponent(ExecutableObjectIF* object);
uint32_t getPeriodMs() const;
ReturnValue_t sleepFor(uint32_t ms);
protected: protected:
using chron_ms = std::chrono::milliseconds; using chron_ms = std::chrono::milliseconds;
bool started; bool started;
//!< Typedef for the List of objects.
typedef std::vector<ExecutableObjectIF*> ObjectList;
std::thread mainThread; std::thread mainThread;
std::atomic<bool> terminateThread{false}; std::atomic<bool> terminateThread{false};
/**
* @brief This attribute holds a list of objects to be executed.
*/
ObjectList objectList;
std::condition_variable initCondition; std::condition_variable initCondition;
std::mutex initMutex; std::mutex initMutex;
std::string taskName; std::string taskName;
/**
* @brief The period of the task.
* @details
* The period determines the frequency of the task's execution.
* It is expressed in clock ticks.
*/
TaskPeriod period;
/**
* @brief The pointer to the deadline-missed function.
* @details
* This pointer stores the function that is executed if the task's deadline
* is missed. So, each may react individually on a timing failure.
* The pointer may be NULL, then nothing happens on missing the deadline.
* The deadline is equal to the next execution of the periodic task.
*/
void (*deadlineMissedFunc)(void);
/** /**
* @brief This is the function executed in the new task's context. * @brief This is the function executed in the new task's context.
* @details * @details
@ -81,9 +124,9 @@ class PeriodicTask : public PeriodicTaskBase {
* the checkAndRestartPeriod system call blocks the task until the next * the checkAndRestartPeriod system call blocks the task until the next
* period. On missing the deadline, the deadlineMissedFunction is executed. * period. On missing the deadline, the deadlineMissedFunction is executed.
*/ */
void taskFunctionality(); void taskFunctionality(void);
static bool delayForInterval(chron_ms* previousWakeTimeMs, chron_ms interval); bool delayForInterval(chron_ms* previousWakeTimeMs, const chron_ms interval);
}; };
#endif /* FRAMEWORK_OSAL_HOST_PERIODICTASK_H_ */ #endif /* PERIODICTASK_H_ */

View File

@ -14,9 +14,9 @@ TaskFactory* TaskFactory::factoryInstance = new TaskFactory();
// Not used for the host implementation for now because C++ thread abstraction is used // Not used for the host implementation for now because C++ thread abstraction is used
const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = 0; const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = 0;
TaskFactory::TaskFactory() = default; TaskFactory::TaskFactory() {}
TaskFactory::~TaskFactory() = default; TaskFactory::~TaskFactory() {}
TaskFactory* TaskFactory::instance() { return TaskFactory::factoryInstance; } TaskFactory* TaskFactory::instance() { return TaskFactory::factoryInstance; }

View File

@ -6,7 +6,7 @@
std::mutex nameMapLock; std::mutex nameMapLock;
std::map<std::thread::id, std::string> taskNameMap; std::map<std::thread::id, std::string> taskNameMap;
ReturnValue_t tasks::insertTaskName(std::thread::id threadId, const std::string& taskName) { ReturnValue_t tasks::insertTaskName(std::thread::id threadId, std::string taskName) {
std::lock_guard<std::mutex> lg(nameMapLock); std::lock_guard<std::mutex> lg(nameMapLock);
auto returnPair = taskNameMap.emplace(threadId, taskName); auto returnPair = taskNameMap.emplace(threadId, taskName);
if (not returnPair.second) { if (not returnPair.second) {

View File

@ -7,7 +7,7 @@
namespace tasks { namespace tasks {
ReturnValue_t insertTaskName(std::thread::id threadId, const std::string& taskName); ReturnValue_t insertTaskName(std::thread::id threadId, std::string taskName);
std::string getTaskName(std::thread::id threadId); std::string getTaskName(std::thread::id threadId);
} // namespace tasks } // namespace tasks

View File

@ -1,6 +1,5 @@
target_sources( target_sources(${LIB_FSFW_NAME} PRIVATE
${LIB_FSFW_NAME} Clock.cpp
PRIVATE Clock.cpp
BinarySemaphore.cpp BinarySemaphore.cpp
CountingSemaphore.cpp CountingSemaphore.cpp
FixedTimeslotTask.cpp FixedTimeslotTask.cpp
@ -14,12 +13,17 @@ target_sources(
SemaphoreFactory.cpp SemaphoreFactory.cpp
TaskFactory.cpp TaskFactory.cpp
tcpipHelpers.cpp tcpipHelpers.cpp
unixUtility.cpp) unixUtility.cpp
)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
target_link_libraries(${LIB_FSFW_NAME} PUBLIC ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(${LIB_FSFW_NAME} PUBLIC
${CMAKE_THREAD_LIBS_INIT}
)
if(NOT APPLE) if(NOT APPLE)
target_link_libraries(${LIB_FSFW_NAME} PUBLIC rt) target_link_libraries(${LIB_FSFW_NAME} PUBLIC
rt
)
endif() endif()

View File

@ -1,20 +1,22 @@
#include "fsfw/osal/linux/FixedTimeslotTask.h" #include "fsfw/osal/linux/FixedTimeslotTask.h"
#include <climits> #include <limits.h>
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
uint32_t FixedTimeslotTask::deadlineMissedCount = 0;
const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = PTHREAD_STACK_MIN; const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = PTHREAD_STACK_MIN;
FixedTimeslotTask::FixedTimeslotTask(const char* name_, TaskPriority priority_, size_t stackSize_, FixedTimeslotTask::FixedTimeslotTask(const char* name_, int priority_, size_t stackSize_,
TaskPeriod periodSeconds_, TaskDeadlineMissedFunction dlmFunc_) uint32_t periodMs_)
: FixedTimeslotTaskBase(periodSeconds_, dlmFunc_), : PosixThread(name_, priority_, stackSize_), pst(periodMs_), started(false) {}
posixThread(name_, priority_, stackSize_),
started(false) {} FixedTimeslotTask::~FixedTimeslotTask() {}
void* FixedTimeslotTask::taskEntryPoint(void* arg) { void* FixedTimeslotTask::taskEntryPoint(void* arg) {
// The argument is re-interpreted as PollingTask. // The argument is re-interpreted as PollingTask.
auto* originalTask(reinterpret_cast<FixedTimeslotTask*>(arg)); FixedTimeslotTask* originalTask(reinterpret_cast<FixedTimeslotTask*>(arg));
// The task's functionality is called. // The task's functionality is called.
originalTask->taskFunctionality(); originalTask->taskFunctionality();
return nullptr; return nullptr;
@ -22,7 +24,7 @@ void* FixedTimeslotTask::taskEntryPoint(void* arg) {
ReturnValue_t FixedTimeslotTask::startTask() { ReturnValue_t FixedTimeslotTask::startTask() {
started = true; started = true;
posixThread.createTask(&taskEntryPoint, this); createTask(&taskEntryPoint, this);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -30,36 +32,63 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
return PosixThread::sleep((uint64_t)ms * 1000000); return PosixThread::sleep((uint64_t)ms * 1000000);
} }
[[noreturn]] void FixedTimeslotTask::taskFunctionality() { uint32_t FixedTimeslotTask::getPeriodMs() const { return pst.getLengthMs(); }
// Like FreeRTOS pthreads are running as soon as they are created
if (!started) { ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs,
posixThread.suspend(); int8_t executionStep) {
ExecutableObjectIF* executableObject =
ObjectManager::instance()->get<ExecutableObjectIF>(componentId);
if (executableObject != nullptr) {
pst.addSlot(componentId, slotTimeMs, executionStep, executableObject, this);
return HasReturnvaluesIF::RETURN_OK;
} }
// Returnvalue ignored for now #if FSFW_CPP_OSTREAM_ENABLED == 1
static_cast<void>(pollingSeqTable.intializeSequenceAfterTaskCreation()); sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst"
<< std::dec << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t FixedTimeslotTask::checkSequence() const { return pst.checkSequence(); }
void FixedTimeslotTask::taskFunctionality() {
// Like FreeRTOS pthreads are running as soon as they are created
if (!started) {
suspend();
}
pst.intializeSequenceAfterTaskCreation();
// The start time for the first entry is read. // The start time for the first entry is read.
uint64_t lastWakeTime = PosixThread::getCurrentMonotonicTimeMs(); uint64_t lastWakeTime = getCurrentMonotonicTimeMs();
uint32_t interval = 0; uint64_t interval = pst.getIntervalToNextSlotMs();
// The task's "infinite" inner loop is entered. // The task's "infinite" inner loop is entered.
while (true) { while (1) {
if (pollingSeqTable.slotFollowsImmediately()) { if (pst.slotFollowsImmediately()) {
// Do nothing // Do nothing
} else { } else {
// The interval for the next polling slot is selected. // The interval for the next polling slot is selected.
interval = pollingSeqTable.getIntervalToPreviousSlotMs(); interval = this->pst.getIntervalToPreviousSlotMs();
// The period is checked and restarted with the new interval. // The period is checked and restarted with the new interval.
// If the deadline was missed, the deadlineMissedFunc is called. // If the deadline was missed, the deadlineMissedFunc is called.
if (!PosixThread::delayUntil(&lastWakeTime, interval)) { if (!PosixThread::delayUntil(&lastWakeTime, interval)) {
// No time left on timer -> we missed the deadline // No time left on timer -> we missed the deadline
if(dlmFunc != nullptr){ missedDeadlineCounter();
dlmFunc();
}
} }
} }
// The device handler for this slot is executed and the next one is chosen. // The device handler for this slot is executed and the next one is chosen.
pollingSeqTable.executeAndAdvance(); this->pst.executeAndAdvance();
}
}
void FixedTimeslotTask::missedDeadlineCounter() {
FixedTimeslotTask::deadlineMissedCount++;
if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PST missed " << FixedTimeslotTask::deadlineMissedCount << " deadlines"
<< std::endl;
#endif
} }
} }

View File

@ -3,12 +3,11 @@
#include <pthread.h> #include <pthread.h>
#include "../../tasks/FixedSlotSequence.h"
#include "../../tasks/FixedTimeslotTaskIF.h"
#include "PosixThread.h" #include "PosixThread.h"
#include "fsfw/tasks/FixedSlotSequence.h"
#include "fsfw/tasks/FixedTimeslotTaskBase.h"
#include "fsfw/tasks/definitions.h"
class FixedTimeslotTask : public FixedTimeslotTaskBase { class FixedTimeslotTask : public FixedTimeslotTaskIF, public PosixThread {
public: public:
/** /**
* Create a generic periodic task. * Create a generic periodic task.
@ -22,13 +21,29 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase {
* @param period_ * @param period_
* @param deadlineMissedFunc_ * @param deadlineMissedFunc_
*/ */
FixedTimeslotTask(const char* name_, TaskPriority priority_, size_t stackSize_, FixedTimeslotTask(const char* name_, int priority_, size_t stackSize_, uint32_t periodMs_);
TaskPeriod periodSeconds_, TaskDeadlineMissedFunction dlmFunc_); virtual ~FixedTimeslotTask();
~FixedTimeslotTask() override = default;
ReturnValue_t startTask() override; virtual ReturnValue_t startTask();
ReturnValue_t sleepFor(uint32_t ms) override; virtual ReturnValue_t sleepFor(uint32_t ms);
virtual uint32_t getPeriodMs() const;
virtual ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep);
virtual ReturnValue_t checkSequence() const;
/**
* This static function can be used as #deadlineMissedFunc.
* It counts missedDeadlines and prints the number of missed deadlines every 10th time.
*/
static void missedDeadlineCounter();
/**
* A helper variable to count missed deadlines.
*/
static uint32_t deadlineMissedCount;
protected: protected:
/** /**
@ -38,12 +53,9 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase {
* It links the functionalities provided by FixedSlotSequence with the * It links the functionalities provided by FixedSlotSequence with the
* OS's System Calls to keep the timing of the periods. * OS's System Calls to keep the timing of the periods.
*/ */
[[noreturn]] virtual void taskFunctionality(); virtual void taskFunctionality();
private: private:
PosixThread posixThread;
bool started;
/** /**
* @brief This is the entry point in a new thread. * @brief This is the entry point in a new thread.
* *
@ -56,6 +68,9 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase {
* arbitrary data. * arbitrary data.
*/ */
static void* taskEntryPoint(void* arg); static void* taskEntryPoint(void* arg);
FixedSlotSequence pst;
bool started;
}; };
#endif /* FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ */ #endif /* FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ */

View File

@ -1,54 +1,86 @@
#include "PeriodicPosixTask.h" #include "fsfw/osal/linux/PeriodicPosixTask.h"
#include "fsfw/serviceinterface.h" #include <errno.h>
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/ExecutableObjectIF.h"
PeriodicPosixTask::PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_, PeriodicPosixTask::PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_,
TaskPeriod period_, TaskDeadlineMissedFunction dlmFunc_) uint32_t period_, void(deadlineMissedFunc_)())
: PeriodicTaskBase(period_, dlmFunc_), : PosixThread(name_, priority_, stackSize_),
posixThread(name_, priority_, stackSize_), objectList(),
started(false) {} started(false),
periodMs(period_),
deadlineMissedFunc(deadlineMissedFunc_) {}
PeriodicPosixTask::~PeriodicPosixTask() {
// Not Implemented
}
void* PeriodicPosixTask::taskEntryPoint(void* arg) { void* PeriodicPosixTask::taskEntryPoint(void* arg) {
// The argument is re-interpreted as PollingTask. // The argument is re-interpreted as PollingTask.
auto* originalTask(reinterpret_cast<PeriodicPosixTask*>(arg)); PeriodicPosixTask* originalTask(reinterpret_cast<PeriodicPosixTask*>(arg));
// The task's functionality is called. // The task's functionality is called.
originalTask->taskFunctionality(); originalTask->taskFunctionality();
return nullptr; return NULL;
} }
ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) { ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) {
return PosixThread::sleep(static_cast<uint64_t>(ms) * 1000000); ExecutableObjectIF* newObject = ObjectManager::instance()->get<ExecutableObjectIF>(object);
return addComponent(newObject);
} }
ReturnValue_t PeriodicPosixTask::startTask() { ReturnValue_t PeriodicPosixTask::addComponent(ExecutableObjectIF* object) {
if (isEmpty()) { if (object == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
<< " it implements ExecutableObjectIF!" << std::endl;
#else
sif::printError(
"PeriodicTask::addComponent: Invalid object. Make sure it "
"implements ExecutableObjectIF!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
started = true; objectList.push_back(object);
posixThread.createTask(&taskEntryPoint, this); object->setTaskIF(this);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
[[noreturn]] void PeriodicPosixTask::taskFunctionality() { ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) {
return PosixThread::sleep((uint64_t)ms * 1000000);
}
ReturnValue_t PeriodicPosixTask::startTask(void) {
started = true;
PosixThread::createTask(&taskEntryPoint, this);
return HasReturnvaluesIF::RETURN_OK;
}
void PeriodicPosixTask::taskFunctionality(void) {
if (not started) { if (not started) {
posixThread.suspend(); suspend();
} }
initObjsAfterTaskCreation(); for (auto const& object : objectList) {
object->initializeAfterTaskCreation();
}
uint64_t lastWakeTime = PosixThread::getCurrentMonotonicTimeMs(); uint64_t lastWakeTime = getCurrentMonotonicTimeMs();
uint64_t periodMs = getPeriodMs();
// The task's "infinite" inner loop is entered. // The task's "infinite" inner loop is entered.
while (true) { while (1) {
for (auto const& objOpCodePair : objectList) { for (auto const& object : objectList) {
objOpCodePair.first->performOperation(objOpCodePair.second); object->performOperation();
} }
if (not PosixThread::delayUntil(&lastWakeTime, periodMs)) { if (not PosixThread::delayUntil(&lastWakeTime, periodMs)) {
if (dlmFunc != nullptr) { if (this->deadlineMissedFunc != nullptr) {
dlmFunc(); this->deadlineMissedFunc();
} }
} }
} }
} }
uint32_t PeriodicPosixTask::getPeriodMs() const { return periodMs; }

View File

@ -3,13 +3,12 @@
#include <vector> #include <vector>
#include "../../objectmanager/ObjectManagerIF.h"
#include "../../tasks/ExecutableObjectIF.h"
#include "../../tasks/PeriodicTaskIF.h"
#include "PosixThread.h" #include "PosixThread.h"
#include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tasks/PeriodicTaskBase.h"
#include "fsfw/tasks/PeriodicTaskIF.h"
class PeriodicPosixTask : public PeriodicTaskBase { class PeriodicPosixTask : public PosixThread, public PeriodicTaskIF {
public: public:
/** /**
* Create a generic periodic task. * Create a generic periodic task.
@ -23,9 +22,9 @@ class PeriodicPosixTask : public PeriodicTaskBase {
* @param period_ * @param period_
* @param deadlineMissedFunc_ * @param deadlineMissedFunc_
*/ */
PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_, TaskPeriod period_, PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_, uint32_t period_,
TaskDeadlineMissedFunction dlmFunc_); void (*deadlineMissedFunc_)());
~PeriodicPosixTask() override = default; virtual ~PeriodicPosixTask();
/** /**
* @brief The method to start the task. * @brief The method to start the task.
@ -35,17 +34,42 @@ class PeriodicPosixTask : public PeriodicTaskBase {
* to the system call. * to the system call.
*/ */
ReturnValue_t startTask() override; ReturnValue_t startTask() override;
/**
* Adds an object to the list of objects to be executed.
* The objects are executed in the order added.
* @param object Id of the object to add.
* @return RETURN_OK on success, RETURN_FAILED if the object could not be added.
*/
ReturnValue_t addComponent(object_id_t object) override;
/**
* Adds an object to the list of objects to be executed.
* The objects are executed in the order added.
* @param object pointer to the object to add.
* @return RETURN_OK on success, RETURN_FAILED if the object could not be added.
*/
ReturnValue_t addComponent(ExecutableObjectIF* object) override;
uint32_t getPeriodMs() const override;
ReturnValue_t sleepFor(uint32_t ms) override; ReturnValue_t sleepFor(uint32_t ms) override;
private: private:
PosixThread posixThread; typedef std::vector<ExecutableObjectIF*> ObjectList; //!< Typedef for the List of objects.
/**
* @brief This attribute holds a list of objects to be executed.
*/
ObjectList objectList;
/** /**
* @brief Flag to indicate that the task was started and is allowed to run * @brief Flag to indicate that the task was started and is allowed to run
*/ */
bool started; bool started;
/**
* @brief Period of the task in milliseconds
*/
uint32_t periodMs;
/** /**
* @brief The function containing the actual functionality of the task. * @brief The function containing the actual functionality of the task.
* @details The method sets and starts * @details The method sets and starts
@ -54,7 +78,7 @@ class PeriodicPosixTask : public PeriodicTaskBase {
* will be blocked until the next period. On missing the deadline, the deadlineMissedFunction is * will be blocked until the next period. On missing the deadline, the deadlineMissedFunction is
* executed. * executed.
*/ */
[[noreturn]] virtual void taskFunctionality(); virtual void taskFunctionality(void);
/** /**
* @brief This is the entry point in a new thread. * @brief This is the entry point in a new thread.
* *
@ -62,6 +86,14 @@ class PeriodicPosixTask : public PeriodicTaskBase {
* of the child class. Needs a valid pointer to the derived class. * of the child class. Needs a valid pointer to the derived class.
*/ */
static void* taskEntryPoint(void* arg); static void* taskEntryPoint(void* arg);
/**
* @brief The pointer to the deadline-missed function.
* @details This pointer stores the function that is executed if the task's deadline is missed.
* So, each may react individually on a timing failure. The pointer may be
* NULL, then nothing happens on missing the deadline. The deadline is equal to the next execution
* of the periodic task.
*/
void (*deadlineMissedFunc)();
}; };
#endif /* FRAMEWORK_OSAL_LINUX_PERIODICPOSIXTASK_H_ */ #endif /* FRAMEWORK_OSAL_LINUX_PERIODICPOSIXTASK_H_ */

View File

@ -35,21 +35,6 @@ class PosixThread {
*/ */
void resume(); void resume();
/**
* @brief Function that has to be called by derived class because the
* derived class pointer has to be valid as argument.
* @details
* This function creates a pthread with the given parameters. As the
* function requires a pointer to the derived object it has to be called
* after the this pointer of the derived object is valid.
* Sets the taskEntryPoint as function to be called by new a thread.
* @param fnc_ Function which will be executed by the thread.
* @param arg_
* argument of the taskEntryPoint function, needs to be this pointer
* of derived class
*/
void createTask(void* (*fnc_)(void*), void* arg_);
/** /**
* Delay function similar to FreeRtos delayUntil function * Delay function similar to FreeRtos delayUntil function
* *
@ -70,6 +55,21 @@ class PosixThread {
protected: protected:
pthread_t thread; pthread_t thread;
/**
* @brief Function that has to be called by derived class because the
* derived class pointer has to be valid as argument.
* @details
* This function creates a pthread with the given parameters. As the
* function requires a pointer to the derived object it has to be called
* after the this pointer of the derived object is valid.
* Sets the taskEntryPoint as function to be called by new a thread.
* @param fnc_ Function which will be executed by the thread.
* @param arg_
* argument of the taskEntryPoint function, needs to be this pointer
* of derived class
*/
void createTask(void* (*fnc_)(void*), void* arg_);
private: private:
char name[PTHREAD_MAX_NAMELEN]; char name[PTHREAD_MAX_NAMELEN];
int priority; int priority;

View File

@ -8,22 +8,21 @@
// TODO: Different variant than the lazy loading in QueueFactory. What's better and why? // TODO: Different variant than the lazy loading in QueueFactory. What's better and why?
TaskFactory* TaskFactory::factoryInstance = new TaskFactory(); TaskFactory* TaskFactory::factoryInstance = new TaskFactory();
TaskFactory::~TaskFactory() = default; TaskFactory::~TaskFactory() {}
TaskFactory* TaskFactory::instance() { return TaskFactory::factoryInstance; } TaskFactory* TaskFactory::instance() { return TaskFactory::factoryInstance; }
PeriodicTaskIF* TaskFactory::createPeriodicTask( PeriodicTaskIF* TaskFactory::createPeriodicTask(
TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_, TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_,
TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_) { TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_) {
return new PeriodicPosixTask(name_, taskPriority_, stackSize_, periodInSeconds_, return new PeriodicPosixTask(name_, taskPriority_, stackSize_, periodInSeconds_ * 1000,
deadLineMissedFunction_); deadLineMissedFunction_);
} }
FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask( FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(
TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_, TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_,
TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_) { TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_) {
return new FixedTimeslotTask(name_, taskPriority_, stackSize_, periodInSeconds_, return new FixedTimeslotTask(name_, taskPriority_, stackSize_, periodInSeconds_ * 1000);
deadLineMissedFunction_);
} }
ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) { ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) {

View File

@ -1,6 +1,6 @@
target_sources( target_sources(${LIB_FSFW_NAME}
${LIB_FSFW_NAME} PRIVATE
PRIVATE Clock.cpp Clock.cpp
CpuUsage.cpp CpuUsage.cpp
InitTask.cpp InitTask.cpp
InternalErrorCodes.cpp InternalErrorCodes.cpp
@ -14,4 +14,7 @@ target_sources(
RTEMSTaskBase.cpp RTEMSTaskBase.cpp
TaskFactory.cpp TaskFactory.cpp
BinarySemaphore.cpp BinarySemaphore.cpp
SemaphoreFactory.cpp) SemaphoreFactory.cpp
)

View File

@ -1,32 +1,42 @@
#include "fsfw/osal/rtems/FixedTimeslotTask.h" #include "fsfw/osal/rtems/FixedTimeslotTask.h"
#include <rtems/bspIo.h>
#include <rtems/io.h> #include <rtems/io.h>
#include <rtems/rtems/ratemon.h>
#include <rtems/rtems/status.h> #include <rtems/rtems/status.h>
#include <rtems/rtems/tasks.h> #include <rtems/rtems/tasks.h>
#include <rtems/rtems/types.h> #include <rtems/rtems/types.h>
#include <sys/_stdint.h>
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/objectmanager/SystemObjectIF.h"
#include "fsfw/osal/rtems/RtemsBasic.h" #include "fsfw/osal/rtems/RtemsBasic.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tasks/FixedSequenceSlot.h"
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
#include <iostream> #include <iostream>
#endif #endif
#include <cstddef> #include <cstddef>
#include <list>
uint32_t FixedTimeslotTask::deadlineMissedCount = 0;
FixedTimeslotTask::FixedTimeslotTask(const char *name, rtems_task_priority setPriority, FixedTimeslotTask::FixedTimeslotTask(const char *name, rtems_task_priority setPriority,
size_t setStack, TaskPeriod setOverallPeriod, size_t setStack, uint32_t setOverallPeriod,
TaskDeadlineMissedFunction dlmFunc_) void (*setDeadlineMissedFunc)(void))
: FixedTimeslotTaskBase(setOverallPeriod, dlmFunc_), : RTEMSTaskBase(setPriority, setStack, name), periodId(0), pst(setOverallPeriod) {
RTEMSTaskBase(setPriority, setStack, name), // All additional attributes are applied to the object.
periodId(0) {} this->deadlineMissedFunc = setDeadlineMissedFunc;
}
FixedTimeslotTask::~FixedTimeslotTask() = default; FixedTimeslotTask::~FixedTimeslotTask() {}
rtems_task FixedTimeslotTask::taskEntryPoint(rtems_task_argument argument) { rtems_task FixedTimeslotTask::taskEntryPoint(rtems_task_argument argument) {
/* The argument is re-interpreted as a FixedTimeslotTask */ /* The argument is re-interpreted as a FixedTimeslotTask */
auto *originalTask(reinterpret_cast<FixedTimeslotTask *>(argument)); FixedTimeslotTask *originalTask(reinterpret_cast<FixedTimeslotTask *>(argument));
/* The task's functionality is called. */ /* The task's functionality is called. */
return originalTask->taskFunctionality(); return originalTask->taskFunctionality();
/* Should never be reached */ /* Should never be reached */
@ -36,6 +46,16 @@ rtems_task FixedTimeslotTask::taskEntryPoint(rtems_task_argument argument) {
#endif #endif
} }
void FixedTimeslotTask::missedDeadlineCounter() {
FixedTimeslotTask::deadlineMissedCount++;
if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PST missed " << FixedTimeslotTask::deadlineMissedCount << " deadlines"
<< std::endl;
#endif
}
}
ReturnValue_t FixedTimeslotTask::startTask() { ReturnValue_t FixedTimeslotTask::startTask() {
rtems_status_code status = rtems_status_code status =
rtems_task_start(id, FixedTimeslotTask::taskEntryPoint, rtems_task_argument((void *)this)); rtems_task_start(id, FixedTimeslotTask::taskEntryPoint, rtems_task_argument((void *)this));
@ -59,35 +79,54 @@ ReturnValue_t FixedTimeslotTask::startTask() {
} }
} }
[[noreturn]] void FixedTimeslotTask::taskFunctionality() { ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs,
int8_t executionStep) {
ExecutableObjectIF *object = ObjectManager::instance()->get<ExecutableObjectIF>(componentId);
if (object != nullptr) {
pst.addSlot(componentId, slotTimeMs, executionStep, object, this);
return HasReturnvaluesIF::RETURN_OK;
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst"
<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
uint32_t FixedTimeslotTask::getPeriodMs() const { return pst.getLengthMs(); }
ReturnValue_t FixedTimeslotTask::checkSequence() const { return pst.checkSequence(); }
void FixedTimeslotTask::taskFunctionality() {
/* A local iterator for the Polling Sequence Table is created to find the start time for /* A local iterator for the Polling Sequence Table is created to find the start time for
the first entry. */ the first entry. */
auto it = pollingSeqTable.current; FixedSlotSequence::SlotListIter it = pst.current;
/* Initialize the PST with the correct calling task */ /* Initialize the PST with the correct calling task */
pollingSeqTable.intializeSequenceAfterTaskCreation(); pst.intializeSequenceAfterTaskCreation();
/* The start time for the first entry is read. */ /* The start time for the first entry is read. */
rtems_interval interval = RtemsBasic::convertMsToTicks(it->pollingTimeMs); rtems_interval interval = RtemsBasic::convertMsToTicks(it->pollingTimeMs);
RTEMSTaskBase::setAndStartPeriod(interval, &periodId); RTEMSTaskBase::setAndStartPeriod(interval, &periodId);
// The task's "infinite" inner loop is entered. // The task's "infinite" inner loop is entered.
while (true) { while (1) {
if (pollingSeqTable.slotFollowsImmediately()) { if (pst.slotFollowsImmediately()) {
/* Do nothing */ /* Do nothing */
} else { } else {
/* The interval for the next polling slot is selected. */ /* The interval for the next polling slot is selected. */
interval = RtemsBasic::convertMsToTicks(pollingSeqTable.getIntervalToNextSlotMs()); interval = RtemsBasic::convertMsToTicks(this->pst.getIntervalToNextSlotMs());
/* The period is checked and restarted with the new interval. /* The period is checked and restarted with the new interval.
If the deadline was missed, the deadlineMissedFunc is called. */ If the deadline was missed, the deadlineMissedFunc is called. */
rtems_status_code status = RTEMSTaskBase::restartPeriod(interval, periodId); rtems_status_code status = RTEMSTaskBase::restartPeriod(interval, periodId);
if (status == RTEMS_TIMEOUT) { if (status == RTEMS_TIMEOUT) {
if (dlmFunc != nullptr) { if (this->deadlineMissedFunc != nullptr) {
dlmFunc(); this->deadlineMissedFunc();
} }
} }
} }
/* The device handler for this slot is executed and the next one is chosen. */ /* The device handler for this slot is executed and the next one is chosen. */
this->pollingSeqTable.executeAndAdvance(); this->pst.executeAndAdvance();
} }
} }

View File

@ -1,11 +1,11 @@
#ifndef FSFW_OSAL_RTEMS_FIXEDTIMESLOTTASK_H_ #ifndef FSFW_OSAL_RTEMS_FIXEDTIMESLOTTASK_H_
#define FSFW_OSAL_RTEMS_FIXEDTIMESLOTTASK_H_ #define FSFW_OSAL_RTEMS_FIXEDTIMESLOTTASK_H_
#include "../../tasks/FixedSlotSequence.h"
#include "../../tasks/FixedTimeslotTaskIF.h"
#include "RTEMSTaskBase.h" #include "RTEMSTaskBase.h"
#include "fsfw/tasks/FixedSlotSequence.h"
#include "fsfw/tasks/FixedTimeslotTaskBase.h"
class FixedTimeslotTask : public FixedTimeslotTaskBase, public RTEMSTaskBase { class FixedTimeslotTask : public RTEMSTaskBase, public FixedTimeslotTaskIF {
public: public:
/** /**
* @brief The standard constructor of the class. * @brief The standard constructor of the class.
@ -17,7 +17,7 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase, public RTEMSTaskBase {
* @param getPst The object id of the completely initialized polling sequence. * @param getPst The object id of the completely initialized polling sequence.
*/ */
FixedTimeslotTask(const char *name, rtems_task_priority setPriority, size_t setStackSize, FixedTimeslotTask(const char *name, rtems_task_priority setPriority, size_t setStackSize,
TaskPeriod overallPeriod, TaskDeadlineMissedFunction dlmFunc); uint32_t overallPeriod, void (*setDeadlineMissedFunc)());
/** /**
* @brief The destructor of the class. * @brief The destructor of the class.
@ -25,17 +25,44 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase, public RTEMSTaskBase {
* The destructor frees all heap memory that was allocated on thread initialization * The destructor frees all heap memory that was allocated on thread initialization
* for the PST andthe device handlers. This is done by calling the PST's destructor. * for the PST andthe device handlers. This is done by calling the PST's destructor.
*/ */
~FixedTimeslotTask() override; virtual ~FixedTimeslotTask(void);
ReturnValue_t startTask(void); ReturnValue_t startTask(void);
/**
* This static function can be used as #deadlineMissedFunc.
* It counts missedDeadlines and prints the number of missed deadlines every 10th time.
*/
static void missedDeadlineCounter();
/**
* A helper variable to count missed deadlines.
*/
static uint32_t deadlineMissedCount;
ReturnValue_t sleepFor(uint32_t ms) override; ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep);
uint32_t getPeriodMs() const;
ReturnValue_t checkSequence() const;
ReturnValue_t sleepFor(uint32_t ms);
protected: protected:
/** /**
* @brief id of the associated OS period * @brief id of the associated OS period
*/ */
rtems_id periodId; rtems_id periodId;
FixedSlotSequence pst;
/**
* @brief This attribute holds a function pointer that is executed when a deadline was missed.
*
* @details
* Another function may be announced to determine the actions to perform when a deadline
* was missed. Currently, only one function for missing any deadline is allowed.
* If not used, it shall be declared NULL.
*/
void (*deadlineMissedFunc)(void) = nullptr;
/** /**
* @brief This is the entry point in a new polling thread. * @brief This is the entry point in a new polling thread.
* @details This method is the entry point in the new thread * @details This method is the entry point in the new thread
@ -49,7 +76,7 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase, public RTEMSTaskBase {
* It links the functionalities provided by FixedSlotSequence with the OS's system calls to * It links the functionalities provided by FixedSlotSequence with the OS's system calls to
* keep the timing of the periods. * keep the timing of the periods.
*/ */
[[noreturn]] void taskFunctionality(); void taskFunctionality(void);
}; };
#endif /* FSFW_OSAL_RTEMS_FIXEDTIMESLOTTASK_H_ */ #endif /* FSFW_OSAL_RTEMS_FIXEDTIMESLOTTASK_H_ */

Some files were not shown because too many files have changed in this diff Show More