Compare commits
15 Commits
mueller/re
...
mueller/cl
Author | SHA1 | Date | |
---|---|---|---|
a7eb165f34 | |||
dd1e26e719 | |||
a2c024b24c | |||
e90960a7b6 | |||
e2b3cdd6c4 | |||
1e7a39a8e1 | |||
28380deab0 | |||
c361751751 | |||
17a153485d | |||
fffe1f812f | |||
2a9300e947 | |||
13f3a312be | |||
9705bf5d40 | |||
5425360876 | |||
b904d33cfe |
7
.run/fsfw-tests_coverage.run.xml
Normal file
7
.run/fsfw-tests_coverage.run.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="fsfw-tests_coverage" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="fsfw-example-hosted" TARGET_NAME="fsfw-tests_coverage" CONFIG_NAME="Debug Unittest" RUN_TARGET_PROJECT_NAME="fsfw-example-hosted" RUN_TARGET_NAME="fsfw-tests">
|
||||||
|
<method v="2">
|
||||||
|
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
7
.run/fsfw.run.xml
Normal file
7
.run/fsfw.run.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="fsfw" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="fsfw-tests" TARGET_NAME="fsfw" CONFIG_NAME="Debug Unittest" RUN_TARGET_PROJECT_NAME="fsfw-tests" RUN_TARGET_NAME="fsfw-tests">
|
||||||
|
<method v="2">
|
||||||
|
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
11
CHANGELOG.md
11
CHANGELOG.md
@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Bump C++ required version to C++17. Every project which uses the FSFW and every modern
|
- 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
|
||||||
@ -40,9 +46,6 @@ 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
|
||||||
- Internal API change: Moved the `fsfw_hal` to the `src` folder and integration and internal
|
|
||||||
tests part of `fsfw_tests` to `src`. Unittests are now in a dedicated folder called `unittests`
|
|
||||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/653
|
|
||||||
|
|
||||||
### Task Module Refactoring
|
### Task Module Refactoring
|
||||||
|
|
||||||
@ -117,8 +120,6 @@ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/593
|
|||||||
|
|
||||||
## Additions
|
## Additions
|
||||||
|
|
||||||
- New constructor for PoolEntry which allows to simply specify the length of the pool entry.
|
|
||||||
This is also the new default constructor for scalar value with 0 as an initial value
|
|
||||||
- Added options for CI/CD builds: `FSFW_CICD_BUILD`. This allows the source code to know
|
- Added options for CI/CD builds: `FSFW_CICD_BUILD`. This allows the source code to know
|
||||||
whether it is running in CI/CD
|
whether it is running in CI/CD
|
||||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/623
|
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/623
|
||||||
|
@ -67,13 +67,13 @@ endif()
|
|||||||
set(FSFW_SOURCES_DIR "${CMAKE_SOURCE_DIR}/src/fsfw")
|
set(FSFW_SOURCES_DIR "${CMAKE_SOURCE_DIR}/src/fsfw")
|
||||||
|
|
||||||
set(FSFW_ETL_LIB_NAME etl)
|
set(FSFW_ETL_LIB_NAME etl)
|
||||||
set(FSFW_ETL_LINK_TARGET etl::etl)
|
|
||||||
set(FSFW_ETL_LIB_MAJOR_VERSION
|
set(FSFW_ETL_LIB_MAJOR_VERSION
|
||||||
20
|
20
|
||||||
CACHE STRING "ETL library major version requirement")
|
CACHE STRING "ETL library major version requirement")
|
||||||
set(FSFW_ETL_LIB_VERSION
|
set(FSFW_ETL_LIB_VERSION
|
||||||
${FSFW_ETL_LIB_MAJOR_VERSION}.28.0
|
${FSFW_ETL_LIB_MAJOR_VERSION}.28.0
|
||||||
CACHE STRING "ETL library exact version requirement")
|
CACHE STRING "ETL library exact version requirement")
|
||||||
|
set(FSFW_ETL_LINK_TARGET etl::etl)
|
||||||
|
|
||||||
set(FSFW_CATCH2_LIB_MAJOR_VERSION
|
set(FSFW_CATCH2_LIB_MAJOR_VERSION
|
||||||
3
|
3
|
||||||
@ -82,15 +82,6 @@ set(FSFW_CATCH2_LIB_VERSION
|
|||||||
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5
|
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5
|
||||||
CACHE STRING "Catch2 library exact version requirement")
|
CACHE STRING "Catch2 library exact version requirement")
|
||||||
|
|
||||||
set(FSFW_FMT_LIB_NAME fmt)
|
|
||||||
set(FSFW_FMT_LINK_TARGET fmt::fmt)
|
|
||||||
set(FSFW_FMT_LIB_MAJOR_VERSION
|
|
||||||
8
|
|
||||||
CACHE STRING "{fmt} library major version requirement")
|
|
||||||
set(FSFW_FMT_LIB_VERSION
|
|
||||||
${FSFW_FMT_LIB_MAJOR_VERSION}.1.1
|
|
||||||
CACHE STRING "{fmt} library exact version requirement")
|
|
||||||
|
|
||||||
# Keep this off by default for now. See PR:
|
# Keep this off by default for now. See PR:
|
||||||
# https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/616 for information which
|
# https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/616 for information which
|
||||||
# keeping this on by default is problematic
|
# keeping this on by default is problematic
|
||||||
@ -112,11 +103,11 @@ 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_TESTS
|
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_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_TESTS)
|
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)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -148,7 +139,7 @@ if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
|
|||||||
TRUE)
|
TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FSFW_BUILD_TESTS)
|
if(FSFW_BUILD_UNITTESTS)
|
||||||
message(
|
message(
|
||||||
STATUS
|
STATUS
|
||||||
"${MSG_PREFIX} Building the FSFW unittests in addition to the static library"
|
"${MSG_PREFIX} Building the FSFW unittests in addition to the static library"
|
||||||
@ -171,17 +162,18 @@ if(FSFW_BUILD_TESTS)
|
|||||||
list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2)
|
list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(FSFW_CONFIG_PATH unittests/testcfg)
|
set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg)
|
||||||
configure_file(unittests/testcfg/FSFWConfig.h.in FSFWConfig.h)
|
configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h)
|
||||||
configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h)
|
configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in
|
||||||
|
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)
|
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
|
||||||
set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION
|
set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION
|
||||||
TRUE)
|
TRUE)
|
||||||
endif()
|
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} "
|
||||||
@ -191,7 +183,7 @@ if(FSFW_BUILD_TESTS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "${MSG_PREFIX} Finding and/or etl (Embedded Template Library)")
|
message(STATUS "${MSG_PREFIX} Finding and/or providing ETL library")
|
||||||
|
|
||||||
# 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} QUIET)
|
||||||
@ -211,26 +203,6 @@ if(NOT ${FSFW_ETL_LIB_NAME}_FOUND)
|
|||||||
list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME})
|
list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "Finding and/or providing {fmt} formatting library")
|
|
||||||
|
|
||||||
# Check whether the user has already installed ETL first
|
|
||||||
find_package(fmt ${FSFW_FMT_LIB_MAJOR_VERSION} QUIET)
|
|
||||||
# Not installed, so use FetchContent to download and provide etl
|
|
||||||
if(NOT ${FSFW_FMT_LIB_NAME}_FOUND)
|
|
||||||
message(
|
|
||||||
STATUS
|
|
||||||
"No {fmt} installation was found with find_package. Installing and providing "
|
|
||||||
"{fmt} with FindPackage")
|
|
||||||
include(FetchContent)
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
|
||||||
${FSFW_FMT_LIB_NAME}
|
|
||||||
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
|
|
||||||
GIT_TAG ${FSFW_FMT_LIB_VERSION})
|
|
||||||
|
|
||||||
list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_FMT_LIB_NAME})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# The documentation for FetchContent recommends declaring all the dependencies
|
# The documentation for FetchContent recommends declaring all the dependencies
|
||||||
# before making them available. We make all declared dependency available here
|
# before making them available. We make all declared dependency available here
|
||||||
# after their declaration
|
# after their declaration
|
||||||
@ -240,7 +212,7 @@ 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 Related
|
||||||
# GitHub issue: https://github.com/catchorg/Catch2/issues/2417
|
# 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()
|
||||||
@ -309,15 +281,16 @@ message(
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(contrib)
|
add_subdirectory(tests)
|
||||||
if(FSFW_BUILD_TESTS)
|
if(FSFW_ADD_HAL)
|
||||||
add_subdirectory(unittests)
|
add_subdirectory(hal)
|
||||||
endif()
|
endif()
|
||||||
|
add_subdirectory(contrib)
|
||||||
if(FSFW_BUILD_DOCS)
|
if(FSFW_BUILD_DOCS)
|
||||||
add_subdirectory(docs)
|
add_subdirectory(docs)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FSFW_BUILD_TESTS)
|
if(FSFW_BUILD_UNITTESTS)
|
||||||
if(FSFW_TESTS_GEN_COV)
|
if(FSFW_TESTS_GEN_COV)
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
include(CodeCoverage)
|
include(CodeCoverage)
|
||||||
@ -473,8 +446,9 @@ target_include_directories(
|
|||||||
|
|
||||||
target_compile_options(${LIB_FSFW_NAME} PRIVATE ${FSFW_WARNING_FLAGS}
|
target_compile_options(${LIB_FSFW_NAME} PRIVATE ${FSFW_WARNING_FLAGS}
|
||||||
${COMPILER_FLAGS})
|
${COMPILER_FLAGS})
|
||||||
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ADDITIONAL_LINK_LIBS})
|
|
||||||
target_link_libraries(${LIB_FSFW_NAME} PUBLIC ${FSFW_ETL_LINK_TARGET} ${FSFW_FMT_LINK_TARGET})
|
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ETL_LINK_TARGET}
|
||||||
|
${FSFW_ADDITIONAL_LINK_LIBS})
|
||||||
|
|
||||||
string(
|
string(
|
||||||
CONCAT
|
CONCAT
|
||||||
@ -484,13 +458,6 @@ string(
|
|||||||
"Target OSAL: ${FSFW_OS_NAME}\n"
|
"Target OSAL: ${FSFW_OS_NAME}\n"
|
||||||
"######################################################################\n")
|
"######################################################################\n")
|
||||||
|
|
||||||
# The additional / is important to remove the last character from the path. Note
|
|
||||||
# that it does not matter if the OS uses / or \, because we are only saving the
|
|
||||||
# path size.
|
|
||||||
string(LENGTH "${CMAKE_SOURCE_DIR}/" FSFW_SOURCE_PATH_SIZE)
|
|
||||||
target_compile_definitions(
|
|
||||||
${LIB_FSFW_NAME} PRIVATE "-DFSFW_SOURCE_PATH_SIZE=${FSFW_SOURCE_PATH_SIZE}")
|
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${LIB_FSFW_NAME}
|
TARGET ${LIB_FSFW_NAME}
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
|
@ -139,7 +139,7 @@ You can also use `-DFSFW_OSAL=linux` on Linux systems.
|
|||||||
|
|
||||||
Coverage data in HTML format can be generated using the `CodeCoverage`
|
Coverage data in HTML format can be generated using the `CodeCoverage`
|
||||||
[CMake module](https://github.com/bilke/cmake-modules/tree/master).
|
[CMake module](https://github.com/bilke/cmake-modules/tree/master).
|
||||||
To build the unittests, run them and then generate the coverage data in this format,
|
To build the unittests, run them and then generare the coverage data in this format,
|
||||||
the following command can be used inside the build directory after the build system was set up
|
the following command can be used inside the build directory after the build system was set up
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@ -188,10 +188,7 @@ and open the documentation conveniently. Try `helper.py -h for more information.
|
|||||||
|
|
||||||
The formatting is done by the `clang-format` tool. The configuration is contained within the
|
The formatting is done by the `clang-format` tool. The configuration is contained within the
|
||||||
`.clang-format` file in the repository root. As long as `clang-format` is installed, you
|
`.clang-format` file in the repository root. As long as `clang-format` is installed, you
|
||||||
can run the `auto-format.sh` helper script to format all source files consistently. Furthermore cmake-format is required to format CMake files which can be installed with:
|
can run the `apply-clang-format.sh` helper script to format all source files consistently.
|
||||||
````sh
|
|
||||||
sudo pip install cmakelang
|
|
||||||
````
|
|
||||||
|
|
||||||
## Index
|
## Index
|
||||||
|
|
||||||
|
@ -12,9 +12,3 @@ RUN git clone https://github.com/catchorg/Catch2.git && \
|
|||||||
git checkout v3.0.0-preview5 && \
|
git checkout v3.0.0-preview5 && \
|
||||||
cmake -Bbuild -H. -DBUILD_TESTING=OFF && \
|
cmake -Bbuild -H. -DBUILD_TESTING=OFF && \
|
||||||
cmake --build build/ --target install
|
cmake --build build/ --target install
|
||||||
|
|
||||||
RUN git clone https://github.com/ETLCPP/etl.git && \
|
|
||||||
cd etl && \
|
|
||||||
git checkout 20.28.0 && \
|
|
||||||
cmake -B build . && \
|
|
||||||
cmake --install build/
|
|
||||||
|
4
automation/Jenkinsfile
vendored
4
automation/Jenkinsfile
vendored
@ -3,7 +3,7 @@ pipeline {
|
|||||||
BUILDDIR = 'build-tests'
|
BUILDDIR = 'build-tests'
|
||||||
}
|
}
|
||||||
agent {
|
agent {
|
||||||
docker { image 'fsfw-ci:d3'}
|
docker { image 'fsfw-ci:d2'}
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('Clean') {
|
stage('Clean') {
|
||||||
@ -14,7 +14,7 @@ pipeline {
|
|||||||
stage('Configure') {
|
stage('Configure') {
|
||||||
steps {
|
steps {
|
||||||
dir(BUILDDIR) {
|
dir(BUILDDIR) {
|
||||||
sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..'
|
sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON -DFSFW_CICD_BUILD=ON ..'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
48
hal/CMakeLists.txt
Normal file
48
hal/CMakeLists.txt
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
# Can also be changed by upper CMakeLists.txt file
|
||||||
|
find_library(LIB_FSFW_NAME fsfw REQUIRED)
|
||||||
|
|
||||||
|
option(FSFW_HAL_ADD_LINUX "Add the Linux HAL to the sources. Requires gpiod library" OFF)
|
||||||
|
# On by default for now because I did not have an issue including and compiling those files
|
||||||
|
# and libraries on a Desktop Linux system and the primary target of the FSFW is still embedded
|
||||||
|
# Linux. The only exception from this is the gpiod library which requires a dedicated installation,
|
||||||
|
# but CMake is able to determine whether this library is installed with find_library.
|
||||||
|
option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add peripheral drivers for embedded Linux" ON)
|
||||||
|
option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Target implements libgpiod" ON)
|
||||||
|
|
||||||
|
option(FSFW_HAL_ADD_RASPBERRY_PI "Add Raspberry Pi specific code to the sources" OFF)
|
||||||
|
option(FSFW_HAL_ADD_STM32H7 "Add the STM32H7 HAL to the sources" OFF)
|
||||||
|
option(FSFW_HAL_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
|
||||||
|
|
||||||
|
set(LINUX_HAL_PATH_NAME linux)
|
||||||
|
set(STM32H7_PATH_NAME stm32h7)
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
foreach(INCLUDE_PATH ${FSFW_HAL_ADDITIONAL_INC_PATHS})
|
||||||
|
if(IS_ABSOLUTE ${INCLUDE_PATH})
|
||||||
|
set(CURR_ABS_INC_PATH "${INCLUDE_PATH}")
|
||||||
|
else()
|
||||||
|
get_filename_component(CURR_ABS_INC_PATH
|
||||||
|
${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_VERBOSE)
|
||||||
|
message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND FSFW_HAL_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
target_include_directories(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
${FSFW_HAL_ADD_INC_PATHS_ABS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
${FSFW_HAL_DEFINES}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
${FSFW_HAL_LINK_LIBS}
|
||||||
|
)
|
9
hal/src/CMakeLists.txt
Normal file
9
hal/src/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
target_include_directories(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${LIB_FSFW_NAME} INTERFACE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(fsfw_hal)
|
@ -1,19 +1,30 @@
|
|||||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||||
|
|
||||||
#include "fsfw/serviceinterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
GpioCookie::GpioCookie() = default;
|
GpioCookie::GpioCookie() {}
|
||||||
|
|
||||||
ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) {
|
ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) {
|
||||||
if (gpioConfig == nullptr) {
|
if (gpioConfig == nullptr) {
|
||||||
FSFW_LOGW("addGpio: gpioConfig is nullpointer\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("GpioCookie::addGpio: gpioConfig is nullpointer\n");
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
auto gpioMapIter = gpioMap.find(gpioId);
|
auto gpioMapIter = gpioMap.find(gpioId);
|
||||||
if (gpioMapIter == gpioMap.end()) {
|
if (gpioMapIter == gpioMap.end()) {
|
||||||
auto statusPair = gpioMap.emplace(gpioId, gpioConfig);
|
auto statusPair = gpioMap.emplace(gpioId, gpioConfig);
|
||||||
if (!statusPair.second) {
|
if (statusPair.second == false) {
|
||||||
FSFW_LOGW("addGpio: Failed to add GPIO {} to GPIO map\n", gpioId);
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << " to GPIO map"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("GpioCookie::addGpio: Failed to add GPIO %d to GPIO map\n", gpioId);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
@ -60,8 +60,16 @@ ReturnValue_t GyroHandlerL3GD20H::buildTransitionDeviceCommand(DeviceCommandId_t
|
|||||||
return buildCommandFromCommand(*id, nullptr, 0);
|
return buildCommandFromCommand(*id, nullptr, 0);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
/* Might be a configuration error. */
|
/* Might be a configuration error. */
|
||||||
FSFW_LOGW("buildTransitionDeviceCommand: Unknown internal state\n");
|
sif::warning << "GyroL3GD20Handler::buildTransitionDeviceCommand: "
|
||||||
|
"Unknown internal state!"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug(
|
||||||
|
"GyroL3GD20Handler::buildTransitionDeviceCommand: "
|
||||||
|
"Unknown internal state!\n");
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
@ -184,8 +192,17 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
if (periodicPrintout) {
|
if (periodicPrintout) {
|
||||||
if (debugDivider.checkAndIncrement()) {
|
if (debugDivider.checkAndIncrement()) {
|
||||||
/* Set terminal to utf-8 if there is an issue with micro printout. */
|
/* Set terminal to utf-8 if there is an issue with micro printout. */
|
||||||
FSFW_LOGI("GyroHandlerL3GD20H: Angular velocities (deg/s):\nX {} | Y {} | Z {}\n",
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
angVelocX, angVelocY, angVelocZ);
|
sif::info << "GyroHandlerL3GD20H: Angular velocities (deg/s):" << std::endl;
|
||||||
|
sif::info << "X: " << angVelocX << std::endl;
|
||||||
|
sif::info << "Y: " << angVelocY << std::endl;
|
||||||
|
sif::info << "Z: " << angVelocZ << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("GyroHandlerL3GD20H: Angular velocities (deg/s):\n");
|
||||||
|
sif::printInfo("X: %f\n", angVelocX);
|
||||||
|
sif::printInfo("Y: %f\n", angVelocY);
|
||||||
|
sif::printInfo("Z: %f\n", angVelocZ);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -17,8 +17,6 @@ MgmLIS3MDLHandler::MgmLIS3MDLHandler(object_id_t objectId, object_id_t deviceCom
|
|||||||
registers[4] = MGMLIS3MDL::CTRL_REG5_DEFAULT;
|
registers[4] = MGMLIS3MDL::CTRL_REG5_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
MgmLIS3MDLHandler::~MgmLIS3MDLHandler() {}
|
|
||||||
|
|
||||||
void MgmLIS3MDLHandler::doStartUp() {
|
void MgmLIS3MDLHandler::doStartUp() {
|
||||||
switch (internalState) {
|
switch (internalState) {
|
||||||
case (InternalState::STATE_NONE): {
|
case (InternalState::STATE_NONE): {
|
||||||
@ -76,11 +74,16 @@ ReturnValue_t MgmLIS3MDLHandler::buildTransitionDeviceCommand(DeviceCommandId_t
|
|||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
/* might be a configuration error. */
|
/* might be a configuration error. */
|
||||||
FSFW_LOGW("buildTransitionDeviceCommand: Unknown internal state\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "GyroHandler::buildTransitionDeviceCommand: Unknown internal state!"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("GyroHandler::buildTransitionDeviceCommand: Unknown internal state!\n");
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buildCommandFromCommand(*id, nullptr, 0);
|
return buildCommandFromCommand(*id, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t MgmLIS3MDLHandler::readCommand(uint8_t command, bool continuousCom) {
|
uint8_t MgmLIS3MDLHandler::readCommand(uint8_t command, bool continuousCom) {
|
||||||
@ -181,7 +184,13 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len,
|
|||||||
// Check validity by checking config registers
|
// Check validity by checking config registers
|
||||||
if (start[1] != registers[0] or start[2] != registers[1] or start[3] != registers[2] or
|
if (start[1] != registers[0] or start[2] != registers[1] or start[3] != registers[2] or
|
||||||
start[4] != registers[3] or start[5] != registers[4]) {
|
start[4] != registers[3] or start[5] != registers[4]) {
|
||||||
FSFW_LOGW("scanForReply: Invalid registers\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "MGMHandlerLIS3MDL::scanForReply: Invalid registers!" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("MGMHandlerLIS3MDL::scanForReply: Invalid registers!\n");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
return DeviceHandlerIF::INVALID_DATA;
|
return DeviceHandlerIF::INVALID_DATA;
|
||||||
}
|
}
|
||||||
if (mode == _MODE_START_UP) {
|
if (mode == _MODE_START_UP) {
|
||||||
@ -199,9 +208,17 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len,
|
|||||||
*foundId = getPendingCommand();
|
*foundId = getPendingCommand();
|
||||||
if (*foundId == MGMLIS3MDL::IDENTIFY_DEVICE) {
|
if (*foundId == MGMLIS3MDL::IDENTIFY_DEVICE) {
|
||||||
if (start[1] != MGMLIS3MDL::DEVICE_ID) {
|
if (start[1] != MGMLIS3MDL::DEVICE_ID) {
|
||||||
FSFW_LOGW(
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
"scanForReply: Device identification failed, found ID {} not equal to expected {}\n",
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
start[1], MGMLIS3MDL::DEVICE_ID);
|
sif::warning << "MGMHandlerLIS3MDL::scanForReply: "
|
||||||
|
"Device identification failed!"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"MGMHandlerLIS3MDL::scanForReply: "
|
||||||
|
"Device identification failed!\n");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
return DeviceHandlerIF::INVALID_DATA;
|
return DeviceHandlerIF::INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,10 +266,19 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
|||||||
|
|
||||||
if (periodicPrintout) {
|
if (periodicPrintout) {
|
||||||
if (debugDivider.checkAndIncrement()) {
|
if (debugDivider.checkAndIncrement()) {
|
||||||
FSFW_LOGI(
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
"MGMHandlerLIS3: Magnetic field strength in"
|
sif::info << "MGMHandlerLIS3: Magnetic field strength in"
|
||||||
" microtesla (uT):\nX {} | Y {} | Z {}\n",
|
" microtesla:"
|
||||||
mgmX, mgmY, mgmZ);
|
<< std::endl;
|
||||||
|
sif::info << "X: " << mgmX << " uT" << std::endl;
|
||||||
|
sif::info << "Y: " << mgmY << " uT" << std::endl;
|
||||||
|
sif::info << "Z: " << mgmZ << " uT" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("MGMHandlerLIS3: Magnetic field strength in microtesla:\n");
|
||||||
|
sif::printInfo("X: %f uT\n", mgmX);
|
||||||
|
sif::printInfo("Y: %f uT\n", mgmY);
|
||||||
|
sif::printInfo("Z: %f uT\n", mgmZ);
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,11 +309,15 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
case MGMLIS3MDL::READ_TEMPERATURE: {
|
case MGMLIS3MDL::READ_TEMPERATURE: {
|
||||||
auto tempValueRaw = static_cast<int16_t>((packet[2] << 8) | packet[1]);
|
int16_t tempValueRaw = packet[2] << 8 | packet[1];
|
||||||
float tempValue = 25.0 + ((static_cast<float>(tempValueRaw)) / 8.0);
|
float tempValue = 25.0 + ((static_cast<float>(tempValueRaw)) / 8.0);
|
||||||
if (periodicPrintout) {
|
if (periodicPrintout) {
|
||||||
if (debugDivider.check()) {
|
if (debugDivider.check()) {
|
||||||
FSFW_LOGI("MGMHandlerLIS3: Temperature: {} C\n", tempValue);
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("MGMHandlerLIS3: Temperature: %f C\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +28,7 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
|||||||
|
|
||||||
MgmLIS3MDLHandler(uint32_t objectId, object_id_t deviceCommunication, CookieIF *comCookie,
|
MgmLIS3MDLHandler(uint32_t objectId, object_id_t deviceCommunication, CookieIF *comCookie,
|
||||||
uint32_t transitionDelay);
|
uint32_t transitionDelay);
|
||||||
virtual ~MgmLIS3MDLHandler();
|
~MgmLIS3MDLHandler() override = default;
|
||||||
|
|
||||||
void enablePeriodicPrintouts(bool enable, uint8_t divider);
|
void enablePeriodicPrintouts(bool enable, uint8_t divider);
|
||||||
/**
|
/**
|
||||||
@ -46,7 +46,7 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
|||||||
void doShutDown() override;
|
void doShutDown() override;
|
||||||
void doStartUp() override;
|
void doStartUp() override;
|
||||||
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
|
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
|
||||||
virtual uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
|
uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
|
||||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
|
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
|
||||||
size_t commandDataLen) override;
|
size_t commandDataLen) override;
|
||||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
|
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
|
||||||
@ -60,9 +60,9 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
|||||||
* @param packet
|
* @param packet
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
|
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
|
||||||
void fillCommandAndReplyMap() override;
|
void fillCommandAndReplyMap() override;
|
||||||
void modeChanged(void) override;
|
void modeChanged() override;
|
||||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||||
LocalDataPoolManager &poolManager) override;
|
LocalDataPoolManager &poolManager) override;
|
||||||
|
|
||||||
@ -72,8 +72,6 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
|||||||
static const uint8_t SINGLE_COMMAND_ANSWER_LEN = 2;
|
static const uint8_t SINGLE_COMMAND_ANSWER_LEN = 2;
|
||||||
|
|
||||||
uint32_t transitionDelay;
|
uint32_t transitionDelay;
|
||||||
// Single SPI command has 2 bytes, first for adress, second for content
|
|
||||||
size_t singleComandSize = 2;
|
|
||||||
// Has the size for all adresses of the lis3mdl + the continous write bit
|
// Has the size for all adresses of the lis3mdl + the continous write bit
|
||||||
uint8_t commandBuffer[MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1];
|
uint8_t commandBuffer[MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1];
|
||||||
|
|
||||||
@ -88,7 +86,6 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
|||||||
*/
|
*/
|
||||||
uint8_t registers[MGMLIS3MDL::NR_OF_CTRL_REGISTERS];
|
uint8_t registers[MGMLIS3MDL::NR_OF_CTRL_REGISTERS];
|
||||||
|
|
||||||
uint8_t statusRegister = 0;
|
|
||||||
bool goToNormalMode = false;
|
bool goToNormalMode = false;
|
||||||
|
|
||||||
enum class InternalState {
|
enum class InternalState {
|
||||||
@ -111,14 +108,14 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
|||||||
* @param single command to set the read-bit at
|
* @param single command to set the read-bit at
|
||||||
* @param boolean to select a continuous read bit, default = false
|
* @param boolean to select a continuous read bit, default = false
|
||||||
*/
|
*/
|
||||||
uint8_t readCommand(uint8_t command, bool continuousCom = false);
|
static uint8_t readCommand(uint8_t command, bool continuousCom = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the write bit for the command
|
* Sets the write bit for the command
|
||||||
* @param single command to set the write-bit at
|
* @param single command to set the write-bit at
|
||||||
* @param boolean to select a continuous write bit, default = false
|
* @param boolean to select a continuous write bit, default = false
|
||||||
*/
|
*/
|
||||||
uint8_t writeCommand(uint8_t command, bool continuousCom = false);
|
static uint8_t writeCommand(uint8_t command, bool continuousCom = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Method gets the full scale for the measurement range
|
* This Method gets the full scale for the measurement range
|
@ -81,8 +81,18 @@ ReturnValue_t MgmRM3100Handler::buildTransitionDeviceCommand(DeviceCommandId_t *
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
// Might be a configuration error
|
// Might be a configuration error
|
||||||
FSFW_LOGW("buildTransitionDeviceCommand: Unknown internal state\n");
|
sif::warning << "MgmRM3100Handler::buildTransitionDeviceCommand: "
|
||||||
|
"Unknown internal state"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"MgmRM3100Handler::buildTransitionDeviceCommand: "
|
||||||
|
"Unknown internal state\n");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,16 +329,25 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) {
|
|||||||
int32_t fieldStrengthRawZ = ((packet[7] << 24) | (packet[8] << 16) | (packet[3] << 8)) >> 8;
|
int32_t fieldStrengthRawZ = ((packet[7] << 24) | (packet[8] << 16) | (packet[3] << 8)) >> 8;
|
||||||
|
|
||||||
// Now scale to physical value in microtesla
|
// Now scale to physical value in microtesla
|
||||||
float fieldStrengthX = fieldStrengthRawX * scaleFactorX;
|
float fieldStrengthX = static_cast<float>(fieldStrengthRawX) * scaleFactorX;
|
||||||
float fieldStrengthY = fieldStrengthRawY * scaleFactorX;
|
float fieldStrengthY = static_cast<float>(fieldStrengthRawY) * scaleFactorY;
|
||||||
float fieldStrengthZ = fieldStrengthRawZ * scaleFactorX;
|
float fieldStrengthZ = static_cast<float>(fieldStrengthRawZ) * scaleFactorZ;
|
||||||
|
|
||||||
if (periodicPrintout) {
|
if (periodicPrintout) {
|
||||||
if (debugDivider.checkAndIncrement()) {
|
if (debugDivider.checkAndIncrement()) {
|
||||||
FSFW_LOGI(
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
"MgmRM3100Handler: Magnetic field strength in"
|
sif::info << "MgmRM3100Handler: Magnetic field strength in"
|
||||||
" microtesla(uT)\nX {} | Y {} | Z {}\n",
|
" microtesla:"
|
||||||
fieldStrengthX, fieldStrengthY, fieldStrengthZ);
|
<< std::endl;
|
||||||
|
sif::info << "X: " << fieldStrengthX << " uT" << std::endl;
|
||||||
|
sif::info << "Y: " << fieldStrengthY << " uT" << std::endl;
|
||||||
|
sif::info << "Z: " << fieldStrengthZ << " uT" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("MgmRM3100Handler: Magnetic field strength in microtesla:\n");
|
||||||
|
sif::printInfo("X: %f uT\n", fieldStrengthX);
|
||||||
|
sif::printInfo("Y: %f uT\n", fieldStrengthY);
|
||||||
|
sif::printInfo("Z: %f uT\n", fieldStrengthZ);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +72,6 @@ class MgmRM3100Handler : public DeviceHandlerBase {
|
|||||||
RM3100::Rm3100PrimaryDataset primaryDataset;
|
RM3100::Rm3100PrimaryDataset primaryDataset;
|
||||||
|
|
||||||
uint8_t commandBuffer[10];
|
uint8_t commandBuffer[10];
|
||||||
uint8_t commandBufferLen = 0;
|
|
||||||
|
|
||||||
uint8_t cmmRegValue = RM3100::CMM_VALUE;
|
uint8_t cmmRegValue = RM3100::CMM_VALUE;
|
||||||
uint8_t tmrcRegValue = RM3100::TMRC_DEFAULT_VALUE;
|
uint8_t tmrcRegValue = RM3100::TMRC_DEFAULT_VALUE;
|
||||||
@ -100,4 +99,4 @@ class MgmRM3100Handler : public DeviceHandlerBase {
|
|||||||
PeriodicOperationDivider debugDivider = PeriodicOperationDivider(3);
|
PeriodicOperationDivider debugDivider = PeriodicOperationDivider(3);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MISSION_DEVICEHANDLING_MGMRM3100HANDLER_H_ */
|
#endif /* MISSION_DEVICES_MGMRM3100HANDLER_H_ */
|
@ -59,16 +59,22 @@ ReturnValue_t CommandExecutor::close() {
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandExecutor::printLastError(const std::string& funcName) const {
|
void CommandExecutor::printLastError(std::string funcName) const {
|
||||||
if (lastError != 0) {
|
if (lastError != 0) {
|
||||||
FSFW_LOGW("{} | pclose failed with code {} | {}\n", funcName, lastError, strerror(lastError));
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << funcName << " pclose failed with code " << lastError << ": "
|
||||||
|
<< strerror(lastError) << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError("%s pclose failed with code %d: %s\n", funcName, lastError,
|
||||||
|
strerror(lastError));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer_,
|
void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer,
|
||||||
DynamicFIFO<uint16_t>* sizesFifo_) {
|
DynamicFIFO<uint16_t>* sizesFifo) {
|
||||||
this->ringBuffer = ringBuffer_;
|
this->ringBuffer = ringBuffer;
|
||||||
this->sizesFifo = sizesFifo_;
|
this->sizesFifo = sizesFifo;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
||||||
@ -96,13 +102,23 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
|||||||
ssize_t readBytes = read(currentFd, readVec.data(), readVec.size());
|
ssize_t readBytes = read(currentFd, readVec.data(), readVec.size());
|
||||||
if (readBytes == 0) {
|
if (readBytes == 0) {
|
||||||
// Should not happen
|
// Should not happen
|
||||||
FSFW_LOGWT("CommandExecutor::check: No bytes read after poll event\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "CommandExecutor::check: No bytes read "
|
||||||
|
"after poll event.."
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("CommandExecutor::check: No bytes read after poll event..\n");
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (readBytes > 0) {
|
} else if (readBytes > 0) {
|
||||||
replyReceived = true;
|
replyReceived = true;
|
||||||
if (printOutput) {
|
if (printOutput) {
|
||||||
// It is assumed the command output is line terminated
|
// It is assumed the command output is line terminated
|
||||||
FSFW_LOGIT("{} | {}", currentCmd, readVec.data());
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << currentCmd << " | " << readVec.data();
|
||||||
|
#else
|
||||||
|
sif::printInfo("%s | %s", currentCmd, readVec.data());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (ringBuffer != nullptr) {
|
if (ringBuffer != nullptr) {
|
||||||
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(readVec.data()), readBytes);
|
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(readVec.data()), readBytes);
|
||||||
@ -114,11 +130,20 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Should also not happen
|
// Should also not happen
|
||||||
FSFW_LOGW("check: Error {} | {}\n", errno, strerror(errno));
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "CommandExecutor::check: Error " << errno << ": " << strerror(errno)
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("CommandExecutor::check: Error %d: %s\n", errno, strerror(errno));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (waiter.revents & POLLERR) {
|
if (waiter.revents & POLLERR) {
|
||||||
FSFW_LOGW("check: Poll error\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "CommandExecuter::check: Poll error" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("CommandExecuter::check: Poll error\n");
|
||||||
|
#endif
|
||||||
return COMMAND_ERROR;
|
return COMMAND_ERROR;
|
||||||
}
|
}
|
||||||
if (waiter.revents & POLLHUP) {
|
if (waiter.revents & POLLHUP) {
|
||||||
@ -158,7 +183,11 @@ ReturnValue_t CommandExecutor::executeBlocking() {
|
|||||||
while (fgets(readVec.data(), readVec.size(), currentCmdFile) != nullptr) {
|
while (fgets(readVec.data(), readVec.size(), currentCmdFile) != nullptr) {
|
||||||
std::string output(readVec.data());
|
std::string output(readVec.data());
|
||||||
if (printOutput) {
|
if (printOutput) {
|
||||||
FSFW_LOGI("{} | {}", currentCmd, output);
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << currentCmd << " | " << output;
|
||||||
|
#else
|
||||||
|
sif::printInfo("%s | %s", currentCmd, output);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (ringBuffer != nullptr) {
|
if (ringBuffer != nullptr) {
|
||||||
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(output.data()), output.size());
|
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(output.data()), output.size());
|
@ -93,7 +93,7 @@ class CommandExecutor {
|
|||||||
|
|
||||||
States getCurrentState() const;
|
States getCurrentState() const;
|
||||||
int getLastError() const;
|
int getLastError() const;
|
||||||
void printLastError(const std::string& funcName) const;
|
void printLastError(std::string funcName) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign a ring buffer and a FIFO which will be filled by the executor with the output
|
* Assign a ring buffer and a FIFO which will be filled by the executor with the output
|
@ -14,8 +14,15 @@ UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags,
|
|||||||
}
|
}
|
||||||
*fileDescriptor = open(device.c_str(), flags);
|
*fileDescriptor = open(device.c_str(), flags);
|
||||||
if (*fileDescriptor < 0) {
|
if (*fileDescriptor < 0) {
|
||||||
FSFW_LOGW("{} | Opening device failed with error code {} | {}\n", diagnosticPrefix, errno,
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << diagnosticPrefix << ": Opening device failed with error code " << errno << ": "
|
||||||
|
<< strerror(errno) << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("%s: Opening device failed with error code %d: %s\n", diagnosticPrefix, errno,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
openStatus = OPEN_FILE_FAILED;
|
openStatus = OPEN_FILE_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,10 +26,19 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
|
|||||||
std::string deviceFile;
|
std::string deviceFile;
|
||||||
|
|
||||||
if (cookie == nullptr) {
|
if (cookie == nullptr) {
|
||||||
FSFW_LOGE("{}", "initializeInterface: Invalid cookie\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "I2cComIF::initializeInterface: Invalid cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
I2cCookie* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||||
|
if (i2cCookie == nullptr) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "I2cComIF::initializeInterface: Invalid I2C cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
|
return NULLPOINTER;
|
||||||
|
}
|
||||||
|
|
||||||
i2cAddress = i2cCookie->getAddress();
|
i2cAddress = i2cCookie->getAddress();
|
||||||
|
|
||||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||||
@ -38,14 +47,20 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
|
|||||||
I2cInstance i2cInstance = {std::vector<uint8_t>(maxReplyLen), 0};
|
I2cInstance i2cInstance = {std::vector<uint8_t>(maxReplyLen), 0};
|
||||||
auto statusPair = i2cDeviceMap.emplace(i2cAddress, i2cInstance);
|
auto statusPair = i2cDeviceMap.emplace(i2cAddress, i2cInstance);
|
||||||
if (not statusPair.second) {
|
if (not statusPair.second) {
|
||||||
FSFW_LOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n",
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
i2cAddress);
|
sif::error << "I2cComIF::initializeInterface: Failed to insert device with address "
|
||||||
|
<< i2cAddress << "to I2C device "
|
||||||
|
<< "map" << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSFW_LOGE("initializeInterface: Device with address {} already in use\n", i2cAddress);
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "I2cComIF::initializeInterface: Device with address " << i2cAddress
|
||||||
|
<< "already in use" << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +70,9 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
|||||||
std::string deviceFile;
|
std::string deviceFile;
|
||||||
|
|
||||||
if (sendData == nullptr) {
|
if (sendData == nullptr) {
|
||||||
FSFW_LOGW("{}", "sendMessage: Send Data is nullptr\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "I2cComIF::sendMessage: Send Data is nullptr" << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,16 +80,21 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
I2cCookie* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||||
if (i2cCookie == nullptr) {
|
if (i2cCookie == nullptr) {
|
||||||
FSFW_LOGWT("{}", "sendMessage: Invalid I2C Cookie\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "I2cComIF::sendMessage: Invalid I2C Cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
address_t i2cAddress = i2cCookie->getAddress();
|
address_t i2cAddress = i2cCookie->getAddress();
|
||||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||||
FSFW_LOGWT("{}", "sendMessage: I2C address of cookie not registered in I2C device map\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not "
|
||||||
|
<< "registered in i2cDeviceMap" << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +109,11 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (write(fd, sendData, sendLen) != static_cast<int>(sendLen)) {
|
if (write(fd, sendData, sendLen) != static_cast<int>(sendLen)) {
|
||||||
FSFW_LOGE("sendMessage: Failed to send data to I2C device with error code {} | {}\n", errno,
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
strerror(errno));
|
sif::error << "I2cComIF::sendMessage: Failed to send data to I2C "
|
||||||
|
"device with error code "
|
||||||
|
<< errno << ". Error description: " << strerror(errno) << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,9 +135,11 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
I2cCookie* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||||
if (i2cCookie == nullptr) {
|
if (i2cCookie == nullptr) {
|
||||||
FSFW_LOGWT("{}", "requestReceiveMessage: Invalid I2C Cookie\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "I2cComIF::requestReceiveMessage: Invalid I2C Cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
i2cDeviceMapIter->second.replyLen = 0;
|
i2cDeviceMapIter->second.replyLen = 0;
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
@ -120,8 +147,10 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
|||||||
address_t i2cAddress = i2cCookie->getAddress();
|
address_t i2cAddress = i2cCookie->getAddress();
|
||||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||||
FSFW_LOGW("requestReceiveMessage: I2C address {} of Cookie not registered in i2cDeviceMap",
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
i2cAddress);
|
sif::error << "I2cComIF::requestReceiveMessage: i2cAddress of Cookie not "
|
||||||
|
<< "registered in i2cDeviceMap" << std::endl;
|
||||||
|
#endif
|
||||||
i2cDeviceMapIter->second.replyLen = 0;
|
i2cDeviceMapIter->second.replyLen = 0;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
@ -139,13 +168,20 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
|||||||
|
|
||||||
uint8_t* replyBuffer = i2cDeviceMapIter->second.replyBuffer.data();
|
uint8_t* replyBuffer = i2cDeviceMapIter->second.replyBuffer.data();
|
||||||
|
|
||||||
ssize_t readLen = read(fd, replyBuffer, requestLen);
|
int readLen = read(fd, replyBuffer, requestLen);
|
||||||
if (readLen != static_cast<int>(requestLen)) {
|
if (readLen != static_cast<int>(requestLen)) {
|
||||||
FSFW_LOGWT(
|
#if FSFW_VERBOSE_LEVEL >= 1 and FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
"requestReceiveMessage: Reading from I2C device failed with error code "
|
sif::error << "I2cComIF::requestReceiveMessage: Reading from I2C "
|
||||||
"{} | {}\nRead only {} from {} bytes\n",
|
<< "device failed with error code " << errno << ". Description"
|
||||||
errno, strerror(errno), readLen, requestLen);
|
<< " of error: " << strerror(errno) << std::endl;
|
||||||
|
sif::error << "I2cComIF::requestReceiveMessage: Read only " << readLen << " from " << requestLen
|
||||||
|
<< " bytes" << std::endl;
|
||||||
|
#endif
|
||||||
i2cDeviceMapIter->second.replyLen = 0;
|
i2cDeviceMapIter->second.replyLen = 0;
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen
|
||||||
|
<< " bytes" << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,17 +195,21 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
||||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
I2cCookie* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||||
if (i2cCookie == nullptr) {
|
if (i2cCookie == nullptr) {
|
||||||
FSFW_LOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "I2cComIF::readReceivedMessage: Invalid I2C Cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
address_t i2cAddress = i2cCookie->getAddress();
|
address_t i2cAddress = i2cCookie->getAddress();
|
||||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||||
FSFW_LOGE("readReceivedMessage: I2C address {} of cookie not found in I2C device map\n",
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
i2cAddress);
|
sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not "
|
||||||
|
<< "found in i2cDeviceMap" << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
*buffer = i2cDeviceMapIter->second.replyBuffer.data();
|
*buffer = i2cDeviceMapIter->second.replyBuffer.data();
|
||||||
@ -181,8 +221,16 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
|||||||
ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress,
|
ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress,
|
||||||
int* fileDescriptor) {
|
int* fileDescriptor) {
|
||||||
if (ioctl(*fileDescriptor, I2C_SLAVE, i2cAddress) < 0) {
|
if (ioctl(*fileDescriptor, I2C_SLAVE, i2cAddress) < 0) {
|
||||||
FSFW_LOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno,
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
strerror(errno));
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "I2cComIF: Specifying target device failed with error code " << errno << "."
|
||||||
|
<< std::endl;
|
||||||
|
sif::warning << "Error description " << strerror(errno) << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("I2cComIF: Specifying target device failed with error code %d.\n");
|
||||||
|
sif::printWarning("Error description: %s\n", strerror(errno));
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
@ -11,7 +11,6 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "fsfw/FSFW.h"
|
#include "fsfw/FSFW.h"
|
||||||
#include "fsfw/serviceinterface.h"
|
|
||||||
#include "fsfw_hal/linux/UnixFileGuard.h"
|
#include "fsfw_hal/linux/UnixFileGuard.h"
|
||||||
#include "fsfw_hal/linux/spi/SpiCookie.h"
|
#include "fsfw_hal/linux/spi/SpiCookie.h"
|
||||||
#include "fsfw_hal/linux/utility.h"
|
#include "fsfw_hal/linux/utility.h"
|
||||||
@ -19,7 +18,13 @@
|
|||||||
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF)
|
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF)
|
||||||
: SystemObject(objectId), gpioComIF(gpioComIF) {
|
: SystemObject(objectId), gpioComIF(gpioComIF) {
|
||||||
if (gpioComIF == nullptr) {
|
if (gpioComIF == nullptr) {
|
||||||
FSFW_LOGET("{}", "SpiComIF::SpiComIF: GPIO communication interface invalid\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "SpiComIF::SpiComIF: GPIO communication interface invalid!" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError("SpiComIF::SpiComIF: GPIO communication interface invalid!\n");
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
spiMutex = MutexFactory::instance()->createMutex();
|
spiMutex = MutexFactory::instance()->createMutex();
|
||||||
@ -27,7 +32,7 @@ SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF)
|
|||||||
|
|
||||||
ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
auto* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||||
if (spiCookie == nullptr) {
|
if (spiCookie == nullptr) {
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
@ -40,17 +45,30 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
|||||||
SpiInstance spiInstance(bufferSize);
|
SpiInstance spiInstance(bufferSize);
|
||||||
auto statusPair = spiDeviceMap.emplace(spiAddress, spiInstance);
|
auto statusPair = spiDeviceMap.emplace(spiAddress, spiInstance);
|
||||||
if (not statusPair.second) {
|
if (not statusPair.second) {
|
||||||
FSFW_LOGWT(
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
"SpiComIF::initializeInterface: Failed to insert device with address {} to SPI device "
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
"map\n",
|
sif::error << "SpiComIF::initializeInterface: Failed to insert device with address "
|
||||||
spiAddress);
|
<< spiAddress << "to SPI device map" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError(
|
||||||
|
"SpiComIF::initializeInterface: Failed to insert device with address "
|
||||||
|
"%lu to SPI device map\n",
|
||||||
|
static_cast<unsigned long>(spiAddress));
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
/* Now we emplaced the read buffer in the map, we still need to assign that location
|
/* Now we emplaced the read buffer in the map, we still need to assign that location
|
||||||
to the SPI driver transfer struct */
|
to the SPI driver transfer struct */
|
||||||
spiCookie->assignReadBuffer(statusPair.first->second.replyBuffer.data());
|
spiCookie->assignReadBuffer(statusPair.first->second.replyBuffer.data());
|
||||||
} else {
|
} else {
|
||||||
FSFW_LOGWT("{}", "initializeInterface: SPI address already exists\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "SpiComIF::initializeInterface: SPI address already exists!" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError("SpiComIF::initializeInterface: SPI address already exists!\n");
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +133,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) {
|
ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) {
|
||||||
auto* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
|
|
||||||
if (spiCookie == nullptr) {
|
if (spiCookie == nullptr) {
|
||||||
@ -123,9 +141,19 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sendLen > spiCookie->getMaxBufferSize()) {
|
if (sendLen > spiCookie->getMaxBufferSize()) {
|
||||||
FSFW_LOGW(
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
"sendMessage: Too much data sent, send length {} larger than maximum buffer length {}\n",
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
spiCookie->getMaxBufferSize(), sendLen);
|
sif::warning << "SpiComIF::sendMessage: Too much data sent, send length " << sendLen
|
||||||
|
<< "larger than maximum buffer length " << spiCookie->getMaxBufferSize()
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"SpiComIF::sendMessage: Too much data sent, send length %lu larger "
|
||||||
|
"than maximum buffer length %lu!\n",
|
||||||
|
static_cast<unsigned long>(sendLen),
|
||||||
|
static_cast<unsigned long>(spiCookie->getMaxBufferSize()));
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return DeviceCommunicationIF::TOO_MUCH_DATA;
|
return DeviceCommunicationIF::TOO_MUCH_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,12 +201,24 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
|||||||
if (gpioId != gpio::NO_GPIO) {
|
if (gpioId != gpio::NO_GPIO) {
|
||||||
result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
FSFW_LOGET("{}", "sendMessage: Failed to lock mutex\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError("SpiComIF::sendMessage: Failed to lock mutex\n");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = gpioComIF->pullLow(gpioId);
|
result = gpioComIF->pullLow(gpioId);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
FSFW_LOGW("{}", "sendMessage: Pulling low CS pin failed\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "SpiComIF::sendMessage: Pulling low CS pin failed" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("SpiComIF::sendMessage: Pulling low CS pin failed");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,7 +237,13 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
|||||||
} else {
|
} else {
|
||||||
/* We write with a blocking half-duplex transfer here */
|
/* We write with a blocking half-duplex transfer here */
|
||||||
if (write(fileDescriptor, sendData, sendLen) != static_cast<ssize_t>(sendLen)) {
|
if (write(fileDescriptor, sendData, sendLen) != static_cast<ssize_t>(sendLen)) {
|
||||||
FSFW_LOGET("{}", "sendMessage: Half-Duplex write operation failed\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "SpiComIF::sendMessage: Half-Duplex write operation failed!" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("SpiComIF::sendMessage: Half-Duplex write operation failed!\n");
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
result = HALF_DUPLEX_TRANSFER_FAILED;
|
result = HALF_DUPLEX_TRANSFER_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,7 +252,9 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
|||||||
gpioComIF->pullHigh(gpioId);
|
gpioComIF->pullHigh(gpioId);
|
||||||
result = spiMutex->unlockMutex();
|
result = spiMutex->unlockMutex();
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
FSFW_LOGWT("{}", "sendMessage: Failed to unlock mutex\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "SpiComIF::sendMessage: Failed to unlock mutex" << std::endl;
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +264,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
|||||||
ReturnValue_t SpiComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; }
|
ReturnValue_t SpiComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; }
|
||||||
|
|
||||||
ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
|
ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
|
||||||
auto* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||||
if (spiCookie == nullptr) {
|
if (spiCookie == nullptr) {
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
@ -248,14 +296,22 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
|
|||||||
if (gpioId != gpio::NO_GPIO) {
|
if (gpioId != gpio::NO_GPIO) {
|
||||||
result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
FSFW_LOGW("{}", "getSendSuccess: Failed to lock mutex\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "SpiComIF::getSendSuccess: Failed to lock mutex" << std::endl;
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
gpioComIF->pullLow(gpioId);
|
gpioComIF->pullLow(gpioId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read(fileDescriptor, rxBuf, readSize) != static_cast<ssize_t>(readSize)) {
|
if (read(fileDescriptor, rxBuf, readSize) != static_cast<ssize_t>(readSize)) {
|
||||||
FSFW_LOGW("{}", "sendMessage: Half-Duplex read operation failed\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "SpiComIF::sendMessage: Half-Duplex read operation failed!" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("SpiComIF::sendMessage: Half-Duplex read operation failed!\n");
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
result = HALF_DUPLEX_TRANSFER_FAILED;
|
result = HALF_DUPLEX_TRANSFER_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +319,9 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
|
|||||||
gpioComIF->pullHigh(gpioId);
|
gpioComIF->pullHigh(gpioId);
|
||||||
result = spiMutex->unlockMutex();
|
result = spiMutex->unlockMutex();
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
FSFW_LOGW("{}", "getSendSuccess: Failed to unlock mutex\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "SpiComIF::getSendSuccess: Failed to unlock mutex" << std::endl;
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,7 +330,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t SpiComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
ReturnValue_t SpiComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
||||||
auto* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||||
if (spiCookie == nullptr) {
|
if (spiCookie == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
@ -303,10 +361,16 @@ void SpiComIF::performSpiWiretapping(SpiCookie* spiCookie) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t dataLen = spiCookie->getTransferStructHandle()->len;
|
size_t dataLen = spiCookie->getTransferStructHandle()->len;
|
||||||
auto* dataPtr = reinterpret_cast<uint8_t*>(spiCookie->getTransferStructHandle()->tx_buf);
|
uint8_t* dataPtr = reinterpret_cast<uint8_t*>(spiCookie->getTransferStructHandle()->tx_buf);
|
||||||
sif::info("Sent SPI data:\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "Sent SPI data: " << std::endl;
|
||||||
arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false);
|
arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false);
|
||||||
sif::info("Received SPI data:\n");
|
sif::info << "Received SPI data: " << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("Sent SPI data: \n");
|
||||||
|
arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false);
|
||||||
|
sif::printInfo("Received SPI data: \n");
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
dataPtr = reinterpret_cast<uint8_t*>(spiCookie->getTransferStructHandle()->rx_buf);
|
dataPtr = reinterpret_cast<uint8_t*>(spiCookie->getTransferStructHandle()->rx_buf);
|
||||||
arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false);
|
arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false);
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
#include "UartComIF.h"
|
#include "UartComIF.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cerrno>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "fsfw/FSFW.h"
|
#include "fsfw/FSFW.h"
|
||||||
@ -23,9 +23,11 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
|
|||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||||
if (uartCookie == nullptr) {
|
if (uartCookie == nullptr) {
|
||||||
FSFW_LOGE("{}", "initializeInterface: Invalid UART Cookie\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "UartComIF::initializeInterface: Invalid UART Cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,12 +42,18 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
|
|||||||
size_t maxReplyLen = uartCookie->getMaxReplyLen();
|
size_t maxReplyLen = uartCookie->getMaxReplyLen();
|
||||||
UartElements uartElements = {fileDescriptor, std::vector<uint8_t>(maxReplyLen), 0};
|
UartElements uartElements = {fileDescriptor, std::vector<uint8_t>(maxReplyLen), 0};
|
||||||
auto status = uartDeviceMap.emplace(deviceFile, uartElements);
|
auto status = uartDeviceMap.emplace(deviceFile, uartElements);
|
||||||
if (!status.second) {
|
if (status.second == false) {
|
||||||
FSFW_LOGW("initializeInterface: Failed to insert device {} to UART device map\n", deviceFile);
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::initializeInterface: Failed to insert device " << deviceFile
|
||||||
|
<< "to UART device map" << std::endl;
|
||||||
|
#endif
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FSFW_LOGW("initializeInterface: UART device {} already in use\n", deviceFile);
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::initializeInterface: UART device " << deviceFile
|
||||||
|
<< " already in use" << std::endl;
|
||||||
|
#endif
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,14 +73,19 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
|
|||||||
int fd = open(deviceFile.c_str(), flags);
|
int fd = open(deviceFile.c_str(), flags);
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
FSFW_LOGW("configureUartPort: Failed to open UART {} with error code {} | {}\n", deviceFile,
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
errno, strerror(errno));
|
sif::warning << "UartComIF::configureUartPort: Failed to open uart " << deviceFile
|
||||||
|
<< "with error code " << errno << strerror(errno) << std::endl;
|
||||||
|
#endif
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read in existing settings */
|
/* Read in existing settings */
|
||||||
if (tcgetattr(fd, &options) != 0) {
|
if (tcgetattr(fd, &options) != 0) {
|
||||||
FSFW_LOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno));
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::configureUartPort: Error " << errno
|
||||||
|
<< "from tcgetattr: " << strerror(errno) << std::endl;
|
||||||
|
#endif
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +106,10 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
|
|||||||
|
|
||||||
/* Save option settings */
|
/* Save option settings */
|
||||||
if (tcsetattr(fd, TCSANOW, &options) != 0) {
|
if (tcsetattr(fd, TCSANOW, &options) != 0) {
|
||||||
FSFW_LOGW("configureUartPort: Failed to set options with error {} | {}\n", errno,
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
strerror(errno));
|
sif::warning << "UartComIF::configureUartPort: Failed to set options with error " << errno
|
||||||
|
<< ": " << strerror(errno);
|
||||||
|
#endif
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
return fd;
|
return fd;
|
||||||
@ -146,8 +161,9 @@ void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCook
|
|||||||
options->c_cflag |= CS8;
|
options->c_cflag |= CS8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FSFW_LOGW("setDatasizeOptions: Invalid size {} specified\n",
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
static_cast<unsigned int>(uartCookie->getBitsPerWord()));
|
sif::warning << "UartComIF::setDatasizeOptions: Invalid size specified" << std::endl;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,7 +316,9 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki
|
|||||||
break;
|
break;
|
||||||
#endif // ! __APPLE__
|
#endif // ! __APPLE__
|
||||||
default:
|
default:
|
||||||
FSFW_LOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::configureBaudrate: Baudrate not supported" << std::endl;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,27 +333,37 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sendData == nullptr) {
|
if (sendData == nullptr) {
|
||||||
FSFW_LOGWT("{}", "sendMessage: Send data is nullptr");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::sendMessage: Send data is nullptr" << std::endl;
|
||||||
|
#endif
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||||
if (uartCookie == nullptr) {
|
if (uartCookie == nullptr) {
|
||||||
FSFW_LOGWT("{}", "sendMessage: Invalid UART Cookie\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::sendMessasge: Invalid UART Cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceFile = uartCookie->getDeviceFile();
|
deviceFile = uartCookie->getDeviceFile();
|
||||||
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
||||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||||
FSFW_LOGWT("{}", "sendMessage: Device file {} not in UART map\n", deviceFile);
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "UartComIF::sendMessage: Device file " << deviceFile << "not in UART map"
|
||||||
|
<< std::endl;
|
||||||
|
#endif
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = uartDeviceMapIter->second.fileDescriptor;
|
fd = uartDeviceMapIter->second.fileDescriptor;
|
||||||
|
|
||||||
if (write(fd, sendData, sendLen) != static_cast<int>(sendLen)) {
|
if (write(fd, sendData, sendLen) != static_cast<int>(sendLen)) {
|
||||||
FSFW_LOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno));
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "UartComIF::sendMessage: Failed to send data with error code " << errno
|
||||||
|
<< ": Error description: " << strerror(errno) << std::endl;
|
||||||
|
#endif
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,9 +376,11 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
|
|||||||
std::string deviceFile;
|
std::string deviceFile;
|
||||||
UartDeviceMapIter uartDeviceMapIter;
|
UartDeviceMapIter uartDeviceMapIter;
|
||||||
|
|
||||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||||
if (uartCookie == nullptr) {
|
if (uartCookie == nullptr) {
|
||||||
FSFW_LOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "UartComIF::requestReceiveMessage: Invalid Uart Cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +393,10 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||||
FSFW_LOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile);
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "UartComIF::requestReceiveMessage: Device file " << deviceFile
|
||||||
|
<< " not in uart map" << std::endl;
|
||||||
|
#endif
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +414,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
|||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
uint8_t maxReadCycles = uartCookie.getReadCycles();
|
uint8_t maxReadCycles = uartCookie.getReadCycles();
|
||||||
uint8_t currentReadCycles = 0;
|
uint8_t currentReadCycles = 0;
|
||||||
ssize_t bytesRead = 0;
|
int bytesRead = 0;
|
||||||
size_t currentBytesRead = 0;
|
size_t currentBytesRead = 0;
|
||||||
size_t maxReplySize = uartCookie.getMaxReplyLen();
|
size_t maxReplySize = uartCookie.getMaxReplyLen();
|
||||||
int fd = iter->second.fileDescriptor;
|
int fd = iter->second.fileDescriptor;
|
||||||
@ -392,7 +425,16 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
|||||||
if (currentBytesRead >= maxReplySize) {
|
if (currentBytesRead >= maxReplySize) {
|
||||||
// Overflow risk. Emit warning, trigger event and break. If this happens,
|
// Overflow risk. Emit warning, trigger event and break. If this happens,
|
||||||
// the reception buffer is not large enough or data is not polled often enough.
|
// the reception buffer is not large enough or data is not polled often enough.
|
||||||
FSFW_LOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::requestReceiveMessage: Next read would cause overflow!"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"UartComIF::requestReceiveMessage: "
|
||||||
|
"Next read would cause overflow!");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
result = UART_RX_BUFFER_TOO_SMALL;
|
result = UART_RX_BUFFER_TOO_SMALL;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -403,7 +445,15 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
|||||||
if (bytesRead < 0) {
|
if (bytesRead < 0) {
|
||||||
// EAGAIN: No data available in non-blocking mode
|
// EAGAIN: No data available in non-blocking mode
|
||||||
if (errno != EAGAIN) {
|
if (errno != EAGAIN) {
|
||||||
FSFW_LOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno));
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::handleCanonicalRead: read failed with code" << errno << ": "
|
||||||
|
<< strerror(errno) << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("UartComIF::handleCanonicalRead: read failed with code %d: %s\n", errno,
|
||||||
|
strerror(errno));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,16 +473,27 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi
|
|||||||
auto bufferPtr = iter->second.replyBuffer.data();
|
auto bufferPtr = iter->second.replyBuffer.data();
|
||||||
// Size check to prevent buffer overflow
|
// Size check to prevent buffer overflow
|
||||||
if (requestLen > uartCookie.getMaxReplyLen()) {
|
if (requestLen > uartCookie.getMaxReplyLen()) {
|
||||||
FSFW_LOGW("{}", "requestReceiveMessage: Next read would cause overflow\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::requestReceiveMessage: Next read would cause overflow!"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"UartComIF::requestReceiveMessage: "
|
||||||
|
"Next read would cause overflow!");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
return UART_RX_BUFFER_TOO_SMALL;
|
return UART_RX_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
ssize_t bytesRead = read(fd, bufferPtr, requestLen);
|
int bytesRead = read(fd, bufferPtr, requestLen);
|
||||||
if (bytesRead < 0) {
|
if (bytesRead < 0) {
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
} else if (bytesRead != static_cast<int>(requestLen)) {
|
} else if (bytesRead != static_cast<int>(requestLen)) {
|
||||||
if (uartCookie.isReplySizeFixed()) {
|
if (uartCookie.isReplySizeFixed()) {
|
||||||
FSFW_LOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead,
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
requestLen);
|
sif::warning << "UartComIF::requestReceiveMessage: Only read " << bytesRead << " of "
|
||||||
|
<< requestLen << " bytes" << std::endl;
|
||||||
|
#endif
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,16 +505,21 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
|||||||
std::string deviceFile;
|
std::string deviceFile;
|
||||||
UartDeviceMapIter uartDeviceMapIter;
|
UartDeviceMapIter uartDeviceMapIter;
|
||||||
|
|
||||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||||
if (uartCookie == nullptr) {
|
if (uartCookie == nullptr) {
|
||||||
FSFW_LOGWT("{}", "readReceivedMessage: Invalid uart cookie");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "UartComIF::readReceivedMessage: Invalid uart cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceFile = uartCookie->getDeviceFile();
|
deviceFile = uartCookie->getDeviceFile();
|
||||||
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
||||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||||
FSFW_LOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile);
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "UartComIF::readReceivedMessage: Device file " << deviceFile << " not in uart map"
|
||||||
|
<< std::endl;
|
||||||
|
#endif
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,9 +535,11 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
|||||||
ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
|
ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
|
||||||
std::string deviceFile;
|
std::string deviceFile;
|
||||||
UartDeviceMapIter uartDeviceMapIter;
|
UartDeviceMapIter uartDeviceMapIter;
|
||||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||||
if (uartCookie == nullptr) {
|
if (uartCookie == nullptr) {
|
||||||
FSFW_LOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::flushUartRxBuffer: Invalid uart cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
deviceFile = uartCookie->getDeviceFile();
|
deviceFile = uartCookie->getDeviceFile();
|
||||||
@ -487,9 +555,11 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
|
|||||||
ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
|
ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
|
||||||
std::string deviceFile;
|
std::string deviceFile;
|
||||||
UartDeviceMapIter uartDeviceMapIter;
|
UartDeviceMapIter uartDeviceMapIter;
|
||||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||||
if (uartCookie == nullptr) {
|
if (uartCookie == nullptr) {
|
||||||
FSFW_LOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::flushUartTxBuffer: Invalid uart cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
deviceFile = uartCookie->getDeviceFile();
|
deviceFile = uartCookie->getDeviceFile();
|
||||||
@ -505,9 +575,11 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
|
|||||||
ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
|
ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
|
||||||
std::string deviceFile;
|
std::string deviceFile;
|
||||||
UartDeviceMapIter uartDeviceMapIter;
|
UartDeviceMapIter uartDeviceMapIter;
|
||||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||||
if (uartCookie == nullptr) {
|
if (uartCookie == nullptr) {
|
||||||
FSFW_LOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "UartComIF::flushUartTxAndRxBuf: Invalid uart cookie!" << std::endl;
|
||||||
|
#endif
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
deviceFile = uartCookie->getDeviceFile();
|
deviceFile = uartCookie->getDeviceFile();
|
@ -90,7 +90,7 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject {
|
|||||||
* parity settings.
|
* parity settings.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void setParityOptions(struct termios* options, UartCookie* uartCookie);
|
void setParityOptions(struct termios* options, UartCookie* uartCookie);
|
||||||
|
|
||||||
void setStopBitOptions(struct termios* options, UartCookie* uartCookie);
|
void setStopBitOptions(struct termios* options, UartCookie* uartCookie);
|
||||||
|
|
@ -12,7 +12,7 @@ enum class StopBits { ONE_STOP_BIT, TWO_STOP_BITS };
|
|||||||
|
|
||||||
enum class UartModes { CANONICAL, NON_CANONICAL };
|
enum class UartModes { CANONICAL, NON_CANONICAL };
|
||||||
|
|
||||||
enum class BitsPerWord : unsigned int { BITS_5 = 5, BITS_6 = 6, BITS_7 = 7, BITS_8 = 8 };
|
enum class BitsPerWord { BITS_5, BITS_6, BITS_7, BITS_8 };
|
||||||
|
|
||||||
enum class UartBaudRate {
|
enum class UartBaudRate {
|
||||||
RATE_50,
|
RATE_50,
|
23
hal/src/fsfw_hal/linux/utility.cpp
Normal file
23
hal/src/fsfw_hal/linux/utility.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "fsfw_hal/linux/utility.h"
|
||||||
|
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "fsfw/FSFW.h"
|
||||||
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
|
void utility::handleIoctlError(const char* const customPrintout) {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
if (customPrintout != nullptr) {
|
||||||
|
sif::warning << customPrintout << std::endl;
|
||||||
|
}
|
||||||
|
sif::warning << "handleIoctlError: Error code " << errno << ", " << strerror(errno) << std::endl;
|
||||||
|
#else
|
||||||
|
if (customPrintout != nullptr) {
|
||||||
|
sif::printWarning("%s\n", customPrintout);
|
||||||
|
}
|
||||||
|
sif::printWarning("handleIoctlError: Error code %d, %s\n", errno, strerror(errno));
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
|
}
|
@ -48,20 +48,6 @@ def main():
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help="Run valgrind on generated test binary",
|
help="Run valgrind on generated test binary",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"-g",
|
|
||||||
"--generators",
|
|
||||||
default = "Ninja",
|
|
||||||
action="store",
|
|
||||||
help="CMake generators",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-w",
|
|
||||||
"--windows",
|
|
||||||
default=False,
|
|
||||||
action="store_true",
|
|
||||||
help="Run on windows",
|
|
||||||
)
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.all:
|
if args.all:
|
||||||
@ -129,14 +115,14 @@ def handle_tests_type(args, build_dir_list: list):
|
|||||||
if args.create:
|
if args.create:
|
||||||
if os.path.exists(UNITTEST_FOLDER_NAME):
|
if os.path.exists(UNITTEST_FOLDER_NAME):
|
||||||
shutil.rmtree(UNITTEST_FOLDER_NAME)
|
shutil.rmtree(UNITTEST_FOLDER_NAME)
|
||||||
create_tests_build_cfg(args)
|
create_tests_build_cfg()
|
||||||
build_directory = UNITTEST_FOLDER_NAME
|
build_directory = UNITTEST_FOLDER_NAME
|
||||||
elif len(build_dir_list) == 0:
|
elif len(build_dir_list) == 0:
|
||||||
print(
|
print(
|
||||||
"No valid CMake tests build directory found. "
|
"No valid CMake tests build directory found. "
|
||||||
"Trying to set up test build system"
|
"Trying to set up test build system"
|
||||||
)
|
)
|
||||||
create_tests_build_cfg(args)
|
create_tests_build_cfg()
|
||||||
build_directory = UNITTEST_FOLDER_NAME
|
build_directory = UNITTEST_FOLDER_NAME
|
||||||
elif len(build_dir_list) == 1:
|
elif len(build_dir_list) == 1:
|
||||||
build_directory = build_dir_list[0]
|
build_directory = build_dir_list[0]
|
||||||
@ -161,15 +147,10 @@ def handle_tests_type(args, build_dir_list: list):
|
|||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
|
|
||||||
|
|
||||||
def create_tests_build_cfg(args):
|
def create_tests_build_cfg():
|
||||||
os.mkdir(UNITTEST_FOLDER_NAME)
|
os.mkdir(UNITTEST_FOLDER_NAME)
|
||||||
os.chdir(UNITTEST_FOLDER_NAME)
|
os.chdir(UNITTEST_FOLDER_NAME)
|
||||||
if args.windows:
|
cmd_runner("cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..")
|
||||||
cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON \
|
|
||||||
-DGCOVR_PATH="py -m gcovr" ..'
|
|
||||||
else:
|
|
||||||
cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON ..'
|
|
||||||
cmd_runner(cmake_cmd)
|
|
||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,8 +4,3 @@ target_include_directories(${LIB_FSFW_NAME}
|
|||||||
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
add_subdirectory(fsfw)
|
add_subdirectory(fsfw)
|
||||||
if(FSFW_ADD_HAL)
|
|
||||||
add_subdirectory(fsfw_hal)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory(fsfw_tests)
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "fsfw/action.h"
|
#include "fsfw/action.h"
|
||||||
#include "fsfw/ipc/MessageQueueSenderIF.h"
|
#include "fsfw/ipc/MessageQueueSenderIF.h"
|
||||||
#include "fsfw/objectmanager/ObjectManager.h"
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
#include "fsfw/serviceinterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue)
|
ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue)
|
||||||
: owner(setOwner), queueToUse(useThisQueue) {}
|
: owner(setOwner), queueToUse(useThisQueue) {}
|
||||||
@ -28,7 +28,13 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (queueToUse == nullptr) {
|
if (queueToUse == nullptr) {
|
||||||
FSFW_LOGW("{}", "initialize: No queue set\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "ActionHelper::initialize: No queue set" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("ActionHelper::initialize: No queue set\n");
|
||||||
|
#endif
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +96,14 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep
|
|||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize, &dataPtr);
|
ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize, &dataPtr);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
FSFW_LOGWT("{}", "reportData: Getting free element from IPC store failed\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "ActionHelper::reportData: Getting free element from IPC store failed!"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"ActionHelper::reportData: Getting free element from IPC "
|
||||||
|
"store failed!\n");
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG);
|
result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||||
@ -125,7 +138,11 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep
|
|||||||
store_address_t storeAddress;
|
store_address_t storeAddress;
|
||||||
ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize);
|
ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
FSFW_LOGWT("{}", "reportData: Adding data to IPC store failed\n");
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "ActionHelper::reportData: Adding data to IPC store failed!" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("ActionHelper::reportData: Adding data to IPC store failed!\n");
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "fsfw/ipc/CommandMessage.h"
|
#include "fsfw/ipc/CommandMessage.h"
|
||||||
#include "fsfw/ipc/QueueFactory.h"
|
#include "fsfw/ipc/QueueFactory.h"
|
||||||
#include "fsfw/objectmanager/ObjectManager.h"
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
#include "fsfw/serviceinterface.h"
|
|
||||||
#include "fsfw/storagemanager/storeAddress.h"
|
#include "fsfw/storagemanager/storeAddress.h"
|
||||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||||
|
|
||||||
@ -29,7 +28,13 @@ ReturnValue_t CFDPHandler::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) {
|
ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) {
|
||||||
FSFW_LOGDT("{}", "CFDPHandler::handleRequest\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "CFDPHandler::handleRequest" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug("CFDPHandler::handleRequest\n");
|
||||||
|
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO read out packet from store using storeId
|
// TODO read out packet from store using storeId
|
||||||
|
|
||||||
|
@ -13,10 +13,12 @@ AckInfo::AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCode ackedC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AckInfo::AckInfo() = default;
|
||||||
|
|
||||||
cfdp::ConditionCode AckInfo::getAckedConditionCode() const { return ackedConditionCode; }
|
cfdp::ConditionCode AckInfo::getAckedConditionCode() const { return ackedConditionCode; }
|
||||||
|
|
||||||
void AckInfo::setAckedConditionCode(cfdp::ConditionCode ackedConditionCode) {
|
void AckInfo::setAckedConditionCode(cfdp::ConditionCode ackedConditionCode_) {
|
||||||
this->ackedConditionCode = ackedConditionCode;
|
ackedConditionCode = ackedConditionCode_;
|
||||||
if (ackedDirective == cfdp::FileDirectives::FINISH) {
|
if (ackedDirective == cfdp::FileDirectives::FINISH) {
|
||||||
this->directiveSubtypeCode = 0b0001;
|
this->directiveSubtypeCode = 0b0001;
|
||||||
} else {
|
} else {
|
||||||
@ -26,20 +28,18 @@ void AckInfo::setAckedConditionCode(cfdp::ConditionCode ackedConditionCode) {
|
|||||||
|
|
||||||
cfdp::FileDirectives AckInfo::getAckedDirective() const { return ackedDirective; }
|
cfdp::FileDirectives AckInfo::getAckedDirective() const { return ackedDirective; }
|
||||||
|
|
||||||
void AckInfo::setAckedDirective(cfdp::FileDirectives ackedDirective) {
|
void AckInfo::setAckedDirective(cfdp::FileDirectives ackedDirective_) {
|
||||||
this->ackedDirective = ackedDirective;
|
ackedDirective = ackedDirective_;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t AckInfo::getDirectiveSubtypeCode() const { return directiveSubtypeCode; }
|
uint8_t AckInfo::getDirectiveSubtypeCode() const { return directiveSubtypeCode; }
|
||||||
|
|
||||||
void AckInfo::setDirectiveSubtypeCode(uint8_t directiveSubtypeCode) {
|
void AckInfo::setDirectiveSubtypeCode(uint8_t directiveSubtypeCode_) {
|
||||||
this->directiveSubtypeCode = directiveSubtypeCode;
|
directiveSubtypeCode = directiveSubtypeCode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdp::AckTransactionStatus AckInfo::getTransactionStatus() const { return transactionStatus; }
|
cfdp::AckTransactionStatus AckInfo::getTransactionStatus() const { return transactionStatus; }
|
||||||
|
|
||||||
AckInfo::AckInfo() {}
|
void AckInfo::setTransactionStatus(cfdp::AckTransactionStatus transactionStatus_) {
|
||||||
|
transactionStatus = transactionStatus_;
|
||||||
void AckInfo::setTransactionStatus(cfdp::AckTransactionStatus transactionStatus) {
|
|
||||||
this->transactionStatus = transactionStatus;
|
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,16 @@ class AckInfo {
|
|||||||
AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCode ackedConditionCode,
|
AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCode ackedConditionCode,
|
||||||
cfdp::AckTransactionStatus transactionStatus, uint8_t directiveSubtypeCode = 0);
|
cfdp::AckTransactionStatus transactionStatus, uint8_t directiveSubtypeCode = 0);
|
||||||
|
|
||||||
cfdp::ConditionCode getAckedConditionCode() const;
|
[[nodiscard]] cfdp::ConditionCode getAckedConditionCode() const;
|
||||||
void setAckedConditionCode(cfdp::ConditionCode ackedConditionCode);
|
void setAckedConditionCode(cfdp::ConditionCode ackedConditionCode_);
|
||||||
|
|
||||||
cfdp::FileDirectives getAckedDirective() const;
|
[[nodiscard]] cfdp::FileDirectives getAckedDirective() const;
|
||||||
void setAckedDirective(cfdp::FileDirectives ackedDirective);
|
void setAckedDirective(cfdp::FileDirectives ackedDirective);
|
||||||
|
|
||||||
uint8_t getDirectiveSubtypeCode() const;
|
[[nodiscard]] uint8_t getDirectiveSubtypeCode() const;
|
||||||
void setDirectiveSubtypeCode(uint8_t directiveSubtypeCode);
|
void setDirectiveSubtypeCode(uint8_t directiveSubtypeCode);
|
||||||
|
|
||||||
cfdp::AckTransactionStatus getTransactionStatus() const;
|
[[nodiscard]] cfdp::AckTransactionStatus getTransactionStatus() const;
|
||||||
void setTransactionStatus(cfdp::AckTransactionStatus transactionStatus);
|
void setTransactionStatus(cfdp::AckTransactionStatus transactionStatus);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -13,7 +13,7 @@ class AckPduDeserializer : public FileDirectiveDeserializer {
|
|||||||
* @return
|
* @return
|
||||||
* - cfdp::INVALID_DIRECTIVE_FIELDS: Invalid fields
|
* - cfdp::INVALID_DIRECTIVE_FIELDS: Invalid fields
|
||||||
*/
|
*/
|
||||||
ReturnValue_t parseData();
|
ReturnValue_t parseData() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkAndSetCodes(uint8_t rawAckedByte, uint8_t rawAckedConditionCode);
|
bool checkAndSetCodes(uint8_t rawAckedByte, uint8_t rawAckedConditionCode);
|
||||||
|
@ -18,7 +18,7 @@ class AckPduSerializer : public FileDirectiveSerializer {
|
|||||||
*/
|
*/
|
||||||
AckPduSerializer(AckInfo& ackInfo, PduConfig& pduConf);
|
AckPduSerializer(AckInfo& ackInfo, PduConfig& pduConf);
|
||||||
|
|
||||||
size_t getSerializedSize() const override;
|
[[nodiscard]] size_t getSerializedSize() const override;
|
||||||
|
|
||||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
Endianness streamEndianness) const override;
|
Endianness streamEndianness) const override;
|
||||||
|
@ -50,9 +50,17 @@ ReturnValue_t EofPduDeserializer::parseData() {
|
|||||||
if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) {
|
if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) {
|
||||||
EntityIdTlv* tlvPtr = info.getFaultLoc();
|
EntityIdTlv* tlvPtr = info.getFaultLoc();
|
||||||
if (tlvPtr == nullptr) {
|
if (tlvPtr == nullptr) {
|
||||||
FSFW_LOGW("{}",
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
"parseData: Ca not deserialize fault location,"
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
" given TLV pointer invalid\n");
|
sif::warning << "EofPduDeserializer::parseData: Ca not deserialize fault location,"
|
||||||
|
" given TLV pointer invalid"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"EofPduDeserializer::parseData: Ca not deserialize fault location,"
|
||||||
|
" given TLV pointer invalid");
|
||||||
|
#endif
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
result = tlvPtr->deSerialize(&bufPtr, &deserLen, endianness);
|
result = tlvPtr->deSerialize(&bufPtr, &deserLen, endianness);
|
||||||
|
@ -7,7 +7,13 @@
|
|||||||
cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, size_t value) : VarLenField() {
|
cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, size_t value) : VarLenField() {
|
||||||
ReturnValue_t result = this->setValue(width, value);
|
ReturnValue_t result = this->setValue(width, value);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
FSFW_LOGW("{}", "cfdp::VarLenField: Setting value failed\n");
|
#if FSFW_DISABLE_PRINTOUT == 0
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "cfdp::VarLenField: Setting value failed" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("cfdp::VarLenField: Setting value failed\n");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <fsfw/cfdp/tlv/Tlv.h>
|
#include <fsfw/cfdp/tlv/Tlv.h>
|
||||||
#include <fsfw/cfdp/tlv/TlvIF.h>
|
#include <fsfw/cfdp/tlv/TlvIF.h>
|
||||||
#include <fsfw/serialize/SerializeIF.h>
|
#include <fsfw/serialize/SerializeIF.h>
|
||||||
#include <fsfw/serviceinterface.h>
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -128,7 +128,17 @@ class FilestoreTlvBase : public TlvIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void secondFileNameMissing() const {
|
void secondFileNameMissing() const {
|
||||||
FSFW_LOGWT("{}", "secondFileNameMissing: Second file name required but TLV pointer not set\n");
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "FilestoreRequestTlv::deSerialize: Second file name required"
|
||||||
|
" but TLV pointer not set"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"FilestoreRequestTlv::deSerialize: Second file name required"
|
||||||
|
" but TLV pointer not set\n");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
FilestoreActionCode getActionCode() const { return actionCode; }
|
FilestoreActionCode getActionCode() const { return actionCode; }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "fsfw/datalinklayer/Clcw.h"
|
#include "fsfw/datalinklayer/Clcw.h"
|
||||||
|
|
||||||
#include "fsfw/serviceinterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
Clcw::Clcw() {
|
Clcw::Clcw() {
|
||||||
content.raw = 0;
|
content.raw = 0;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user