Merge branch 'eive/develop' into meier/uioMapper
This commit is contained in:
commit
faf7da2743
7
.clang-format
Normal file
7
.clang-format
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
BasedOnStyle: Google
|
||||||
|
IndentWidth: 2
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
ColumnLimit: 100
|
||||||
|
---
|
@ -4,6 +4,9 @@ set(FSFW_VERSION 2)
|
|||||||
set(FSFW_SUBVERSION 0)
|
set(FSFW_SUBVERSION 0)
|
||||||
set(FSFW_REVISION 0)
|
set(FSFW_REVISION 0)
|
||||||
|
|
||||||
|
# Add the cmake folder so the FindSphinx module is found
|
||||||
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
option(FSFW_GENERATE_SECTIONS
|
option(FSFW_GENERATE_SECTIONS
|
||||||
"Generate function and data sections. Required to remove unused code" ON
|
"Generate function and data sections. Required to remove unused code" ON
|
||||||
)
|
)
|
||||||
@ -12,6 +15,7 @@ if(FSFW_GENERATE_SECTIONS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(FSFW_BUILD_UNITTESTS "Build unittest binary in addition to static library" OFF)
|
option(FSFW_BUILD_UNITTESTS "Build unittest binary in addition to static library" OFF)
|
||||||
|
option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF)
|
||||||
if(FSFW_BUILD_UNITTESTS)
|
if(FSFW_BUILD_UNITTESTS)
|
||||||
option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON)
|
option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON)
|
||||||
endif()
|
endif()
|
||||||
@ -36,7 +40,9 @@ option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF)
|
|||||||
|
|
||||||
set(LIB_FSFW_NAME fsfw)
|
set(LIB_FSFW_NAME fsfw)
|
||||||
set(FSFW_TEST_TGT fsfw-tests)
|
set(FSFW_TEST_TGT fsfw-tests)
|
||||||
|
set(FSFW_DUMMY_TGT fsfw-dummy)
|
||||||
|
|
||||||
|
project(${LIB_FSFW_NAME})
|
||||||
add_library(${LIB_FSFW_NAME})
|
add_library(${LIB_FSFW_NAME})
|
||||||
|
|
||||||
if(FSFW_BUILD_UNITTESTS)
|
if(FSFW_BUILD_UNITTESTS)
|
||||||
@ -59,7 +65,6 @@ if(FSFW_BUILD_UNITTESTS)
|
|||||||
set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg)
|
set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg)
|
||||||
configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h)
|
configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h)
|
||||||
configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in tests/TestsConfig.h)
|
configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in tests/TestsConfig.h)
|
||||||
configure_file(tests/src/fsfw_tests/unit/testcfg/OBSWConfig.h.in OBSWConfig.h)
|
|
||||||
|
|
||||||
project(${FSFW_TEST_TGT} CXX C)
|
project(${FSFW_TEST_TGT} CXX C)
|
||||||
add_executable(${FSFW_TEST_TGT})
|
add_executable(${FSFW_TEST_TGT})
|
||||||
@ -147,7 +152,7 @@ else()
|
|||||||
set(OS_FSFW "host")
|
set(OS_FSFW "host")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FSFW_BUILD_UNITTESTS)
|
if(FSFW_BUILD_UNITTESTS OR FSFW_BUILD_DOCS)
|
||||||
configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h)
|
configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h)
|
||||||
configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h)
|
configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h)
|
||||||
else()
|
else()
|
||||||
@ -163,6 +168,9 @@ if(FSFW_ADD_HAL)
|
|||||||
add_subdirectory(hal)
|
add_subdirectory(hal)
|
||||||
endif()
|
endif()
|
||||||
add_subdirectory(contrib)
|
add_subdirectory(contrib)
|
||||||
|
if(FSFW_BUILD_DOCS)
|
||||||
|
add_subdirectory(docs)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(FSFW_BUILD_UNITTESTS)
|
if(FSFW_BUILD_UNITTESTS)
|
||||||
if(FSFW_TESTS_GEN_COV)
|
if(FSFW_TESTS_GEN_COV)
|
||||||
@ -234,9 +242,11 @@ endif()
|
|||||||
# The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it.
|
# The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it.
|
||||||
# If this is not given, we include the default configuration and emit a warning.
|
# If this is not given, we include the default configuration and emit a warning.
|
||||||
if(NOT FSFW_CONFIG_PATH)
|
if(NOT FSFW_CONFIG_PATH)
|
||||||
message(WARNING "Flight Software Framework configuration path not set!")
|
|
||||||
set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig)
|
set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig)
|
||||||
message(WARNING "Setting default configuration from ${DEF_CONF_PATH} ..")
|
if(NOT FSFW_BUILD_DOCS)
|
||||||
|
message(WARNING "Flight Software Framework configuration path not set!")
|
||||||
|
message(WARNING "Setting default configuration from ${DEF_CONF_PATH} ..")
|
||||||
|
endif()
|
||||||
add_subdirectory(${DEF_CONF_PATH})
|
add_subdirectory(${DEF_CONF_PATH})
|
||||||
set(FSFW_CONFIG_PATH ${DEF_CONF_PATH})
|
set(FSFW_CONFIG_PATH ${DEF_CONF_PATH})
|
||||||
endif()
|
endif()
|
||||||
|
24
README.md
24
README.md
@ -42,7 +42,7 @@ There are some functions like `printChar` which are different depending on the t
|
|||||||
and need to be implemented by the mission developer.
|
and need to be implemented by the mission developer.
|
||||||
|
|
||||||
A template configuration folder was provided and can be copied into the project root to have
|
A template configuration folder was provided and can be copied into the project root to have
|
||||||
a starting point. The [configuration section](doc/README-config.md#top) provides more specific
|
a starting point. The [configuration section](docs/README-config.md#top) provides more specific
|
||||||
information about the possible options.
|
information about the possible options.
|
||||||
|
|
||||||
## Adding the library
|
## Adding the library
|
||||||
@ -107,16 +107,22 @@ cmake --build . -- fsfw-tests_coverage -j
|
|||||||
|
|
||||||
The `coverage.py` script located in the `script` folder can also be used to do this conveniently.
|
The `coverage.py` script located in the `script` folder can also be used to do this conveniently.
|
||||||
|
|
||||||
|
## Formatting the sources
|
||||||
|
|
||||||
|
The formatting is done by the `clang-format` tool. The configuration is contained within the
|
||||||
|
`.clang-format` file in the repository root. As long as `clang-format` is installed, you
|
||||||
|
can run the `apply-clang-format.sh` helper script to format all source files consistently.
|
||||||
|
|
||||||
## Index
|
## Index
|
||||||
|
|
||||||
[1. High-level overview](doc/README-highlevel.md#top) <br>
|
[1. High-level overview](docs/README-highlevel.md#top) <br>
|
||||||
[2. Core components](doc/README-core.md#top) <br>
|
[2. Core components](docs/README-core.md#top) <br>
|
||||||
[3. Configuration](doc/README-config.md#top) <br>
|
[3. Configuration](docs/README-config.md#top) <br>
|
||||||
[4. OSAL overview](doc/README-osal.md#top) <br>
|
[4. OSAL overview](docs/README-osal.md#top) <br>
|
||||||
[5. PUS services](doc/README-pus.md#top) <br>
|
[5. PUS services](docs/README-pus.md#top) <br>
|
||||||
[6. Device Handler overview](doc/README-devicehandlers.md#top) <br>
|
[6. Device Handler overview](docs/README-devicehandlers.md#top) <br>
|
||||||
[7. Controller overview](doc/README-controllers.md#top) <br>
|
[7. Controller overview](docs/README-controllers.md#top) <br>
|
||||||
[8. Local Data Pools](doc/README-localpools.md#top) <br>
|
[8. Local Data Pools](docs/README-localpools.md#top) <br>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
13
cmake/FindSphinx.cmake
Normal file
13
cmake/FindSphinx.cmake
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Look for an executable called sphinx-build
|
||||||
|
find_program(SPHINX_EXECUTABLE
|
||||||
|
NAMES sphinx-build
|
||||||
|
DOC "Path to sphinx-build executable")
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
# Handle standard arguments to find_package like REQUIRED and QUIET
|
||||||
|
find_package_handle_standard_args(
|
||||||
|
Sphinx
|
||||||
|
"Failed to find sphinx-build executable"
|
||||||
|
SPHINX_EXECUTABLE
|
||||||
|
)
|
66
docs/CMakeLists.txt
Normal file
66
docs/CMakeLists.txt
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
# This is based on this excellent posting provided by Sy:
|
||||||
|
# https://devblogs.microsoft.com/cppblog/clear-functional-c-documentation-with-sphinx-breathe-doxygen-cmake/
|
||||||
|
find_package(Doxygen REQUIRED)
|
||||||
|
find_package(Sphinx REQUIRED)
|
||||||
|
|
||||||
|
get_target_property(LIB_FSFW_PUBLIC_HEADER_DIRS ${LIB_FSFW_NAME} INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
# TODO: Add HAL as well
|
||||||
|
file(GLOB_RECURSE LIB_FSFW_PUBLIC_HEADERS ${PROJECT_SOURCE_DIR}/src/*.h)
|
||||||
|
file(GLOB_RECURSE RST_DOC_FILES ${PROJECT_SOURCE_DIR}/docs/*.rst)
|
||||||
|
|
||||||
|
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/src)
|
||||||
|
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
|
||||||
|
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml)
|
||||||
|
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
|
||||||
|
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||||
|
|
||||||
|
# Replace variables inside @@ with the current values
|
||||||
|
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
|
||||||
|
|
||||||
|
# Doxygen won't create this for us
|
||||||
|
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
|
||||||
|
|
||||||
|
# Only regenerate Doxygen when the Doxyfile or public headers change
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${DOXYGEN_INDEX_FILE}
|
||||||
|
DEPENDS ${LIB_FSFW_PUBLIC_HEADERS}
|
||||||
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
|
||||||
|
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
|
||||||
|
COMMENT "Generating docs"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
|
||||||
|
# Nice named target so we can run the job easily
|
||||||
|
add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE})
|
||||||
|
|
||||||
|
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/sphinx)
|
||||||
|
set(SPHINX_INDEX_FILE ${SPHINX_BUILD}/index.html)
|
||||||
|
|
||||||
|
# Only regenerate Sphinx when:
|
||||||
|
# - Doxygen has rerun
|
||||||
|
# - Our doc files have been updated
|
||||||
|
# - The Sphinx config has been updated
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${SPHINX_INDEX_FILE}
|
||||||
|
COMMAND
|
||||||
|
${SPHINX_EXECUTABLE} -b html
|
||||||
|
# Tell Breathe where to find the Doxygen output
|
||||||
|
-Dbreathe_projects.fsfw=${DOXYGEN_OUTPUT_DIR}/xml
|
||||||
|
${SPHINX_SOURCE} ${SPHINX_BUILD}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
DEPENDS
|
||||||
|
# Other docs files you want to track should go here (or in some variable)
|
||||||
|
${RST_DOC_FILES}
|
||||||
|
${DOXYGEN_INDEX_FILE}
|
||||||
|
MAIN_DEPENDENCY ${SPHINX_SOURCE}/conf.py
|
||||||
|
COMMENT "Generating documentation with Sphinx"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Nice named target so we can run the job easily
|
||||||
|
add_custom_target(Sphinx ALL DEPENDS ${SPHINX_INDEX_FILE})
|
||||||
|
|
||||||
|
# Add an install target to install the docs
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
install(DIRECTORY ${SPHINX_BUILD}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
7
docs/Doxyfile.in
Normal file
7
docs/Doxyfile.in
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
INPUT = "@DOXYGEN_INPUT_DIR@"
|
||||||
|
|
||||||
|
RECURSIVE = YES
|
||||||
|
|
||||||
|
OUTPUT_DIRECTORY = "@DOXYGEN_OUTPUT_DIR@"
|
||||||
|
|
||||||
|
GENERATE_XML = YES
|
20
docs/Makefile
Normal file
20
docs/Makefile
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Minimal makefile for Sphinx documentation
|
||||||
|
#
|
||||||
|
|
||||||
|
# You can set these variables from the command line, and also
|
||||||
|
# from the environment for the first two.
|
||||||
|
SPHINXOPTS ?=
|
||||||
|
SPHINXBUILD ?= sphinx-build
|
||||||
|
SOURCEDIR = .
|
||||||
|
BUILDDIR = _build
|
||||||
|
|
||||||
|
# Put it first so that "make" without argument is like "make help".
|
||||||
|
help:
|
||||||
|
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
|
|
||||||
|
.PHONY: help Makefile
|
||||||
|
|
||||||
|
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||||
|
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||||
|
%: Makefile
|
||||||
|
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
@ -31,7 +31,9 @@ cohesive pool variables. These sets simply iterator over the list of variables a
|
|||||||
`read` and `commit` functions of each variable. The following diagram shows the
|
`read` and `commit` functions of each variable. The following diagram shows the
|
||||||
high-level architecture of the local data pools.
|
high-level architecture of the local data pools.
|
||||||
|
|
||||||
<img align="center" src="./images/PoolArchitecture.png" width="50%"> <br>
|
.. image:: ../misc/logo/FSFW_Logo_V3_bw.png
|
||||||
|
:alt: FSFW Logo
|
||||||
|
|
||||||
|
|
||||||
An example is shown for using the local data pools with a Gyroscope.
|
An example is shown for using the local data pools with a Gyroscope.
|
||||||
For example, the following code shows an implementation to access data from a Gyroscope taken
|
For example, the following code shows an implementation to access data from a Gyroscope taken
|
16
docs/api.rst
Normal file
16
docs/api.rst
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
API
|
||||||
|
====
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 4
|
||||||
|
|
||||||
|
api/objectmanager
|
||||||
|
api/task
|
||||||
|
api/ipc
|
||||||
|
api/returnvalue
|
||||||
|
api/event
|
||||||
|
api/modes
|
||||||
|
api/health
|
||||||
|
api/action
|
||||||
|
api/devicehandler
|
||||||
|
api/controller
|
15
docs/api/action.rst
Normal file
15
docs/api/action.rst
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
Action Module API
|
||||||
|
=================
|
||||||
|
|
||||||
|
``ActionHelper``
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
.. doxygenclass:: ActionHelper
|
||||||
|
:members:
|
||||||
|
|
||||||
|
``HasActionsIF``
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
.. doxygenclass:: HasActionsIF
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
16
docs/api/controller.rst
Normal file
16
docs/api/controller.rst
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
Controller API
|
||||||
|
=================
|
||||||
|
|
||||||
|
``ControllerBase``
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: ControllerBase
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
||||||
|
|
||||||
|
``ExtendedControllerBase``
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: ExtendedControllerBase
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
16
docs/api/devicehandler.rst
Normal file
16
docs/api/devicehandler.rst
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
Device Handler Base API
|
||||||
|
=========================
|
||||||
|
|
||||||
|
``DeviceHandlerBase``
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: DeviceHandlerBase
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
||||||
|
|
||||||
|
``DeviceHandlerIF``
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: DeviceHandlerIF
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
6
docs/api/event.rst
Normal file
6
docs/api/event.rst
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.. _eventapi:
|
||||||
|
|
||||||
|
Event API
|
||||||
|
============
|
||||||
|
|
||||||
|
.. doxygenfile:: Event.h
|
9
docs/api/health.rst
Normal file
9
docs/api/health.rst
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Health API
|
||||||
|
===========
|
||||||
|
|
||||||
|
``HasHealthIF``
|
||||||
|
------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: HasHealthIF
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
9
docs/api/ipc.rst
Normal file
9
docs/api/ipc.rst
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
IPC Module API
|
||||||
|
=================
|
||||||
|
|
||||||
|
``MessageQueueIF``
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: MessageQueueIF
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
10
docs/api/modes.rst
Normal file
10
docs/api/modes.rst
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Modes API
|
||||||
|
=========
|
||||||
|
|
||||||
|
|
||||||
|
``HasModesIF``
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. doxygenclass:: HasModesIF
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
30
docs/api/objectmanager.rst
Normal file
30
docs/api/objectmanager.rst
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
Object Manager API
|
||||||
|
=========================
|
||||||
|
|
||||||
|
``SystemObject``
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: SystemObject
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
||||||
|
|
||||||
|
``ObjectManager``
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: ObjectManager
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
||||||
|
|
||||||
|
``SystemObjectIF``
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: SystemObjectIF
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
||||||
|
|
||||||
|
``ObjectManagerIF``
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: ObjectManagerIF
|
||||||
|
:members:
|
||||||
|
:protected-members:
|
10
docs/api/returnvalue.rst
Normal file
10
docs/api/returnvalue.rst
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.. _retvalapi:
|
||||||
|
|
||||||
|
Returnvalue API
|
||||||
|
==================
|
||||||
|
|
||||||
|
.. doxygenfile:: HasReturnvaluesIF.h
|
||||||
|
|
||||||
|
.. _fwclassids:
|
||||||
|
|
||||||
|
.. doxygenfile:: FwClassIds.h
|
8
docs/api/task.rst
Normal file
8
docs/api/task.rst
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Task API
|
||||||
|
=========
|
||||||
|
|
||||||
|
``ExecutableObjectIF``
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
.. doxygenclass:: ExecutableObjectIF
|
||||||
|
:members:
|
56
docs/conf.py
Normal file
56
docs/conf.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# Configuration file for the Sphinx documentation builder.
|
||||||
|
#
|
||||||
|
# This file only contains a selection of the most common options. For a full
|
||||||
|
# list see the documentation:
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||||
|
|
||||||
|
# -- Path setup --------------------------------------------------------------
|
||||||
|
|
||||||
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
|
#
|
||||||
|
# import os
|
||||||
|
# import sys
|
||||||
|
# sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
|
||||||
|
|
||||||
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
|
project = 'Flight Software Framework'
|
||||||
|
copyright = '2021, Institute of Space Systems (IRS)'
|
||||||
|
author = 'Institute of Space Systems (IRS)'
|
||||||
|
|
||||||
|
# The full version, including alpha/beta/rc tags
|
||||||
|
release = '2.0.1'
|
||||||
|
|
||||||
|
|
||||||
|
# -- General configuration ---------------------------------------------------
|
||||||
|
|
||||||
|
# Add any Sphinx extension module names here, as strings. They can be
|
||||||
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
|
# ones.
|
||||||
|
extensions = [ "breathe" ]
|
||||||
|
|
||||||
|
breathe_default_project = "fsfw"
|
||||||
|
|
||||||
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
|
templates_path = ['_templates']
|
||||||
|
|
||||||
|
# List of patterns, relative to source directory, that match files and
|
||||||
|
# directories to ignore when looking for source files.
|
||||||
|
# This pattern also affects html_static_path and html_extra_path.
|
||||||
|
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for HTML output -------------------------------------------------
|
||||||
|
|
||||||
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
|
# a list of builtin themes.
|
||||||
|
#
|
||||||
|
html_theme = 'alabaster'
|
||||||
|
|
||||||
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
|
html_static_path = []
|
41
docs/config.rst
Normal file
41
docs/config.rst
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
Configuring the FSFW
|
||||||
|
=====================
|
||||||
|
|
||||||
|
The FSFW can be configured via the ``fsfwconfig`` folder. A template folder has been provided in
|
||||||
|
``misc/defaultcfg`` to have a starting point for this. The folder should be added
|
||||||
|
to the include path. The primary configuration file is the ``FSFWConfig.h`` folder. Some
|
||||||
|
of the available options will be explained in more detail here.
|
||||||
|
|
||||||
|
Auto-Translation of Events
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
The FSFW allows the automatic translation of events, which allows developers to track triggered
|
||||||
|
events directly via console output. Using this feature requires:
|
||||||
|
|
||||||
|
1. ``FSFW_OBJ_EVENT_TRANSLATION`` set to 1 in the configuration file.
|
||||||
|
2. Special auto-generated translation files which translate event IDs and object IDs into
|
||||||
|
human readable strings. These files can be generated using the
|
||||||
|
`fsfwgen Python scripts <https://egit.irs.uni-stuttgart.de/fsfw/fsfw-gen>`_.
|
||||||
|
3. The generated translation files for the object IDs should be named ``translatesObjects.cpp``
|
||||||
|
and ``translateObjects.h`` and should be copied to the ``fsfwconfig/objects`` folder
|
||||||
|
4. The generated translation files for the event IDs should be named ``translateEvents.cpp`` and
|
||||||
|
``translateEvents.h`` and should be copied to the ``fsfwconfig/events`` folder
|
||||||
|
|
||||||
|
An example implementations of these translation file generators can be found as part
|
||||||
|
of the `SOURCE project here <https://git.ksat-stuttgart.de/source/sourceobsw/-/tree/develop/generators>`_
|
||||||
|
or the `FSFW example <https://egit.irs.uni-stuttgart.de/fsfw/fsfw-example-hosted/src/branch/master/generators>`_
|
||||||
|
|
||||||
|
Configuring the Event Manager
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
The number of allowed subscriptions can be modified with the following
|
||||||
|
parameters:
|
||||||
|
|
||||||
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
namespace fsfwconfig {
|
||||||
|
//! Configure the allocated pool sizes for the event manager.
|
||||||
|
static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
|
||||||
|
static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120;
|
||||||
|
static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
|
||||||
|
}
|
2
docs/controllers.rst
Normal file
2
docs/controllers.rst
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Controllers
|
||||||
|
=============
|
70
docs/core.rst
Normal file
70
docs/core.rst
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
.. _core:
|
||||||
|
|
||||||
|
Core Modules
|
||||||
|
=============
|
||||||
|
|
||||||
|
The core modules provide the most important functionalities of the Flight Software Framework.
|
||||||
|
|
||||||
|
Clock
|
||||||
|
------
|
||||||
|
|
||||||
|
- This is a class of static functions that can be used at anytime
|
||||||
|
- Leap Seconds must be set if any time conversions from UTC to other times is used
|
||||||
|
|
||||||
|
Object Manager
|
||||||
|
---------------
|
||||||
|
|
||||||
|
- Must be created during program startup
|
||||||
|
- The component which handles all references. All :cpp:class:`SystemObject`\s register at this
|
||||||
|
component.
|
||||||
|
- All :cpp:class:`SystemObject`\s needs to have a unique Object ID. Those can be managed like
|
||||||
|
framework objects.
|
||||||
|
- A reference to an object can be retrieved by calling the ``get`` function of
|
||||||
|
:cpp:class:`ObjectManagerIF`. The target type must be specified as a template argument.
|
||||||
|
A ``nullptr`` check of the returning pointer must be done. This function is based on
|
||||||
|
run-time type information.
|
||||||
|
|
||||||
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
template <typename T> T* ObjectManagerIF::get(object_id_t id);
|
||||||
|
|
||||||
|
- A typical way to create all objects on startup is a handing a static produce function to the
|
||||||
|
ObjectManager on creation. By calling ``ObjectManager::instance()->initialize(produceFunc)`` the
|
||||||
|
produce function will be called and all :cpp:class:`SystemObject`\s will be initialized
|
||||||
|
afterwards.
|
||||||
|
|
||||||
|
Event Manager
|
||||||
|
---------------
|
||||||
|
|
||||||
|
- Component which allows routing of events
|
||||||
|
- Other objects can subscribe to specific events, ranges of events or all events of an object.
|
||||||
|
- Subscriptions can be done during runtime but should be done during initialization
|
||||||
|
- Amounts of allowed subscriptions can be configured in ``FSFWConfig.h``
|
||||||
|
|
||||||
|
Health Table
|
||||||
|
---------------
|
||||||
|
|
||||||
|
- A component which holds every health state
|
||||||
|
- Provides a thread safe way to access all health states without the need of message exchanges
|
||||||
|
|
||||||
|
Stores
|
||||||
|
--------------
|
||||||
|
|
||||||
|
- The message based communication can only exchange a few bytes of information inside the message
|
||||||
|
itself. Therefore, additional information can be exchanged with Stores. With this, only the
|
||||||
|
store address must be exchanged in the message.
|
||||||
|
- Internally, the FSFW uses an IPC Store to exchange data between processes. For incoming TCs a TC
|
||||||
|
Store is used. For outgoing TM a TM store is used.
|
||||||
|
- All of them should use the Thread Safe Class storagemanager/PoolManager
|
||||||
|
|
||||||
|
Tasks
|
||||||
|
---------
|
||||||
|
|
||||||
|
There are two different types of tasks:
|
||||||
|
|
||||||
|
- The PeriodicTask just executes objects that are of type ExecutableObjectIF in the order of the
|
||||||
|
insertion to the Tasks.
|
||||||
|
- FixedTimeslotTask executes a list of calls in the order of the given list. This is intended for
|
||||||
|
DeviceHandlers, where polling should be in a defined order. An example can be found in
|
||||||
|
``defaultcfg/fsfwconfig/pollingSequence`` folder
|
||||||
|
|
3
docs/devicehandlers.rst
Normal file
3
docs/devicehandlers.rst
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Device Handlers
|
||||||
|
==================
|
||||||
|
|
115
docs/getting_started.rst
Normal file
115
docs/getting_started.rst
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
Getting Started
|
||||||
|
================
|
||||||
|
|
||||||
|
|
||||||
|
Getting started
|
||||||
|
----------------
|
||||||
|
|
||||||
|
The `Hosted FSFW example`_ provides a good starting point and a demo to see the FSFW capabilities.
|
||||||
|
It is recommended to get started by building and playing around with the demo application.
|
||||||
|
There are also other examples provided for all OSALs using the popular embedded platforms
|
||||||
|
Raspberry Pi, Beagle Bone Black and STM32H7.
|
||||||
|
|
||||||
|
Generally, the FSFW is included in a project by providing
|
||||||
|
a configuration folder, building the static library and linking against it.
|
||||||
|
There are some functions like ``printChar`` which are different depending on the target architecture
|
||||||
|
and need to be implemented by the mission developer.
|
||||||
|
|
||||||
|
A template configuration folder was provided and can be copied into the project root to have
|
||||||
|
a starting point. The [configuration section](docs/README-config.md#top) provides more specific
|
||||||
|
information about the possible options.
|
||||||
|
|
||||||
|
Adding the library
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
The following steps show how to add and use FSFW components. It is still recommended to
|
||||||
|
try out the example mentioned above to get started, but the following steps show how to
|
||||||
|
add and link against the FSFW library in general.
|
||||||
|
|
||||||
|
1. Add this repository as a submodule
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
git submodule add https://egit.irs.uni-stuttgart.de/fsfw/fsfw.git fsfw
|
||||||
|
|
||||||
|
2. Add the following directive inside the uppermost ``CMakeLists.txt`` file of your project
|
||||||
|
|
||||||
|
.. code-block:: cmake
|
||||||
|
|
||||||
|
add_subdirectory(fsfw)
|
||||||
|
|
||||||
|
3. Make sure to provide a configuration folder and supply the path to that folder with
|
||||||
|
the `FSFW_CONFIG_PATH` CMake variable from the uppermost `CMakeLists.txt` file.
|
||||||
|
It is also necessary to provide the `printChar` function. You can find an example
|
||||||
|
implementation for a hosted build
|
||||||
|
`here <https://egit.irs.uni-stuttgart.de/fsfw/fsfw-example-hosted/src/branch/master/bsp_hosted/utility/printChar.c>`_.
|
||||||
|
|
||||||
|
4. Link against the FSFW library
|
||||||
|
|
||||||
|
.. code-block:: cmake
|
||||||
|
|
||||||
|
target_link_libraries(<YourProjectName> PRIVATE fsfw)
|
||||||
|
|
||||||
|
|
||||||
|
5. It should now be possible use the FSFW as a static library from the user code.
|
||||||
|
|
||||||
|
Building the unittests
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
The FSFW also has unittests which use the `Catch2 library`_.
|
||||||
|
These are built by setting the CMake option ``FSFW_BUILD_UNITTESTS`` to ``ON`` or `TRUE`
|
||||||
|
from your project `CMakeLists.txt` file or from the command line.
|
||||||
|
|
||||||
|
The fsfw-tests binary will be built as part of the static library and dropped alongside it.
|
||||||
|
If the unittests are built, the library and the tests will be built with coverage information by
|
||||||
|
default. This can be disabled by setting the `FSFW_TESTS_COV_GEN` option to `OFF` or `FALSE`.
|
||||||
|
|
||||||
|
You can use the following commands inside the ``fsfw`` folder to set up the build system
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
mkdir build-tests && cd build-tests
|
||||||
|
cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host ..
|
||||||
|
|
||||||
|
|
||||||
|
You can also use ``-DFSFW_OSAL=linux`` on Linux systems.
|
||||||
|
|
||||||
|
Coverage data in HTML format can be generated using the `Code coverage`_ CMake module.
|
||||||
|
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
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
cmake --build . -- fsfw-tests_coverage -j
|
||||||
|
|
||||||
|
|
||||||
|
The ``helper.py`` script located in the ``script`` folder can also be used to create, build
|
||||||
|
and open the unittests conveniently. Try ``helper.py -h`` for more information.
|
||||||
|
|
||||||
|
Building the documentation
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
The FSFW documentation is built using the tools Sphinx, doxygen and breathe based on the
|
||||||
|
instructions provided in `this blogpost <https://devblogs.microsoft.com/cppblog/clear-functional-c-documentation-with-sphinx-breathe-doxygen-cmake/>`_. You can set up a
|
||||||
|
documentation build system using the following commands
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
mkdir build-docs && cd build-docs
|
||||||
|
cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..
|
||||||
|
|
||||||
|
Then you can generate the documentation using
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
cmake --build . -j
|
||||||
|
|
||||||
|
You can find the generated documentation inside the ``docs/sphinx`` folder inside the build
|
||||||
|
folder. Simply open the ``index.html`` in the webbrowser of your choice.
|
||||||
|
|
||||||
|
The ``helper.py`` script located in the ``script`` folder can also be used to create, build
|
||||||
|
and open the documentation conveniently. Try ``helper.py -h`` for more information.
|
||||||
|
|
||||||
|
.. _`Hosted FSFW example`: https://egit.irs.uni-stuttgart.de/fsfw/fsfw-example-hosted
|
||||||
|
.. _`Catch2 library`: https://github.com/catchorg/Catch2
|
||||||
|
.. _`Code coverage`: https://github.com/bilke/cmake-modules/tree/master
|
149
docs/highlevel.rst
Normal file
149
docs/highlevel.rst
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
.. _highlevel:
|
||||||
|
|
||||||
|
High-level overview
|
||||||
|
===================
|
||||||
|
|
||||||
|
Structure
|
||||||
|
----------
|
||||||
|
|
||||||
|
The general structure is driven by the usage of interfaces provided by objects.
|
||||||
|
The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be
|
||||||
|
widely available, even with older compilers.
|
||||||
|
The FSFW uses dynamic allocation during the initialization but provides static containers during runtime.
|
||||||
|
This simplifies the instantiation of objects and allows the usage of some standard containers.
|
||||||
|
Dynamic Allocation after initialization is discouraged and different solutions are provided in the
|
||||||
|
FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed.
|
||||||
|
|
||||||
|
Failure Handling
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
Functions should return a defined :cpp:type:`ReturnValue_t` to signal to the caller that something has
|
||||||
|
gone wrong. Returnvalues must be unique. For this the function :cpp:func:`HasReturnvaluesIF::makeReturnCode`
|
||||||
|
or the :ref:`macro MAKE_RETURN_CODE <retvalapi>` can be used. The ``CLASS_ID`` is a unique ID for that type of object.
|
||||||
|
See the :ref:`FSFW Class IDs file <fwclassids>`. The user can add custom ``CLASS_ID``\s via the
|
||||||
|
``fsfwconfig`` folder.
|
||||||
|
|
||||||
|
OSAL
|
||||||
|
------------
|
||||||
|
|
||||||
|
The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS.
|
||||||
|
The OSAL provides periodic tasks, message queues, clocks and semaphores as well as mutexes.
|
||||||
|
The :ref:`OSAL README <osal>` provides more detailed information on provided components
|
||||||
|
and how to use them.
|
||||||
|
|
||||||
|
Core Components
|
||||||
|
----------------
|
||||||
|
|
||||||
|
The FSFW has following core components. More detailed informations can be found in the
|
||||||
|
:ref:`core component section <core>`:
|
||||||
|
|
||||||
|
1. Tasks: Abstraction for different (periodic) task types like periodic tasks or tasks
|
||||||
|
with fixed timeslots
|
||||||
|
2. ObjectManager: This module stores all `SystemObjects` by mapping a provided unique object ID
|
||||||
|
to the object handles.
|
||||||
|
3. Static Stores: Different stores are provided to store data of variable size (like telecommands
|
||||||
|
or small telemetry) in a pool structure without using dynamic memory allocation.
|
||||||
|
These pools are allocated up front.
|
||||||
|
4. Clock: This module provided common time related functions
|
||||||
|
5. EventManager: This module allows routing of events generated by `SystemObjects`
|
||||||
|
6. HealthTable: A component which stores the health states of objects
|
||||||
|
|
||||||
|
Static IDs in the framework
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
Some parts of the framework use a static routing address for communication.
|
||||||
|
An example setup of IDs can be found in the example config in ``misc/defaultcfg/fsfwconfig/objects``
|
||||||
|
inside the function ``Factory::setStaticFrameworkObjectIds``.
|
||||||
|
|
||||||
|
Events
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Events are tied to objects. EventIds can be generated by calling the
|
||||||
|
:ref:`macro MAKE_EVENT <eventapi>` or the function :cpp:func:`event::makeEvent`.
|
||||||
|
This works analog to the returnvalues. Every object that needs own Event IDs has to get a
|
||||||
|
unique ``SUBSYSTEM_ID``. Every :cpp:class:`SystemObject` can call
|
||||||
|
:cpp:func:`SystemObject::triggerEvent` from the parent class.
|
||||||
|
Therefore, event messages contain the specific EventId and the objectId of the object that
|
||||||
|
has triggered.
|
||||||
|
|
||||||
|
Internal Communication
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Components communicate mostly via Messages through Queues.
|
||||||
|
Those queues are created by calling the singleton ``QueueFactory::instance()->create`` which
|
||||||
|
will create `MessageQueue` instances for the used OSAL.
|
||||||
|
|
||||||
|
External Communication
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
The external communication with the mission control system is mostly up to the user implementation.
|
||||||
|
The FSFW provides PUS Services which can be used to but don't need to be used.
|
||||||
|
The services can be seen as a conversion from a TC to a message based communication and back.
|
||||||
|
|
||||||
|
TMTC Communication
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
The FSFW provides some components to facilitate TMTC handling via the PUS commands.
|
||||||
|
For example, a UDP or TCP PUS server socket can be opened on a specific port using the
|
||||||
|
files located in ``osal/common``. The FSFW example uses this functionality to allow sending
|
||||||
|
telecommands and receiving telemetry using the
|
||||||
|
`TMTC commander application <https://github.com/robamu-org/tmtccmd>`_.
|
||||||
|
|
||||||
|
Simple commands like the PUS Service 17 ping service can be tested by simply running the
|
||||||
|
``tmtc_client_cli.py`` or ``tmtc_client_gui.py`` utility in
|
||||||
|
the `example tmtc folder <https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example_public/src/branch/master/tmtc>`_
|
||||||
|
while the `fsfw_example` application is running.
|
||||||
|
|
||||||
|
More generally, any class responsible for handling incoming telecommands and sending telemetry
|
||||||
|
can implement the generic ``TmTcBridge`` class located in ``tmtcservices``. Many applications
|
||||||
|
also use a dedicated polling task for reading telecommands which passes telecommands
|
||||||
|
to the ``TmTcBridge`` implementation.
|
||||||
|
|
||||||
|
CCSDS Frames, CCSDS Space Packets and PUS
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
If the communication is based on CCSDS Frames and Space Packets, several classes can be used to
|
||||||
|
distributed the packets to the corresponding services. Those can be found in ``tcdistribution``.
|
||||||
|
If Space Packets are used, a timestamper has to be provided by the user.
|
||||||
|
An example can be found in the ``timemanager`` folder, which uses ``CCSDSTime::CDS_short``.
|
||||||
|
|
||||||
|
Device Handlers
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
DeviceHandlers are another important component of the FSFW. The idea is, to have a software
|
||||||
|
counterpart of every physical device to provide a simple mode, health and commanding interface.
|
||||||
|
By separating the underlying Communication Interface with
|
||||||
|
``DeviceCommunicationIF``, a device handler (DH) can be tested on different hardware.
|
||||||
|
The DH has mechanisms to monitor the communication with the physical device which allow
|
||||||
|
for FDIR reaction. Device Handlers can be created by implementing ``DeviceHandlerBase``.
|
||||||
|
A standard FDIR component for the DH will be created automatically but can
|
||||||
|
be overwritten by the user. More information on DeviceHandlers can be found in the
|
||||||
|
related [documentation section](doc/README-devicehandlers.md#top).
|
||||||
|
|
||||||
|
Modes and Health
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
The two interfaces ``HasModesIF`` and ``HasHealthIF`` provide access for commanding and monitoring
|
||||||
|
of components. On-board mode management is implement in hierarchy system.
|
||||||
|
|
||||||
|
- Device handlers and controllers are the lowest part of the hierarchy.
|
||||||
|
- The next layer are assemblies. Those assemblies act as a component which handle
|
||||||
|
redundancies of handlers. Assemblies share a common core with the top level subsystem components
|
||||||
|
- The top level subsystem components are used to group assemblies, controllers and device handlers.
|
||||||
|
For example, a spacecraft can have a atttitude control subsystem and a power subsystem.
|
||||||
|
|
||||||
|
Those assemblies are intended to act as auto-generated components from a database which describes
|
||||||
|
the subsystem modes. The definitions contain transition and target tables which contain the DH,
|
||||||
|
Assembly and Controller Modes to be commanded.
|
||||||
|
Transition tables contain as many steps as needed to reach the mode from any other mode, e.g. a
|
||||||
|
switch into any higher AOCS mode might first turn on the sensors, than the actuators and the
|
||||||
|
controller as last component.
|
||||||
|
The target table is used to describe the state that is checked continuously by the subsystem.
|
||||||
|
All of this allows System Modes to be generated as Subsystem object as well from the same database.
|
||||||
|
This System contains list of subsystem modes in the transition and target tables.
|
||||||
|
Therefore, it allows a modular system to create system modes and easy commanding of those, because
|
||||||
|
only the highest components must be commanded.
|
||||||
|
|
||||||
|
The health state represents if the component is able to perform its tasks.
|
||||||
|
This can be used to signal the system to avoid using this component instead of a redundant one.
|
||||||
|
The on-board FDIR uses the health state for isolation and recovery.
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
69
docs/index.rst
Normal file
69
docs/index.rst
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
.. Flight Software Framework documentation master file, created by
|
||||||
|
sphinx-quickstart on Tue Nov 30 10:56:03 2021.
|
||||||
|
You can adapt this file completely to your liking, but it should at least
|
||||||
|
contain the root `toctree` directive.
|
||||||
|
|
||||||
|
Flight Software Framework (FSFW) documentation
|
||||||
|
================================================
|
||||||
|
|
||||||
|
.. image:: ../misc/logo/FSFW_Logo_V3_bw.png
|
||||||
|
:alt: FSFW Logo
|
||||||
|
|
||||||
|
The Flight Software Framework is a C++ Object Oriented Framework for unmanned,
|
||||||
|
automated systems like Satellites.
|
||||||
|
|
||||||
|
The initial version of the Flight Software Framework was developed during
|
||||||
|
the Flying Laptop Project by the University of Stuttgart in cooperation
|
||||||
|
with Airbus Defence and Space GmbH.
|
||||||
|
|
||||||
|
Quick facts
|
||||||
|
---------------
|
||||||
|
|
||||||
|
The framework is designed for systems, which communicate with external devices, perform control
|
||||||
|
loops, receive telecommands and send telemetry, and need to maintain a high level of availability.
|
||||||
|
Therefore, a mode and health system provides control over the states of the software and the
|
||||||
|
controlled devices. In addition, a simple mechanism of event based fault detection, isolation and
|
||||||
|
recovery is implemented as well.
|
||||||
|
|
||||||
|
The FSFW provides abstraction layers for operating systems to provide a uniform operating system
|
||||||
|
abstraction layer (OSAL). Some components of this OSAL are required internally by the FSFW but is
|
||||||
|
also very useful for developers to implement the same application logic on different operating
|
||||||
|
systems with a uniform interface.
|
||||||
|
|
||||||
|
Currently, the FSFW provides the following OSALs:
|
||||||
|
|
||||||
|
- Linux
|
||||||
|
- Host
|
||||||
|
- FreeRTOS
|
||||||
|
- RTEMS
|
||||||
|
|
||||||
|
The recommended hardware is a microprocessor with more than 1 MB of RAM and 1 MB of non-volatile
|
||||||
|
memory. For reference, current applications use a Cobham Gaisler UT699 (LEON3FT), a
|
||||||
|
ISISPACE IOBC or a Zynq-7020 SoC. The ``fsfw`` was also successfully run on the
|
||||||
|
STM32H743ZI-Nucleo board and on a Raspberry Pi and is currently running on the active
|
||||||
|
satellite mission Flying Laptop.
|
||||||
|
|
||||||
|
Index
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:caption: Contents:
|
||||||
|
|
||||||
|
getting_started
|
||||||
|
highlevel
|
||||||
|
core
|
||||||
|
config
|
||||||
|
osal
|
||||||
|
pus
|
||||||
|
devicehandlers
|
||||||
|
controllers
|
||||||
|
localpools
|
||||||
|
api
|
||||||
|
|
||||||
|
Indices and tables
|
||||||
|
==================
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`modindex`
|
||||||
|
* :ref:`search`
|
181
docs/localpools.rst
Normal file
181
docs/localpools.rst
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
Local Data Pools
|
||||||
|
=========================================
|
||||||
|
|
||||||
|
The following text is targeted towards mission software developers which would like
|
||||||
|
to use the local data pools provided by the FSFW to store data like sensor values so they can be
|
||||||
|
used by other software objects like controllers as well. If a custom class should have a local
|
||||||
|
pool which can be used by other software objects as well, following steps have to be performed:
|
||||||
|
|
||||||
|
1. Create a ``LocalDataPoolManager`` member object in the custom class
|
||||||
|
2. Implement the ``HasLocalDataPoolIF`` with specifies the interface between the local pool
|
||||||
|
manager and the class owning the local pool.
|
||||||
|
|
||||||
|
The local data pool manager is also able to process housekeeping service requests in form
|
||||||
|
of messages, generate periodic housekeeping packet, generate notification and snapshots of changed
|
||||||
|
variables and datasets and process notifications and snapshots coming from other objects.
|
||||||
|
The two former tasks are related to the external interface using telemetry and telecommands (TMTC)
|
||||||
|
while the later two are related to data consumers like controllers only acting on data change
|
||||||
|
detected by the data creator instead of checking the data manually each cycle. Two important
|
||||||
|
framework classes ``DeviceHandlerBase`` and ``ExtendedControllerBase`` already perform the two steps
|
||||||
|
shown above so the steps required are altered slightly.
|
||||||
|
|
||||||
|
Storing and Accessing pool data
|
||||||
|
-------------------------------------
|
||||||
|
|
||||||
|
The pool manager is responsible for thread-safe access of the pool data, but the actual
|
||||||
|
access to the pool data from the point of view of a mission software developer happens via proxy
|
||||||
|
classes like pool variable classes. These classes store a copy
|
||||||
|
of the pool variable with the matching datatype and copy the actual data from the local pool
|
||||||
|
on a ``read`` call. Changed variables can then be written to the local pool with a ``commit`` call.
|
||||||
|
The ``read`` and ``commit`` calls are thread-safe and can be called concurrently from data creators
|
||||||
|
and data consumers. Generally, a user will create a dataset class which in turn groups all
|
||||||
|
cohesive pool variables. These sets simply iterator over the list of variables and call the
|
||||||
|
``read`` and ``commit`` functions of each variable. The following diagram shows the
|
||||||
|
high-level architecture of the local data pools.
|
||||||
|
|
||||||
|
.. image:: ../docs/images/PoolArchitecture.png
|
||||||
|
:alt: Pool Architecture
|
||||||
|
|
||||||
|
An example is shown for using the local data pools with a Gyroscope.
|
||||||
|
For example, the following code shows an implementation to access data from a Gyroscope taken
|
||||||
|
from the SOURCE CubeSat project:
|
||||||
|
|
||||||
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
class GyroPrimaryDataset: public StaticLocalDataSet<3 * sizeof(float)> {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor for data users
|
||||||
|
* @param gyroId
|
||||||
|
*/
|
||||||
|
GyroPrimaryDataset(object_id_t gyroId):
|
||||||
|
StaticLocalDataSet(sid_t(gyroId, gyrodefs::GYRO_DATA_SET_ID)) {
|
||||||
|
setAllVariablesReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
|
lp_var_t<float> angVelocityX = lp_var_t<float>(sid.objectId,
|
||||||
|
gyrodefs::ANGULAR_VELOCITY_X, this);
|
||||||
|
lp_var_t<float> angVelocityY = lp_var_t<float>(sid.objectId,
|
||||||
|
gyrodefs::ANGULAR_VELOCITY_Y, this);
|
||||||
|
lp_var_t<float> angVelocityZ = lp_var_t<float>(sid.objectId,
|
||||||
|
gyrodefs::ANGULAR_VELOCITY_Z, this);
|
||||||
|
private:
|
||||||
|
|
||||||
|
friend class GyroHandler;
|
||||||
|
/**
|
||||||
|
* Constructor for data creator
|
||||||
|
* @param hkOwner
|
||||||
|
*/
|
||||||
|
GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner):
|
||||||
|
StaticLocalDataSet(hkOwner, gyrodefs::GYRO_DATA_SET_ID) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
There is a public constructor for users which sets all variables to read-only and there is a
|
||||||
|
constructor for the GyroHandler data creator by marking it private and declaring the ``GyroHandler``
|
||||||
|
as a friend class. Both the atittude controller and the ``GyroHandler`` can now
|
||||||
|
use the same class definition to access the pool variables with ``read`` and ``commit`` semantics
|
||||||
|
in a thread-safe way. Generally, each class requiring access will have the set class as a member
|
||||||
|
class. The data creator will also be generally a ``DeviceHandlerBase`` subclass and some additional
|
||||||
|
steps are necessary to expose the set for housekeeping purposes.
|
||||||
|
|
||||||
|
Using the local data pools in a ``DeviceHandlerBase`` subclass
|
||||||
|
--------------------------------------------------------------
|
||||||
|
|
||||||
|
It is very common to store data generated by devices like a sensor into a pool which can
|
||||||
|
then be used by other objects. Therefore, the ``DeviceHandlerBase`` already has a
|
||||||
|
local pool. Using the aforementioned example, the ``GyroHandler`` will now have the set class
|
||||||
|
as a member:
|
||||||
|
|
||||||
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
class GyroHandler: ... {
|
||||||
|
|
||||||
|
public:
|
||||||
|
...
|
||||||
|
private:
|
||||||
|
...
|
||||||
|
GyroPrimaryDataset gyroData;
|
||||||
|
...
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
The constructor used for the creators expects the owner class as a parameter, so we initialize
|
||||||
|
the object in the `GyroHandler` constructor like this:
|
||||||
|
|
||||||
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
GyroHandler::GyroHandler(object_id_t objectId, object_id_t comIF,
|
||||||
|
CookieIF *comCookie, uint8_t switchId):
|
||||||
|
DeviceHandlerBase(objectId, comIF, comCookie), switchId(switchId),
|
||||||
|
gyroData(this) {}
|
||||||
|
|
||||||
|
|
||||||
|
We need to assign the set to a reply ID used in the ``DeviceHandlerBase``.
|
||||||
|
The combination of the ``GyroHandler`` object ID and the reply ID will be the 64-bit structure ID
|
||||||
|
``sid_t`` and is used to globally identify the set, for example when requesting housekeeping data or
|
||||||
|
generating update messages. We need to assign our custom set class in some way so that the local
|
||||||
|
pool manager can access the custom data sets as well.
|
||||||
|
By default, the ``getDataSetHandle`` will take care of this tasks. The default implementation for a
|
||||||
|
``DeviceHandlerBase`` subclass will use the internal command map to retrieve
|
||||||
|
a handle to a dataset from a given reply ID. Therefore,
|
||||||
|
we assign the set in the ``fillCommandAndReplyMap`` function:
|
||||||
|
|
||||||
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
void GyroHandler::fillCommandAndReplyMap() {
|
||||||
|
...
|
||||||
|
this->insertInCommandAndReplyMap(gyrodefs::GYRO_DATA, 3, &gyroData);
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Now, we need to create the actual pool entries as well, using the ``initializeLocalDataPool``
|
||||||
|
function. Here, we also immediately subscribe for periodic housekeeping packets
|
||||||
|
with an interval of 4 seconds. They are still disabled in this example and can be enabled
|
||||||
|
with a housekeeping service command.
|
||||||
|
|
||||||
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
ReturnValue_t GyroHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||||
|
LocalDataPoolManager &poolManager) {
|
||||||
|
localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_X,
|
||||||
|
new PoolEntry<float>({0.0}));
|
||||||
|
localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_Y,
|
||||||
|
new PoolEntry<float>({0.0}));
|
||||||
|
localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_Z,
|
||||||
|
new PoolEntry<float>({0.0}));
|
||||||
|
localDataPoolMap.emplace(gyrodefs::GENERAL_CONFIG_REG42,
|
||||||
|
new PoolEntry<uint8_t>({0}));
|
||||||
|
localDataPoolMap.emplace(gyrodefs::RANGE_CONFIG_REG43,
|
||||||
|
new PoolEntry<uint8_t>({0}));
|
||||||
|
|
||||||
|
poolManager.subscribeForPeriodicPacket(gyroData.getSid(), false, 4.0, false);
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
Now, if we receive some sensor data and converted them into the right format,
|
||||||
|
we can write it into the pool like this, using a guard class to ensure the set is commited back
|
||||||
|
in any case:
|
||||||
|
|
||||||
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
PoolReadGuard readHelper(&gyroData);
|
||||||
|
if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
if(not gyroData.isValid()) {
|
||||||
|
gyroData.setValidity(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
gyroData.angVelocityX = angularVelocityX;
|
||||||
|
gyroData.angVelocityY = angularVelocityY;
|
||||||
|
gyroData.angVelocityZ = angularVelocityZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
The guard class will commit the changed data on destruction automatically.
|
||||||
|
|
||||||
|
Using the local data pools in a ``ExtendedControllerBase`` subclass
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Coming soon
|
||||||
|
|
||||||
|
|
35
docs/make.bat
Normal file
35
docs/make.bat
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
|
||||||
|
pushd %~dp0
|
||||||
|
|
||||||
|
REM Command file for Sphinx documentation
|
||||||
|
|
||||||
|
if "%SPHINXBUILD%" == "" (
|
||||||
|
set SPHINXBUILD=sphinx-build
|
||||||
|
)
|
||||||
|
set SOURCEDIR=.
|
||||||
|
set BUILDDIR=_build
|
||||||
|
|
||||||
|
if "%1" == "" goto help
|
||||||
|
|
||||||
|
%SPHINXBUILD% >NUL 2>NUL
|
||||||
|
if errorlevel 9009 (
|
||||||
|
echo.
|
||||||
|
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||||
|
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||||
|
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||||
|
echo.may add the Sphinx directory to PATH.
|
||||||
|
echo.
|
||||||
|
echo.If you don't have Sphinx installed, grab it from
|
||||||
|
echo.http://sphinx-doc.org/
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:help
|
||||||
|
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||||
|
|
||||||
|
:end
|
||||||
|
popd
|
63
docs/osal.rst
Normal file
63
docs/osal.rst
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
.. _osal:
|
||||||
|
|
||||||
|
Operating System Abstraction Layer (OSAL)
|
||||||
|
============================================
|
||||||
|
|
||||||
|
Some specific information on the provided OSALs are provided.
|
||||||
|
|
||||||
|
Linux
|
||||||
|
-------
|
||||||
|
|
||||||
|
This OSAL can be used to compile for Linux host systems like Ubuntu 20.04 or for
|
||||||
|
embedded Linux targets like the Raspberry Pi. This OSAL generally requires threading support
|
||||||
|
and real-time functionalities. For most UNIX systems, this is done by adding ``-lrt`` and
|
||||||
|
``-lpthread`` to the linked libraries in the compilation process. The CMake build support provided
|
||||||
|
will do this automatically for the ``fsfw`` target. It should be noted that most UNIX systems need
|
||||||
|
to be configured specifically to allow the real-time functionalities required by the FSFW.
|
||||||
|
|
||||||
|
Hosted OSAL
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
This is the newest OSAL. Support for Semaphores has not been implemented yet and will propably be
|
||||||
|
implemented as soon as C++20 with Semaphore support has matured. This OSAL can be used to run the
|
||||||
|
FSFW on any host system, but currently has only been tested on Windows 10 and Ubuntu 20.04. Unlike
|
||||||
|
the other OSALs, it uses dynamic memory allocation (e.g. for the message queue implementation).
|
||||||
|
Cross-platform serial port (USB) support might be added soon.
|
||||||
|
|
||||||
|
FreeRTOS OSAL
|
||||||
|
------------------
|
||||||
|
|
||||||
|
FreeRTOS is not included and the developer needs to take care of compiling the FreeRTOS sources and
|
||||||
|
adding the ``FreeRTOSConfig.h`` file location to the include path. This OSAL has only been tested
|
||||||
|
extensively with the pre-emptive scheduler configuration so far but it should in principle also be
|
||||||
|
possible to use a cooperative scheduler. It is recommended to use the `heap_4` allocation scheme.
|
||||||
|
When using newlib (nano), it is also recommended to add ``#define configUSE_NEWLIB_REENTRANT`` to
|
||||||
|
the FreeRTOS configuration file to ensure thread-safety.
|
||||||
|
|
||||||
|
When using this OSAL, developers also need to provide an implementation for the
|
||||||
|
``vRequestContextSwitchFromISR`` function. This has been done because the call to request a context
|
||||||
|
switch from an ISR is generally located in the ``portmacro.h`` header and is different depending on
|
||||||
|
the target architecture or device.
|
||||||
|
|
||||||
|
RTEMS OSAL
|
||||||
|
---------------
|
||||||
|
|
||||||
|
The RTEMS OSAL was the first implemented OSAL which is also used on the active satellite Flying Laptop.
|
||||||
|
|
||||||
|
TCP/IP socket abstraction
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
The Linux and Host OSAL provide abstraction layers for the socket API. Currently, only UDP sockets
|
||||||
|
have been imlemented. This is very useful to test TMTC handling either on the host computer
|
||||||
|
directly (targeting localhost with a TMTC application) or on embedded Linux devices, sending
|
||||||
|
TMTC packets via Ethernet.
|
||||||
|
|
||||||
|
Example Applications
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
There are example applications available for each OSAL
|
||||||
|
|
||||||
|
- `Hosted OSAL <https://egit.irs.uni-stuttgart.de/fsfw/fsfw-example-hosted>`_
|
||||||
|
- `Linux OSAL for MCUs <https://egit.irs.uni-stuttgart.de/fsfw/fsfw-example-linux-mcu>`_
|
||||||
|
- `FreeRTOS OSAL on the STM32H743ZIT <https://egit.irs.uni-stuttgart.de/fsfw/fsfw-example-stm32h7-freertos>`_
|
||||||
|
- `RTEMS OSAL on the STM32H743ZIT <https://egit.irs.uni-stuttgart.de/fsfw/fsfw-example-stm32h7-rtems>`_
|
2
docs/pus.rst
Normal file
2
docs/pus.rst
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
PUS Services
|
||||||
|
==============
|
@ -16,8 +16,8 @@ enum Levels: uint8_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum Direction: uint8_t {
|
enum Direction: uint8_t {
|
||||||
IN = 0,
|
DIR_IN = 0,
|
||||||
OUT = 1
|
DIR_OUT = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GpioOperation {
|
enum GpioOperation {
|
||||||
@ -30,7 +30,7 @@ enum class GpioTypes {
|
|||||||
GPIO_REGULAR_BY_CHIP,
|
GPIO_REGULAR_BY_CHIP,
|
||||||
GPIO_REGULAR_BY_LABEL,
|
GPIO_REGULAR_BY_LABEL,
|
||||||
GPIO_REGULAR_BY_LINE_NAME,
|
GPIO_REGULAR_BY_LINE_NAME,
|
||||||
CALLBACK
|
TYPE_CALLBACK
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr gpioId_t NO_GPIO = -1;
|
static constexpr gpioId_t NO_GPIO = -1;
|
||||||
@ -68,7 +68,7 @@ public:
|
|||||||
// Can be used to cast GpioBase to a concrete child implementation
|
// Can be used to cast GpioBase to a concrete child implementation
|
||||||
gpio::GpioTypes gpioType = gpio::GpioTypes::NONE;
|
gpio::GpioTypes gpioType = gpio::GpioTypes::NONE;
|
||||||
std::string consumer;
|
std::string consumer;
|
||||||
gpio::Direction direction = gpio::Direction::IN;
|
gpio::Direction direction = gpio::Direction::DIR_IN;
|
||||||
gpio::Levels initValue = gpio::Levels::NONE;
|
gpio::Levels initValue = gpio::Levels::NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ class GpiodRegularByChip: public GpiodRegularBase {
|
|||||||
public:
|
public:
|
||||||
GpiodRegularByChip() :
|
GpiodRegularByChip() :
|
||||||
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP,
|
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP,
|
||||||
std::string(), gpio::Direction::IN, gpio::LOW, 0) {
|
std::string(), gpio::Direction::DIR_IN, gpio::LOW, 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_,
|
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_,
|
||||||
@ -104,7 +104,7 @@ public:
|
|||||||
|
|
||||||
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_) :
|
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_) :
|
||||||
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, consumer_,
|
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, consumer_,
|
||||||
gpio::Direction::IN, gpio::LOW, lineNum_),
|
gpio::Direction::DIR_IN, gpio::LOW, lineNum_),
|
||||||
chipname(chipname_) {
|
chipname(chipname_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ public:
|
|||||||
|
|
||||||
GpiodRegularByLabel(std::string label_, int lineNum_, std::string consumer_) :
|
GpiodRegularByLabel(std::string label_, int lineNum_, std::string consumer_) :
|
||||||
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_,
|
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_,
|
||||||
gpio::Direction::IN, gpio::LOW, lineNum_),
|
gpio::Direction::DIR_IN, gpio::LOW, lineNum_),
|
||||||
label(label_) {
|
label(label_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ public:
|
|||||||
|
|
||||||
GpiodRegularByLineName(std::string lineName_, std::string consumer_) :
|
GpiodRegularByLineName(std::string lineName_, std::string consumer_) :
|
||||||
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_,
|
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_,
|
||||||
gpio::Direction::IN, gpio::LOW), lineName(lineName_) {
|
gpio::Direction::DIR_IN, gpio::LOW), lineName(lineName_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string lineName;
|
std::string lineName;
|
||||||
@ -154,7 +154,7 @@ class GpioCallback: public GpioBase {
|
|||||||
public:
|
public:
|
||||||
GpioCallback(std::string consumer, gpio::Direction direction_, gpio::Levels initValue_,
|
GpioCallback(std::string consumer, gpio::Direction direction_, gpio::Levels initValue_,
|
||||||
gpio::gpio_cb_t callback, void* callbackArgs):
|
gpio::gpio_cb_t callback, void* callbackArgs):
|
||||||
GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_),
|
GpioBase(gpio::GpioTypes::TYPE_CALLBACK, consumer, direction_, initValue_),
|
||||||
callback(callback), callbackArgs(callbackArgs) {}
|
callback(callback), callbackArgs(callbackArgs) {}
|
||||||
|
|
||||||
gpio::gpio_cb_t callback = nullptr;
|
gpio::gpio_cb_t callback = nullptr;
|
||||||
|
@ -9,7 +9,7 @@ GyroHandlerL3GD20H::GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceC
|
|||||||
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
||||||
transitionDelayMs(transitionDelayMs), dataset(this) {
|
transitionDelayMs(transitionDelayMs), dataset(this) {
|
||||||
#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1
|
#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1
|
||||||
debugDivider = new PeriodicOperationDivider(3);
|
debugDivider = new PeriodicOperationDivider(10);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ MgmLIS3MDLHandler::MgmLIS3MDLHandler(object_id_t objectId, object_id_t deviceCom
|
|||||||
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
||||||
dataset(this), transitionDelay(transitionDelay) {
|
dataset(this), transitionDelay(transitionDelay) {
|
||||||
#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1
|
#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1
|
||||||
debugDivider = new PeriodicOperationDivider(3);
|
debugDivider = new PeriodicOperationDivider(10);
|
||||||
#endif
|
#endif
|
||||||
// Set to default values right away
|
// Set to default values right away
|
||||||
registers[0] = MGMLIS3MDL::CTRL_REG1_DEFAULT;
|
registers[0] = MGMLIS3MDL::CTRL_REG1_DEFAULT;
|
||||||
@ -283,7 +283,7 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
int16_t mgmMeasurementRawZ = packet[MGMLIS3MDL::Z_HIGHBYTE_IDX] << 8
|
int16_t mgmMeasurementRawZ = packet[MGMLIS3MDL::Z_HIGHBYTE_IDX] << 8
|
||||||
| packet[MGMLIS3MDL::Z_LOWBYTE_IDX] ;
|
| packet[MGMLIS3MDL::Z_LOWBYTE_IDX] ;
|
||||||
|
|
||||||
/* Target value in microtesla */
|
// Target value in microtesla
|
||||||
float mgmX = static_cast<float>(mgmMeasurementRawX) * sensitivityFactor
|
float mgmX = static_cast<float>(mgmMeasurementRawX) * sensitivityFactor
|
||||||
* MGMLIS3MDL::GAUSS_TO_MICROTESLA_FACTOR;
|
* MGMLIS3MDL::GAUSS_TO_MICROTESLA_FACTOR;
|
||||||
float mgmY = static_cast<float>(mgmMeasurementRawY) * sensitivityFactor
|
float mgmY = static_cast<float>(mgmMeasurementRawY) * sensitivityFactor
|
||||||
@ -339,7 +339,7 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
case MGMLIS3MDL::READ_TEMPERATURE: {
|
case MGMLIS3MDL::READ_TEMPERATURE: {
|
||||||
int16_t tempValueRaw = 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 FSFW_HAL_LIS3MDL_MGM_DEBUG == 1
|
#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1
|
||||||
if(debugDivider->check()) {
|
if(debugDivider->check()) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" <<
|
sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" <<
|
||||||
@ -489,7 +489,7 @@ ReturnValue_t MgmLIS3MDLHandler::prepareCtrlRegisterWrite() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MgmLIS3MDLHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
void MgmLIS3MDLHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||||
|
DeviceHandlerBase::doTransition(modeFrom, subModeFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MgmLIS3MDLHandler::getTransitionDelayMs(Mode_t from, Mode_t to) {
|
uint32_t MgmLIS3MDLHandler::getTransitionDelayMs(Mode_t from, Mode_t to) {
|
||||||
|
@ -12,7 +12,7 @@ MgmRM3100Handler::MgmRM3100Handler(object_id_t objectId,
|
|||||||
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
||||||
primaryDataset(this), transitionDelay(transitionDelay) {
|
primaryDataset(this), transitionDelay(transitionDelay) {
|
||||||
#if FSFW_HAL_RM3100_MGM_DEBUG == 1
|
#if FSFW_HAL_RM3100_MGM_DEBUG == 1
|
||||||
debugDivider = new PeriodicOperationDivider(3);
|
debugDivider = new PeriodicOperationDivider(10);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ endif()
|
|||||||
|
|
||||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
UnixFileGuard.cpp
|
UnixFileGuard.cpp
|
||||||
|
CommandExecutor.cpp
|
||||||
utility.cpp
|
utility.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
210
hal/src/fsfw_hal/linux/CommandExecutor.cpp
Normal file
210
hal/src/fsfw_hal/linux/CommandExecutor.cpp
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
#include "CommandExecutor.h"
|
||||||
|
|
||||||
|
#include "fsfw/serviceinterface.h"
|
||||||
|
#include "fsfw/container/SimpleRingBuffer.h"
|
||||||
|
#include "fsfw/container/DynamicFIFO.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
CommandExecutor::CommandExecutor(const size_t maxSize):
|
||||||
|
readVec(maxSize) {
|
||||||
|
waiter.events = POLLIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CommandExecutor::load(std::string command, bool blocking, bool printOutput) {
|
||||||
|
if(state == States::PENDING) {
|
||||||
|
return COMMAND_PENDING;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentCmd = command;
|
||||||
|
this->blocking = blocking;
|
||||||
|
this->printOutput = printOutput;
|
||||||
|
if(state == States::IDLE) {
|
||||||
|
state = States::COMMAND_LOADED;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CommandExecutor::execute() {
|
||||||
|
if(state == States::IDLE) {
|
||||||
|
return NO_COMMAND_LOADED_OR_PENDING;
|
||||||
|
}
|
||||||
|
else if(state == States::PENDING) {
|
||||||
|
return COMMAND_PENDING;
|
||||||
|
}
|
||||||
|
currentCmdFile = popen(currentCmd.c_str(), "r");
|
||||||
|
if(currentCmdFile == nullptr) {
|
||||||
|
lastError = errno;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
if(blocking) {
|
||||||
|
return executeBlocking();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currentFd = fileno(currentCmdFile);
|
||||||
|
waiter.fd = currentFd;
|
||||||
|
}
|
||||||
|
state = States::PENDING;
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CommandExecutor::close() {
|
||||||
|
if(state == States::PENDING) {
|
||||||
|
// Attempt to close process, irrespective of if it is running or not
|
||||||
|
if(currentCmdFile != nullptr) {
|
||||||
|
pclose(currentCmdFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandExecutor::printLastError(std::string funcName) const {
|
||||||
|
if(lastError != 0) {
|
||||||
|
#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,
|
||||||
|
DynamicFIFO<uint16_t>* sizesFifo) {
|
||||||
|
this->ringBuffer = ringBuffer;
|
||||||
|
this->sizesFifo = sizesFifo;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CommandExecutor::check(bool& bytesRead) {
|
||||||
|
if(blocking) {
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
switch(state) {
|
||||||
|
case(States::IDLE):
|
||||||
|
case(States::COMMAND_LOADED): {
|
||||||
|
return NO_COMMAND_LOADED_OR_PENDING;
|
||||||
|
}
|
||||||
|
case(States::PENDING): {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = poll(&waiter, 1, 0);
|
||||||
|
switch(result) {
|
||||||
|
case(0): {
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(1): {
|
||||||
|
if (waiter.revents & POLLIN) {
|
||||||
|
ssize_t readBytes = read(currentFd, readVec.data(), readVec.size());
|
||||||
|
if(readBytes == 0) {
|
||||||
|
// Should not happen
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
else if(readBytes > 0) {
|
||||||
|
bytesRead = true;
|
||||||
|
if(printOutput) {
|
||||||
|
// It is assumed the command output is line terminated
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << currentCmd << " | " << readVec.data();
|
||||||
|
#else
|
||||||
|
sif::printInfo("%s | %s", currentCmd, readVec.data());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if(ringBuffer != nullptr) {
|
||||||
|
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(
|
||||||
|
readVec.data()), readBytes);
|
||||||
|
}
|
||||||
|
if(sizesFifo != nullptr) {
|
||||||
|
if(not sizesFifo->full()) {
|
||||||
|
sizesFifo->insert(readBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BYTES_READ;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Should also not happen
|
||||||
|
#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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(waiter.revents & POLLERR) {
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
else if(waiter.revents & POLLHUP) {
|
||||||
|
int result = pclose(currentCmdFile);
|
||||||
|
if(result != 0) {
|
||||||
|
lastError = result;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
state = States::IDLE;
|
||||||
|
currentCmdFile = nullptr;
|
||||||
|
currentFd = 0;
|
||||||
|
return EXECUTION_FINISHED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandExecutor::reset() {
|
||||||
|
CommandExecutor::close();
|
||||||
|
currentCmdFile = nullptr;
|
||||||
|
currentFd = 0;
|
||||||
|
state = States::IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CommandExecutor::getLastError() const {
|
||||||
|
return this->lastError;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandExecutor::States CommandExecutor::getCurrentState() const {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CommandExecutor::executeBlocking() {
|
||||||
|
while(fgets(readVec.data(), readVec.size(), currentCmdFile) != nullptr) {
|
||||||
|
std::string output(readVec.data());
|
||||||
|
if(printOutput) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << currentCmd << " | " << output;
|
||||||
|
#else
|
||||||
|
sif::printInfo("%s | %s", currentCmd, output);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if(ringBuffer != nullptr) {
|
||||||
|
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(output.data()), output.size());
|
||||||
|
}
|
||||||
|
if(sizesFifo != nullptr) {
|
||||||
|
if(not sizesFifo->full()) {
|
||||||
|
sizesFifo->insert(output.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int result = pclose(currentCmdFile);
|
||||||
|
if(result != 0) {
|
||||||
|
lastError = result;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
134
hal/src/fsfw_hal/linux/CommandExecutor.h
Normal file
134
hal/src/fsfw_hal/linux/CommandExecutor.h
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
#ifndef FSFW_SRC_FSFW_OSAL_LINUX_COMMANDEXECUTOR_H_
|
||||||
|
#define FSFW_SRC_FSFW_OSAL_LINUX_COMMANDEXECUTOR_H_
|
||||||
|
|
||||||
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
|
#include "fsfw/returnvalues/FwClassIds.h"
|
||||||
|
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class SimpleRingBuffer;
|
||||||
|
template <typename T> class DynamicFIFO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Helper class to execute shell commands in blocking and non-blocking mode
|
||||||
|
* @details
|
||||||
|
* This class is able to execute processes by using the Linux popen call. It also has the
|
||||||
|
* capability of writing the read output of a process into a provided ring buffer.
|
||||||
|
*
|
||||||
|
* The executor works by first loading the command which should be executed and specifying
|
||||||
|
* whether it should be executed blocking or non-blocking. After that, execution can be started
|
||||||
|
* with the execute command. In blocking mode, the execute command will block until the command
|
||||||
|
* has finished
|
||||||
|
*/
|
||||||
|
class CommandExecutor {
|
||||||
|
public:
|
||||||
|
enum class States {
|
||||||
|
IDLE,
|
||||||
|
COMMAND_LOADED,
|
||||||
|
PENDING
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr uint8_t CLASS_ID = CLASS_ID::LINUX_OSAL;
|
||||||
|
|
||||||
|
//! [EXPORT] : [COMMENT] Execution of the current command has finished
|
||||||
|
static constexpr ReturnValue_t EXECUTION_FINISHED =
|
||||||
|
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0);
|
||||||
|
|
||||||
|
//! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries
|
||||||
|
//! to load another command but a command is still pending
|
||||||
|
static constexpr ReturnValue_t COMMAND_PENDING =
|
||||||
|
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1);
|
||||||
|
//! [EXPORT] : [COMMENT] Some bytes have been read from the executing process
|
||||||
|
static constexpr ReturnValue_t BYTES_READ =
|
||||||
|
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2);
|
||||||
|
//! [EXPORT] : [COMMENT] Command execution failed
|
||||||
|
static constexpr ReturnValue_t COMMAND_ERROR =
|
||||||
|
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3);
|
||||||
|
//! [EXPORT] : [COMMENT]
|
||||||
|
static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING =
|
||||||
|
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4);
|
||||||
|
static constexpr ReturnValue_t PCLOSE_CALL_ERROR =
|
||||||
|
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 6);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Is initialized with maximum size of internal buffer to read data from the
|
||||||
|
* executed process.
|
||||||
|
* @param maxSize
|
||||||
|
*/
|
||||||
|
CommandExecutor(const size_t maxSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a new command which should be executed
|
||||||
|
* @param command
|
||||||
|
* @param blocking
|
||||||
|
* @param printOutput
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ReturnValue_t load(std::string command, bool blocking, bool printOutput = true);
|
||||||
|
/**
|
||||||
|
* Execute the loaded command.
|
||||||
|
* @return
|
||||||
|
* - In blocking mode, it will return RETURN_FAILED if
|
||||||
|
* the result of the system call was not 0. The error value can be accessed using
|
||||||
|
* getLastError
|
||||||
|
* - In non-blocking mode, this call will start
|
||||||
|
* the execution and then return RETURN_OK
|
||||||
|
*/
|
||||||
|
ReturnValue_t execute();
|
||||||
|
/**
|
||||||
|
* Only used in non-blocking mode. Checks the currently running command.
|
||||||
|
* @param bytesRead Will be set to the number of bytes read, if bytes have been read
|
||||||
|
* @return
|
||||||
|
* - BYTES_READ if bytes have been read from the executing process. It is recommended to call
|
||||||
|
* check again after this
|
||||||
|
* - RETURN_OK execution is pending, but no bytes have been read from the executing process
|
||||||
|
* - RETURN_FAILED if execution has failed, error value can be accessed using getLastError
|
||||||
|
* - EXECUTION_FINISHED if the process was executed successfully
|
||||||
|
* - COMMAND_ERROR internal poll error
|
||||||
|
*/
|
||||||
|
ReturnValue_t check(bool& bytesRead);
|
||||||
|
/**
|
||||||
|
* Abort the current command. Should normally not be necessary, check can be used to find
|
||||||
|
* out whether command execution was successful
|
||||||
|
* @return RETURN_OK
|
||||||
|
*/
|
||||||
|
ReturnValue_t close();
|
||||||
|
|
||||||
|
States getCurrentState() const;
|
||||||
|
int getLastError() const;
|
||||||
|
void printLastError(std::string funcName) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign a ring buffer and a FIFO which will be filled by the executor with the output
|
||||||
|
* read from the started process
|
||||||
|
* @param ringBuffer
|
||||||
|
* @param sizesFifo
|
||||||
|
*/
|
||||||
|
void setRingBuffer(SimpleRingBuffer* ringBuffer, DynamicFIFO<uint16_t>* sizesFifo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the executor. This calls close internally and then reset the state machine so new
|
||||||
|
* commands can be loaded and executed
|
||||||
|
*/
|
||||||
|
void reset();
|
||||||
|
private:
|
||||||
|
std::string currentCmd;
|
||||||
|
bool blocking = true;
|
||||||
|
FILE* currentCmdFile = nullptr;
|
||||||
|
int currentFd = 0;
|
||||||
|
bool printOutput = true;
|
||||||
|
std::vector<char> readVec;
|
||||||
|
struct pollfd waiter {};
|
||||||
|
SimpleRingBuffer* ringBuffer = nullptr;
|
||||||
|
DynamicFIFO<uint16_t>* sizesFifo = nullptr;
|
||||||
|
|
||||||
|
States state = States::IDLE;
|
||||||
|
int lastError = 0;
|
||||||
|
|
||||||
|
ReturnValue_t executeBlocking();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_SRC_FSFW_OSAL_LINUX_COMMANDEXECUTOR_H_ */
|
@ -75,7 +75,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) {
|
|||||||
configureGpioByLineName(gpioConfig.first, *regularGpio);
|
configureGpioByLineName(gpioConfig.first, *regularGpio);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpio::GpioTypes::CALLBACK): {
|
case(gpio::GpioTypes::TYPE_CALLBACK): {
|
||||||
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioConfig.second);
|
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioConfig.second);
|
||||||
if(gpioCallback->callback == nullptr) {
|
if(gpioCallback->callback == nullptr) {
|
||||||
return GPIO_INVALID_INSTANCE;
|
return GPIO_INVALID_INSTANCE;
|
||||||
@ -163,12 +163,12 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
|
|||||||
consumer = regularGpio.consumer;
|
consumer = regularGpio.consumer;
|
||||||
/* Configure direction and add a description to the GPIO */
|
/* Configure direction and add a description to the GPIO */
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case(gpio::OUT): {
|
case(gpio::DIR_OUT): {
|
||||||
result = gpiod_line_request_output(lineHandle, consumer.c_str(),
|
result = gpiod_line_request_output(lineHandle, consumer.c_str(),
|
||||||
regularGpio.initValue);
|
regularGpio.initValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpio::IN): {
|
case(gpio::DIR_IN): {
|
||||||
result = gpiod_line_request_input(lineHandle, consumer.c_str());
|
result = gpiod_line_request_input(lineHandle, consumer.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpio::GpioTypes::CALLBACK): {
|
case(gpio::GpioTypes::TYPE_CALLBACK): {
|
||||||
auto callbackGpio = dynamic_cast<GpioCallback*>(gpioConfig.second);
|
auto callbackGpio = dynamic_cast<GpioCallback*>(gpioConfig.second);
|
||||||
if(callbackGpio == nullptr) {
|
if(callbackGpio == nullptr) {
|
||||||
return GPIO_TYPE_FAILURE;
|
return GPIO_TYPE_FAILURE;
|
||||||
@ -371,13 +371,13 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsById(gpioId_t gpioIdToCheck,
|
|||||||
case(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP):
|
case(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP):
|
||||||
case(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL):
|
case(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL):
|
||||||
case(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME): {
|
case(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME): {
|
||||||
if(gpioType == gpio::GpioTypes::NONE or gpioType == gpio::GpioTypes::CALLBACK) {
|
if(gpioType == gpio::GpioTypes::NONE or gpioType == gpio::GpioTypes::TYPE_CALLBACK) {
|
||||||
eraseDuplicateDifferentType = true;
|
eraseDuplicateDifferentType = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpio::GpioTypes::CALLBACK): {
|
case(gpio::GpioTypes::TYPE_CALLBACK): {
|
||||||
if(gpioType != gpio::GpioTypes::CALLBACK) {
|
if(gpioType != gpio::GpioTypes::TYPE_CALLBACK) {
|
||||||
eraseDuplicateDifferentType = true;
|
eraseDuplicateDifferentType = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin,
|
ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin,
|
||||||
std::string consumer, gpio::Direction direction, int initValue) {
|
std::string consumer, gpio::Direction direction, gpio::Levels initValue) {
|
||||||
if(cookie == nullptr) {
|
if(cookie == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace gpio {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ReturnValue_t createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin,
|
ReturnValue_t createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin,
|
||||||
std::string consumer, gpio::Direction direction, int initValue);
|
std::string consumer, gpio::Direction direction, gpio::Levels initValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* BSP_RPI_GPIO_GPIORPI_H_ */
|
#endif /* BSP_RPI_GPIO_GPIORPI_H_ */
|
||||||
|
@ -1,23 +1,49 @@
|
|||||||
target_include_directories(${TARGET_NAME} PRIVATE
|
if(DEFINED TARGET_NAME)
|
||||||
|
target_include_directories(${TARGET_NAME} PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
|
||||||
|
|
||||||
target_sources(${TARGET_NAME} PRIVATE
|
|
||||||
ipc/missionMessageTypes.cpp
|
|
||||||
pollingsequence/PollingSequenceFactory.cpp
|
|
||||||
objects/FsfwFactory.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# If a special translation file for object IDs exists, compile it.
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp")
|
|
||||||
target_sources(${TARGET_NAME} PRIVATE
|
|
||||||
objects/translateObjects.cpp
|
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
# If a special translation file for events exists, compile it.
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp")
|
|
||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
events/translateEvents.cpp
|
ipc/missionMessageTypes.cpp
|
||||||
|
pollingsequence/PollingSequenceFactory.cpp
|
||||||
|
objects/FsfwFactory.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# If a special translation file for object IDs exists, compile it.
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp")
|
||||||
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
|
objects/translateObjects.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# If a special translation file for events exists, compile it.
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp")
|
||||||
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
|
events/translateEvents.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
target_include_directories(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
ipc/missionMessageTypes.cpp
|
||||||
|
pollingsequence/PollingSequenceFactory.cpp
|
||||||
|
objects/FsfwFactory.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# If a special translation file for object IDs exists, compile it.
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp")
|
||||||
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
objects/translateObjects.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# If a special translation file for events exists, compile it.
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp")
|
||||||
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
events/translateEvents.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <fsfw/tmtcpacket/pus/tm/TmPacketStored.h>
|
#include <fsfw/tmtcpacket/pus/tm/TmPacketStored.h>
|
||||||
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
||||||
#include <fsfw/tmtcservices/PusServiceBase.h>
|
#include <fsfw/tmtcservices/PusServiceBase.h>
|
||||||
#include <fsfw/internalError/InternalErrorReporter.h>
|
#include <fsfw/internalerror/InternalErrorReporter.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@ -48,6 +48,6 @@ void Factory::setStaticFrameworkObjectIds() {
|
|||||||
|
|
||||||
DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
|
DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
|
||||||
|
|
||||||
TmPacketStored::timeStamperId = objects::NO_OBJECT;
|
TmPacketBase::timeStamperId = objects::NO_OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
scripts/apply-clang-format.sh
Executable file
8
scripts/apply-clang-format.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
if [[ ! -f README.md ]]; then
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
find ./src -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
||||||
|
find ./hal -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
||||||
|
find ./tests -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
@ -1,76 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*
|
|
||||||
"""Small portable helper script to generate LCOV HTML coverage data"""
|
|
||||||
import os
|
|
||||||
import platform
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
import argparse
|
|
||||||
from typing import List
|
|
||||||
|
|
||||||
|
|
||||||
"""Copy this helper script into your project folder. It will try to determine a CMake build folder
|
|
||||||
and then attempt to build your project with coverage information.
|
|
||||||
|
|
||||||
See Unittest documentation at https://egit.irs.uni-stuttgart.de/fsfw/fsfw for more
|
|
||||||
information how to set up the build folder.
|
|
||||||
"""
|
|
||||||
def main():
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Processing arguments for LCOV helper script.")
|
|
||||||
|
|
||||||
build_dir_list = []
|
|
||||||
if not os.path.isfile('README.md'):
|
|
||||||
os.chdir('..')
|
|
||||||
for directory in os.listdir("."):
|
|
||||||
if os.path.isdir(directory):
|
|
||||||
os.chdir(directory)
|
|
||||||
check_for_cmake_build_dir(build_dir_list)
|
|
||||||
os.chdir("..")
|
|
||||||
|
|
||||||
if len(build_dir_list) == 0:
|
|
||||||
print("No valid CMake build directory found. Trying to set up hosted build")
|
|
||||||
build_directory = 'build-Debug-Host'
|
|
||||||
os.mkdir(build_directory)
|
|
||||||
os.chdir(build_directory)
|
|
||||||
os.system('cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..')
|
|
||||||
os.chdir('..')
|
|
||||||
elif len(build_dir_list) == 1:
|
|
||||||
build_directory = build_dir_list[0]
|
|
||||||
else:
|
|
||||||
print("Multiple build directories found!")
|
|
||||||
build_directory = determine_build_dir(build_dir_list)
|
|
||||||
perform_lcov_operation(build_directory)
|
|
||||||
|
|
||||||
|
|
||||||
def check_for_cmake_build_dir(build_dir_dict: list):
|
|
||||||
if os.path.isfile("CMakeCache.txt"):
|
|
||||||
build_dir_dict.append(os.getcwd())
|
|
||||||
|
|
||||||
|
|
||||||
def perform_lcov_operation(directory):
|
|
||||||
os.chdir(directory)
|
|
||||||
os.system("cmake --build . -- fsfw-tests_coverage -j")
|
|
||||||
|
|
||||||
|
|
||||||
def determine_build_dir(build_dir_list: List[str]):
|
|
||||||
build_directory = ""
|
|
||||||
for idx, directory in enumerate(build_dir_list):
|
|
||||||
print(f"{idx + 1}: {directory}")
|
|
||||||
while True:
|
|
||||||
idx = input("Pick the directory to perform LCOV HTML generation by index: ")
|
|
||||||
if not idx.isdigit():
|
|
||||||
print("Invalid input!")
|
|
||||||
continue
|
|
||||||
|
|
||||||
idx = int(idx)
|
|
||||||
if idx > len(build_dir_list) or idx < 1:
|
|
||||||
print("Invalid input!")
|
|
||||||
continue
|
|
||||||
build_directory = build_dir_list[idx - 1]
|
|
||||||
break
|
|
||||||
return build_directory
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
188
scripts/helper.py
Executable file
188
scripts/helper.py
Executable file
@ -0,0 +1,188 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*
|
||||||
|
"""Small portable helper script to generate test or doc configuration for the
|
||||||
|
flight software framework
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
import webbrowser
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
|
UNITTEST_FOLDER_NAME = 'build-tests'
|
||||||
|
DOCS_FOLDER_NAME = 'build-docs'
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description="FSFW helper script")
|
||||||
|
choices = ('docs', 'tests')
|
||||||
|
parser.add_argument(
|
||||||
|
'type', metavar='type', choices=choices,
|
||||||
|
help=f'Target type. Choices: {choices}'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-a', '--all', action='store_true',
|
||||||
|
help='Create, build and open specified type'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-c', '--create', action='store_true',
|
||||||
|
help='Create docs or test build configuration'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-b', '--build', action='store_true',
|
||||||
|
help='Build the specified type'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-o', '--open', action='store_true',
|
||||||
|
help='Open test or documentation data in webbrowser'
|
||||||
|
)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
if args.all:
|
||||||
|
args.build = True
|
||||||
|
args.create = True
|
||||||
|
args.open = True
|
||||||
|
elif not args.build and not args.create and not args.open:
|
||||||
|
print(
|
||||||
|
'Please select at least one operation to perform. '
|
||||||
|
'Use helper.py -h for more information'
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# This script can be called from root and from script folder
|
||||||
|
if not os.path.isfile('README.md'):
|
||||||
|
os.chdir('..')
|
||||||
|
build_dir_list = []
|
||||||
|
if not args.create:
|
||||||
|
build_dir_list = build_build_dir_list()
|
||||||
|
|
||||||
|
if args.type == 'tests':
|
||||||
|
handle_tests_type(args, build_dir_list)
|
||||||
|
elif args.type == 'docs':
|
||||||
|
handle_docs_type(args, build_dir_list)
|
||||||
|
else:
|
||||||
|
print('Invalid or unknown type')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_docs_type(args, build_dir_list: list):
|
||||||
|
if args.create:
|
||||||
|
if os.path.exists(DOCS_FOLDER_NAME):
|
||||||
|
shutil.rmtree(DOCS_FOLDER_NAME)
|
||||||
|
create_docs_build_cfg()
|
||||||
|
build_directory = DOCS_FOLDER_NAME
|
||||||
|
elif len(build_dir_list) == 0:
|
||||||
|
print('No valid CMake docs build directory found. Trying to set up docs build system')
|
||||||
|
shutil.rmtree(DOCS_FOLDER_NAME)
|
||||||
|
create_docs_build_cfg()
|
||||||
|
build_directory = DOCS_FOLDER_NAME
|
||||||
|
elif len(build_dir_list) == 1:
|
||||||
|
build_directory = build_dir_list[0]
|
||||||
|
else:
|
||||||
|
print("Multiple build directories found!")
|
||||||
|
build_directory = determine_build_dir(build_dir_list)
|
||||||
|
os.chdir(build_directory)
|
||||||
|
if args.build:
|
||||||
|
os.system('cmake --build . -j')
|
||||||
|
if args.open:
|
||||||
|
if not os.path.isfile('docs/sphinx/index.html'):
|
||||||
|
# try again..
|
||||||
|
os.system('cmake --build . -j')
|
||||||
|
if not os.path.isfile('docs/sphinx/index.html'):
|
||||||
|
print(
|
||||||
|
"No Sphinx documentation file detected. "
|
||||||
|
"Try to build it first with the -b argument"
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
webbrowser.open('docs/sphinx/index.html')
|
||||||
|
|
||||||
|
|
||||||
|
def handle_tests_type(args, build_dir_list: list):
|
||||||
|
if args.create:
|
||||||
|
if os.path.exists(UNITTEST_FOLDER_NAME):
|
||||||
|
shutil.rmtree(UNITTEST_FOLDER_NAME)
|
||||||
|
create_tests_build_cfg()
|
||||||
|
build_directory = UNITTEST_FOLDER_NAME
|
||||||
|
elif len(build_dir_list) == 0:
|
||||||
|
print(
|
||||||
|
'No valid CMake tests build directory found. '
|
||||||
|
'Trying to set up test build system'
|
||||||
|
)
|
||||||
|
create_tests_build_cfg()
|
||||||
|
build_directory = UNITTEST_FOLDER_NAME
|
||||||
|
elif len(build_dir_list) == 1:
|
||||||
|
build_directory = build_dir_list[0]
|
||||||
|
else:
|
||||||
|
print("Multiple build directories found!")
|
||||||
|
build_directory = determine_build_dir(build_dir_list)
|
||||||
|
os.chdir(build_directory)
|
||||||
|
if args.build:
|
||||||
|
perform_lcov_operation(build_directory, False)
|
||||||
|
if args.open:
|
||||||
|
if not os.path.isdir('fsfw-tests_coverage'):
|
||||||
|
print("No Unittest folder detected. Try to build them first with the -b argument")
|
||||||
|
sys.exit(1)
|
||||||
|
webbrowser.open('fsfw-tests_coverage/index.html')
|
||||||
|
|
||||||
|
|
||||||
|
def create_tests_build_cfg():
|
||||||
|
os.mkdir(UNITTEST_FOLDER_NAME)
|
||||||
|
os.chdir(UNITTEST_FOLDER_NAME)
|
||||||
|
os.system('cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..')
|
||||||
|
os.chdir('..')
|
||||||
|
|
||||||
|
|
||||||
|
def create_docs_build_cfg():
|
||||||
|
os.mkdir(DOCS_FOLDER_NAME)
|
||||||
|
os.chdir(DOCS_FOLDER_NAME)
|
||||||
|
os.system('cmake -DFSFW_OSAL=host -DFSFW_BUILD_DOCS=ON ..')
|
||||||
|
os.chdir('..')
|
||||||
|
|
||||||
|
|
||||||
|
def build_build_dir_list() -> list:
|
||||||
|
build_dir_list = []
|
||||||
|
for directory in os.listdir("."):
|
||||||
|
if os.path.isdir(directory):
|
||||||
|
os.chdir(directory)
|
||||||
|
build_dir_list = check_for_cmake_build_dir(build_dir_list)
|
||||||
|
os.chdir("..")
|
||||||
|
return build_dir_list
|
||||||
|
|
||||||
|
|
||||||
|
def check_for_cmake_build_dir(build_dir_list: list) -> list:
|
||||||
|
if os.path.isfile("CMakeCache.txt"):
|
||||||
|
build_dir_list.append(os.getcwd())
|
||||||
|
return build_dir_list
|
||||||
|
|
||||||
|
|
||||||
|
def perform_lcov_operation(directory: str, chdir: bool):
|
||||||
|
if chdir:
|
||||||
|
os.chdir(directory)
|
||||||
|
os.system("cmake --build . -- fsfw-tests_coverage -j")
|
||||||
|
|
||||||
|
|
||||||
|
def determine_build_dir(build_dir_list: List[str]):
|
||||||
|
build_directory = ""
|
||||||
|
for idx, directory in enumerate(build_dir_list):
|
||||||
|
print(f"{idx + 1}: {directory}")
|
||||||
|
while True:
|
||||||
|
idx = input("Pick the directory: ")
|
||||||
|
if not idx.isdigit():
|
||||||
|
print("Invalid input!")
|
||||||
|
continue
|
||||||
|
|
||||||
|
idx = int(idx)
|
||||||
|
if idx > len(build_dir_list) or idx < 1:
|
||||||
|
print("Invalid input!")
|
||||||
|
continue
|
||||||
|
build_directory = build_dir_list[idx - 1]
|
||||||
|
break
|
||||||
|
return build_directory
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -18,6 +18,10 @@
|
|||||||
|
|
||||||
// FSFW core defines
|
// FSFW core defines
|
||||||
|
|
||||||
|
#ifndef FSFW_TCP_RECV_WIRETAPPING_ENABLED
|
||||||
|
#define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef FSFW_CPP_OSTREAM_ENABLED
|
#ifndef FSFW_CPP_OSTREAM_ENABLED
|
||||||
#define FSFW_CPP_OSTREAM_ENABLED 1
|
#define FSFW_CPP_OSTREAM_ENABLED 1
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED */
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Circular buffer implementation, useful for buffering
|
* @brief Circular buffer implementation, useful for buffering into data streams.
|
||||||
* into data streams.
|
|
||||||
* @details
|
* @details
|
||||||
* Note that the deleteData() has to be called to increment the read pointer.
|
* Note that the deleteData() has to be called to increment the read pointer.
|
||||||
* This class allocated dynamically, so
|
* This class allocated dynamically, so
|
||||||
@ -20,8 +19,8 @@ public:
|
|||||||
* @param size
|
* @param size
|
||||||
* @param overwriteOld If the ring buffer is overflowing at a write
|
* @param overwriteOld If the ring buffer is overflowing at a write
|
||||||
* operation, the oldest data will be overwritten.
|
* operation, the oldest data will be overwritten.
|
||||||
* @param maxExcessBytes These additional bytes will be allocated in addtion
|
* @param maxExcessBytes These additional bytes will be allocated in addition
|
||||||
* to the specified size to accomodate contiguous write operations
|
* to the specified size to accommodate continuous write operations
|
||||||
* with getFreeElement.
|
* with getFreeElement.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -32,10 +31,10 @@ public:
|
|||||||
* @param buffer
|
* @param buffer
|
||||||
* @param size
|
* @param size
|
||||||
* @param overwriteOld
|
* @param overwriteOld
|
||||||
* If the ring buffer is overflowing at a write operartion, the oldest data
|
* If the ring buffer is overflowing at a write operation, the oldest data
|
||||||
* will be overwritten.
|
* will be overwritten.
|
||||||
* @param maxExcessBytes
|
* @param maxExcessBytes
|
||||||
* If the buffer can accomodate additional bytes for contigous write
|
* If the buffer can accommodate additional bytes for contiguous write
|
||||||
* operations with getFreeElement, this is the maximum allowed additional
|
* operations with getFreeElement, this is the maximum allowed additional
|
||||||
* size
|
* size
|
||||||
*/
|
*/
|
||||||
@ -48,7 +47,7 @@ public:
|
|||||||
* Write to circular buffer and increment write pointer by amount.
|
* Write to circular buffer and increment write pointer by amount.
|
||||||
* @param data
|
* @param data
|
||||||
* @param amount
|
* @param amount
|
||||||
* @return -@c RETURN_OK if write operation was successfull
|
* @return -@c RETURN_OK if write operation was successful
|
||||||
* -@c RETURN_FAILED if
|
* -@c RETURN_FAILED if
|
||||||
*/
|
*/
|
||||||
ReturnValue_t writeData(const uint8_t* data, size_t amount);
|
ReturnValue_t writeData(const uint8_t* data, size_t amount);
|
||||||
@ -108,7 +107,7 @@ public:
|
|||||||
* Delete data by incrementing read pointer.
|
* Delete data by incrementing read pointer.
|
||||||
* @param amount
|
* @param amount
|
||||||
* @param deleteRemaining
|
* @param deleteRemaining
|
||||||
* If the amount specified is larger than the remaing size to read and this
|
* If the amount specified is larger than the remaining size to read and this
|
||||||
* is set to true, the remaining amount will be deleted as well
|
* is set to true, the remaining amount will be deleted as well
|
||||||
* @param trueAmount [out]
|
* @param trueAmount [out]
|
||||||
* If deleteRemaining was set to true, the amount deleted will be assigned
|
* If deleteRemaining was set to true, the amount deleted will be assigned
|
||||||
|
@ -321,3 +321,7 @@ float LocalPoolDataSetBase::getCollectionInterval() const {
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalPoolDataSetBase::printSet() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@ -176,6 +176,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
float getCollectionInterval() const;
|
float getCollectionInterval() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Can be overwritten by a specific implementation of a dataset to print the set.
|
||||||
|
*/
|
||||||
|
virtual void printSet();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
sid_t sid;
|
sid_t sid;
|
||||||
//! This mutex is used if the data is created by one object only.
|
//! This mutex is used if the data is created by one object only.
|
||||||
@ -234,7 +239,6 @@ protected:
|
|||||||
|
|
||||||
PeriodicHousekeepingHelper* periodicHelper = nullptr;
|
PeriodicHousekeepingHelper* periodicHelper = nullptr;
|
||||||
LocalDataPoolManager* poolManager = nullptr;
|
LocalDataPoolManager* poolManager = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,11 +46,12 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
|
|||||||
HasLocalDataPoolIF* hkOwner = ObjectManager::instance()->get<HasLocalDataPoolIF>(poolOwner);
|
HasLocalDataPoolIF* hkOwner = ObjectManager::instance()->get<HasLocalDataPoolIF>(poolOwner);
|
||||||
if(hkOwner == nullptr) {
|
if(hkOwner == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "LocalPoolVariable: The supplied pool owner did not implement the correct "
|
sif::error << "LocalPoolVariable: The supplied pool owner 0x" << std::hex <<
|
||||||
"interface HasLocalDataPoolIF!" << std::endl;
|
poolOwner << std::dec << " did not implement the correct interface " <<
|
||||||
|
"HasLocalDataPoolIF" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError( "LocalPoolVariable: The supplied pool owner did not implement the correct "
|
sif::printError( "LocalPoolVariable: The supplied pool owner 0x%08x did not implement the correct "
|
||||||
"interface HasLocalDataPoolIF!\n");
|
"interface HasLocalDataPoolIF\n", poolOwner);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Base class to implement reconfiguration and failure handling for
|
* @brief Base class to implement reconfiguration and failure handling for
|
||||||
* redundant devices by monitoring their modes health states.
|
* redundant devices by monitoring their modes and health states.
|
||||||
* @details
|
* @details
|
||||||
* Documentation: Dissertation Baetz p.156, 157.
|
* Documentation: Dissertation Baetz p.156, 157.
|
||||||
*
|
*
|
||||||
|
@ -85,9 +85,10 @@ public:
|
|||||||
* Called by DHB in the GET_WRITE doGetWrite().
|
* Called by DHB in the GET_WRITE doGetWrite().
|
||||||
* Get send confirmation that the data in sendMessage() was sent successfully.
|
* Get send confirmation that the data in sendMessage() was sent successfully.
|
||||||
* @param cookie
|
* @param cookie
|
||||||
* @return - @c RETURN_OK if data was sent successfull
|
* @return
|
||||||
* - Everything else triggers falure event with
|
* - @c RETURN_OK if data was sent successfully but a reply is expected
|
||||||
* returnvalue as parameter 1
|
* - NO_REPLY_EXPECTED if data was sent successfully and no reply is expected
|
||||||
|
* - Everything else to indicate failure
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t getSendSuccess(CookieIF *cookie) = 0;
|
virtual ReturnValue_t getSendSuccess(CookieIF *cookie) = 0;
|
||||||
|
|
||||||
|
@ -684,6 +684,11 @@ void DeviceHandlerBase::doGetWrite() {
|
|||||||
void DeviceHandlerBase::doSendRead() {
|
void DeviceHandlerBase::doSendRead() {
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
|
|
||||||
|
result = doSendReadHook();
|
||||||
|
if (result != RETURN_OK){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
size_t replyLen = 0;
|
size_t replyLen = 0;
|
||||||
if(cookieInfo.pendingCommand != deviceCommandMap.end()) {
|
if(cookieInfo.pendingCommand != deviceCommandMap.end()) {
|
||||||
replyLen = getNextReplyLength(cookieInfo.pendingCommand->first);
|
replyLen = getNextReplyLength(cookieInfo.pendingCommand->first);
|
||||||
@ -950,6 +955,10 @@ void DeviceHandlerBase::commandSwitch(ReturnValue_t onOff) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t DeviceHandlerBase::doSendReadHook() {
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::getSwitches(const uint8_t **switches,
|
ReturnValue_t DeviceHandlerBase::getSwitches(const uint8_t **switches,
|
||||||
uint8_t *numberOfSwitches) {
|
uint8_t *numberOfSwitches) {
|
||||||
return DeviceHandlerBase::NO_SWITCH;
|
return DeviceHandlerBase::NO_SWITCH;
|
||||||
|
@ -334,8 +334,7 @@ protected:
|
|||||||
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen
|
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen
|
||||||
* have been set.
|
* have been set.
|
||||||
* - @c HasActionsIF::EXECUTION_COMPLETE to generate a finish reply immediately. This can
|
* - @c HasActionsIF::EXECUTION_COMPLETE to generate a finish reply immediately. This can
|
||||||
* be used if no reply is expected. Otherwise, the developer can call #actionHelper.finish
|
* be used if no reply is expected
|
||||||
* to finish the command handling.
|
|
||||||
* - Anything else triggers an event with the return code as a parameter as well as a
|
* - Anything else triggers an event with the return code as a parameter as well as a
|
||||||
* step reply failed with the return code
|
* step reply failed with the return code
|
||||||
*/
|
*/
|
||||||
@ -1095,6 +1094,12 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void commandSwitch(ReturnValue_t onOff);
|
void commandSwitch(ReturnValue_t onOff);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function can be used to insert device specific code during the do-send-read
|
||||||
|
* step.
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t doSendReadHook();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,7 +120,8 @@ public:
|
|||||||
static const ReturnValue_t WRONG_MODE_FOR_COMMAND = MAKE_RETURN_CODE(0xA5);
|
static const ReturnValue_t WRONG_MODE_FOR_COMMAND = MAKE_RETURN_CODE(0xA5);
|
||||||
static const ReturnValue_t TIMEOUT = MAKE_RETURN_CODE(0xA6);
|
static const ReturnValue_t TIMEOUT = MAKE_RETURN_CODE(0xA6);
|
||||||
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(0xA7);
|
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(0xA7);
|
||||||
static const ReturnValue_t NO_REPLY_EXPECTED = MAKE_RETURN_CODE(0xA8); //!< Used to indicate that this is a command-only command.
|
//!< Used to indicate that this is a command-only command.
|
||||||
|
static const ReturnValue_t NO_REPLY_EXPECTED = MAKE_RETURN_CODE(0xA8);
|
||||||
static const ReturnValue_t NON_OP_TEMPERATURE = MAKE_RETURN_CODE(0xA9);
|
static const ReturnValue_t NON_OP_TEMPERATURE = MAKE_RETURN_CODE(0xA9);
|
||||||
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xAA);
|
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xAA);
|
||||||
|
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
#define TIMEVALOPERATIONS_H_
|
#define TIMEVALOPERATIONS_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <fsfw/platform.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef PLATFORM_WIN
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -1,30 +1,29 @@
|
|||||||
target_sources(${LIB_FSFW_NAME}
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
PRIVATE
|
Clock.cpp
|
||||||
Clock.cpp
|
BinarySemaphore.cpp
|
||||||
BinarySemaphore.cpp
|
CountingSemaphore.cpp
|
||||||
CountingSemaphore.cpp
|
FixedTimeslotTask.cpp
|
||||||
FixedTimeslotTask.cpp
|
InternalErrorCodes.cpp
|
||||||
InternalErrorCodes.cpp
|
MessageQueue.cpp
|
||||||
MessageQueue.cpp
|
Mutex.cpp
|
||||||
Mutex.cpp
|
MutexFactory.cpp
|
||||||
MutexFactory.cpp
|
PeriodicPosixTask.cpp
|
||||||
PeriodicPosixTask.cpp
|
PosixThread.cpp
|
||||||
PosixThread.cpp
|
QueueFactory.cpp
|
||||||
QueueFactory.cpp
|
SemaphoreFactory.cpp
|
||||||
SemaphoreFactory.cpp
|
TaskFactory.cpp
|
||||||
TaskFactory.cpp
|
tcpipHelpers.cpp
|
||||||
tcpipHelpers.cpp
|
unixUtility.cpp
|
||||||
unixUtility.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
|
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
rt
|
rt
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${LIB_FSFW_NAME} INTERFACE
|
target_link_libraries(${LIB_FSFW_NAME} INTERFACE
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -108,8 +108,6 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) {
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
|
ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
|
||||||
timespec timeUnix;
|
timespec timeUnix;
|
||||||
int status = clock_gettime(CLOCK_REALTIME,&timeUnix);
|
int status = clock_gettime(CLOCK_REALTIME,&timeUnix);
|
||||||
|
@ -285,10 +285,10 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
|||||||
|
|
||||||
utility::printUnixErrorGeneric(CLASS_NAME, "sendMessageFromMessageQueue", "EBADF");
|
utility::printUnixErrorGeneric(CLASS_NAME, "sendMessageFromMessageQueue", "EBADF");
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "mq_send to: " << sendTo << " sent from "
|
sif::warning << "mq_send to " << sendTo << " sent from "
|
||||||
<< sentFrom << "failed" << std::endl;
|
<< sentFrom << " failed" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("mq_send to: %d sent from %d failed\n", sendTo, sentFrom);
|
sif::printWarning("mq_send to %d sent from %d failed\n", sendTo, sentFrom);
|
||||||
#endif
|
#endif
|
||||||
return DESTINATION_INVALID;
|
return DESTINATION_INVALID;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief These adapters provides an interface to use the SerializeIF functions
|
* @brief These adapters provides an interface to use the SerializeIF functions
|
||||||
* with arbitrary template objects to facilitate and simplify the
|
* with arbitrary template objects to facilitate and simplify the
|
||||||
* serialization of classes with different multiple different data types
|
* serialization of classes with different multiple different data types
|
||||||
@ -20,174 +20,250 @@
|
|||||||
*/
|
*/
|
||||||
class SerializeAdapter {
|
class SerializeAdapter {
|
||||||
public:
|
public:
|
||||||
/***
|
/***
|
||||||
* This function can be used to serialize a trivial copy-able type or a
|
* @brief Serialize a trivial copy-able type or a child of SerializeIF.
|
||||||
* child of SerializeIF.
|
* @details
|
||||||
* The right template to be called is determined in the function itself.
|
* The right template to be called is determined in the function itself.
|
||||||
* For objects of non trivial copy-able type this function is almost never
|
* For objects of non trivial copy-able type this function is almost never
|
||||||
* called by the user directly. Instead helpers for specific types like
|
* called by the user directly. Instead helpers for specific types like
|
||||||
* SerialArrayListAdapter or SerialLinkedListAdapter is the right choice here.
|
* SerialArrayListAdapter or SerialLinkedListAdapter are the right choice here.
|
||||||
*
|
*
|
||||||
* @param[in] object Object to serialize, the used type is deduced from this pointer
|
* @param[in] object: Object to serialize, the used type is deduced from this pointer
|
||||||
* @param[in/out] buffer Buffer to serialize into. Will be moved by the function.
|
* @param[in/out] buffer: Pointer to the buffer to serialize into. Buffer position will be
|
||||||
* @param[in/out] size Size of current written buffer. Will be incremented by the function.
|
* incremented by the function.
|
||||||
* @param[in] maxSize Max size of Buffer
|
* @param[in/out] size: Pointer to size of current written buffer.
|
||||||
* @param[in] streamEndianness Endianness of serialized element as in according to SerializeIF::Endianness
|
* SIze will be incremented by the function.
|
||||||
* @return
|
* @param[in] maxSize: Max size of Buffer
|
||||||
* - @c BUFFER_TOO_SHORT The given buffer in is too short
|
* @param[in] streamEndianness: Endianness of serialized element as in according to
|
||||||
* - @c RETURN_FAILED Generic Error
|
* SerializeIF::Endianness
|
||||||
* - @c RETURN_OK Successful serialization
|
* @return
|
||||||
*/
|
* - @c BUFFER_TOO_SHORT The given buffer in is too short
|
||||||
template<typename T>
|
* - @c RETURN_FAILED Generic Error
|
||||||
static ReturnValue_t serialize(const T *object, uint8_t **buffer,
|
* - @c RETURN_OK Successful serialization
|
||||||
size_t *size, size_t maxSize,
|
*/
|
||||||
SerializeIF::Endianness streamEndianness) {
|
template<typename T>
|
||||||
InternalSerializeAdapter<T, std::is_base_of<SerializeIF, T>::value> adapter;
|
static ReturnValue_t serialize(const T *object, uint8_t **buffer,
|
||||||
return adapter.serialize(object, buffer, size, maxSize,
|
size_t *size, size_t maxSize,
|
||||||
streamEndianness);
|
SerializeIF::Endianness streamEndianness) {
|
||||||
}
|
InternalSerializeAdapter<T, std::is_base_of<SerializeIF, T>::value> adapter;
|
||||||
/**
|
return adapter.serialize(object, buffer, size, maxSize,
|
||||||
* Function to return the serialized size of the object in the pointer.
|
streamEndianness);
|
||||||
* May be a trivially copy-able object or a Child of SerializeIF
|
}
|
||||||
*
|
|
||||||
* @param object Pointer to Object
|
/***
|
||||||
* @return Serialized size of object
|
* This function can be used to serialize a trivial copy-able type or a child of SerializeIF.
|
||||||
*/
|
* The right template to be called is determined in the function itself.
|
||||||
template<typename T>
|
* For objects of non trivial copy-able type this function is almost never
|
||||||
static size_t getSerializedSize(const T *object){
|
* called by the user directly. Instead helpers for specific types like
|
||||||
InternalSerializeAdapter<T, std::is_base_of<SerializeIF, T>::value> adapter;
|
* SerialArrayListAdapter or SerialLinkedListAdapter are the right choice here.
|
||||||
return adapter.getSerializedSize(object);
|
*
|
||||||
}
|
* @param[in] object: Object to serialize, the used type is deduced from this pointer
|
||||||
/**
|
* @param[in/out] buffer: Buffer to serialize into.
|
||||||
* @brief
|
* @param[out] serSize: Serialized size
|
||||||
* Deserializes a object from a given buffer of given size.
|
* @param[in] maxSize: Max size of buffer
|
||||||
* Object Must be trivially copy-able or a child of SerializeIF.
|
* @param[in] streamEndianness: Endianness of serialized element as in according to
|
||||||
*
|
* SerializeIF::Endianness
|
||||||
* @details
|
* @return
|
||||||
* Buffer will be moved to the current read location. Size will be decreased by the function.
|
* - @c BUFFER_TOO_SHORT The given buffer in is too short
|
||||||
*
|
* - @c RETURN_FAILED Generic Error
|
||||||
* @param[in/out] buffer Buffer to deSerialize from. Will be moved by the function.
|
* - @c RETURN_OK Successful serialization
|
||||||
* @param[in/out] size Remaining size of the buffer to read from. Will be decreased by function.
|
*/
|
||||||
* @param[in] streamEndianness Endianness as in according to SerializeIF::Endianness
|
template<typename T>
|
||||||
* @return
|
static ReturnValue_t serialize(const T *object, uint8_t* const buffer, size_t* serSize,
|
||||||
* - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object
|
size_t maxSize, SerializeIF::Endianness streamEndianness) {
|
||||||
* - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected
|
if(object == nullptr or buffer == nullptr) {
|
||||||
* - @c RETURN_FAILED Generic Error
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
* - @c RETURN_OK Successful deserialization
|
}
|
||||||
*/
|
InternalSerializeAdapter<T, std::is_base_of<SerializeIF, T>::value> adapter;
|
||||||
template<typename T>
|
uint8_t** tempPtr = const_cast<uint8_t**>(&buffer);
|
||||||
static ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
|
size_t tmpSize = 0;
|
||||||
size_t *size, SerializeIF::Endianness streamEndianness) {
|
ReturnValue_t result = adapter.serialize(object, tempPtr, &tmpSize, maxSize,
|
||||||
InternalSerializeAdapter<T, std::is_base_of<SerializeIF, T>::value> adapter;
|
streamEndianness);
|
||||||
return adapter.deSerialize(object, buffer, size, streamEndianness);
|
if(serSize != nullptr) {
|
||||||
}
|
*serSize = tmpSize;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Function to return the serialized size of the object in the pointer.
|
||||||
|
* @details
|
||||||
|
* May be a trivially copy-able object or a child of SerializeIF.
|
||||||
|
*
|
||||||
|
* @param object Pointer to Object
|
||||||
|
* @return Serialized size of object
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
static size_t getSerializedSize(const T *object){
|
||||||
|
InternalSerializeAdapter<T, std::is_base_of<SerializeIF, T>::value> adapter;
|
||||||
|
return adapter.getSerializedSize(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deserializes a object from a given buffer of given size.
|
||||||
|
*
|
||||||
|
* @details
|
||||||
|
* Object Must be trivially copy-able or a child of SerializeIF.
|
||||||
|
* Buffer will be moved to the current read location. Size will be decreased by the function.
|
||||||
|
*
|
||||||
|
* @param[in] object: Pointer to object to deserialize
|
||||||
|
* @param[in/out] buffer: Pointer to the buffer to deSerialize from. Buffer position will be
|
||||||
|
* incremented by the function
|
||||||
|
* @param[in/out] size: Pointer to remaining size of the buffer to read from.
|
||||||
|
* Will be decreased by function.
|
||||||
|
* @param[in] streamEndianness: Endianness as in according to SerializeIF::Endianness
|
||||||
|
* @return
|
||||||
|
* - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object
|
||||||
|
* - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected
|
||||||
|
* - @c RETURN_FAILED Generic Error
|
||||||
|
* - @c RETURN_OK Successful deserialization
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
static ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
|
||||||
|
size_t *size, SerializeIF::Endianness streamEndianness) {
|
||||||
|
InternalSerializeAdapter<T, std::is_base_of<SerializeIF, T>::value> adapter;
|
||||||
|
return adapter.deSerialize(object, buffer, size, streamEndianness);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deserializes a object from a given buffer of given size.
|
||||||
|
*
|
||||||
|
* @details
|
||||||
|
* Object Must be trivially copy-able or a child of SerializeIF.
|
||||||
|
*
|
||||||
|
* @param[in] object: Pointer to object to deserialize
|
||||||
|
* @param[in] buffer: Buffer to deSerialize from
|
||||||
|
* @param[out] deserSize: Deserialized length
|
||||||
|
* @param[in] streamEndianness: Endianness as in according to SerializeIF::Endianness
|
||||||
|
* @return
|
||||||
|
* - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object
|
||||||
|
* - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected
|
||||||
|
* - @c RETURN_FAILED Generic Error
|
||||||
|
* - @c RETURN_OK Successful deserialization
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
static ReturnValue_t deSerialize(T *object, const uint8_t* buffer,
|
||||||
|
size_t* deserSize, SerializeIF::Endianness streamEndianness) {
|
||||||
|
if(object == nullptr or buffer == nullptr) {
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
InternalSerializeAdapter<T, std::is_base_of<SerializeIF, T>::value> adapter;
|
||||||
|
const uint8_t** tempPtr = &buffer;
|
||||||
|
size_t maxVal = -1;
|
||||||
|
ReturnValue_t result = adapter.deSerialize(object, tempPtr, &maxVal, streamEndianness);
|
||||||
|
if(deserSize != nullptr) {
|
||||||
|
*deserSize = -1 - maxVal;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Internal template to deduce the right function calls at compile time
|
* Internal template to deduce the right function calls at compile time
|
||||||
*/
|
*/
|
||||||
template<typename T, bool> class InternalSerializeAdapter;
|
template<typename T, bool> class InternalSerializeAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template to be used if T is not a child of SerializeIF
|
* Template to be used if T is not a child of SerializeIF
|
||||||
*
|
*
|
||||||
* @tparam T T must be trivially_copyable
|
* @tparam T T must be trivially_copyable
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class InternalSerializeAdapter<T, false> {
|
class InternalSerializeAdapter<T, false> {
|
||||||
static_assert (std::is_trivially_copyable<T>::value,
|
static_assert (std::is_trivially_copyable<T>::value,
|
||||||
"If a type needs to be serialized it must be a child of "
|
"If a type needs to be serialized it must be a child of "
|
||||||
"SerializeIF or trivially copy-able");
|
"SerializeIF or trivially copy-able");
|
||||||
public:
|
public:
|
||||||
static ReturnValue_t serialize(const T *object, uint8_t **buffer,
|
static ReturnValue_t serialize(const T *object, uint8_t **buffer,
|
||||||
size_t *size, size_t max_size,
|
size_t *size, size_t max_size,
|
||||||
SerializeIF::Endianness streamEndianness) {
|
SerializeIF::Endianness streamEndianness) {
|
||||||
size_t ignoredSize = 0;
|
size_t ignoredSize = 0;
|
||||||
if (size == nullptr) {
|
if (size == nullptr) {
|
||||||
size = &ignoredSize;
|
size = &ignoredSize;
|
||||||
}
|
}
|
||||||
// Check remaining size is large enough and check integer
|
// Check remaining size is large enough and check integer
|
||||||
// overflow of *size
|
// overflow of *size
|
||||||
size_t newSize = sizeof(T) + *size;
|
size_t newSize = sizeof(T) + *size;
|
||||||
if ((newSize <= max_size) and (newSize > *size)) {
|
if ((newSize <= max_size) and (newSize > *size)) {
|
||||||
T tmp;
|
T tmp;
|
||||||
switch (streamEndianness) {
|
switch (streamEndianness) {
|
||||||
case SerializeIF::Endianness::BIG:
|
case SerializeIF::Endianness::BIG:
|
||||||
tmp = EndianConverter::convertBigEndian<T>(*object);
|
tmp = EndianConverter::convertBigEndian<T>(*object);
|
||||||
break;
|
break;
|
||||||
case SerializeIF::Endianness::LITTLE:
|
case SerializeIF::Endianness::LITTLE:
|
||||||
tmp = EndianConverter::convertLittleEndian<T>(*object);
|
tmp = EndianConverter::convertLittleEndian<T>(*object);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case SerializeIF::Endianness::MACHINE:
|
case SerializeIF::Endianness::MACHINE:
|
||||||
tmp = *object;
|
tmp = *object;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::memcpy(*buffer, &tmp, sizeof(T));
|
std::memcpy(*buffer, &tmp, sizeof(T));
|
||||||
*size += sizeof(T);
|
*size += sizeof(T);
|
||||||
(*buffer) += sizeof(T);
|
(*buffer) += sizeof(T);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
} else {
|
} else {
|
||||||
return SerializeIF::BUFFER_TOO_SHORT;
|
return SerializeIF::BUFFER_TOO_SHORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
|
ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
|
||||||
size_t *size, SerializeIF::Endianness streamEndianness) {
|
size_t *size, SerializeIF::Endianness streamEndianness) {
|
||||||
T tmp;
|
T tmp;
|
||||||
if (*size >= sizeof(T)) {
|
if (*size >= sizeof(T)) {
|
||||||
*size -= sizeof(T);
|
*size -= sizeof(T);
|
||||||
std::memcpy(&tmp, *buffer, sizeof(T));
|
std::memcpy(&tmp, *buffer, sizeof(T));
|
||||||
switch (streamEndianness) {
|
switch (streamEndianness) {
|
||||||
case SerializeIF::Endianness::BIG:
|
case SerializeIF::Endianness::BIG:
|
||||||
*object = EndianConverter::convertBigEndian<T>(tmp);
|
*object = EndianConverter::convertBigEndian<T>(tmp);
|
||||||
break;
|
break;
|
||||||
case SerializeIF::Endianness::LITTLE:
|
case SerializeIF::Endianness::LITTLE:
|
||||||
*object = EndianConverter::convertLittleEndian<T>(tmp);
|
*object = EndianConverter::convertLittleEndian<T>(tmp);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case SerializeIF::Endianness::MACHINE:
|
case SerializeIF::Endianness::MACHINE:
|
||||||
*object = tmp;
|
*object = tmp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*buffer += sizeof(T);
|
*buffer += sizeof(T);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
} else {
|
} else {
|
||||||
return SerializeIF::STREAM_TOO_SHORT;
|
return SerializeIF::STREAM_TOO_SHORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getSerializedSize(const T *object) {
|
uint32_t getSerializedSize(const T *object) {
|
||||||
return sizeof(T);
|
return sizeof(T);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template for objects that inherit from SerializeIF
|
* Template for objects that inherit from SerializeIF
|
||||||
*
|
*
|
||||||
* @tparam T A child of SerializeIF
|
* @tparam T A child of SerializeIF
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class InternalSerializeAdapter<T, true> {
|
class InternalSerializeAdapter<T, true> {
|
||||||
public:
|
public:
|
||||||
ReturnValue_t serialize(const T *object, uint8_t **buffer, size_t *size,
|
ReturnValue_t serialize(const T *object, uint8_t **buffer, size_t *size,
|
||||||
size_t max_size,
|
size_t max_size,
|
||||||
SerializeIF::Endianness streamEndianness) const {
|
SerializeIF::Endianness streamEndianness) const {
|
||||||
size_t ignoredSize = 0;
|
size_t ignoredSize = 0;
|
||||||
if (size == nullptr) {
|
if (size == nullptr) {
|
||||||
size = &ignoredSize;
|
size = &ignoredSize;
|
||||||
}
|
}
|
||||||
return object->serialize(buffer, size, max_size, streamEndianness);
|
return object->serialize(buffer, size, max_size, streamEndianness);
|
||||||
}
|
}
|
||||||
size_t getSerializedSize(const T *object) const {
|
size_t getSerializedSize(const T *object) const {
|
||||||
return object->getSerializedSize();
|
return object->getSerializedSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
|
ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
|
||||||
size_t *size, SerializeIF::Endianness streamEndianness) {
|
size_t *size, SerializeIF::Endianness streamEndianness) {
|
||||||
return object->deSerialize(buffer, size, streamEndianness);
|
return object->deSerialize(buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _FSFW_SERIALIZE_SERIALIZEADAPTER_H_ */
|
#endif /* _FSFW_SERIALIZE_SERIALIZEADAPTER_H_ */
|
||||||
|
@ -62,7 +62,8 @@ protected:
|
|||||||
struct ChildInfo {
|
struct ChildInfo {
|
||||||
MessageQueueId_t commandQueue;
|
MessageQueueId_t commandQueue;
|
||||||
Mode_t mode;
|
Mode_t mode;
|
||||||
Submode_t submode;bool healthChanged;
|
Submode_t submode;
|
||||||
|
bool healthChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
Mode_t mode;
|
Mode_t mode;
|
||||||
|
@ -99,6 +99,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
static ReturnValue_t getDateAndTime(TimeOfDay_t *time);
|
static ReturnValue_t getDateAndTime(TimeOfDay_t *time);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert to time of day struct given the POSIX timeval struct
|
||||||
|
* @param from
|
||||||
|
* @param to
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static ReturnValue_t convertTimevalToTimeOfDay(const timeval *from,
|
||||||
|
TimeOfDay_t *to);
|
||||||
/**
|
/**
|
||||||
* Converts a time of day struct to POSIX seconds.
|
* Converts a time of day struct to POSIX seconds.
|
||||||
* @param time The time of day as input
|
* @param time The time of day as input
|
||||||
|
@ -42,6 +42,20 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t *leapSeconds_) {
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t Clock::convertTimevalToTimeOfDay(const timeval* from, TimeOfDay_t* to) {
|
||||||
|
struct tm* timeInfo;
|
||||||
|
timeInfo = gmtime(&from->tv_sec);
|
||||||
|
to->year = timeInfo->tm_year + 1900;
|
||||||
|
to->month = timeInfo->tm_mon+1;
|
||||||
|
to->day = timeInfo->tm_mday;
|
||||||
|
to->hour = timeInfo->tm_hour;
|
||||||
|
to->minute = timeInfo->tm_min;
|
||||||
|
to->second = timeInfo->tm_sec;
|
||||||
|
to->usecond = from->tv_usec;
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t Clock::checkOrCreateClockMutex() {
|
ReturnValue_t Clock::checkOrCreateClockMutex() {
|
||||||
if (timeMutex == nullptr) {
|
if (timeMutex == nullptr) {
|
||||||
MutexFactory *mutexFactory = MutexFactory::instance();
|
MutexFactory *mutexFactory = MutexFactory::instance();
|
||||||
|
@ -73,7 +73,7 @@ namespace spacepacket {
|
|||||||
|
|
||||||
constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid,
|
constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid,
|
||||||
bool secondaryHeaderFlag = true) {
|
bool secondaryHeaderFlag = true) {
|
||||||
return (((isTc << 5) & 0x10) | ((secondaryHeaderFlag << 4) & 0x08) |
|
return ((isTc << 4) | (secondaryHeaderFlag << 3) |
|
||||||
((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff);
|
((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,13 +183,16 @@ ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage *message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(tmFifo->full()) {
|
if(tmFifo->full()) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
if(warningLatch) {
|
||||||
sif::warning << "TmTcBridge::storeDownlinkData: TM downlink max. number "
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
"of stored packet IDs reached!" << std::endl;
|
sif::warning << "TmTcBridge::storeDownlinkData: TM downlink max. number "
|
||||||
#else
|
"of stored packet IDs reached!" << std::endl;
|
||||||
sif::printWarning("TmTcBridge::storeDownlinkData: TM downlink max. number "
|
#else
|
||||||
"of stored packet IDs reached!\n");
|
sif::printWarning("TmTcBridge::storeDownlinkData: TM downlink max. number "
|
||||||
#endif
|
"of stored packet IDs reached!\n");
|
||||||
|
#endif
|
||||||
|
warningLatch = true;
|
||||||
|
}
|
||||||
if(overwriteOld) {
|
if(overwriteOld) {
|
||||||
tmFifo->retrieve(&storeId);
|
tmFifo->retrieve(&storeId);
|
||||||
tmStore->deleteData(storeId);
|
tmStore->deleteData(storeId);
|
||||||
|
@ -75,6 +75,7 @@ public:
|
|||||||
virtual uint16_t getIdentifier() override;
|
virtual uint16_t getIdentifier() override;
|
||||||
virtual MessageQueueId_t getRequestQueue() override;
|
virtual MessageQueueId_t getRequestQueue() override;
|
||||||
|
|
||||||
|
bool warningLatch = true;
|
||||||
protected:
|
protected:
|
||||||
//! Cached for initialize function.
|
//! Cached for initialize function.
|
||||||
object_id_t tmStoreId = objects::NO_OBJECT;
|
object_id_t tmStoreId = objects::NO_OBJECT;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
TestTask.cpp
|
TestTask.cpp
|
||||||
)
|
)
|
@ -3,128 +3,213 @@
|
|||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <catch2/catch_approx.hpp>
|
#include <catch2/catch_approx.hpp>
|
||||||
|
#include <fsfw/serialize/SerialBufferAdapter.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
static bool test_value_bool = true;
|
static bool testBool = true;
|
||||||
static uint8_t tv_uint8 {5};
|
static uint8_t tvUint8 {5};
|
||||||
static uint16_t tv_uint16 {283};
|
static uint16_t tvUint16 {283};
|
||||||
static uint32_t tv_uint32 {929221};
|
static uint32_t tvUint32 {929221};
|
||||||
static uint64_t tv_uint64 {2929329429};
|
static uint64_t tvUint64 {2929329429};
|
||||||
|
|
||||||
static int8_t tv_int8 {-16};
|
static int8_t tvInt8 {-16};
|
||||||
static int16_t tv_int16 {-829};
|
static int16_t tvInt16 {-829};
|
||||||
static int32_t tv_int32 {-2312};
|
static int32_t tvInt32 {-2312};
|
||||||
|
|
||||||
static float tv_float {8.2149214};
|
static float tvFloat {8.2149214};
|
||||||
static float tv_sfloat = {-922.2321321};
|
static float tvSfloat = {-922.2321321};
|
||||||
static double tv_double {9.2132142141e8};
|
static double tvDouble {9.2132142141e8};
|
||||||
static double tv_sdouble {-2.2421e19};
|
static double tvSdouble {-2.2421e19};
|
||||||
|
|
||||||
static std::array<uint8_t, 512> test_array;
|
static std::array<uint8_t, 512> TEST_ARRAY;
|
||||||
|
|
||||||
TEST_CASE( "Serialization size tests", "[TestSerialization]") {
|
TEST_CASE( "Serialization size tests", "[SerSizeTest]") {
|
||||||
//REQUIRE(unitTestClass.test_autoserialization() == 0);
|
//REQUIRE(unitTestClass.test_autoserialization() == 0);
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&test_value_bool) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&testBool) ==
|
||||||
sizeof(test_value_bool));
|
sizeof(testBool));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_uint8) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvUint8) ==
|
||||||
sizeof(tv_uint8));
|
sizeof(tvUint8));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_uint16) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvUint16) ==
|
||||||
sizeof(tv_uint16));
|
sizeof(tvUint16));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_uint32 ) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvUint32 ) ==
|
||||||
sizeof(tv_uint32));
|
sizeof(tvUint32));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_uint64) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvUint64) ==
|
||||||
sizeof(tv_uint64));
|
sizeof(tvUint64));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_int8) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvInt8) ==
|
||||||
sizeof(tv_int8));
|
sizeof(tvInt8));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_int16) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvInt16) ==
|
||||||
sizeof(tv_int16));
|
sizeof(tvInt16));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_int32) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvInt32) ==
|
||||||
sizeof(tv_int32));
|
sizeof(tvInt32));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_float) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvFloat) ==
|
||||||
sizeof(tv_float));
|
sizeof(tvFloat));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_sfloat) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvSfloat) ==
|
||||||
sizeof(tv_sfloat ));
|
sizeof(tvSfloat ));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_double) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvDouble) ==
|
||||||
sizeof(tv_double));
|
sizeof(tvDouble));
|
||||||
REQUIRE(SerializeAdapter::getSerializedSize(&tv_sdouble) ==
|
REQUIRE(SerializeAdapter::getSerializedSize(&tvSdouble) ==
|
||||||
sizeof(tv_sdouble));
|
sizeof(tvSdouble));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Auto Serialize Adapter", "[SerAdapter]") {
|
||||||
|
size_t serializedSize = 0;
|
||||||
|
uint8_t * pArray = TEST_ARRAY.data();
|
||||||
|
|
||||||
TEST_CASE("Auto Serialize Adapter testing", "[single-file]") {
|
SECTION("SerDe") {
|
||||||
size_t serialized_size = 0;
|
size_t deserSize = 0;
|
||||||
uint8_t * p_array = test_array.data();
|
SerializeAdapter::serialize(&testBool, TEST_ARRAY.data(), &deserSize, TEST_ARRAY.size(),
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
REQUIRE(deserSize == 1);
|
||||||
|
REQUIRE(TEST_ARRAY[0] == true);
|
||||||
|
bool readBack = false;
|
||||||
|
SerializeAdapter::deSerialize(&readBack, TEST_ARRAY.data(), &deserSize,
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
REQUIRE(deserSize == 1);
|
||||||
|
REQUIRE(readBack == true);
|
||||||
|
SerializeAdapter::serialize(&tvUint8, TEST_ARRAY.data(), &deserSize, TEST_ARRAY.size(),
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
REQUIRE(deserSize == 1);
|
||||||
|
REQUIRE(TEST_ARRAY[0] == 5);
|
||||||
|
uint8_t readBackUint8 = 0;
|
||||||
|
uint8_t* const testPtr = TEST_ARRAY.data();
|
||||||
|
uint8_t* const shouldStayConst = testPtr;
|
||||||
|
SerializeAdapter::deSerialize(&readBackUint8, testPtr, &deserSize,
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
REQUIRE(testPtr == shouldStayConst);
|
||||||
|
REQUIRE(deserSize == 1);
|
||||||
|
REQUIRE(readBackUint8 == 5);
|
||||||
|
SerializeAdapter::serialize(&tvUint16, TEST_ARRAY.data(), &deserSize, TEST_ARRAY.size(),
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
REQUIRE(deserSize == 2);
|
||||||
|
deserSize = 0;
|
||||||
|
uint16_t readBackUint16 = 0;
|
||||||
|
SerializeAdapter::deSerialize(&readBackUint16, TEST_ARRAY.data(), &deserSize,
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
REQUIRE(deserSize == 2);
|
||||||
|
REQUIRE(readBackUint16 == 283);
|
||||||
|
|
||||||
SECTION("Serializing...") {
|
SerializeAdapter::serialize(&tvUint32, TEST_ARRAY.data(), &deserSize, TEST_ARRAY.size(),
|
||||||
SerializeAdapter::serialize(&test_value_bool, &p_array,
|
SerializeIF::Endianness::MACHINE);
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
REQUIRE(deserSize == 4);
|
||||||
SerializeAdapter::serialize(&tv_uint8, &p_array,
|
uint32_t readBackUint32 = 0;
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
deserSize = 0;
|
||||||
SerializeAdapter::serialize(&tv_uint16, &p_array,
|
SerializeAdapter::deSerialize(&readBackUint32, TEST_ARRAY.data(), &deserSize,
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::serialize(&tv_uint32, &p_array,
|
REQUIRE(deserSize == 4);
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
REQUIRE(readBackUint32 == 929221);
|
||||||
SerializeAdapter::serialize(&tv_int8, &p_array,
|
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
SerializeAdapter::serialize(&tvInt16, TEST_ARRAY.data(), &deserSize, TEST_ARRAY.size(),
|
||||||
SerializeAdapter::serialize(&tv_int16, &p_array,
|
SerializeIF::Endianness::MACHINE);
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
REQUIRE(deserSize == 2);
|
||||||
SerializeAdapter::serialize(&tv_int32, &p_array,
|
int16_t readBackInt16 = 0;
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
SerializeAdapter::deSerialize(&readBackInt16, TEST_ARRAY.data(), &deserSize,
|
||||||
SerializeAdapter::serialize(&tv_uint64, &p_array,
|
SerializeIF::Endianness::MACHINE);
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
REQUIRE(readBackInt16 == -829);
|
||||||
SerializeAdapter::serialize(&tv_float, &p_array,
|
REQUIRE(deserSize == 2);
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
|
||||||
SerializeAdapter::serialize(&tv_double, &p_array,
|
SerializeAdapter::serialize(&tvFloat, TEST_ARRAY.data(), &deserSize, TEST_ARRAY.size(),
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::serialize(&tv_sfloat, &p_array,
|
float readBackFloat = 0.0;
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
SerializeAdapter::deSerialize(&readBackFloat, TEST_ARRAY.data(), &deserSize,
|
||||||
SerializeAdapter::serialize(&tv_sdouble, &p_array,
|
SerializeIF::Endianness::MACHINE);
|
||||||
&serialized_size, test_array.size(), SerializeIF::Endianness::MACHINE);
|
REQUIRE(readBackFloat == Catch::Approx(8.214921));
|
||||||
REQUIRE (serialized_size == 47);
|
|
||||||
|
SerializeAdapter::serialize(&tvSdouble, TEST_ARRAY.data(), &deserSize, TEST_ARRAY.size(),
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
double readBackSignedDouble = 0.0;
|
||||||
|
SerializeAdapter::deSerialize(&readBackSignedDouble, TEST_ARRAY.data(), &deserSize,
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
REQUIRE(readBackSignedDouble == Catch::Approx(-2.2421e19));
|
||||||
|
|
||||||
|
uint8_t testBuf[4] = {1, 2, 3, 4};
|
||||||
|
SerialBufferAdapter<uint8_t> bufferAdapter(testBuf, sizeof(testBuf));
|
||||||
|
SerializeAdapter::serialize(&bufferAdapter, TEST_ARRAY.data(), &deserSize,
|
||||||
|
TEST_ARRAY.size(), SerializeIF::Endianness::MACHINE);
|
||||||
|
REQUIRE(deserSize == 4);
|
||||||
|
for(uint8_t idx = 0; idx < 4; idx++) {
|
||||||
|
REQUIRE(TEST_ARRAY[idx] == idx + 1);
|
||||||
|
}
|
||||||
|
deserSize = 0;
|
||||||
|
testBuf[0] = 0;
|
||||||
|
testBuf[1] = 12;
|
||||||
|
SerializeAdapter::deSerialize(&bufferAdapter, TEST_ARRAY.data(), &deserSize,
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
REQUIRE(deserSize == 4);
|
||||||
|
for(uint8_t idx = 0; idx < 4; idx++) {
|
||||||
|
REQUIRE(testBuf[idx] == idx + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Serialize incrementing") {
|
||||||
|
SerializeAdapter::serialize(&testBool, &pArray, &serializedSize,
|
||||||
|
TEST_ARRAY.size(), SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvUint8, &pArray, &serializedSize,
|
||||||
|
TEST_ARRAY.size(), SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvUint16, &pArray, &serializedSize,
|
||||||
|
TEST_ARRAY.size(), SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvUint32, &pArray, &serializedSize,
|
||||||
|
TEST_ARRAY.size(), SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvInt8, &pArray, &serializedSize,
|
||||||
|
TEST_ARRAY.size(), SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvInt16, &pArray, &serializedSize,
|
||||||
|
TEST_ARRAY.size(), SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvInt32, &pArray, &serializedSize,
|
||||||
|
TEST_ARRAY.size(), SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvUint64, &pArray, &serializedSize,
|
||||||
|
TEST_ARRAY.size(), SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvFloat, &pArray, &serializedSize,
|
||||||
|
TEST_ARRAY.size(), SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvDouble, &pArray, &serializedSize, TEST_ARRAY.size(),
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvSfloat, &pArray, &serializedSize, TEST_ARRAY.size(),
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
SerializeAdapter::serialize(&tvSdouble, &pArray, &serializedSize, TEST_ARRAY.size(),
|
||||||
|
SerializeIF::Endianness::MACHINE);
|
||||||
|
REQUIRE (serializedSize == 47);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Deserializing") {
|
SECTION("Deserialize decrementing") {
|
||||||
p_array = test_array.data();
|
pArray = TEST_ARRAY.data();
|
||||||
size_t remaining_size = serialized_size;
|
size_t remaining_size = serializedSize;
|
||||||
SerializeAdapter::deSerialize(&test_value_bool,
|
SerializeAdapter::deSerialize(&testBool, const_cast<const uint8_t**>(&pArray),
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
&remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_uint8,
|
SerializeAdapter::deSerialize(&tvUint8, const_cast<const uint8_t**>(&pArray),
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
&remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_uint16,
|
SerializeAdapter::deSerialize(&tvUint16, const_cast<const uint8_t**>(&pArray),
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
&remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_uint32,
|
SerializeAdapter::deSerialize(&tvUint32, const_cast<const uint8_t**>(&pArray),
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
&remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_int8,
|
SerializeAdapter::deSerialize(&tvInt8, const_cast<const uint8_t**>(&pArray),
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
&remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_int16,
|
SerializeAdapter::deSerialize(&tvInt16, const_cast<const uint8_t**>(&pArray),
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
&remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_int32,
|
SerializeAdapter::deSerialize(&tvInt32, const_cast<const uint8_t**>(&pArray),
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
&remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_uint64,
|
SerializeAdapter::deSerialize(&tvUint64,
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
const_cast<const uint8_t**>(&pArray), &remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_float,
|
SerializeAdapter::deSerialize(&tvFloat,
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
const_cast<const uint8_t**>(&pArray), &remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_double,
|
SerializeAdapter::deSerialize(&tvDouble,
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
const_cast<const uint8_t**>(&pArray), &remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_sfloat,
|
SerializeAdapter::deSerialize(&tvSfloat,
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
const_cast<const uint8_t**>(&pArray), &remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
SerializeAdapter::deSerialize(&tv_sdouble,
|
SerializeAdapter::deSerialize(&tvSdouble,
|
||||||
const_cast<const uint8_t**>(&p_array), &remaining_size, SerializeIF::Endianness::MACHINE);
|
const_cast<const uint8_t**>(&pArray), &remaining_size, SerializeIF::Endianness::MACHINE);
|
||||||
|
|
||||||
REQUIRE(test_value_bool == true);
|
REQUIRE(testBool == true);
|
||||||
REQUIRE(tv_uint8 == 5);
|
REQUIRE(tvUint8 == 5);
|
||||||
REQUIRE(tv_uint16 == 283);
|
REQUIRE(tvUint16 == 283);
|
||||||
REQUIRE(tv_uint32 == 929221);
|
REQUIRE(tvUint32 == 929221);
|
||||||
REQUIRE(tv_uint64 == 2929329429);
|
REQUIRE(tvUint64 == 2929329429);
|
||||||
REQUIRE(tv_int8 == -16);
|
REQUIRE(tvInt8 == -16);
|
||||||
REQUIRE(tv_int16 == -829);
|
REQUIRE(tvInt16 == -829);
|
||||||
REQUIRE(tv_int32 == -2312);
|
REQUIRE(tvInt32 == -2312);
|
||||||
|
|
||||||
REQUIRE(tv_float == Catch::Approx(8.214921));
|
REQUIRE(tvFloat == Catch::Approx(8.214921));
|
||||||
REQUIRE(tv_double == Catch::Approx(9.2132142141e8));
|
REQUIRE(tvDouble == Catch::Approx(9.2132142141e8));
|
||||||
REQUIRE(tv_sfloat == Catch::Approx(-922.2321321));
|
REQUIRE(tvSfloat == Catch::Approx(-922.2321321));
|
||||||
REQUIRE(tv_sdouble == Catch::Approx(-2.2421e19));
|
REQUIRE(tvSdouble == Catch::Approx(-2.2421e19));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
target_sources(${FSFW_TEST_TGT} PRIVATE
|
target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||||
PusTmTest.cpp
|
testCcsds.cpp
|
||||||
)
|
)
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
11
tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp
Normal file
11
tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include "fsfw/tmtcpacket/SpacePacket.h"
|
||||||
|
|
||||||
|
TEST_CASE( "CCSDS Test" , "[ccsds]") {
|
||||||
|
REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x22) == 0x1822);
|
||||||
|
REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x22) == 0x0822);
|
||||||
|
|
||||||
|
REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff);
|
||||||
|
REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x7ff) == 0xfff);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user