Compare commits

..

161 Commits

Author SHA1 Message Date
af7ebd3564 Merge branch 'development' into mueller/refactor-logging-with-fmt 2022-07-18 15:12:55 +02:00
9a2e68b37e Merge pull request 'Move HAL and Tests folder' (#653) from mueller/move-hal-tests-folder into development
Reviewed-on: fsfw/fsfw#653
2022-07-18 15:05:25 +02:00
91067cde98 typo 2022-07-18 15:00:40 +02:00
428018e4f1 update changelog 2022-07-18 14:59:25 +02:00
6e5239e9a0 update jenkinsfile 2022-07-18 14:36:40 +02:00
78b09ed0c9 fixes includes 2022-07-18 11:58:55 +02:00
fdf35232ee some fixes 2022-07-18 11:47:00 +02:00
8465670374 separate unittest folder 2022-07-18 11:42:51 +02:00
3b23fb77b4 add obsolete add_subdirectory calls 2022-07-18 09:01:45 +02:00
6f7be281ef move HAL and tests folder 2022-07-18 08:59:40 +02:00
a6ff3bb328 Merge remote-tracking branch 'origin/development' into mueller/refactor-logging-with-fmt 2022-07-18 08:53:35 +02:00
3686bbc486 Merge pull request 'DHB Reply Timeout' (#637) from meier/dhbReplyTimeout into development
Reviewed-on: fsfw/fsfw#637
2022-07-14 09:17:18 +02:00
ecac08814e better naming for functions which reset states of replies 2022-07-14 09:15:13 +02:00
e8b8fff0b5 Merge branch 'development' into meier/dhbReplyTimeout 2022-07-14 09:01:28 +02:00
4d34f93cfc missing reset of timedOut value in loop of decrementDeviceReplyMap 2022-07-14 08:58:23 +02:00
adbf375f38 some small fixes to dhb countdown addition 2022-07-13 21:58:07 +02:00
2e42f53682 Merge pull request 'New PoolEntry constructor' (#651) from eive/fsfw:mueller/new-pool-entry-ctor into development
Reviewed-on: fsfw/fsfw#651
2022-07-13 17:43:56 +02:00
c519b70302 Merge pull request 'printout tweak' (#652) from mueller/printout-tweak-mq-linux-osal into development
Reviewed-on: fsfw/fsfw#652
2022-07-13 17:35:53 +02:00
45ee307bc4 Merge pull request 'remove duplicate CHANGELOG entries' (#649) from eive/fsfw:mueller/clean-changelog into development
Reviewed-on: fsfw/fsfw#649
2022-07-13 16:50:50 +02:00
8a2068aca6 Merge pull request 'clang-tidy changes for controller module' (#648) from clang-tidy-controllers into development
Reviewed-on: fsfw/fsfw#648
2022-07-13 16:49:15 +02:00
aa60484111 Merge pull request 'clang-tidy changes for actions module' (#647) from clang-tidy-actions into development
Reviewed-on: fsfw/fsfw#647
2022-07-13 16:42:39 +02:00
e99c7f3824 Merge pull request 'Install ETL library in CI/CD' (#645) from mueller/install-etl-cicd into development
Reviewed-on: fsfw/fsfw#645
2022-07-13 16:39:29 +02:00
2ee3ef1f1d Merge branch 'development' into mueller/install-etl-cicd 2022-07-13 16:38:30 +02:00
ce48827ee5 Merge branch 'development' into clang-tidy-actions 2022-07-13 16:00:50 +02:00
0d80fad685 Merge branch 'development' into clang-tidy-controllers 2022-07-13 16:00:42 +02:00
c6253bf0dd Merge branch 'development' into mueller/new-pool-entry-ctor 2022-07-13 15:41:47 +02:00
93933dee02 Merge pull request 'delete run configs' (#646) from mueller/del-cmake-run-cfgs into development
Reviewed-on: fsfw/fsfw#646
2022-07-13 15:37:55 +02:00
0e49640306 update CHANGELOG 2022-07-08 17:59:43 +02:00
32fea9838e add new pool entry constructor
- This constructor allows to simply specify the length.
  This is also the new default constructor for scalar values
  which are initially invalid
2022-07-08 17:56:44 +02:00
0519083894 remove duplicate entries 2022-07-08 17:48:06 +02:00
14bac9a418 clang-tidy changes for controller module 2022-07-04 11:48:36 +02:00
3bef73708f clang-tidy changes for actions module 2022-07-04 11:44:26 +02:00
fef6ddceff delete run configs 2022-07-04 11:16:13 +02:00
5a9db72814 test public linkage 2022-07-04 10:27:14 +02:00
5cccd5caba bump used container 2022-07-04 10:21:47 +02:00
7de56f189b install etl library in ci/cd 2022-07-04 10:13:48 +02:00
df97bbc691 run auto-formatter 2022-06-23 11:56:46 +02:00
2d2f65bf89 moved activation of periodic replies to updatePeriodicReply 2022-06-23 11:54:51 +02:00
42a1e784c0 logging fixes 2022-06-21 11:15:00 +02:00
67b67de753 remove fsfw-test run files 2022-06-21 11:03:36 +02:00
3e9ae62b28 Merge branch 'development' into meier/dhbReplyTimeout 2022-06-21 10:49:06 +02:00
059e60cada Merge remote-tracking branch 'origin/development' into mueller/refactor-logging-with-fmt 2022-06-21 10:47:16 +02:00
541f563683 Merge pull request 'Fix StorageAccessor move assignment' (#643) from gaisser/fsfw:gaisser_storage_accessor_fix into development
Reviewed-on: fsfw/fsfw#643
2022-06-21 10:31:36 +02:00
28ea71a077 Merge branch 'development' into gaisser_storage_accessor_fix 2022-06-20 17:56:58 +02:00
a044d7d724 Merge pull request 'new cmake options for CICD build' (#623) from mueller/new-cicd-cmake-opts into development
Reviewed-on: fsfw/fsfw#623
2022-06-20 17:56:29 +02:00
687700cee8 Merge branch 'development' into gaisser_storage_accessor_fix 2022-06-20 16:36:49 +02:00
732b615cb3 Merge branch 'development' into mueller/new-cicd-cmake-opts 2022-06-20 16:34:13 +02:00
394ce2ec3e Merge pull request 'LocalDataPoolManager Warning Text' (#642) from meier/debug-info into development
Reviewed-on: fsfw/fsfw#642
2022-06-20 16:15:30 +02:00
dde96ae220 Merge branch 'development' into gaisser_storage_accessor_fix 2022-06-20 16:15:05 +02:00
c3aaab4b93 Merge pull request 'Task IF refactoring' (#636) from mueller/task-if-refactoring into development
Reviewed-on: fsfw/fsfw#636
2022-06-20 16:08:03 +02:00
edf1d5ae8d Added more test cases 2022-06-20 16:02:35 +02:00
690991b4b5 include fix 2022-06-20 15:42:08 +02:00
1a294e6a13 include TestsConfig.h 2022-06-20 15:40:15 +02:00
8c4e34153b README updates 2022-06-20 15:36:48 +02:00
b60e4bcb90 Fix StorageAccessor move assignment
* Added Unittest for this
* Fixed missing include in test
2022-06-20 15:15:33 +02:00
b18410aa63 Merge remote-tracking branch 'refs/remotes/origin/mueller/task-if-refactoring' into mueller/task-if-refactoring 2022-06-20 15:02:38 +02:00
7f57a8784a Fixed deadline missed call on linux 2022-06-20 15:02:16 +02:00
4b33aa8262 bump ETL version 2022-06-20 14:25:39 +02:00
d47a908117 Merge branch 'development' into mueller/task-if-refactoring 2022-06-20 09:40:31 +02:00
fce95e04a8 Merge branch 'development' into mueller/new-cicd-cmake-opts 2022-06-20 09:39:58 +02:00
fc742e4270 Merge branch 'development' into meier/debug-info 2022-06-16 07:22:43 +02:00
b5183a19fc minor change in debug text 2022-06-16 07:03:58 +02:00
ca453a8f16 Merge pull request 'run auto formatters' (#641) from KSat/fsfw:mueller/reapply-fmt into development
Reviewed-on: fsfw/fsfw#641
2022-06-13 17:04:11 +02:00
b7c0c07141 Merge remote-tracking branch 'origin/development' into mueller/new-cicd-cmake-opts 2022-06-13 16:28:01 +02:00
0158102f11 Merge pull request 'apply afmt, basic CLion support' (#625) from mueller/apply-afmt into development
Reviewed-on: fsfw/fsfw#625
2022-06-13 16:27:02 +02:00
69859fdbc9 rerun afmt 2022-06-13 16:21:20 +02:00
90bccc744e Merge pull request 'Fix SPI ComIF shadowing warning' (#639) from KSat/fsfw:mueller/spi-com-if-shadowing into development
Reviewed-on: fsfw/fsfw#639
2022-06-13 14:35:46 +02:00
ab89108c55 Merge pull request 'some fixes for TC Map printout function' (#640) from KSat/fsfw:mueller/pus-11-printout-fixes into development
Reviewed-on: fsfw/fsfw#640
2022-06-13 14:29:36 +02:00
a682bbe400 remove static missed deadline 2022-06-13 14:23:56 +02:00
e67fc2ab0d some fixes for TC Map printout function 2022-06-13 10:56:37 +02:00
71ce966531 Merge branch 'mueller/spi-com-if-shadowing' of https://egit.irs.uni-stuttgart.de/KSat/fsfw into mueller/spi-com-if-shadowing 2022-06-13 10:54:25 +02:00
6b0f4a159f Merge remote-tracking branch 'upstream/development' into mueller/spi-com-if-shadowing 2022-06-13 10:54:20 +02:00
4a06b558c1 Fix SPI ComIF shadowing warning 2022-06-13 10:53:04 +02:00
6d921f03fd Fix SPI ComIF shadowing warning 2022-06-13 10:50:49 +02:00
65bc8213fe Merge branch 'development' into mueller/new-cicd-cmake-opts 2022-06-13 09:43:32 +02:00
a0ee86ace8 use override instead of virtual as recommended 2022-06-08 17:36:20 +02:00
a07a368272 Merge branch 'development' into mueller/apply-afmt 2022-06-08 17:34:04 +02:00
cb8a4bbbec Merge remote-tracking branch 'origin/development' into mueller/task-if-refactoring 2022-06-08 17:33:12 +02:00
17f54006b8 Merge pull request 'rtems fixes' (#635) from mueller/rtems-fixes into development
Reviewed-on: fsfw/fsfw#635
2022-06-08 16:12:53 +02:00
395cf9cfa7 added clion base files 2022-06-08 12:12:33 +02:00
a3c0b441ec update changelog 2022-06-08 12:12:33 +02:00
b4132800ae apply afmt, update .gitignore 2022-06-08 12:12:33 +02:00
ad53b48fcb explicitely ignore returnvalue in linux OSAL 2022-06-08 12:12:09 +02:00
dee40f9079 fixed unittests 2022-06-08 12:12:09 +02:00
92ec24352f fix unit test 2022-06-08 12:12:09 +02:00
3f9e459f48 update changelog 2022-06-08 12:12:09 +02:00
e0c7f8d51d apply afmt 2022-06-08 12:12:09 +02:00
eb79386c92 new addSlot function taking executable pointer 2022-06-08 12:12:09 +02:00
4542f31c40 improved custom checker API
- More clang-tidy improvements
2022-06-08 12:12:09 +02:00
689fb378d8 a regular set should suffice here 2022-06-08 12:12:09 +02:00
98b711a872 update changelog 2022-06-08 12:12:09 +02:00
800aa131fa reverted some unrelated changes 2022-06-08 12:12:09 +02:00
6983980304 missing newline and clang-tidy improvement 2022-06-08 12:12:09 +02:00
7c0ba59993 remove include 2022-06-08 12:12:09 +02:00
28873fc87b refactores rtems task module 2022-06-08 12:12:09 +02:00
24e849ed9c avoid compiler warning 2022-06-08 12:12:09 +02:00
d8985c141e some clang tidy stuff and bugfixes 2022-06-08 12:12:09 +02:00
7602b15256 important bugfix 2022-06-08 12:12:09 +02:00
d1a82bceed rtems fixes 2022-06-08 12:12:09 +02:00
7292b02907 refactor freeRTOS task components 2022-06-08 12:12:09 +02:00
347714d53a refactored and tested hosted and linux task IF 2022-06-08 12:12:09 +02:00
f230fa1617 continued refactoring 2022-06-08 12:12:09 +02:00
93615b100c continued refactoring 2022-06-08 12:12:09 +02:00
e18d3d559e refactoring host osal 2022-06-08 12:12:09 +02:00
08ff061d07 minor bugfix 2022-06-08 12:12:09 +02:00
cc351c1066 new base class for periodic tasks 2022-06-08 12:12:09 +02:00
664a548c53 removed some changes which belong in separate PR 2022-06-08 12:12:09 +02:00
e9895559a3 vector as core container is ok 2022-06-08 12:12:09 +02:00
eda5b8f593 refactor task IF 2022-06-08 12:12:09 +02:00
e03f55604a rtems fixes 2022-06-08 12:11:26 +02:00
51d7df2dba Merge branch 'development' into mueller/new-cicd-cmake-opts 2022-06-08 11:13:13 +02:00
12046a2db6 Merge pull request 'bump etl to 20.28.0' (#634) from mueller/bump-etl into development
Reviewed-on: fsfw/fsfw#634
2022-06-08 11:09:42 +02:00
21eb386f3c changed reply timeouts 2022-06-06 12:34:57 +02:00
ade36e65c6 missed reply check in simple command nominal test case 2022-06-06 12:30:27 +02:00
103661facc deugging 2022-06-06 12:26:00 +02:00
ae2f7219fd run auto-formatter 2022-06-06 11:55:42 +02:00
4fba2704aa unit test for detection of missed reply when commanded externally 2022-06-06 10:53:08 +02:00
161dbde0d7 fixed merge conflicts 2022-06-06 10:30:17 +02:00
2fa4fd61d0 device fdir mock 2022-06-05 12:54:13 +02:00
bf673c56c6 unit test for dhb 2022-06-05 12:52:55 +02:00
c697d0f8ab bump etl to 20.28.0 2022-05-30 10:34:03 +02:00
9f83894d4c Merge remote-tracking branch 'origin/development' into mueller/refactor-logging-with-fmt 2022-05-27 15:26:37 +02:00
c7cf8e710d Merge pull request 'return end iterator instead of crashing' (#633) from mueller/possible-fix-ccsds-distrib into development
Reviewed-on: fsfw/fsfw#633
2022-05-25 13:59:35 +02:00
7dddcdfd55 Merge branch 'development' into mueller/possible-fix-ccsds-distrib 2022-05-25 09:52:33 +02:00
261eea381e Merge pull request 'PUS11 TC sched update and bugfixes' (#632) from mueller/tc-11-tweaks into development
Reviewed-on: fsfw/fsfw#632
2022-05-24 17:48:06 +02:00
e59f1f26bf return end iterator instead of crashing 2022-05-24 14:33:18 +02:00
f7cde80088 added missing delete 2022-05-24 14:32:35 +02:00
e60a665de4 added 3 new subservices 2022-05-24 11:52:29 +02:00
34658ef7db afmt 2022-05-24 10:40:25 +02:00
940fd6f465 Merge branch 'development' into mueller/new-cicd-cmake-opts 2022-05-23 15:59:13 +02:00
f288d5120d Merge branch 'development' into mueller/tc-11-tweaks 2022-05-23 15:34:00 +02:00
5a425a1c58 Merge pull request 'cache the TCP client address now' (#630) from eive/fsfw:mueller/tcp-server-cache-client-addr into development
Reviewed-on: fsfw/fsfw#630
2022-05-23 14:42:12 +02:00
5e62258aa6 Merge branch 'development' into mueller/tcp-server-cache-client-addr 2022-05-23 14:38:05 +02:00
0b53b4873f bugfix for srv11 2022-05-20 11:20:31 +02:00
8e2597f609 clang-format 2022-05-20 11:09:03 +02:00
dac700b80a static STORE renamed 2022-05-20 08:59:06 +02:00
d0fc360697 apply afmt 2022-05-20 08:34:14 +02:00
adcb646c9b Merge remote-tracking branch 'origin/development' into mueller/refactor-logging-with-fmt 2022-05-18 13:15:54 +02:00
576414438c Merge pull request 'Apply cmake-format and auto-format script on all CMakeLists.txt file' (#628) from eive/fsfw:mueller/apply-clang-format-on-all-files into development
Reviewed-on: fsfw/fsfw#628
2022-05-18 13:14:18 +02:00
13cda86d23 remove commented code 2022-05-18 13:13:24 +02:00
e1dd27b9dd cache the TCP client address now 2022-05-17 13:16:36 +02:00
8e9d4b451c better printout if ping test fails 2022-05-16 16:18:44 +02:00
816550b69c Merge remote-tracking branch 'upstream/development' into mueller/new-cicd-cmake-opts 2022-05-16 14:58:25 +02:00
7fee852dbd re-apply updated auto-formatter 2022-05-16 14:55:15 +02:00
1e7032f89c minor improvements for auto-formatter 2022-05-16 14:54:43 +02:00
1611a4e1f0 device handler unittest wip 2022-05-16 11:10:35 +02:00
8a12a5097e Merge branch 'mueller/apply-afmt' into mueller/new-cicd-cmake-opts 2022-05-13 13:50:41 +02:00
87e4a57ef7 added clion base files 2022-05-13 13:48:13 +02:00
0375ee1881 update changelog 2022-05-13 13:46:54 +02:00
c8e034d975 Merge branch 'development' into mueller/new-cicd-cmake-opts 2022-05-13 13:41:58 +02:00
2708b71d77 Merge remote-tracking branch 'origin/development' into mueller/new-cicd-cmake-opts 2022-05-13 12:00:40 +02:00
6366283ce2 Merge branch 'development' into mueller/apply-afmt 2022-05-13 11:50:03 +02:00
8dc640c162 apply afmt, update .gitignore 2022-05-13 11:39:37 +02:00
2e4b9bcd7c Merge remote-tracking branch 'origin/development' into mueller/new-cicd-cmake-opts 2022-05-12 17:42:49 +02:00
aacaf52fd9 Merge branch 'development' into mueller/new-cicd-cmake-opts 2022-05-09 15:34:36 +02:00
89f83f4e3d update changelog 2022-05-09 15:33:03 +02:00
39b7976056 new cmake options for CICD build 2022-05-09 15:26:38 +02:00
7afe30ea88 fixed merge conflict 2022-05-09 12:56:22 +02:00
0aee86442e typo in readme 2022-04-26 11:48:18 +02:00
951c077abc option to use Countdown object to time out replies 2022-04-26 10:03:04 +02:00
adfefdd93f printout tweak 2022-04-11 14:19:01 +02:00
374 changed files with 1938 additions and 1741 deletions

View File

@ -1,7 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="fsfw-tests_coverage" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="fsfw-tests" TARGET_NAME="fsfw-tests_coverage" CONFIG_NAME="Debug Unittest" RUN_TARGET_PROJECT_NAME="fsfw-tests" RUN_TARGET_NAME="fsfw-tests">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

View File

@ -1,7 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="fsfw" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="fsfw-tests" TARGET_NAME="fsfw" CONFIG_NAME="Debug Unittest" RUN_TARGET_PROJECT_NAME="fsfw-tests" RUN_TARGET_NAME="fsfw-tests">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

View File

@ -12,15 +12,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Changes
- Renamed auto-formatting script to `auto-formatter.sh` and made it more robust.
If `cmake-format` is installed, it will also auto-format the `CMakeLists.txt` files now.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/625
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/626
- Bump C++ required version to C++17. Every project which uses the FSFW and every modern
compiler supports it
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/622
- HAL Linux SPI: Set the Clock Default State when setting new SPI speed
and mode
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/573
- GPIO HAL: `Direction`, `GpioOperation` and `Levels` are enum classes now, which prevents
name clashes with Windows defines.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572
- New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572
- HAL Devicehandlers: Periodic printout is run-time configurable now
@ -42,6 +40,41 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
creation call. It allows passing context information and an arbitrary user argument into
the message queue. Also streamlined and simplified `MessageQueue` implementation for all OSALs
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/583
- Internal API change: Moved the `fsfw_hal` to the `src` folder and integration and internal
tests part of `fsfw_tests` to `src`. Unittests are now in a dedicated folder called `unittests`
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/653
### Task Module Refactoring
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/636
**Refactoring general task code**
- There was a lot of duplicate/boilerplate code inside the individual task IF OSAL implementations.
Remove it by introducing base classes `PeriodicTaskBase` and `FixedTimeslotTaskBase`.
**Refactor PeriodicTaskIF**
- Convert `virtual ReturnValue_t addComponent(object_id_t object)` to
`virtual ReturnValue_t addComponent(object_id_t object, uint8_t opCode = 0)`, allowing to pass
the operation code passed to `performOperation`. Updated API taking
an `ExecutableObjectIF` accordingly
**Refactor FixedTimeslotTaskIF**
- Add additional `addSlot` function which takes an `ExecutableObjectIF` pointer and its Object ID
**Refactor FixedSequenceSlot**
- Introduce typedef `CustomCheckFunc` for `ReturnValue_t (*customCheckFunction)(const SlotList&)`.
- Convert `ReturnValue_t (*customCheckFunction)(const SlotList&)` to
`ReturnValue_t (*customCheckFunction)(const SlotList&, void*)`, allowing arbitrary user arguments
for the custom checker
**Linux Task Module**
- Use composition instead of inheritance for the `PeriodicPosixTask` and make the `PosixTask` a
member of the class
### HAL
@ -84,6 +117,13 @@ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/593
## Additions
- New constructor for PoolEntry which allows to simply specify the length of the pool entry.
This is also the new default constructor for scalar value with 0 as an initial value
- Added options for CI/CD builds: `FSFW_CICD_BUILD`. This allows the source code to know
whether it is running in CI/CD
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/623
- Basic `clion` support: Update `.gitignore` and add some basic run configurations
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/625
- LTO support: Allow using LTO/IPO by setting `FSFW_ENABLE_LTO=1`. CMake is able to detect whether
the user compiler supports IPO/LPO. LTO is on by default now. Most modern compilers support it,
can make good use of it and it usually makes the code faster and/or smaller.

View File

@ -72,7 +72,7 @@ set(FSFW_ETL_LIB_MAJOR_VERSION
20
CACHE STRING "ETL library major version requirement")
set(FSFW_ETL_LIB_VERSION
${FSFW_ETL_LIB_MAJOR_VERSION}.27.3
${FSFW_ETL_LIB_MAJOR_VERSION}.28.0
CACHE STRING "ETL library exact version requirement")
set(FSFW_CATCH2_LIB_MAJOR_VERSION
@ -112,10 +112,11 @@ if(FSFW_GENERATE_SECTIONS)
option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON)
endif()
option(FSFW_BUILD_UNITTESTS
option(FSFW_BUILD_TESTS
"Build unittest binary in addition to static library" OFF)
option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF)
option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF)
if(FSFW_BUILD_UNITTESTS)
if(FSFW_BUILD_TESTS)
option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON)
endif()
@ -147,7 +148,7 @@ if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
TRUE)
endif()
if(FSFW_BUILD_UNITTESTS)
if(FSFW_BUILD_TESTS)
message(
STATUS
"${MSG_PREFIX} Building the FSFW unittests in addition to the static library"
@ -170,10 +171,9 @@ if(FSFW_BUILD_UNITTESTS)
list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2)
endif()
set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg)
configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h)
configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in
tests/TestsConfig.h)
set(FSFW_CONFIG_PATH unittests/testcfg)
configure_file(unittests/testcfg/FSFWConfig.h.in FSFWConfig.h)
configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h)
project(${FSFW_TEST_TGT} CXX C)
add_executable(${FSFW_TEST_TGT})
@ -309,16 +309,15 @@ message(
)
add_subdirectory(src)
add_subdirectory(tests)
if(FSFW_ADD_HAL)
add_subdirectory(hal)
endif()
add_subdirectory(contrib)
if(FSFW_BUILD_TESTS)
add_subdirectory(unittests)
endif()
if(FSFW_BUILD_DOCS)
add_subdirectory(docs)
endif()
if(FSFW_BUILD_UNITTESTS)
if(FSFW_BUILD_TESTS)
if(FSFW_TESTS_GEN_COV)
if(CMAKE_COMPILER_IS_GNUCXX)
include(CodeCoverage)
@ -474,14 +473,8 @@ target_include_directories(
target_compile_options(${LIB_FSFW_NAME} PRIVATE ${FSFW_WARNING_FLAGS}
${COMPILER_FLAGS})
target_link_libraries(${LIB_FSFW_NAME} PUBLIC ${FSFW_FMT_LINK_TARGET})
target_link_libraries(
${LIB_FSFW_NAME}
PRIVATE # If any ELT headers are ever exposed inside a header or as part of
# the API, the ETL target needs to be linked PUBLIC
${FSFW_ETL_LINK_TARGET} ${FSFW_ADDITIONAL_LINK_LIBS})
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ADDITIONAL_LINK_LIBS})
target_link_libraries(${LIB_FSFW_NAME} PUBLIC ${FSFW_ETL_LINK_TARGET} ${FSFW_FMT_LINK_TARGET})
string(
CONCAT

View File

@ -99,7 +99,7 @@ add and link against the FSFW library in general.
4. Link against the FSFW library
```cmake
```sh
target_link_libraries(${YourProjectName} PRIVATE fsfw)
```
@ -131,7 +131,7 @@ default. This can be disabled by setting the `FSFW_TESTS_COV_GEN` option to `OFF
You can use the following commands inside the `fsfw` folder to set up the build system
```sh
mkdir build-Unittest && cd build-Unittest
mkdir build-tests && cd build-tests
cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug ..
```
@ -139,7 +139,7 @@ You can also use `-DFSFW_OSAL=linux` on Linux systems.
Coverage data in HTML format can be generated using the `CodeCoverage`
[CMake module](https://github.com/bilke/cmake-modules/tree/master).
To build the unittests, run them and then generare the coverage data in this format,
To build the unittests, run them and then generate the coverage data in this format,
the following command can be used inside the build directory after the build system was set up
```sh
@ -188,7 +188,10 @@ and open the documentation conveniently. Try `helper.py -h for more information.
The formatting is done by the `clang-format` tool. The configuration is contained within the
`.clang-format` file in the repository root. As long as `clang-format` is installed, you
can run the `apply-clang-format.sh` helper script to format all source files consistently.
can run the `auto-format.sh` helper script to format all source files consistently. Furthermore cmake-format is required to format CMake files which can be installed with:
````sh
sudo pip install cmakelang
````
## Index

View File

@ -12,3 +12,9 @@ RUN git clone https://github.com/catchorg/Catch2.git && \
git checkout v3.0.0-preview5 && \
cmake -Bbuild -H. -DBUILD_TESTING=OFF && \
cmake --build build/ --target install
RUN git clone https://github.com/ETLCPP/etl.git && \
cd etl && \
git checkout 20.28.0 && \
cmake -B build . && \
cmake --install build/

View File

@ -3,7 +3,7 @@ pipeline {
BUILDDIR = 'build-tests'
}
agent {
docker { image 'fsfw-ci:d2'}
docker { image 'fsfw-ci:d3'}
}
stages {
stage('Clean') {
@ -14,7 +14,7 @@ pipeline {
stage('Configure') {
steps {
dir(BUILDDIR) {
sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..'
sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..'
}
}
}

View File

@ -1,48 +0,0 @@
cmake_minimum_required(VERSION 3.13)
# Can also be changed by upper CMakeLists.txt file
find_library(LIB_FSFW_NAME fsfw REQUIRED)
option(FSFW_HAL_ADD_LINUX "Add the Linux HAL to the sources. Requires gpiod library" OFF)
# On by default for now because I did not have an issue including and compiling those files
# and libraries on a Desktop Linux system and the primary target of the FSFW is still embedded
# Linux. The only exception from this is the gpiod library which requires a dedicated installation,
# but CMake is able to determine whether this library is installed with find_library.
option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add peripheral drivers for embedded Linux" ON)
option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Target implements libgpiod" ON)
option(FSFW_HAL_ADD_RASPBERRY_PI "Add Raspberry Pi specific code to the sources" OFF)
option(FSFW_HAL_ADD_STM32H7 "Add the STM32H7 HAL to the sources" OFF)
option(FSFW_HAL_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
set(LINUX_HAL_PATH_NAME linux)
set(STM32H7_PATH_NAME stm32h7)
add_subdirectory(src)
foreach(INCLUDE_PATH ${FSFW_HAL_ADDITIONAL_INC_PATHS})
if(IS_ABSOLUTE ${INCLUDE_PATH})
set(CURR_ABS_INC_PATH "${INCLUDE_PATH}")
else()
get_filename_component(CURR_ABS_INC_PATH
${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR})
endif()
if(CMAKE_VERBOSE)
message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}")
endif()
list(APPEND FSFW_HAL_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH})
endforeach()
target_include_directories(${LIB_FSFW_NAME} PRIVATE
${FSFW_HAL_ADD_INC_PATHS_ABS}
)
target_compile_definitions(${LIB_FSFW_NAME} PRIVATE
${FSFW_HAL_DEFINES}
)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
${FSFW_HAL_LINK_LIBS}
)

View File

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

View File

@ -4,9 +4,10 @@ if [[ ! -f README.md ]]; then
fi
cmake_fmt="cmake-format"
file_selectors="-iname CMakeLists.txt"
if command -v ${cmake_fmt} &> /dev/null; then
cmake_fmt_cmd="${cmake_fmt} -i CMakeLists.txt"
eval ${cmake_fmt_cmd}
${cmake_fmt} -i CMakeLists.txt
find ./src ${file_selectors} | xargs ${cmake_fmt} -i
else
echo "No ${cmake_fmt} tool found, not formatting CMake files"
fi
@ -14,9 +15,9 @@ fi
cpp_format="clang-format"
file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp"
if command -v ${cpp_format} &> /dev/null; then
find ./src ${file_selectors} | xargs clang-format --style=file -i
find ./hal ${file_selectors} | xargs clang-format --style=file -i
find ./tests ${file_selectors} | xargs clang-format --style=file -i
find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i
find ./hal ${file_selectors} | xargs ${cpp_format} --style=file -i
find ./tests ${file_selectors} | xargs ${cpp_format} --style=file -i
else
echo "No ${cpp_format} tool found, not formatting C++/C files"
fi

View File

@ -48,6 +48,20 @@ def main():
action="store_true",
help="Run valgrind on generated test binary",
)
parser.add_argument(
"-g",
"--generators",
default = "Ninja",
action="store",
help="CMake generators",
)
parser.add_argument(
"-w",
"--windows",
default=False,
action="store_true",
help="Run on windows",
)
args = parser.parse_args()
if args.all:
@ -115,14 +129,14 @@ def handle_tests_type(args, build_dir_list: list):
if args.create:
if os.path.exists(UNITTEST_FOLDER_NAME):
shutil.rmtree(UNITTEST_FOLDER_NAME)
create_tests_build_cfg()
create_tests_build_cfg(args)
build_directory = UNITTEST_FOLDER_NAME
elif len(build_dir_list) == 0:
print(
"No valid CMake tests build directory found. "
"Trying to set up test build system"
)
create_tests_build_cfg()
create_tests_build_cfg(args)
build_directory = UNITTEST_FOLDER_NAME
elif len(build_dir_list) == 1:
build_directory = build_dir_list[0]
@ -147,10 +161,15 @@ def handle_tests_type(args, build_dir_list: list):
os.chdir("..")
def create_tests_build_cfg():
def create_tests_build_cfg(args):
os.mkdir(UNITTEST_FOLDER_NAME)
os.chdir(UNITTEST_FOLDER_NAME)
cmd_runner("cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..")
if args.windows:
cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON \
-DGCOVR_PATH="py -m gcovr" ..'
else:
cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON ..'
cmd_runner(cmake_cmd)
os.chdir("..")

View File

@ -1,9 +1,11 @@
target_include_directories(${LIB_FSFW_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_include_directories(${LIB_FSFW_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${LIB_FSFW_NAME} INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_include_directories(${LIB_FSFW_NAME}
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(fsfw)
if(FSFW_ADD_HAL)
add_subdirectory(fsfw_hal)
endif()
add_subdirectory(fsfw_tests)

View File

@ -1,6 +1,4 @@
target_sources(${LIB_FSFW_NAME} PRIVATE
version.cpp
)
target_sources(${LIB_FSFW_NAME} PRIVATE version.cpp)
# Core
@ -37,22 +35,22 @@ add_subdirectory(tmtcservices)
# Optional
if(FSFW_ADD_MONITORING)
add_subdirectory(monitoring)
add_subdirectory(monitoring)
endif()
if(FSFW_ADD_PUS)
add_subdirectory(pus)
add_subdirectory(pus)
endif()
if(FSFW_ADD_TMSTORAGE)
add_subdirectory(tmstorage)
add_subdirectory(tmstorage)
endif()
if(FSFW_ADD_COORDINATES)
add_subdirectory(coordinates)
add_subdirectory(coordinates)
endif()
if(FSFW_ADD_RMAP)
add_subdirectory(rmap)
add_subdirectory(rmap)
endif()
if(FSFW_ADD_DATALINKLAYER)
add_subdirectory(datalinklayer)
add_subdirectory(datalinklayer)
endif()
# OSAL

View File

@ -6,7 +6,7 @@
ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue)
: owner(setOwner), queueToUse(useThisQueue) {}
ActionHelper::~ActionHelper() {}
ActionHelper::~ActionHelper() = default;
ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) {
if (command->getCommand() == ActionMessage::EXECUTE_ACTION) {
@ -53,7 +53,7 @@ void ActionHelper::setQueueToUse(MessageQueueIF* queue) { queueToUse = queue; }
void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId,
store_address_t dataAddress) {
const uint8_t* dataPtr = NULL;
const uint8_t* dataPtr = nullptr;
size_t size = 0;
ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size);
if (result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -1,9 +1,9 @@
#ifndef FSFW_ACTION_ACTIONHELPER_H_
#define FSFW_ACTION_ACTIONHELPER_H_
#include "../ipc/MessageQueueIF.h"
#include "../serialize/SerializeIF.h"
#include "ActionMessage.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/serialize/SerializeIF.h"
/**
* @brief Action Helper is a helper class which handles action messages
*

View File

@ -2,9 +2,9 @@
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
ActionMessage::ActionMessage() {}
ActionMessage::ActionMessage() = default;
ActionMessage::~ActionMessage() {}
ActionMessage::~ActionMessage() = default;
void ActionMessage::setCommand(CommandMessage* message, ActionId_t fid,
store_address_t parameters) {
@ -64,9 +64,8 @@ void ActionMessage::clear(CommandMessage* message) {
switch (message->getCommand()) {
case EXECUTE_ACTION:
case DATA_REPLY: {
StorageManagerIF* ipcStore =
ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (ipcStore != NULL) {
auto* ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (ipcStore != nullptr) {
ipcStore->deleteData(getStoreId(message));
}
break;

View File

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

View File

@ -2,14 +2,14 @@
#include "fsfw/objectmanager/ObjectManager.h"
CommandActionHelper::CommandActionHelper(CommandsActionsIF *setOwner)
: owner(setOwner), queueToUse(NULL), ipcStore(NULL), commandCount(0), lastTarget(0) {}
: owner(setOwner), queueToUse(nullptr), ipcStore(nullptr), commandCount(0), lastTarget(0) {}
CommandActionHelper::~CommandActionHelper() {}
CommandActionHelper::~CommandActionHelper() = default;
ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId_t actionId,
SerializeIF *data) {
HasActionsIF *receiver = ObjectManager::instance()->get<HasActionsIF>(commandTo);
if (receiver == NULL) {
auto *receiver = ObjectManager::instance()->get<HasActionsIF>(commandTo);
if (receiver == nullptr) {
return CommandsActionsIF::OBJECT_HAS_NO_FUNCTIONS;
}
store_address_t storeId;
@ -29,11 +29,8 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId
ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId_t actionId,
const uint8_t *data, uint32_t size) {
// if (commandCount != 0) {
// return CommandsFunctionsIF::ALREADY_COMMANDING;
// }
HasActionsIF *receiver = ObjectManager::instance()->get<HasActionsIF>(commandTo);
if (receiver == NULL) {
auto *receiver = ObjectManager::instance()->get<HasActionsIF>(commandTo);
if (receiver == nullptr) {
return CommandsActionsIF::OBJECT_HAS_NO_FUNCTIONS;
}
store_address_t storeId;
@ -59,12 +56,12 @@ ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId, ActionI
ReturnValue_t CommandActionHelper::initialize() {
ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (ipcStore == NULL) {
if (ipcStore == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
queueToUse = owner->getCommandQueuePtr();
if (queueToUse == NULL) {
if (queueToUse == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
@ -104,7 +101,7 @@ ReturnValue_t CommandActionHelper::handleReply(CommandMessage *reply) {
uint8_t CommandActionHelper::getCommandCount() const { return commandCount; }
void CommandActionHelper::extractDataForOwner(ActionId_t actionId, store_address_t storeId) {
const uint8_t *data = NULL;
const uint8_t *data = nullptr;
size_t size = 0;
ReturnValue_t result = ipcStore->getData(storeId, &data, &size);
if (result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -14,14 +14,14 @@ class CommandActionHelper {
friend class CommandsActionsIF;
public:
CommandActionHelper(CommandsActionsIF* owner);
explicit CommandActionHelper(CommandsActionsIF* owner);
virtual ~CommandActionHelper();
ReturnValue_t commandAction(object_id_t commandTo, ActionId_t actionId, const uint8_t* data,
uint32_t size);
ReturnValue_t commandAction(object_id_t commandTo, ActionId_t actionId, SerializeIF* data);
ReturnValue_t initialize();
ReturnValue_t handleReply(CommandMessage* reply);
uint8_t getCommandCount() const;
[[nodiscard]] uint8_t getCommandCount() const;
private:
CommandsActionsIF* owner;

View File

@ -1,9 +1,9 @@
#ifndef FSFW_ACTION_COMMANDSACTIONSIF_H_
#define FSFW_ACTION_COMMANDSACTIONSIF_H_
#include "../ipc/MessageQueueIF.h"
#include "../returnvalues/HasReturnvaluesIF.h"
#include "CommandActionHelper.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
/**
* Interface to separate commanding actions of other objects.
@ -21,7 +21,7 @@ class CommandsActionsIF {
static const uint8_t INTERFACE_ID = CLASS_ID::COMMANDS_ACTIONS_IF;
static const ReturnValue_t OBJECT_HAS_NO_FUNCTIONS = MAKE_RETURN_CODE(1);
static const ReturnValue_t ALREADY_COMMANDING = MAKE_RETURN_CODE(2);
virtual ~CommandsActionsIF() {}
virtual ~CommandsActionsIF() = default;
virtual MessageQueueIF* getCommandQueuePtr() = 0;
protected:

View File

@ -1,11 +1,11 @@
#ifndef FSFW_ACTION_HASACTIONSIF_H_
#define FSFW_ACTION_HASACTIONSIF_H_
#include "../ipc/MessageQueueIF.h"
#include "../returnvalues/HasReturnvaluesIF.h"
#include "ActionHelper.h"
#include "ActionMessage.h"
#include "SimpleActionHelper.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
/**
* @brief
@ -40,12 +40,12 @@ class HasActionsIF {
static const ReturnValue_t INVALID_PARAMETERS = MAKE_RETURN_CODE(2);
static const ReturnValue_t EXECUTION_FINISHED = MAKE_RETURN_CODE(3);
static const ReturnValue_t INVALID_ACTION_ID = MAKE_RETURN_CODE(4);
virtual ~HasActionsIF() {}
virtual ~HasActionsIF() = default;
/**
* Function to get the MessageQueueId_t of the implementing object
* @return MessageQueueId_t of the object
*/
virtual MessageQueueId_t getCommandQueue() const = 0;
[[nodiscard]] virtual MessageQueueId_t getCommandQueue() const = 0;
/**
* Execute or initialize the execution of a certain function.
* The ActionHelpers will execute this function and behave differently

View File

@ -3,7 +3,7 @@
SimpleActionHelper::SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue)
: ActionHelper(setOwner, useThisQueue), isExecuting(false) {}
SimpleActionHelper::~SimpleActionHelper() {}
SimpleActionHelper::~SimpleActionHelper() = default;
void SimpleActionHelper::step(ReturnValue_t result) {
// STEP_OFFESET is subtracted to compensate for adding offset in base
@ -38,7 +38,7 @@ void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId
ActionMessage::setStepReply(&reply, actionId, 0, HasActionsIF::IS_BUSY);
queueToUse->sendMessage(commandedBy, &reply);
}
const uint8_t* dataPtr = NULL;
const uint8_t* dataPtr = nullptr;
size_t size = 0;
ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size);
if (result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -11,15 +11,15 @@
class SimpleActionHelper : public ActionHelper {
public:
SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue);
virtual ~SimpleActionHelper();
~SimpleActionHelper() override;
void step(ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
void finish(ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
ReturnValue_t reportData(SerializeIF* data);
protected:
void prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId,
store_address_t dataAddress);
virtual void resetHelper();
store_address_t dataAddress) override;
void resetHelper() override;
private:
bool isExecuting;
@ -28,4 +28,4 @@ class SimpleActionHelper : public ActionHelper {
uint8_t stepCount = 0;
};
#endif /* SIMPLEACTIONHELPER_H_ */
#endif /* FSFW_ACTION_SIMPLEACTIONHELPER_H_ */

View File

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

View File

@ -1,32 +1,30 @@
target_sources(${LIB_FSFW_NAME} PRIVATE
PduConfig.cpp
VarLenField.cpp
HeaderSerializer.cpp
HeaderDeserializer.cpp
FileDirectiveDeserializer.cpp
FileDirectiveSerializer.cpp
AckInfo.cpp
AckPduSerializer.cpp
AckPduDeserializer.cpp
EofInfo.cpp
EofPduSerializer.cpp
EofPduDeserializer.cpp
NakInfo.cpp
NakPduSerializer.cpp
NakPduDeserializer.cpp
FinishedInfo.cpp
FinishedPduSerializer.cpp
FinishedPduDeserializer.cpp
MetadataInfo.cpp
MetadataPduSerializer.cpp
MetadataPduDeserializer.cpp
KeepAlivePduSerializer.cpp
KeepAlivePduDeserializer.cpp
PromptPduSerializer.cpp
PromptPduDeserializer.cpp
FileDataSerializer.cpp
FileDataDeserializer.cpp
FileDataInfo.cpp
)
target_sources(
${LIB_FSFW_NAME}
PRIVATE PduConfig.cpp
VarLenField.cpp
HeaderSerializer.cpp
HeaderDeserializer.cpp
FileDirectiveDeserializer.cpp
FileDirectiveSerializer.cpp
AckInfo.cpp
AckPduSerializer.cpp
AckPduDeserializer.cpp
EofInfo.cpp
EofPduSerializer.cpp
EofPduDeserializer.cpp
NakInfo.cpp
NakPduSerializer.cpp
NakPduDeserializer.cpp
FinishedInfo.cpp
FinishedPduSerializer.cpp
FinishedPduDeserializer.cpp
MetadataInfo.cpp
MetadataPduSerializer.cpp
MetadataPduDeserializer.cpp
KeepAlivePduSerializer.cpp
KeepAlivePduDeserializer.cpp
PromptPduSerializer.cpp
PromptPduDeserializer.cpp
FileDataSerializer.cpp
FileDataDeserializer.cpp
FileDataInfo.cpp)

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@ ReturnValue_t ControllerBase::initialize() {
MessageQueueId_t parentQueue = 0;
if (parentId != objects::NO_OBJECT) {
SubsystemBase* parent = ObjectManager::instance()->get<SubsystemBase>(parentId);
auto* parent = ObjectManager::instance()->get<SubsystemBase>(parentId);
if (parent == nullptr) {
return RETURN_FAILED;
}
@ -52,7 +52,7 @@ MessageQueueId_t ControllerBase::getCommandQueue() const { return commandQueue->
void ControllerBase::handleQueue() {
CommandMessage command;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
ReturnValue_t result;
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
result = commandQueue->receiveMessage(&command)) {
result = modeHelper.handleModeCommand(&command);
@ -73,20 +73,20 @@ void ControllerBase::handleQueue() {
}
}
void ControllerBase::startTransition(Mode_t mode, Submode_t submode) {
void ControllerBase::startTransition(Mode_t mode_, Submode_t submode_) {
changeHK(this->mode, this->submode, false);
triggerEvent(CHANGING_MODE, mode, submode);
this->mode = mode;
this->submode = submode;
mode = mode_;
submode = submode_;
modeHelper.modeChanged(mode, submode);
modeChanged(mode, submode);
announceMode(false);
changeHK(this->mode, this->submode, true);
}
void ControllerBase::getMode(Mode_t* mode, Submode_t* submode) {
*mode = this->mode;
*submode = this->submode;
void ControllerBase::getMode(Mode_t* mode_, Submode_t* submode_) {
*mode_ = this->mode;
*submode_ = this->submode;
}
void ControllerBase::setToExternalControl() { healthHelper.setHealth(EXTERNAL_CONTROL); }
@ -99,7 +99,7 @@ ReturnValue_t ControllerBase::performOperation(uint8_t opCode) {
return RETURN_OK;
}
void ControllerBase::modeChanged(Mode_t mode, Submode_t submode) { return; }
void ControllerBase::modeChanged(Mode_t mode_, Submode_t submode_) {}
ReturnValue_t ControllerBase::setHealth(HealthState health) {
switch (health) {
@ -115,6 +115,6 @@ ReturnValue_t ControllerBase::setHealth(HealthState health) {
HasHealthIF::HealthState ControllerBase::getHealth() { return healthHelper.getHealth(); }
void ControllerBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; }
void ControllerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) {}
void ControllerBase::changeHK(Mode_t mode_, Submode_t submode_, bool enable) {}
ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return HasReturnvaluesIF::RETURN_OK; }

View File

@ -24,21 +24,21 @@ class ControllerBase : public HasModesIF,
static const Mode_t MODE_NORMAL = 2;
ControllerBase(object_id_t setObjectId, object_id_t parentId, size_t commandQueueDepth = 3);
virtual ~ControllerBase();
~ControllerBase() override;
/** SystemObject override */
virtual ReturnValue_t initialize() override;
ReturnValue_t initialize() override;
virtual MessageQueueId_t getCommandQueue() const override;
[[nodiscard]] MessageQueueId_t getCommandQueue() const override;
/** HasHealthIF overrides */
virtual ReturnValue_t setHealth(HealthState health) override;
virtual HasHealthIF::HealthState getHealth() override;
ReturnValue_t setHealth(HealthState health) override;
HasHealthIF::HealthState getHealth() override;
/** ExecutableObjectIF overrides */
virtual ReturnValue_t performOperation(uint8_t opCode) override;
virtual void setTaskIF(PeriodicTaskIF *task) override;
virtual ReturnValue_t initializeAfterTaskCreation() override;
ReturnValue_t performOperation(uint8_t opCode) override;
void setTaskIF(PeriodicTaskIF *task) override;
ReturnValue_t initializeAfterTaskCreation() override;
protected:
/**
@ -54,8 +54,8 @@ class ControllerBase : public HasModesIF,
*/
virtual void performControlOperation() = 0;
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) override = 0;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) override = 0;
const object_id_t parentId;
@ -80,10 +80,10 @@ class ControllerBase : public HasModesIF,
/** Mode helpers */
virtual void modeChanged(Mode_t mode, Submode_t submode);
virtual void startTransition(Mode_t mode, Submode_t submode) override;
virtual void getMode(Mode_t *mode, Submode_t *submode) override;
virtual void setToExternalControl() override;
virtual void announceMode(bool recursive);
void startTransition(Mode_t mode, Submode_t submode) override;
void getMode(Mode_t *mode, Submode_t *submode) override;
void setToExternalControl() override;
void announceMode(bool recursive) override;
/** HK helpers */
virtual void changeHK(Mode_t mode, Submode_t submode, bool enable);
};

View File

@ -6,7 +6,7 @@ ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, object_id_t
poolManager(this, commandQueue),
actionHelper(this, commandQueue) {}
ExtendedControllerBase::~ExtendedControllerBase() {}
ExtendedControllerBase::~ExtendedControllerBase() = default;
ReturnValue_t ExtendedControllerBase::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy,
@ -31,7 +31,7 @@ ReturnValue_t ExtendedControllerBase::handleCommandMessage(CommandMessage *messa
void ExtendedControllerBase::handleQueue() {
CommandMessage command;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
ReturnValue_t result;
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
result = commandQueue->receiveMessage(&command)) {
result = actionHelper.handleActionMessage(&command);

View File

@ -18,16 +18,16 @@ class ExtendedControllerBase : public ControllerBase,
public HasLocalDataPoolIF {
public:
ExtendedControllerBase(object_id_t objectId, object_id_t parentId, size_t commandQueueDepth = 3);
virtual ~ExtendedControllerBase();
~ExtendedControllerBase() override;
/* SystemObjectIF overrides */
virtual ReturnValue_t initialize() override;
ReturnValue_t initialize() override;
virtual MessageQueueId_t getCommandQueue() const override;
[[nodiscard]] MessageQueueId_t getCommandQueue() const override;
/* ExecutableObjectIF overrides */
virtual ReturnValue_t performOperation(uint8_t opCode) override;
virtual ReturnValue_t initializeAfterTaskCreation() override;
ReturnValue_t performOperation(uint8_t opCode) override;
ReturnValue_t initializeAfterTaskCreation() override;
protected:
LocalDataPoolManager poolManager;
@ -39,32 +39,32 @@ class ExtendedControllerBase : public ControllerBase,
* @param message
* @return
*/
virtual ReturnValue_t handleCommandMessage(CommandMessage* message) = 0;
ReturnValue_t handleCommandMessage(CommandMessage* message) override = 0;
/**
* Periodic helper from ControllerBase, implemented by child class.
*/
virtual void performControlOperation() = 0;
void performControlOperation() override = 0;
/* Handle the four messages mentioned above */
void handleQueue() override;
/* HasActionsIF overrides */
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
/* HasLocalDatapoolIF overrides */
virtual LocalDataPoolManager* getHkManagerHandle() override;
virtual object_id_t getObjectId() const override;
virtual uint32_t getPeriodicOperationFrequency() const override;
LocalDataPoolManager* getHkManagerHandle() override;
[[nodiscard]] object_id_t getObjectId() const override;
[[nodiscard]] uint32_t getPeriodicOperationFrequency() const override;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override = 0;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override = 0;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override = 0;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override = 0;
// Mode abstract functions
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) override = 0;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) override = 0;
};
#endif /* FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_ */

View File

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

View File

@ -1,12 +1,11 @@
target_sources(${LIB_FSFW_NAME}
PRIVATE
Clcw.cpp
DataLinkLayer.cpp
Farm1StateLockout.cpp
Farm1StateOpen.cpp
Farm1StateWait.cpp
MapPacketExtraction.cpp
TcTransferFrame.cpp
TcTransferFrameLocal.cpp
VirtualChannelReception.cpp
)
target_sources(
${LIB_FSFW_NAME}
PRIVATE Clcw.cpp
DataLinkLayer.cpp
Farm1StateLockout.cpp
Farm1StateOpen.cpp
Farm1StateWait.cpp
MapPacketExtraction.cpp
TcTransferFrame.cpp
TcTransferFrameLocal.cpp
VirtualChannelReception.cpp)

View File

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

View File

@ -7,24 +7,26 @@
#include "fsfw/serviceinterface.h"
template <typename T>
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValue, bool setValid)
: length(static_cast<uint8_t>(initValue.size())), valid(setValid) {
this->address = new T[this->length];
if (initValue.size() == 0) {
std::memset(this->address, 0, this->getByteSize());
} else {
std::copy(initValue.begin(), initValue.end(), this->address);
PoolEntry<T>::PoolEntry(uint8_t len, bool setValid) : length(len), valid(setValid) {
this->address = new T[this->length]();
std::memset(this->address, 0, this->getByteSize());
}
template <typename T>
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValues, bool setValid)
: length(static_cast<uint8_t>(initValues.size())), valid(setValid) {
this->address = new T[this->length]();
if (initValues.size() > 0) {
std::copy(initValues.begin(), initValues.end(), this->address);
}
}
template <typename T>
PoolEntry<T>::PoolEntry(T* initValue, uint8_t setLength, bool setValid)
PoolEntry<T>::PoolEntry(const T* initValue, uint8_t setLength, bool setValid)
: length(setLength), valid(setValid) {
this->address = new T[this->length];
this->address = new T[this->length]();
if (initValue != nullptr) {
std::memcpy(this->address, initValue, this->getByteSize());
} else {
std::memset(this->address, 0, this->getByteSize());
}
}

View File

@ -33,6 +33,9 @@ class PoolEntry : public PoolEntryIF {
"instead! The ECSS standard defines a boolean as a one bit "
"field. Therefore it is preferred to store a boolean as an "
"uint8_t");
PoolEntry(uint8_t len = 1, bool setValid = false);
/**
* @brief In the classe's constructor, space is allocated on the heap and
* potential initialization values are copied to that space.
@ -49,7 +52,7 @@ class PoolEntry : public PoolEntryIF {
* @param setValid
* Sets the initialization flag. It is invalid by default.
*/
PoolEntry(std::initializer_list<T> initValue = {0}, bool setValid = false);
PoolEntry(std::initializer_list<T> initValue, bool setValid = false);
/**
* @brief In the classe's constructor, space is allocated on the heap and
@ -62,7 +65,7 @@ class PoolEntry : public PoolEntryIF {
* @param setValid
* Sets the initialization flag. It is invalid by default.
*/
PoolEntry(T* initValue, uint8_t setLength = 1, bool setValid = false);
PoolEntry(const T* initValue, uint8_t setLength = 1, bool setValid = false);
//! Explicitely deleted copy ctor, copying is not allowed.
PoolEntry(const PoolEntry&) = delete;

View File

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

View File

@ -688,7 +688,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
ReturnValue_t result = generateHousekeepingPacket(sid, dataSet, true);
if (result != HasReturnvaluesIF::RETURN_OK) {
/* Configuration error */
FSFW_LOGWT("{}", "performHkOperation: HK generation failed");
FSFW_LOGWT("performPeriodicHkOperation: HK generation failed\n");
}
}

View File

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

View File

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

View File

@ -65,7 +65,9 @@ void DeviceHandlerBase::setThermalStateRequestPoolIds(lp_id_t thermalStatePoolId
}
DeviceHandlerBase::~DeviceHandlerBase() {
delete comCookie;
if (comCookie != nullptr) {
delete comCookie;
}
if (defaultFDIRUsed) {
delete fdirInstance;
}
@ -219,17 +221,26 @@ ReturnValue_t DeviceHandlerBase::initialize() {
}
void DeviceHandlerBase::decrementDeviceReplyMap() {
bool timedOut = false;
for (std::pair<const DeviceCommandId_t, DeviceReplyInfo>& replyPair : deviceReplyMap) {
if (replyPair.second.delayCycles != 0) {
if (replyPair.second.countdown != nullptr && replyPair.second.active) {
if (replyPair.second.countdown->hasTimedOut()) {
resetTimeoutControlledReply(&replyPair.second);
timedOut = true;
}
}
if (replyPair.second.delayCycles != 0 && replyPair.second.countdown == nullptr) {
replyPair.second.delayCycles--;
if (replyPair.second.delayCycles == 0) {
if (replyPair.second.periodic) {
replyPair.second.delayCycles = replyPair.second.maxDelayCycles;
}
replyToReply(replyPair.first, replyPair.second, TIMEOUT);
missedReply(replyPair.first);
resetDelayCyclesControlledReply(&replyPair.second);
timedOut = true;
}
}
if (timedOut) {
replyToReply(replyPair.first, replyPair.second, TIMEOUT);
missedReply(replyPair.first);
timedOut = false;
}
}
}
@ -344,7 +355,6 @@ void DeviceHandlerBase::doStateMachine() {
setMode(MODE_OFF);
break;
}
if (currentUptime - timeoutStart >= powerSwitcher->getSwitchDelayMs()) {
triggerEvent(MODE_TRANSITION_FAILED, PowerSwitchIF::SWITCH_TIMEOUT, 0);
setMode(MODE_ERROR_ON);
@ -393,20 +403,22 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode, Submode_t s
ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap(
DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, LocalPoolDataSetBase* replyDataSet,
size_t replyLen, bool periodic, bool hasDifferentReplyId, DeviceCommandId_t replyId) {
size_t replyLen, bool periodic, bool hasDifferentReplyId, DeviceCommandId_t replyId,
Countdown* countdown) {
// No need to check, as we may try to insert multiple times.
insertInCommandMap(deviceCommand, hasDifferentReplyId, replyId);
if (hasDifferentReplyId) {
return insertInReplyMap(replyId, maxDelayCycles, replyDataSet, replyLen, periodic);
return insertInReplyMap(replyId, maxDelayCycles, replyDataSet, replyLen, periodic, countdown);
} else {
return insertInReplyMap(deviceCommand, maxDelayCycles, replyDataSet, replyLen, periodic);
return insertInReplyMap(deviceCommand, maxDelayCycles, replyDataSet, replyLen, periodic,
countdown);
}
}
ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId,
uint16_t maxDelayCycles,
LocalPoolDataSetBase* dataSet, size_t replyLen,
bool periodic) {
bool periodic, Countdown* countdown) {
DeviceReplyInfo info;
info.maxDelayCycles = maxDelayCycles;
info.periodic = periodic;
@ -414,6 +426,7 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId,
info.replyLen = replyLen;
info.dataSet = dataSet;
info.command = deviceCommandMap.end();
info.countdown = countdown;
auto resultPair = deviceReplyMap.emplace(replyId, info);
if (resultPair.second) {
return RETURN_OK;
@ -449,7 +462,8 @@ size_t DeviceHandlerBase::getNextReplyLength(DeviceCommandId_t commandId) {
}
DeviceReplyIter iter = deviceReplyMap.find(replyId);
if (iter != deviceReplyMap.end()) {
if (iter->second.delayCycles != 0) {
if ((iter->second.delayCycles != 0 && iter->second.countdown == nullptr) ||
(iter->second.active && iter->second.countdown != nullptr)) {
return iter->second.replyLen;
}
}
@ -485,9 +499,19 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI
return COMMAND_NOT_SUPPORTED;
}
if (enable) {
info->delayCycles = info->maxDelayCycles;
info->active = true;
if (info->countdown != nullptr) {
info->delayCycles = info->maxDelayCycles;
} else {
info->countdown->resetTimer();
}
} else {
info->delayCycles = 0;
info->active = false;
if (info->countdown != nullptr) {
info->delayCycles = 0;
} else {
info->countdown->timeOut();
}
}
}
return HasReturnvaluesIF::RETURN_OK;
@ -791,17 +815,18 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, DeviceCommandId
DeviceReplyInfo* info = &(iter->second);
if (info->delayCycles != 0) {
if ((info->delayCycles != 0 && info->countdown == nullptr) ||
(info->active && info->countdown != nullptr)) {
result = interpretDeviceReply(foundId, receivedData);
if (result == IGNORE_REPLY_DATA) {
return;
}
if (info->periodic) {
info->delayCycles = info->maxDelayCycles;
} else {
info->delayCycles = 0;
if (info->active && info->countdown != nullptr) {
resetTimeoutControlledReply(info);
} else if (info->delayCycles != 0) {
resetDelayCyclesControlledReply(info);
}
if (result != RETURN_OK) {
@ -820,6 +845,24 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, DeviceCommandId
}
}
void DeviceHandlerBase::resetTimeoutControlledReply(DeviceReplyInfo* info) {
if (info->periodic) {
info->countdown->resetTimer();
} else {
info->active = false;
info->countdown->timeOut();
}
}
void DeviceHandlerBase::resetDelayCyclesControlledReply(DeviceReplyInfo* info) {
if (info->periodic) {
info->delayCycles = info->maxDelayCycles;
} else {
info->delayCycles = 0;
info->active = false;
}
}
ReturnValue_t DeviceHandlerBase::getStorageData(store_address_t storageAddress, uint8_t** data,
size_t* len) {
size_t lenTmp;
@ -942,9 +985,15 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(DeviceCommandMap::iterato
}
if (iter != deviceReplyMap.end()) {
DeviceReplyInfo* info = &(iter->second);
// If a countdown has been set, the delay cycles will be ignored and the reply times out
// as soon as the countdown has expired
info->delayCycles = info->maxDelayCycles;
info->command = command;
command->second.expectedReplies = expectedReplies;
if (info->countdown != nullptr) {
info->countdown->resetTimer();
}
info->active = true;
return RETURN_OK;
} else {
return NO_REPLY_EXPECTED;
@ -1179,7 +1228,8 @@ void DeviceHandlerBase::setParentQueue(MessageQueueId_t parentQueueId) {
bool DeviceHandlerBase::isAwaitingReply() {
std::map<DeviceCommandId_t, DeviceReplyInfo>::iterator iter;
for (iter = deviceReplyMap.begin(); iter != deviceReplyMap.end(); ++iter) {
if (iter->second.delayCycles != 0) {
if ((iter->second.delayCycles != 0 && iter->second.countdown == nullptr) ||
(iter->second.active && iter->second.countdown != nullptr)) {
return true;
}
}
@ -1334,6 +1384,13 @@ uint8_t DeviceHandlerBase::getReplyDelayCycles(DeviceCommandId_t deviceCommand)
auto iter = deviceReplyMap.find(deviceCommand);
if (iter == deviceReplyMap.end()) {
return 0;
} else if (iter->second.countdown != nullptr) {
// fake a useful return value for legacy code
if (iter->second.active) {
return 1;
} else {
return 0;
}
}
return iter->second.delayCycles;
}

View File

@ -447,6 +447,9 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* by the device repeatedly without request) or not. Default is aperiodic (0).
* Please note that periodic replies are disabled by default. You can enable them with
* #updatePeriodicReply
* @param countdown Instead of using maxDelayCycles to timeout a device reply it is also possible
* to provide a pointer to a Countdown object which will signal the timeout
* when expired
* @return - @c RETURN_OK when the command was successfully inserted,
* - @c RETURN_FAILED else.
*/
@ -454,7 +457,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
LocalPoolDataSetBase *replyDataSet = nullptr,
size_t replyLen = 0, bool periodic = false,
bool hasDifferentReplyId = false,
DeviceCommandId_t replyId = 0);
DeviceCommandId_t replyId = 0,
Countdown *countdown = nullptr);
/**
* @brief This is a helper method to insert replies in the reply map.
* @param deviceCommand Identifier of the reply to add.
@ -464,12 +468,15 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* by the device repeatedly without request) or not. Default is aperiodic (0).
* Please note that periodic replies are disabled by default. You can enable them with
* #updatePeriodicReply
* @param countdown Instead of using maxDelayCycles to timeout a device reply it is also possible
* to provide a pointer to a Countdown object which will signal the timeout
* when expired
* @return - @c RETURN_OK when the command was successfully inserted,
* - @c RETURN_FAILED else.
*/
ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles,
LocalPoolDataSetBase *dataSet = nullptr, size_t replyLen = 0,
bool periodic = false);
bool periodic = false, Countdown *countdown = nullptr);
/**
* @brief A simple command to add a command to the commandList.
@ -782,6 +789,11 @@ class DeviceHandlerBase : public DeviceHandlerIF,
LocalPoolDataSetBase *dataSet = nullptr;
//! The command that expects this reply.
DeviceCommandMap::iterator command;
//! Instead of using delayCycles to specify the maximum time to wait for the device reply, it
//! is also possible specify a countdown
Countdown *countdown = nullptr;
//! will be set to true when reply is enabled
bool active = false;
};
using DeviceReplyMap = std::map<DeviceCommandId_t, DeviceReplyInfo>;
@ -1243,6 +1255,17 @@ class DeviceHandlerBase : public DeviceHandlerIF,
*/
void doGetRead(void);
/**
* @brief Resets replies which use a timeout to detect missed replies.
*/
void resetTimeoutControlledReply(DeviceReplyInfo *info);
/**
* @brief Resets replies which use a number of maximum delay cycles to detect
* missed replies.
*/
void resetDelayCyclesControlledReply(DeviceReplyInfo *info);
/**
* Retrive data from the #IPCStore.
*

View File

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

View File

@ -88,6 +88,11 @@ ReturnValue_t EventManager::subscribeToEventRange(MessageQueueId_t listener, Eve
return result;
}
ReturnValue_t EventManager::unsubscribeFromAllEvents(MessageQueueId_t listener,
object_id_t object) {
return unsubscribeFromEventRange(listener, 0, 0, true, object);
}
ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener, EventId_t idFrom,
EventId_t idTo, bool idInverted,
object_id_t reporterFrom,

View File

@ -37,6 +37,7 @@ class EventManager : public EventManagerIF, public ExecutableObjectIF, public Sy
EventId_t idTo = 0, bool idInverted = false,
object_id_t reporterFrom = 0, object_id_t reporterTo = 0,
bool reporterInverted = false);
ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, object_id_t object);
ReturnValue_t unsubscribeFromEventRange(MessageQueueId_t listener, EventId_t idFrom = 0,
EventId_t idTo = 0, bool idInverted = false,
object_id_t reporterFrom = 0, object_id_t reporterTo = 0,

View File

@ -20,6 +20,7 @@ class EventManagerIF {
bool forwardAllButSelected = false) = 0;
virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event) = 0;
virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener, object_id_t object) = 0;
virtual ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, object_id_t object) = 0;
virtual ReturnValue_t subscribeToEventRange(MessageQueueId_t listener, EventId_t idFrom = 0,
EventId_t idTo = 0, bool idInverted = false,
object_id_t reporterFrom = 0,

View File

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

View File

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

View File

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

View File

@ -14,6 +14,16 @@ FailureIsolationBase::FailureIsolationBase(object_id_t owner, object_id_t parent
}
FailureIsolationBase::~FailureIsolationBase() {
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
if (manager == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::~FailureIsolationBase: Event Manager has not"
" been initialized!"
<< std::endl;
#endif
return;
}
manager->unsubscribeFromAllEvents(eventQueue->getId(), ownerId);
QueueFactory::instance()->deleteMessageQueue(eventQueue);
}

View File

@ -60,14 +60,14 @@ ReturnValue_t FaultCounter::getParameter(uint8_t domainId, uint8_t uniqueId,
return INVALID_DOMAIN_ID;
}
switch (uniqueId) {
case 0:
switch (static_cast<ParameterIds>(uniqueId)) {
case ParameterIds::FAILURE_THRESHOLD:
parameterWrapper->set(failureThreshold);
break;
case 1:
case ParameterIds::FAULT_COUNT:
parameterWrapper->set(faultCount);
break;
case 2:
case ParameterIds::TIMEOUT:
parameterWrapper->set(timer.timeout);
break;
default:

View File

@ -6,6 +6,8 @@
class FaultCounter : public HasParametersIF {
public:
enum class ParameterIds { FAILURE_THRESHOLD, FAULT_COUNT, TIMEOUT };
FaultCounter();
FaultCounter(uint32_t failureThreshold, uint32_t decrementAfterMs,
uint8_t setParameterDomain = 0);
@ -25,7 +27,8 @@ class FaultCounter : public HasParametersIF {
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
ParameterWrapper *parameterWrapper,
const ParameterWrapper *newValues, uint16_t startAtIndex);
const ParameterWrapper *newValues = nullptr,
uint16_t startAtIndex = 0);
void setParameterDomain(uint8_t domain);

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@
HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId)
: objectId(objectId), owner(owner) {}
HealthHelper::~HealthHelper() {}
HealthHelper::~HealthHelper() { healthTable->removeObject(objectId); }
ReturnValue_t HealthHelper::handleHealthCommand(CommandMessage* message) {
switch (message->getCommand()) {

View File

@ -28,6 +28,15 @@ ReturnValue_t HealthTable::registerObject(object_id_t object,
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t HealthTable::removeObject(object_id_t object) {
mapIterator = healthMap.find(object);
if (mapIterator == healthMap.end()) {
return HasReturnvaluesIF::RETURN_FAILED;
}
healthMap.erase(mapIterator);
return HasReturnvaluesIF::RETURN_OK;
}
void HealthTable::setHealth(object_id_t object, HasHealthIF::HealthState newState) {
MutexGuard(mutex, timeoutType, mutexTimeoutMs);
HealthMap::iterator iter = healthMap.find(object);

View File

@ -17,6 +17,7 @@ class HealthTable : public HealthTableIF, public SystemObject {
/** HealthTableIF overrides */
virtual ReturnValue_t registerObject(
object_id_t object, HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY) override;
ReturnValue_t removeObject(object_id_t object) override;
virtual size_t getPrintSize() override;
virtual void printAll(uint8_t* pointer, size_t maxSize) override;

View File

@ -14,6 +14,8 @@ class HealthTableIF : public ManagesHealthIF {
virtual ReturnValue_t registerObject(
object_id_t object, HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY) = 0;
virtual ReturnValue_t removeObject(object_id_t objectId) = 0;
virtual size_t getPrintSize() = 0;
virtual void printAll(uint8_t *pointer, size_t maxSize) = 0;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,27 +1,23 @@
target_sources(${LIB_FSFW_NAME} PRIVATE
Clock.cpp
FixedTimeslotTask.cpp
MessageQueue.cpp
Mutex.cpp
MutexFactory.cpp
PeriodicTask.cpp
QueueFactory.cpp
QueueMapManager.cpp
SemaphoreFactory.cpp
TaskFactory.cpp
taskHelpers.cpp
)
target_sources(
${LIB_FSFW_NAME}
PRIVATE Clock.cpp
FixedTimeslotTask.cpp
MessageQueue.cpp
Mutex.cpp
MutexFactory.cpp
PeriodicTask.cpp
QueueFactory.cpp
QueueMapManager.cpp
SemaphoreFactory.cpp
TaskFactory.cpp
taskHelpers.cpp)
if(UNIX)
find_package(Threads REQUIRED)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
${CMAKE_THREAD_LIBS_INIT}
)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
if(NOT APPLE)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
rt
)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE rt)
endif()
endif()
endif()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,29 +1,25 @@
target_sources(${LIB_FSFW_NAME} PRIVATE
Clock.cpp
BinarySemaphore.cpp
CountingSemaphore.cpp
FixedTimeslotTask.cpp
InternalErrorCodes.cpp
MessageQueue.cpp
Mutex.cpp
MutexFactory.cpp
PeriodicPosixTask.cpp
PosixThread.cpp
QueueFactory.cpp
SemaphoreFactory.cpp
TaskFactory.cpp
tcpipHelpers.cpp
unixUtility.cpp
)
target_sources(
${LIB_FSFW_NAME}
PRIVATE Clock.cpp
BinarySemaphore.cpp
CountingSemaphore.cpp
FixedTimeslotTask.cpp
InternalErrorCodes.cpp
MessageQueue.cpp
Mutex.cpp
MutexFactory.cpp
PeriodicPosixTask.cpp
PosixThread.cpp
QueueFactory.cpp
SemaphoreFactory.cpp
TaskFactory.cpp
tcpipHelpers.cpp
unixUtility.cpp)
find_package(Threads REQUIRED)
target_link_libraries(${LIB_FSFW_NAME} PUBLIC
${CMAKE_THREAD_LIBS_INIT}
)
target_link_libraries(${LIB_FSFW_NAME} PUBLIC ${CMAKE_THREAD_LIBS_INIT})
if(NOT APPLE)
target_link_libraries(${LIB_FSFW_NAME} PUBLIC
rt
)
target_link_libraries(${LIB_FSFW_NAME} PUBLIC rt)
endif()

View File

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

View File

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

View File

@ -290,10 +290,9 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag
*/
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg
<< " is too small for requested size " << messageDepth << std::endl;
<< " is too small for requested message depth " << messageDepth << std::endl;
sif::error << "This error can be fixed by setting the maximum "
"allowed message size higher!"
<< std::endl;
"allowed message depth higher" << std::endl;
#else
sif::printError(
"MessageQueue::MessageQueue: Default MQ size %d is too small for"

View File

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

View File

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

View File

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

View File

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

View File

@ -1,20 +1,17 @@
target_sources(${LIB_FSFW_NAME}
PRIVATE
Clock.cpp
CpuUsage.cpp
InitTask.cpp
InternalErrorCodes.cpp
MessageQueue.cpp
PeriodicTask.cpp
Mutex.cpp
MutexFactory.cpp
FixedTimeslotTask.cpp
QueueFactory.cpp
RtemsBasic.cpp
RTEMSTaskBase.cpp
TaskFactory.cpp
BinarySemaphore.cpp
SemaphoreFactory.cpp
)
target_sources(
${LIB_FSFW_NAME}
PRIVATE Clock.cpp
CpuUsage.cpp
InitTask.cpp
InternalErrorCodes.cpp
MessageQueue.cpp
PeriodicTask.cpp
Mutex.cpp
MutexFactory.cpp
FixedTimeslotTask.cpp
QueueFactory.cpp
RtemsBasic.cpp
RTEMSTaskBase.cpp
TaskFactory.cpp
BinarySemaphore.cpp
SemaphoreFactory.cpp)

View File

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

View File

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

View File

@ -65,7 +65,7 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo, MessageQueu
}
ReturnValue_t returnCode = convertReturnCode(result);
if (result == MessageQueueIF::EMPTY) {
if (returnCode == MessageQueueIF::EMPTY) {
return HasReturnvaluesIF::RETURN_FAILED;
}

View File

@ -36,9 +36,9 @@ class MessageQueue : public MessageQueueBase {
* @param max_message_size With this parameter, the maximum message size can be adjusted.
* This should be left default.
*/
MessageQueue(size_t message_depth = 3,
size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE,
MqArgs* args = nullptr);
explicit MessageQueue(size_t message_depth = 3,
size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE,
MqArgs* args = nullptr);
/** Copying message queues forbidden */
MessageQueue(const MessageQueue&) = delete;
@ -48,18 +48,19 @@ class MessageQueue : public MessageQueueBase {
* @brief The destructor deletes the formerly created message queue.
* @details This is accomplished by using the delete call provided by the operating system.
*/
virtual ~MessageQueue();
~MessageQueue() override;
// Implement non-generic MessageQueueIF functions not handled by MessageQueueBase
ReturnValue_t flush(uint32_t* count) override;
ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override;
ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
MessageQueueId_t sentFrom = NO_QUEUE,
bool ignoreFault = false) override;
MessageQueueId_t sentFrom, bool ignoreFault) override;
private:
/**
* \brief This attribute stores a reference to the internal error reporter for reporting full
* queues. \details In the event of a full destination queue, the reporter will be notified. The
* @brief This attribute stores a reference to the internal error reporter for reporting full
* queues. @details In the event of a full destination queue, the reporter will be notified. The
* reference is set by lazy loading
*/
InternalErrorReporterIF* internalErrorReporter;

View File

@ -5,12 +5,12 @@
#include "fsfw/tasks/ExecutableObjectIF.h"
PeriodicTask::PeriodicTask(const char* name, rtems_task_priority setPriority, size_t setStack,
rtems_interval setPeriod, void (*setDeadlineMissedFunc)())
: RTEMSTaskBase(setPriority, setStack, name),
periodTicks(RtemsBasic::convertMsToTicks(setPeriod)),
deadlineMissedFunc(setDeadlineMissedFunc) {}
TaskPeriod setPeriod, TaskDeadlineMissedFunction dlmFunc_)
: PeriodicTaskBase(setPeriod, dlmFunc_),
RTEMSTaskBase(setPriority, setStack, name),
periodTicks(RtemsBasic::convertMsToTicks(static_cast<uint32_t>(setPeriod * 1000.0))) {}
PeriodicTask::~PeriodicTask(void) {
PeriodicTask::~PeriodicTask() {
/* Do not delete objects, we were responsible for pointers only. */
rtems_rate_monotonic_delete(periodId);
}
@ -18,7 +18,7 @@ PeriodicTask::~PeriodicTask(void) {
rtems_task PeriodicTask::taskEntryPoint(rtems_task_argument argument) {
/* The argument is re-interpreted as MultiObjectTask. The Task object is global,
so it is found from any place. */
PeriodicTask* originalTask(reinterpret_cast<PeriodicTask*>(argument));
auto* originalTask(reinterpret_cast<PeriodicTask*>(argument));
return originalTask->taskFunctionality();
;
}
@ -28,8 +28,10 @@ ReturnValue_t PeriodicTask::startTask() {
rtems_task_start(id, PeriodicTask::taskEntryPoint, rtems_task_argument((void*)this));
if (status != RTEMS_SUCCESSFUL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectTask::startTask for " << std::hex << this->getId() << std::dec
<< " failed." << std::endl;
sif::error << "PeriodicTask::startTask for " << std::hex << this->getId() << std::dec
<< " failed" << std::endl;
#else
sif::printError("PeriodicTask::startTask for 0x%08x failed\n", getId());
#endif
}
switch (status) {
@ -47,38 +49,20 @@ ReturnValue_t PeriodicTask::startTask() {
ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) { return RTEMSTaskBase::sleepFor(ms); }
void PeriodicTask::taskFunctionality() {
[[noreturn]] void PeriodicTask::taskFunctionality() {
RTEMSTaskBase::setAndStartPeriod(periodTicks, &periodId);
for (const auto& object : objectList) {
object->initializeAfterTaskCreation();
}
initObjsAfterTaskCreation();
/* The task's "infinite" inner loop is entered. */
while (1) {
for (const auto& object : objectList) {
object->performOperation();
while (true) {
for (const auto& objectPair : objectList) {
objectPair.first->performOperation(objectPair.second);
}
rtems_status_code status = RTEMSTaskBase::restartPeriod(periodTicks, periodId);
if (status == RTEMS_TIMEOUT) {
if (this->deadlineMissedFunc != nullptr) {
this->deadlineMissedFunc();
if (dlmFunc != nullptr) {
dlmFunc();
}
}
}
}
ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
ExecutableObjectIF* newObject = ObjectManager::instance()->get<ExecutableObjectIF>(object);
return addComponent(newObject);
}
ReturnValue_t PeriodicTask::addComponent(ExecutableObjectIF* object) {
if (object == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
objectList.push_back(object);
object->setTaskIF(this);
return HasReturnvaluesIF::RETURN_OK;
}
uint32_t PeriodicTask::getPeriodMs() const { return RtemsBasic::convertTicksToMs(periodTicks); }

View File

@ -3,9 +3,10 @@
#include <vector>
#include "../../objectmanager/ObjectManagerIF.h"
#include "../../tasks/PeriodicTaskIF.h"
#include "RTEMSTaskBase.h"
#include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/tasks/PeriodicTaskBase.h"
#include "fsfw/tasks/PeriodicTaskIF.h"
class ExecutableObjectIF;
@ -18,7 +19,7 @@ class ExecutableObjectIF;
* @author baetz
* @ingroup task_handling
*/
class PeriodicTask : public RTEMSTaskBase, public PeriodicTaskIF {
class PeriodicTask : public PeriodicTaskBase, public RTEMSTaskBase {
public:
/**
* @brief Standard constructor of the class.
@ -36,12 +37,12 @@ class PeriodicTask : public RTEMSTaskBase, public PeriodicTaskIF {
* that shall be assigned.
*/
PeriodicTask(const char *name, rtems_task_priority setPriority, size_t setStack,
rtems_interval setPeriod, void (*setDeadlineMissedFunc)());
TaskPeriod setPeriod, TaskDeadlineMissedFunction dlmFunc);
/**
* @brief Currently, the executed object's lifetime is not coupled with the task object's
* lifetime, so the destructor is empty.
*/
virtual ~PeriodicTask(void);
~PeriodicTask() override;
/**
* @brief The method to start the task.
@ -50,33 +51,11 @@ class PeriodicTask : public RTEMSTaskBase, public PeriodicTaskIF {
* The address of the task object is passed as an argument
* to the system call.
*/
ReturnValue_t startTask(void);
/**
* Adds an object to the list of objects to be executed.
* The objects are executed in the order added.
* @param object Id of the object to add.
* @return RETURN_OK on success, RETURN_FAILED if the object could not be added.
*/
ReturnValue_t addComponent(object_id_t object) override;
/**
* Adds an object to the list of objects to be executed.
* The objects are executed in the order added.
* @param object pointer to the object to add.
* @return RETURN_OK on success, RETURN_FAILED if the object could not be added.
*/
ReturnValue_t addComponent(ExecutableObjectIF *object) override;
uint32_t getPeriodMs() const override;
ReturnValue_t startTask() override;
ReturnValue_t sleepFor(uint32_t ms) override;
protected:
typedef std::vector<ExecutableObjectIF *> ObjectList; //!< Typedef for the List of objects.
/**
* @brief This attribute holds a list of objects to be executed.
*/
ObjectList objectList;
/**
* @brief The period of the task.
* @details The period determines the frequency of the task's execution. It is expressed in
@ -87,14 +66,7 @@ class PeriodicTask : public RTEMSTaskBase, public PeriodicTaskIF {
* @brief id of the associated OS period
*/
rtems_id periodId = 0;
/**
* @brief The pointer to the deadline-missed function.
* @details This pointer stores the function that is executed if the task's deadline is missed.
* So, each may react individually on a timing failure. The pointer may be
* nullptr, then nothing happens on missing the deadline. The deadline is equal to the next
* execution of the periodic task.
*/
void (*deadlineMissedFunc)(void);
/**
* @brief This is the function executed in the new task's context.
* @details It converts the argument back to the thread object type and copies the class
@ -110,7 +82,7 @@ class PeriodicTask : public RTEMSTaskBase, public PeriodicTaskIF {
* are called. Afterwards the checkAndRestartPeriod system call blocks the task until the next
* period. On missing the deadline, the deadlineMissedFunction is executed.
*/
void taskFunctionality(void);
[[noreturn]] void taskFunctionality();
};
#endif /* FSFW_OSAL_RTEMS_PERIODICTASK_H_ */

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