Compare commits
440 Commits
8f83f7becd
...
ASTP_1.0.0
Author | SHA1 | Date | |
---|---|---|---|
2f511523cb | |||
9f83739771 | |||
054de9781b | |||
20e7fe6cb1 | |||
f8cd8e1e7d | |||
818634755d | |||
87fee9bd0e | |||
6a40b8244d | |||
4fd443f70b | |||
06631d06a5
|
|||
9244a96e7b | |||
03ef63302b
|
|||
c50796b785 | |||
a0caa92a8a | |||
a91139be76 | |||
fee2ac0eb9 | |||
2878f21c93 | |||
4caf906d96 | |||
b38e9ede0c | |||
17b3672330 | |||
629814bc9b
|
|||
4fb792447e
|
|||
40dae8c961 | |||
9e1f3ee585 | |||
e851d8a46c | |||
0038c1dc53 | |||
1a3bb5bada | |||
0055d34d9a | |||
a2ba3181b9 | |||
864621ee37 | |||
54ff8f9341 | |||
e4efc01e34 | |||
c455fc1417 | |||
d792679d49 | |||
38a5e7e618 | |||
0c342ad7fc | |||
524e50a6dd | |||
17adb2cc3e | |||
7b29583f8f | |||
1af7870b15 | |||
1cbeb54b8d | |||
0ec83afa13 | |||
153c44601b
|
|||
e6a8371d4a | |||
64efb8ec7f | |||
c8b2b3a038 | |||
6873d2b847 | |||
91c3692f6d | |||
69788e1279 | |||
ec69076652 | |||
a62bda97a0 | |||
32f0131973 | |||
9784d5123b | |||
ea8d887a6b | |||
29cebab790 | |||
03095776f1
|
|||
bad9f67c39 | |||
98add88d14 | |||
e1b595d620 | |||
39940823d1 | |||
4479a2628d | |||
b09119cd8d | |||
10bc568560 | |||
6e09e29ec2 | |||
43fb05ac5d | |||
e832487081 | |||
01acbaa270 | |||
a8b5fec725 | |||
321de4e46b | |||
2635ec3d56 | |||
3f7915fe49 | |||
f87a10891a | |||
f4ac5c3844 | |||
922f145ffa | |||
9731127eaf | |||
5124f314f4 | |||
4bb078c451 | |||
547538fbc5 | |||
06d34efa74 | |||
b786b53c35 | |||
e50d0738ab | |||
01d0bd6c64 | |||
5676969fe3 | |||
b4594e6f43 | |||
6e12f08965 | |||
2dd2d8f133 | |||
10c3483fe5 | |||
23e3f2f34f | |||
6983ddc3e0 | |||
c234da6f07 | |||
8930be9f32 | |||
32996338a0 | |||
2736ebbd19 | |||
509945c323 | |||
435c6e6410 | |||
3429918f5e | |||
3a75be2683 | |||
aa9d7b2226 | |||
eea482b438 | |||
3a90578780 | |||
1d818294e4 | |||
581832e4f4 | |||
9e559658a7 | |||
b1c532078e | |||
37ac579f51 | |||
aaceac81af | |||
d781c6fcec | |||
bdd9889718 | |||
a5f44b8580 | |||
d1265a55b4 | |||
b542ed5c03 | |||
8b42132cbe | |||
b1670decf7 | |||
1d3d2be853 | |||
d4ab2c6cdb | |||
1c021651d7 | |||
3175883346 | |||
4d403b40c9 | |||
f6afa36b1c | |||
0c77ce4dcf | |||
4c11b2f660 | |||
614d1ccb7c | |||
e3c44fd27f | |||
078116c7be | |||
b5a14bb9df | |||
86577f4b80 | |||
d625642abc | |||
951eb40e96 | |||
538dec7062 | |||
8f17d6623a | |||
0585ef9051 | |||
0da95b75a2 | |||
e44f8bfea3 | |||
fe2b3a01cf | |||
aa849894c6 | |||
a4ca61d834 | |||
b41eb518e7 | |||
1b8878a81f | |||
95096d83de | |||
2331188536 | |||
b2937ae510 | |||
3f8fae24dd | |||
12f47fdd0d | |||
b757c5523c | |||
5271375063 | |||
4955015f3f | |||
898e06591b | |||
d62dea442d | |||
66a09b94ac | |||
125dffcf28 | |||
8dec4c9311 | |||
26ce8d7185 | |||
1996f5949f | |||
ca4a0b1bb8 | |||
588f9471d8 | |||
703dfe9854 | |||
7bc04014e8 | |||
5eb6b277ba | |||
2684b0c68e | |||
76c571b969 | |||
c08e2f0bf7 | |||
bceca86da6 | |||
8ab2044c30 | |||
7173d2ecfc | |||
cf120e2d86 | |||
e92d3901f7 | |||
b071c850af | |||
df7434dae5 | |||
6e5b032dbb | |||
67b05fee2e | |||
286a3649cf | |||
9eefd5b95d | |||
36e524abe3 | |||
c527391b10 | |||
9602a3ed6a | |||
33823b445c | |||
e55f74a00e | |||
8b83de6ca9 | |||
3bacc8ec53 | |||
6f78c13dcf | |||
824f272432 | |||
78b6a83285 | |||
620b2ae79e | |||
8d28bc4b6a | |||
dcde177fe3 | |||
4f89fc62ab | |||
c59fa578c7 | |||
6c0972b2d5 | |||
7ad8763b14 | |||
03936fc5c1 | |||
3789663db7 | |||
b2e4438811 | |||
6501c16fd7 | |||
943495117b | |||
30910034f0 | |||
596d3bc68a | |||
1e73302ba2 | |||
9ba7fabdea | |||
676c9ffcf3 | |||
5095fd206f | |||
bb5b7bed40 | |||
e5b3b6d75e | |||
61affafecd | |||
7525c88392 | |||
3e9c19ee11 | |||
a7bf9a6734 | |||
82d7b7ed6f | |||
7598eb6b56 | |||
7b3616c41f | |||
9737d4cf2a | |||
c815905b5a | |||
59028ccc3f | |||
372e8c66a8 | |||
f5ac4368d8 | |||
6d0bc26624 | |||
baafeadcf4 | |||
dbda6fee82 | |||
cad302730e | |||
da2f594a00 | |||
d5a065eaa8 | |||
b695242420 | |||
494dd0db32 | |||
8be4f45969 | |||
4e5e6e145e | |||
e67ff6a937 | |||
bdd66072d1 | |||
1966b33613 | |||
331bbd14e7 | |||
9efc5dbd61 | |||
e7cd7c8dc3 | |||
caa3cf538b | |||
b3ca7b8667 | |||
2d069896a5 | |||
cb514e7493 | |||
bc7d956899 | |||
227074fd4d | |||
a56cf43897 | |||
e501390d7b | |||
e0d7363eed | |||
69b428222a | |||
6df1abf570 | |||
d84003d62a | |||
a7878aaf04 | |||
23873f6bc6 | |||
8de33f1301 | |||
35825a6561 | |||
043d47e5e4 | |||
bd903b8447 | |||
4250c7e022 | |||
d66e486f16 | |||
21a7fd621d | |||
dae4a5fa74 | |||
d8d18c9333 | |||
041461a066 | |||
bff8d103ba | |||
6580aa73bf | |||
9a3cd1d7fc | |||
e64de87af7 | |||
7ea4fedcea | |||
1caa45118b | |||
6e43a70af5 | |||
559c8d0637 | |||
ef5c0d50f3 | |||
3f47db9c18 | |||
91db9c362e | |||
1d3438bb7d | |||
cc84d542c8 | |||
9e9113912b | |||
9f09c190bb | |||
2b6ccbc17f | |||
458d783211 | |||
5cf2197c06 | |||
940bbf47e4 | |||
714f11f117 | |||
ffce336801 | |||
50ba377380 | |||
304773f7a7 | |||
16566a5690 | |||
68415853b5 | |||
fb5a1b93fc | |||
828115a566 | |||
d79f0e1172 | |||
35d8453b48 | |||
36039266ee | |||
a65211be51 | |||
fcff06c83f | |||
ea6ee7e79c | |||
110159eea1 | |||
788dbe4eca | |||
f45d19a961 | |||
c5ee2260d1 | |||
242a146f61 | |||
8eb25c02aa | |||
94f9d1ee16 | |||
6cded300ae | |||
1bec19bdd7 | |||
2fba1a6cfe | |||
ce770a67b2 | |||
06eadb55ab | |||
58e219981f | |||
671bab012e | |||
1443758274 | |||
e013ae954f | |||
c28398257b | |||
4154c06825 | |||
8a1f043b39 | |||
2a1aea7c73 | |||
8d748a4bbf | |||
dc88424910 | |||
03b2e1be3e | |||
10390de63b | |||
0416aaf3fe | |||
ee67e46a9f | |||
eb37a0ad2f | |||
b9cb0495a9 | |||
ac5d0cf58f | |||
48375a5221 | |||
46e4816faf | |||
85b92af777 | |||
5136d90659 | |||
cb2c66e256 | |||
72ce47358e | |||
36d1a36a74 | |||
ae5d880406 | |||
bcd51c0725 | |||
5209a9bb89 | |||
712ba5124c | |||
16763202c1 | |||
9998de086f | |||
d4d3da60a9 | |||
9b2772c126 | |||
d736e9c874 | |||
257e79f8fc | |||
3bd7ba961e | |||
6be6d593a3 | |||
1829d9cf0a | |||
255d4a90a9 | |||
f7c1aae464 | |||
cdb012fe5a | |||
2bca40c527 | |||
1446ce94bf | |||
8c5e261a0d | |||
5f197be2ff | |||
6e5252b69e | |||
093eb05269 | |||
c1cb93baa9 | |||
c0b490df65 | |||
e27d4fd060 | |||
a404bc881e | |||
5ac3762dc5 | |||
4522668066 | |||
8b90360b45 | |||
f067695353 | |||
503de9ba89 | |||
cf945d4d34 | |||
7f0db5b47c | |||
e65990feff | |||
484f9b6b37 | |||
bc722b5583 | |||
6b4bed8ca9 | |||
7f47a10cbd | |||
9266c874c1 | |||
ac6e34fc65 | |||
6127bb5ea4 | |||
98f89302c4 | |||
76d81b5b49 | |||
17a1ae9d0e | |||
dcb569a7c8 | |||
5b0758638b | |||
f85ab2b300 | |||
3b7bebeb6f | |||
2fce82db10 | |||
73dcb78a65 | |||
a0e7b45d94 | |||
8b5abd1fd5 | |||
8a0431c578 | |||
942ecc89bd | |||
3036793814 | |||
f40cdcf472 | |||
686ae101ee | |||
4136420685 | |||
de45e9b8a9 | |||
47698418fc | |||
d1cd180534 | |||
a93984869c | |||
a0dea39670 | |||
35d75bae56 | |||
578664ad06 | |||
86d0d5c4ee | |||
7e0cc471c9 | |||
194a9eef64 | |||
18fddf2755 | |||
31517604c9 | |||
38c7e050ab | |||
7310d2b5fe | |||
d39c729a16 | |||
f11e7407d6 | |||
52c177479f | |||
0bb19c5ee5 | |||
4dbd5a58e3 | |||
df9f534d12 | |||
ef93c70665 | |||
47402055f9 | |||
0495f390ef | |||
d1c83159e5 | |||
5289c274f3 | |||
094d237814 | |||
e245f56a4f | |||
a85c94ea80 | |||
8850b770ee | |||
bdd1bdb080 | |||
7b82a7c1a7 | |||
cc2e26443d | |||
50733e223a | |||
6a5f5af233 | |||
e0f8113eac | |||
94d1b5acae | |||
2e9a855181 | |||
fd5252bb57 | |||
583d354fb5 | |||
d4ca1ddb20 | |||
ca22ff5d8e | |||
b6888a8185 | |||
f4a60a0323 | |||
f7b70984c1 | |||
74def820c6 | |||
6e6e1304bb | |||
2c21400aed | |||
aa7ea35b80 | |||
0514ab4d05 | |||
a9135696a5 | |||
38dd230887 | |||
eae3175976 | |||
79cf009049 | |||
73b9d058e5 | |||
baba8fa5d7 | |||
05508418a7 | |||
f69d6d49c7 | |||
eb5548333e | |||
fd11cae7be |
24
CHANGELOG
24
CHANGELOG
@@ -22,7 +22,9 @@ a C file without issues
|
||||
|
||||
### Local Pool
|
||||
|
||||
- Interface of LocalPools has changed. LocalPool is not a template anymore. Instead the size and bucket number of the pools per page and the number of pages are passed to the ctor instead of two ctor arguments and a template parameter
|
||||
- Interface of LocalPools has changed. LocalPool is not a template anymore. Instead the size and
|
||||
bucket number of the pools per page and the number of pages are passed to the ctor instead of
|
||||
two ctor arguments and a template parameter
|
||||
|
||||
### Parameter Service
|
||||
|
||||
@@ -40,7 +42,8 @@ important use-case)
|
||||
|
||||
### File System Interface
|
||||
|
||||
- A new interfaces specifies the functions for a software object which exposes the file system of a given hardware to use message based file handling (e.g. PUS commanding)
|
||||
- A new interfaces specifies the functions for a software object which exposes the file system of
|
||||
a given hardware to use message based file handling (e.g. PUS commanding)
|
||||
|
||||
### Internal Error Reporter
|
||||
|
||||
@@ -52,7 +55,8 @@ ID for now.
|
||||
### Device Handler Base
|
||||
|
||||
- There is an additional `PERFORM_OPERATION` step for the device handler base. It is important
|
||||
that DHB users adapt their polling sequence tables to perform this step. This steps allows for aclear distinction between operation and communication steps
|
||||
that DHB users adapt their polling sequence tables to perform this step. This steps allows for
|
||||
a clear distinction between operation and communication steps
|
||||
- setNormalDatapoolEntriesInvalid is not an abstract method and a default implementation was provided
|
||||
- getTransitionDelayMs is now an abstract method
|
||||
|
||||
@@ -69,7 +73,8 @@ now
|
||||
|
||||
### Commanding Service Base
|
||||
|
||||
- CSB uses the new fsfwconfig::FSFW_CSB_FIFO_DEPTH variable to determine the FIFO depth for each CSB instance. This variable has to be set in the FSFWConfig.h file
|
||||
- CSB uses the new fsfwconfig::FSFW_CSB_FIFO_DEPTH variable to determine the FIFO depth for each
|
||||
CSB instance. This variable has to be set in the FSFWConfig.h file
|
||||
|
||||
### Service Interface
|
||||
|
||||
@@ -81,4 +86,13 @@ now
|
||||
For the fsfw, this can be done by checking the processor define FSFW_CPP_OSTREAM_ENABLED from FSFWConfig.h.
|
||||
For mission code, developers need to replace sif:: calls by the printf counterparts, but only if the CPP stream are excluded.
|
||||
If this is not the case, everything should work as usual.
|
||||
-
|
||||
|
||||
### ActionHelper and ActionMessage
|
||||
|
||||
- ActionHelper finish function and ActionMessage::setCompletionReply now expects explicit
|
||||
information whether to report a success or failure message instead of deriving it implicitely
|
||||
from returnvalue
|
||||
|
||||
### PUS Parameter Service 20
|
||||
|
||||
Added PUS parameter service 20 (only custom subservices available).
|
||||
|
@@ -1,5 +1,13 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
option(FSFW_GENERATE_SECTIONS
|
||||
"Generate function and data sections. Required to remove unused code" ON
|
||||
)
|
||||
|
||||
if(FSFW_GENERATE_SECTIONS)
|
||||
option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON)
|
||||
endif()
|
||||
|
||||
option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
|
||||
# Options to exclude parts of the FSFW from compilation.
|
||||
option(FSFW_USE_RMAP "Compile with RMAP" ON)
|
||||
@@ -26,15 +34,22 @@ if(NOT OS_FSFW)
|
||||
|
||||
endif()
|
||||
|
||||
set(FSFW_OSAL_DEFINITION FSFW_HOST)
|
||||
|
||||
if(${OS_FSFW} STREQUAL host)
|
||||
set(OS_FSFW_NAME "Host")
|
||||
elseif(${OS_FSFW} STREQUAL linux)
|
||||
set(OS_FSFW_NAME "Linux")
|
||||
set(FSFW_OSAL_DEFINITION FSFW_LINUX)
|
||||
elseif(${OS_FSFW} STREQUAL freertos)
|
||||
set(OS_FSFW_NAME "FreeRTOS")
|
||||
target_link_libraries(${LIB_FSFW_NAME} ${LIB_OS_NAME})
|
||||
set(FSFW_OSAL_DEFINITION FSFW_FREERTOS)
|
||||
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
|
||||
${LIB_OS_NAME}
|
||||
)
|
||||
elseif(${OS_FSFW} STREQUAL rtems)
|
||||
set(OS_FSFW_NAME "RTEMS")
|
||||
set(FSFW_OSAL_DEFINITION FSFW_RTEMS)
|
||||
else()
|
||||
message(WARNING
|
||||
"Invalid operating system for FSFW specified! Setting to host.."
|
||||
@@ -43,10 +58,16 @@ else()
|
||||
set(OS_FSFW "host")
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${LIB_FSFW_NAME} PRIVATE
|
||||
${FSFW_OSAL_DEFINITION}
|
||||
)
|
||||
|
||||
target_compile_definitions(${LIB_FSFW_NAME} INTERFACE
|
||||
${FSFW_OSAL_DEFINITION}
|
||||
)
|
||||
|
||||
message(STATUS "Compiling FSFW for the ${OS_FSFW_NAME} operating system.")
|
||||
|
||||
|
||||
|
||||
add_subdirectory(action)
|
||||
add_subdirectory(container)
|
||||
add_subdirectory(controller)
|
||||
@@ -90,6 +111,7 @@ add_subdirectory(timemanager)
|
||||
add_subdirectory(tmstorage)
|
||||
add_subdirectory(tmtcpacket)
|
||||
add_subdirectory(tmtcservices)
|
||||
add_subdirectory(unittest)
|
||||
|
||||
# The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it.
|
||||
# If this is not given, we include the default configuration and emit a warning.
|
||||
@@ -109,16 +131,44 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATH})
|
||||
if(IS_ABSOLUTE ${INCLUDE_PATH})
|
||||
set(CURR_ABS_INC_PATH "${FREERTOS_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_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH})
|
||||
endforeach()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
if(NOT DEFINED FSFW_WARNING_FLAGS)
|
||||
set(FSFW_WARNING_FLAGS
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wshadow=local
|
||||
-Wimplicit-fallthrough=1
|
||||
-Wno-unused-parameter
|
||||
-Wno-psabi
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FSFW_GENERATE_SECTIONS)
|
||||
target_compile_options(${LIB_FSFW_NAME} PRIVATE
|
||||
"-ffunction-sections"
|
||||
"-fdata-sections"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FSFW_REMOVE_UNUSED_CODE)
|
||||
target_link_options(${LIB_FSFW_NAME} PRIVATE
|
||||
"Wl,--gc-sections"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FSFW_WARNING_SHADOW_LOCAL_GCC)
|
||||
list(APPEND WARNING_FLAGS "-Wshadow=local")
|
||||
@@ -134,6 +184,7 @@ endif()
|
||||
target_include_directories(${LIB_FSFW_NAME} INTERFACE
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${FSFW_CONFIG_PATH_ABSOLUTE}
|
||||
${FSFW_ADD_INC_PATHS_ABS}
|
||||
)
|
||||
|
||||
# Includes path required to compile FSFW itself as well
|
||||
@@ -142,9 +193,14 @@ target_include_directories(${LIB_FSFW_NAME} INTERFACE
|
||||
target_include_directories(${LIB_FSFW_NAME} PRIVATE
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${FSFW_CONFIG_PATH_ABSOLUTE}
|
||||
${FSFW_ADD_INC_PATHS_ABS}
|
||||
)
|
||||
|
||||
target_compile_options(${LIB_FSFW_NAME} PRIVATE
|
||||
${FSFW_WARNING_FLAGS}
|
||||
${COMPILER_FLAGS}
|
||||
)
|
||||
|
||||
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
|
||||
${FSFW_ADDITIONAL_LINK_LIBS}
|
||||
)
|
@@ -3,9 +3,9 @@
|
||||
|
||||
const char* const FSFW_VERSION_NAME = "ASTP";
|
||||
|
||||
#define FSFW_VERSION 0
|
||||
#define FSFW_VERSION 1
|
||||
#define FSFW_SUBVERSION 0
|
||||
#define FSFW_REVISION 1
|
||||
#define FSFW_REVISION 0
|
||||
|
||||
|
||||
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
|
||||
ActionHelper::ActionHelper(HasActionsIF* setOwner,
|
||||
MessageQueueIF* useThisQueue) :
|
||||
@@ -42,10 +43,10 @@ void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo,
|
||||
queueToUse->sendMessage(reportTo, &reply);
|
||||
}
|
||||
|
||||
void ActionHelper::finish(MessageQueueId_t reportTo, ActionId_t commandId,
|
||||
void ActionHelper::finish(bool success, MessageQueueId_t reportTo, ActionId_t commandId,
|
||||
ReturnValue_t result) {
|
||||
CommandMessage reply;
|
||||
ActionMessage::setCompletionReply(&reply, commandId, result);
|
||||
ActionMessage::setCompletionReply(&reply, commandId, success, result);
|
||||
queueToUse->sendMessage(reportTo, &reply);
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy,
|
||||
ipcStore->deleteData(dataAddress);
|
||||
if(result == HasActionsIF::EXECUTION_FINISHED) {
|
||||
CommandMessage reply;
|
||||
ActionMessage::setCompletionReply(&reply, actionId, result);
|
||||
ActionMessage::setCompletionReply(&reply, actionId, true, result);
|
||||
queueToUse->sendMessage(commandedBy, &reply);
|
||||
}
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@@ -86,13 +87,20 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
|
||||
uint8_t *dataPtr;
|
||||
size_t maxSize = data->getSerializedSize();
|
||||
if (maxSize == 0) {
|
||||
//No error, there's simply nothing to report.
|
||||
/* No error, there's simply nothing to report. */
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize,
|
||||
&dataPtr);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ActionHelper::reportData: Getting free element from IPC store failed!" <<
|
||||
std::endl;
|
||||
#else
|
||||
sif::printWarning("ActionHelper::reportData: Getting free element from IPC "
|
||||
"store failed!\n");
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
result = data->serialize(&dataPtr, &size, maxSize,
|
||||
@@ -101,14 +109,13 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
|
||||
ipcStore->deleteData(storeAddress);
|
||||
return result;
|
||||
}
|
||||
// We don't need to report the objectId, as we receive REQUESTED data
|
||||
// before the completion success message.
|
||||
// True aperiodic replies need to be reported with
|
||||
// another dedicated message.
|
||||
|
||||
/* We don't need to report the objectId, as we receive REQUESTED data before the completion
|
||||
success message. True aperiodic replies need to be reported with another dedicated message. */
|
||||
ActionMessage::setDataReply(&reply, replyId, storeAddress);
|
||||
|
||||
// If the sender needs to be hidden, for example to handle packet
|
||||
// as unrequested reply, this will be done here.
|
||||
/* If the sender needs to be hidden, for example to handle packet
|
||||
as unrequested reply, this will be done here. */
|
||||
if (hideSender) {
|
||||
result = MessageQueueSenderIF::sendMessage(reportTo, &reply);
|
||||
}
|
||||
@@ -132,22 +139,20 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
|
||||
store_address_t storeAddress;
|
||||
ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ActionHelper::reportData: Adding data to IPC store failed!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("ActionHelper::reportData: Adding data to IPC store failed!\n");
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
ipcStore->deleteData(storeAddress);
|
||||
return result;
|
||||
}
|
||||
|
||||
// We don't need to report the objectId, as we receive REQUESTED data
|
||||
// before the completion success message.
|
||||
// True aperiodic replies need to be reported with
|
||||
// another dedicated message.
|
||||
/* We don't need to report the objectId, as we receive REQUESTED data before the completion
|
||||
success message. True aperiodic replies need to be reported with another dedicated message. */
|
||||
ActionMessage::setDataReply(&reply, replyId, storeAddress);
|
||||
|
||||
// If the sender needs to be hidden, for example to handle packet
|
||||
// as unrequested reply, this will be done here.
|
||||
/* If the sender needs to be hidden, for example to handle packet
|
||||
as unrequested reply, this will be done here. */
|
||||
if (hideSender) {
|
||||
result = MessageQueueSenderIF::sendMessage(reportTo, &reply);
|
||||
}
|
||||
|
@@ -62,12 +62,12 @@ public:
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
/**
|
||||
* Function to be called by the owner to send a action completion message
|
||||
*
|
||||
* @param success Specify whether action was completed successfully or not.
|
||||
* @param reportTo MessageQueueId_t to report the action completion message to
|
||||
* @param commandId ID of the executed command
|
||||
* @param result Result of the execution
|
||||
*/
|
||||
void finish(MessageQueueId_t reportTo, ActionId_t commandId,
|
||||
void finish(bool success, MessageQueueId_t reportTo, ActionId_t commandId,
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
/**
|
||||
* Function to be called by the owner if an action does report data.
|
||||
@@ -99,9 +99,10 @@ public:
|
||||
*/
|
||||
void setQueueToUse(MessageQueueIF *queue);
|
||||
protected:
|
||||
//!< Increase of value of this per step
|
||||
//! Increase of value of this per step
|
||||
static const uint8_t STEP_OFFSET = 1;
|
||||
HasActionsIF* owner;//!< Pointer to the owner
|
||||
//! Pointer to the owner
|
||||
HasActionsIF* owner;
|
||||
//! Queue to be used as response sender, has to be set in ctor or with
|
||||
//! setQueueToUse
|
||||
MessageQueueIF* queueToUse;
|
||||
|
@@ -54,10 +54,11 @@ void ActionMessage::setDataReply(CommandMessage* message, ActionId_t actionId,
|
||||
}
|
||||
|
||||
void ActionMessage::setCompletionReply(CommandMessage* message,
|
||||
ActionId_t fid, ReturnValue_t result) {
|
||||
if (result == HasReturnvaluesIF::RETURN_OK or result == HasActionsIF::EXECUTION_FINISHED) {
|
||||
ActionId_t fid, bool success, ReturnValue_t result) {
|
||||
if (success) {
|
||||
message->setCommand(COMPLETION_SUCCESS);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
message->setCommand(COMPLETION_FAILED);
|
||||
}
|
||||
message->setParameter(fid);
|
||||
|
@@ -24,11 +24,14 @@ public:
|
||||
static const Command_t DATA_REPLY = MAKE_COMMAND_ID(4);
|
||||
static const Command_t COMPLETION_SUCCESS = MAKE_COMMAND_ID(5);
|
||||
static const Command_t COMPLETION_FAILED = MAKE_COMMAND_ID(6);
|
||||
|
||||
virtual ~ActionMessage();
|
||||
static void setCommand(CommandMessage* message, ActionId_t fid,
|
||||
store_address_t parameters);
|
||||
|
||||
static ActionId_t getActionId(const CommandMessage* message );
|
||||
static store_address_t getStoreId(const CommandMessage* message);
|
||||
|
||||
static void setStepReply(CommandMessage* message, ActionId_t fid,
|
||||
uint8_t step, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
static uint8_t getStep(const CommandMessage* message );
|
||||
@@ -36,7 +39,8 @@ public:
|
||||
static void setDataReply(CommandMessage* message, ActionId_t actionId,
|
||||
store_address_t data);
|
||||
static void setCompletionReply(CommandMessage* message, ActionId_t fid,
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
bool success, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
|
||||
static void clear(CommandMessage* message);
|
||||
};
|
||||
|
||||
|
@@ -63,7 +63,7 @@ void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy,
|
||||
break;
|
||||
case HasActionsIF::EXECUTION_FINISHED:
|
||||
ActionMessage::setCompletionReply(&reply, actionId,
|
||||
HasReturnvaluesIF::RETURN_OK);
|
||||
true, HasReturnvaluesIF::RETURN_OK);
|
||||
queueToUse->sendMessage(commandedBy, &reply);
|
||||
break;
|
||||
default:
|
||||
|
@@ -8,7 +8,9 @@
|
||||
*/
|
||||
template<typename T, size_t MAX_SIZE, typename count_t = uint8_t>
|
||||
class FixedArrayList: public ArrayList<T, count_t> {
|
||||
static_assert(MAX_SIZE <= (pow(2,sizeof(count_t)*8)-1), "count_t is not large enough to hold MAX_SIZE");
|
||||
#if !defined(_MSC_VER)
|
||||
static_assert(MAX_SIZE <= (std::pow(2,sizeof(count_t)*8)-1), "count_t is not large enough to hold MAX_SIZE");
|
||||
#endif
|
||||
private:
|
||||
T data[MAX_SIZE];
|
||||
public:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "SharedRingBuffer.h"
|
||||
#include "../ipc/MutexFactory.h"
|
||||
#include "../ipc/MutexHelper.h"
|
||||
#include "../ipc/MutexGuard.h"
|
||||
|
||||
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes):
|
||||
@@ -17,6 +17,9 @@ SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer,
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
SharedRingBuffer::~SharedRingBuffer() {
|
||||
MutexFactory::instance()->deleteMutex(mutex);
|
||||
}
|
||||
|
||||
void SharedRingBuffer::setToUseReceiveSizeFIFO(size_t fifoDepth) {
|
||||
this->fifoDepth = fifoDepth;
|
||||
|
@@ -26,6 +26,18 @@ public:
|
||||
*/
|
||||
SharedRingBuffer(object_id_t objectId, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes);
|
||||
/**
|
||||
* This constructor takes an external buffer with the specified size.
|
||||
* @param buffer
|
||||
* @param size
|
||||
* @param overwriteOld
|
||||
* If the ring buffer is overflowing at a write operartion, the oldest data
|
||||
* will be overwritten.
|
||||
*/
|
||||
SharedRingBuffer(object_id_t objectId, uint8_t* buffer, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes);
|
||||
|
||||
virtual~ SharedRingBuffer();
|
||||
|
||||
/**
|
||||
* @brief This function can be used to add an optional FIFO to the class
|
||||
@@ -37,16 +49,7 @@ public:
|
||||
*/
|
||||
void setToUseReceiveSizeFIFO(size_t fifoDepth);
|
||||
|
||||
/**
|
||||
* This constructor takes an external buffer with the specified size.
|
||||
* @param buffer
|
||||
* @param size
|
||||
* @param overwriteOld
|
||||
* If the ring buffer is overflowing at a write operartion, the oldest data
|
||||
* will be overwritten.
|
||||
*/
|
||||
SharedRingBuffer(object_id_t objectId, uint8_t* buffer, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes);
|
||||
|
||||
|
||||
/**
|
||||
* Unless a read-only constant value is read, all operations on the
|
||||
@@ -66,7 +69,7 @@ public:
|
||||
|
||||
/**
|
||||
* The mutex handle can be accessed directly, for example to perform
|
||||
* the lock with the #MutexHelper for a RAII compliant lock operation.
|
||||
* the lock with the #MutexGuard for a RAII compliant lock operation.
|
||||
* @return
|
||||
*/
|
||||
MutexIF* getMutexHandle() const;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
target_sources(${LIB_FSFW_NAME}
|
||||
PRIVATE
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
ControllerBase.cpp
|
||||
ExtendedControllerBase.cpp
|
||||
)
|
@@ -8,17 +8,12 @@ ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId,
|
||||
actionHelper(this, commandQueue) {
|
||||
}
|
||||
|
||||
ReturnValue_t ExtendedControllerBase::executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t *data, size_t size) {
|
||||
// needs to be overriden and implemented by child class.
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
ExtendedControllerBase::~ExtendedControllerBase() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
ReturnValue_t ExtendedControllerBase::initializeLocalDataPool(
|
||||
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
|
||||
// needs to be overriden and implemented by child class.
|
||||
ReturnValue_t ExtendedControllerBase::executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t *data, size_t size) {
|
||||
/* Needs to be overriden and implemented by child class. */
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@@ -93,8 +88,10 @@ ReturnValue_t ExtendedControllerBase::initializeAfterTaskCreation() {
|
||||
|
||||
ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) {
|
||||
handleQueue();
|
||||
poolManager.performHkOperation();
|
||||
performControlOperation();
|
||||
/* We do this after performing control operation because variables will be set changed
|
||||
in this function. */
|
||||
poolManager.performHkOperation();
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
@@ -102,14 +99,6 @@ MessageQueueId_t ExtendedControllerBase::getCommandQueue() const {
|
||||
return commandQueue->getId();
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ExtendedControllerBase::getDataSetHandle: No child "
|
||||
<< " implementation provided, returning nullptr!" << std::endl;
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LocalDataPoolManager* ExtendedControllerBase::getHkManagerHandle() {
|
||||
return &poolManager;
|
||||
}
|
||||
|
@@ -22,13 +22,14 @@ class ExtendedControllerBase: public ControllerBase,
|
||||
public:
|
||||
ExtendedControllerBase(object_id_t objectId, object_id_t parentId,
|
||||
size_t commandQueueDepth = 3);
|
||||
virtual ~ExtendedControllerBase();
|
||||
|
||||
/** SystemObjectIF overrides */
|
||||
/* SystemObjectIF overrides */
|
||||
virtual ReturnValue_t initialize() override;
|
||||
|
||||
virtual MessageQueueId_t getCommandQueue() const override;
|
||||
|
||||
/** ExecutableObjectIF overrides */
|
||||
/* ExecutableObjectIF overrides */
|
||||
virtual ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
virtual ReturnValue_t initializeAfterTaskCreation() override;
|
||||
|
||||
@@ -49,22 +50,22 @@ protected:
|
||||
*/
|
||||
virtual void performControlOperation() = 0;
|
||||
|
||||
/** Handle the four messages mentioned above */
|
||||
/* Handle the four messages mentioned above */
|
||||
void handleQueue() override;
|
||||
|
||||
/** HasActionsIF overrides */
|
||||
/* HasActionsIF overrides */
|
||||
virtual ReturnValue_t executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t* data,
|
||||
size_t size) override;
|
||||
|
||||
/** HasLocalDatapoolIF overrides */
|
||||
/* HasLocalDatapoolIF overrides */
|
||||
virtual LocalDataPoolManager* getHkManagerHandle() override;
|
||||
virtual object_id_t getObjectId() const override;
|
||||
virtual ReturnValue_t initializeLocalDataPool(
|
||||
localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
virtual uint32_t getPeriodicOperationFrequency() const override;
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
|
||||
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override = 0;
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -18,15 +18,13 @@ class PoolVariableIF;
|
||||
class DataSetIF {
|
||||
public:
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::DATA_SET_CLASS;
|
||||
static constexpr ReturnValue_t INVALID_PARAMETER_DEFINITION =
|
||||
MAKE_RETURN_CODE( 0x01 );
|
||||
static constexpr ReturnValue_t SET_WAS_ALREADY_READ = MAKE_RETURN_CODE( 0x02 );
|
||||
static constexpr ReturnValue_t COMMITING_WITHOUT_READING =
|
||||
MAKE_RETURN_CODE(0x03);
|
||||
static constexpr ReturnValue_t INVALID_PARAMETER_DEFINITION = MAKE_RETURN_CODE(1);
|
||||
static constexpr ReturnValue_t SET_WAS_ALREADY_READ = MAKE_RETURN_CODE(2);
|
||||
static constexpr ReturnValue_t COMMITING_WITHOUT_READING = MAKE_RETURN_CODE(3);
|
||||
|
||||
static constexpr ReturnValue_t DATA_SET_UNINITIALISED = MAKE_RETURN_CODE( 0x04 );
|
||||
static constexpr ReturnValue_t DATA_SET_FULL = MAKE_RETURN_CODE( 0x05 );
|
||||
static constexpr ReturnValue_t POOL_VAR_NULL = MAKE_RETURN_CODE( 0x06 );
|
||||
static constexpr ReturnValue_t DATA_SET_UNINITIALISED = MAKE_RETURN_CODE(4);
|
||||
static constexpr ReturnValue_t DATA_SET_FULL = MAKE_RETURN_CODE(5);
|
||||
static constexpr ReturnValue_t POOL_VAR_NULL = MAKE_RETURN_CODE(6);
|
||||
|
||||
/**
|
||||
* @brief This is an empty virtual destructor,
|
||||
|
@@ -7,7 +7,7 @@ HkSwitchHelper::HkSwitchHelper(EventReportingProxyIF* eventProxy) :
|
||||
}
|
||||
|
||||
HkSwitchHelper::~HkSwitchHelper() {
|
||||
// TODO Auto-generated destructor stub
|
||||
QueueFactory::instance()->deleteMessageQueue(actionQueue);
|
||||
}
|
||||
|
||||
ReturnValue_t HkSwitchHelper::initialize() {
|
||||
|
@@ -1,35 +1,44 @@
|
||||
#include "PoolDataSetBase.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "ReadCommitIFAttorney.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxFillCount):
|
||||
registeredVariables(registeredVariablesArray),
|
||||
maxFillCount(maxFillCount) {
|
||||
}
|
||||
maxFillCount(maxFillCount) {}
|
||||
|
||||
PoolDataSetBase::~PoolDataSetBase() {}
|
||||
|
||||
|
||||
ReturnValue_t PoolDataSetBase::registerVariable(
|
||||
PoolVariableIF *variable) {
|
||||
ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF *variable) {
|
||||
if(registeredVariables == nullptr) {
|
||||
/* Underlying container invalid */
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (state != States::STATE_SET_UNINITIALISED) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "DataSet::registerVariable: "
|
||||
"Call made in wrong position." << std::endl;
|
||||
sif::error << "DataSet::registerVariable: Call made in wrong position." << std::endl;
|
||||
#else
|
||||
sif::printError("DataSet::registerVariable: Call made in wrong position.");
|
||||
#endif
|
||||
return DataSetIF::DATA_SET_UNINITIALISED;
|
||||
}
|
||||
if (variable == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "DataSet::registerVariable: "
|
||||
"Pool variable is nullptr." << std::endl;
|
||||
sif::error << "DataSet::registerVariable: Pool variable is nullptr." << std::endl;
|
||||
#else
|
||||
sif::printError("DataSet::registerVariable: Pool variable is nullptr.\n");
|
||||
#endif
|
||||
return DataSetIF::POOL_VAR_NULL;
|
||||
}
|
||||
if (fillCount >= maxFillCount) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "DataSet::registerVariable: "
|
||||
"DataSet is full." << std::endl;
|
||||
sif::error << "DataSet::registerVariable: DataSet is full." << std::endl;
|
||||
#else
|
||||
sif::printError("DataSet::registerVariable: DataSet is full.\n");
|
||||
#endif
|
||||
return DataSetIF::DATA_SET_FULL;
|
||||
}
|
||||
@@ -55,10 +64,12 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType,
|
||||
}
|
||||
else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "DataSet::read(): "
|
||||
"Call made in wrong position. Don't forget to commit"
|
||||
" member datasets!" << std::endl;
|
||||
#endif
|
||||
sif::warning << "PoolDataSetBase::read: Call made in wrong position. Don't forget to "
|
||||
"commit member datasets!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("PoolDataSetBase::read: Call made in wrong position. Don't forget to "
|
||||
"commit member datasets!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
result = SET_WAS_ALREADY_READ;
|
||||
}
|
||||
|
||||
@@ -75,24 +86,21 @@ uint16_t PoolDataSetBase::getFillCount() const {
|
||||
ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
if(registeredVariables[count] == nullptr) {
|
||||
// configuration error.
|
||||
/* Configuration error. */
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
// These checks are often performed by the respective
|
||||
// variable implementation too, but I guess a double check does not hurt.
|
||||
if (registeredVariables[count]->getReadWriteMode() !=
|
||||
PoolVariableIF::VAR_WRITE and
|
||||
registeredVariables[count]->getDataPoolId()
|
||||
!= PoolVariableIF::NO_PARAMETER)
|
||||
{
|
||||
/* These checks are often performed by the respective variable implementation too, but I guess
|
||||
a double check does not hurt. */
|
||||
if (registeredVariables[count]->getReadWriteMode() != PoolVariableIF::VAR_WRITE and
|
||||
registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER) {
|
||||
if(protectEveryReadCommitCall) {
|
||||
result = registeredVariables[count]->read(
|
||||
timeoutTypeForSingleVars,
|
||||
result = registeredVariables[count]->read(timeoutTypeForSingleVars,
|
||||
mutexTimeoutForSingleVars);
|
||||
}
|
||||
else {
|
||||
result = registeredVariables[count]->readWithoutLock();
|
||||
/* The readWithoutLock function is protected, so we use the attorney here */
|
||||
result = ReadCommitIFAttorney::readWithoutLock(registeredVariables[count]);
|
||||
}
|
||||
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@@ -117,17 +125,15 @@ void PoolDataSetBase::handleAlreadyReadDatasetCommit(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) {
|
||||
lockDataPool(timeoutType, lockTimeout);
|
||||
for (uint16_t count = 0; count < fillCount; count++) {
|
||||
if (registeredVariables[count]->getReadWriteMode()
|
||||
!= PoolVariableIF::VAR_READ
|
||||
&& registeredVariables[count]->getDataPoolId()
|
||||
!= PoolVariableIF::NO_PARAMETER) {
|
||||
if ((registeredVariables[count]->getReadWriteMode() != PoolVariableIF::VAR_READ) and
|
||||
(registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER)) {
|
||||
if(protectEveryReadCommitCall) {
|
||||
registeredVariables[count]->commit(
|
||||
timeoutTypeForSingleVars,
|
||||
registeredVariables[count]->commit(timeoutTypeForSingleVars,
|
||||
mutexTimeoutForSingleVars);
|
||||
}
|
||||
else {
|
||||
registeredVariables[count]->commitWithoutLock();
|
||||
/* The commitWithoutLock function is protected, so we use the attorney here */
|
||||
ReadCommitIFAttorney::commitWithoutLock(registeredVariables[count]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,17 +146,15 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
lockDataPool(timeoutType, lockTimeout);
|
||||
for (uint16_t count = 0; count < fillCount; count++) {
|
||||
if (registeredVariables[count]->getReadWriteMode()
|
||||
== PoolVariableIF::VAR_WRITE
|
||||
&& registeredVariables[count]->getDataPoolId()
|
||||
!= PoolVariableIF::NO_PARAMETER) {
|
||||
if ((registeredVariables[count]->getReadWriteMode() == PoolVariableIF::VAR_WRITE) and
|
||||
(registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER)) {
|
||||
if(protectEveryReadCommitCall) {
|
||||
result = registeredVariables[count]->commit(
|
||||
timeoutTypeForSingleVars,
|
||||
result = registeredVariables[count]->commit(timeoutTypeForSingleVars,
|
||||
mutexTimeoutForSingleVars);
|
||||
}
|
||||
else {
|
||||
result = registeredVariables[count]->commitWithoutLock();
|
||||
/* The commitWithoutLock function is protected, so we use the attorney here */
|
||||
ReadCommitIFAttorney::commitWithoutLock(registeredVariables[count]);
|
||||
}
|
||||
|
||||
} else if (registeredVariables[count]->getDataPoolId()
|
||||
@@ -183,8 +187,7 @@ ReturnValue_t PoolDataSetBase::serialize(uint8_t** buffer, size_t* size,
|
||||
const size_t maxSize, SerializeIF::Endianness streamEndianness) const {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
for (uint16_t count = 0; count < fillCount; count++) {
|
||||
result = registeredVariables[count]->serialize(buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
result = registeredVariables[count]->serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
@@ -29,7 +29,8 @@
|
||||
* @author Bastian Baetz
|
||||
* @ingroup data_pool
|
||||
*/
|
||||
class PoolDataSetBase: public PoolDataSetIF,
|
||||
class PoolDataSetBase:
|
||||
public PoolDataSetIF,
|
||||
public SerializeIF,
|
||||
public HasReturnvaluesIF {
|
||||
public:
|
||||
@@ -39,8 +40,12 @@ public:
|
||||
* supply a pointer to this dataset to PoolVariable
|
||||
* initializations to register pool variables.
|
||||
*/
|
||||
PoolDataSetBase(PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxFillCount);
|
||||
PoolDataSetBase(PoolVariableIF** registeredVariablesArray, const size_t maxFillCount);
|
||||
|
||||
/* Forbidden for now */
|
||||
PoolDataSetBase(const PoolDataSetBase& otherSet) = delete;
|
||||
const PoolDataSetBase& operator=(const PoolDataSetBase& otherSet) = delete;
|
||||
|
||||
virtual~ PoolDataSetBase();
|
||||
|
||||
/**
|
||||
@@ -63,8 +68,7 @@ public:
|
||||
* - @c SET_WAS_ALREADY_READ if read() is called twice without calling
|
||||
* commit() in between
|
||||
*/
|
||||
virtual ReturnValue_t read(
|
||||
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
||||
virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
||||
uint32_t lockTimeout = 20) override;
|
||||
/**
|
||||
* @brief The commit call initializes writing back the registered variables.
|
||||
@@ -84,8 +88,7 @@ public:
|
||||
* - @c COMMITING_WITHOUT_READING if set was not read yet and
|
||||
* contains non write-only variables
|
||||
*/
|
||||
virtual ReturnValue_t commit(
|
||||
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
||||
virtual ReturnValue_t commit(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
||||
uint32_t lockTimeout = 20) override;
|
||||
|
||||
/**
|
||||
|
@@ -8,7 +8,9 @@
|
||||
* @brief Extendes the DataSetIF by adding abstract functions to lock
|
||||
* and unlock a data pool and read/commit semantics.
|
||||
*/
|
||||
class PoolDataSetIF: public DataSetIF, public ReadCommitIF {
|
||||
class PoolDataSetIF:
|
||||
virtual public DataSetIF,
|
||||
virtual public ReadCommitIF {
|
||||
public:
|
||||
virtual~ PoolDataSetIF() {};
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
template <typename T>
|
||||
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValue, bool setValid ):
|
||||
length(initValue.size()), valid(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());
|
||||
|
@@ -8,9 +8,9 @@
|
||||
/**
|
||||
* @brief Helper class to read data sets or pool variables
|
||||
*/
|
||||
class PoolReadHelper {
|
||||
class PoolReadGuard {
|
||||
public:
|
||||
PoolReadHelper(ReadCommitIF* readObject,
|
||||
PoolReadGuard(ReadCommitIF* readObject,
|
||||
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
||||
uint32_t mutexTimeout = 20):
|
||||
readObject(readObject), mutexTimeout(mutexTimeout) {
|
||||
@@ -32,8 +32,18 @@ public:
|
||||
return readResult;
|
||||
}
|
||||
|
||||
~PoolReadHelper() {
|
||||
if(readObject != nullptr) {
|
||||
/**
|
||||
* @brief Can be used to suppress commit on destruction.
|
||||
*/
|
||||
void setNoCommitMode(bool commit) {
|
||||
this->noCommit = commit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Default destructor which will take care of commiting changed values.
|
||||
*/
|
||||
~PoolReadGuard() {
|
||||
if(readObject != nullptr and not noCommit) {
|
||||
readObject->commit(timeoutType, mutexTimeout);
|
||||
}
|
||||
|
||||
@@ -42,6 +52,7 @@ public:
|
||||
private:
|
||||
ReadCommitIF* readObject = nullptr;
|
||||
ReturnValue_t readResult = HasReturnvaluesIF::RETURN_OK;
|
||||
bool noCommit = false;
|
||||
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
|
||||
uint32_t mutexTimeout = 20;
|
||||
};
|
@@ -1,9 +1,10 @@
|
||||
#ifndef FSFW_DATAPOOL_POOLVARIABLEIF_H_
|
||||
#define FSFW_DATAPOOL_POOLVARIABLEIF_H_
|
||||
|
||||
#include "ReadCommitIF.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
#include "ReadCommitIF.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief This interface is used to control data pool
|
||||
@@ -18,10 +19,10 @@
|
||||
* @author Bastian Baetz
|
||||
* @ingroup data_pool
|
||||
*/
|
||||
class PoolVariableIF : public SerializeIF,
|
||||
class PoolVariableIF :
|
||||
public SerializeIF,
|
||||
public ReadCommitIF {
|
||||
friend class PoolDataSetBase;
|
||||
friend class LocalPoolDataSetBase;
|
||||
|
||||
public:
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::POOL_VARIABLE_IF;
|
||||
static constexpr ReturnValue_t INVALID_READ_WRITE_MODE = MAKE_RETURN_CODE(0xA0);
|
||||
@@ -45,6 +46,8 @@ public:
|
||||
* read-write or read-only.
|
||||
*/
|
||||
virtual ReadWriteMode_t getReadWriteMode() const = 0;
|
||||
virtual void setReadWriteMode(ReadWriteMode_t newMode) = 0;
|
||||
|
||||
/**
|
||||
* @brief This operation shall return the data pool id of the variable.
|
||||
*/
|
||||
@@ -58,7 +61,6 @@ public:
|
||||
* @brief With this call, the valid information of the variable is set.
|
||||
*/
|
||||
virtual void setValid(bool validity) = 0;
|
||||
|
||||
};
|
||||
|
||||
using pool_rwm_t = PoolVariableIF::ReadWriteMode_t;
|
||||
|
@@ -9,6 +9,7 @@
|
||||
* semantics.
|
||||
*/
|
||||
class ReadCommitIF {
|
||||
friend class ReadCommitIFAttorney;
|
||||
public:
|
||||
virtual ~ReadCommitIF() {}
|
||||
virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType,
|
||||
@@ -18,9 +19,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
//! Optional and protected because this is interesting for classes grouping
|
||||
//! members with commit and read semantics where the lock is only necessary
|
||||
//! once.
|
||||
/* Optional and protected because this is interesting for classes grouping members with commit
|
||||
and read semantics where the lock is only necessary once. */
|
||||
virtual ReturnValue_t readWithoutLock() {
|
||||
return read(MutexIF::TimeoutType::WAITING, 20);
|
||||
}
|
||||
|
32
datapool/ReadCommitIFAttorney.h
Normal file
32
datapool/ReadCommitIFAttorney.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_
|
||||
#define FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_
|
||||
|
||||
#include <fsfw/datapool/ReadCommitIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
/**
|
||||
* @brief This class determines which members are allowed to access protected members
|
||||
* of the ReadCommitIF.
|
||||
*/
|
||||
class ReadCommitIFAttorney {
|
||||
private:
|
||||
static ReturnValue_t readWithoutLock(ReadCommitIF* readCommitIF) {
|
||||
if(readCommitIF == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return readCommitIF->readWithoutLock();
|
||||
}
|
||||
|
||||
static ReturnValue_t commitWithoutLock(ReadCommitIF* readCommitIF) {
|
||||
if(readCommitIF == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return readCommitIF->commitWithoutLock();
|
||||
}
|
||||
|
||||
friend class PoolDataSetBase;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_ */
|
@@ -1,13 +1,15 @@
|
||||
#ifndef FRAMEWORK_DATAPOOL_SHAREDDATASETIF_H_
|
||||
#define FRAMEWORK_DATAPOOL_SHAREDDATASETIF_H_
|
||||
|
||||
#include "PoolDataSetIF.h"
|
||||
|
||||
class SharedDataSetIF: public PoolDataSetIF {
|
||||
class SharedDataSetIF {
|
||||
public:
|
||||
virtual ~SharedDataSetIF() {};
|
||||
|
||||
private:
|
||||
virtual ReturnValue_t lockDataset(dur_millis_t mutexTimeout) = 0;
|
||||
virtual ReturnValue_t lockDataset(MutexIF::TimeoutType timeoutType,
|
||||
dur_millis_t mutexTimeout) = 0;
|
||||
virtual ReturnValue_t unlockDataset() = 0;
|
||||
};
|
||||
|
||||
|
@@ -18,7 +18,7 @@ public:
|
||||
* This function is protected because it should only be used by the
|
||||
* class imlementing the interface.
|
||||
*/
|
||||
virtual LocalDataPoolManager* getHkManagerHandle() = 0;
|
||||
virtual LocalDataPoolManager* getPoolManagerHandle() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
|
@@ -23,11 +23,21 @@ class LocalPoolObjectBase;
|
||||
* @details
|
||||
* Any class implementing this interface shall also have a LocalDataPoolManager member class which
|
||||
* contains the actual pool data structure and exposes the public interface for it.
|
||||
*
|
||||
* The local data pool can be accessed using helper classes by using the
|
||||
* LocalPoolVariable, LocalPoolVector or LocalDataSet classes. Every local pool variable can
|
||||
* be uniquely identified by a global pool ID (gp_id_t) and every dataset tied
|
||||
* to a pool manager can be uniqely identified by a global structure ID (sid_t).
|
||||
*
|
||||
* All software objects which want to use the local pool of another object shall also use this
|
||||
* interface, for example to get a handle to the subscription interface. The interface
|
||||
* can be retrieved using the object manager, provided the target object is a SystemObject.
|
||||
* For example, the following line of code can be used to retrieve the interface
|
||||
*
|
||||
* HasLocalDataPoolIF* poolIF = objectManager->get<HasLocalDataPoolIF>(objects::SOME_OBJECT);
|
||||
* if(poolIF != nullptr) {
|
||||
* doSomething()
|
||||
* }
|
||||
*/
|
||||
class HasLocalDataPoolIF {
|
||||
friend class HasLocalDpIFManagerAttorney;
|
||||
@@ -55,34 +65,45 @@ public:
|
||||
* usually be the period the pool owner performs its periodic operation.
|
||||
* @return
|
||||
*/
|
||||
virtual uint32_t getPeriodicOperationFrequency() const = 0;
|
||||
virtual dur_millis_t getPeriodicOperationFrequency() const = 0;
|
||||
|
||||
/**
|
||||
* @brief This function will be called by the manager if an update
|
||||
* notification is received.
|
||||
* @details HasLocalDataPoolIF
|
||||
* Can be overriden by the child class to handle changed datasets.
|
||||
* @param sid
|
||||
* @param sid SID of the updated set
|
||||
* @param storeId If a snapshot was requested, data will be located inside
|
||||
* the IPC store with this store ID.
|
||||
* @param clearMessage If this is set to true, the pool manager will take care of
|
||||
* clearing the store automatically
|
||||
*/
|
||||
virtual void handleChangedDataset(sid_t sid,
|
||||
store_address_t storeId = storeId::INVALID_STORE_ADDRESS) {
|
||||
return;
|
||||
store_address_t storeId = storeId::INVALID_STORE_ADDRESS,
|
||||
bool* clearMessage = nullptr) {
|
||||
if(clearMessage != nullptr) {
|
||||
*clearMessage = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function will be called by the manager if an update
|
||||
* notification is received.
|
||||
* @details
|
||||
* Can be overriden by the child class to handle changed pool IDs.
|
||||
* @param sid
|
||||
* Can be overriden by the child class to handle changed pool variables.
|
||||
* @param gpid GPID of the updated variable.
|
||||
* @param storeId If a snapshot was requested, data will be located inside
|
||||
* the IPC store with this store ID.
|
||||
* @param clearMessage Relevant for snapshots. If the boolean this points to is set to true,
|
||||
* the pool manager will take care of clearing the store automatically
|
||||
* after the callback.
|
||||
*/
|
||||
virtual void handleChangedPoolVariable(lp_id_t poolId,
|
||||
store_address_t storeId = storeId::INVALID_STORE_ADDRESS) {
|
||||
return;
|
||||
virtual void handleChangedPoolVariable(gp_id_t gpid,
|
||||
store_address_t storeId = storeId::INVALID_STORE_ADDRESS,
|
||||
bool* clearMessage = nullptr) {
|
||||
if(clearMessage != nullptr) {
|
||||
*clearMessage = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,8 +173,8 @@ protected:
|
||||
*/
|
||||
virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden"
|
||||
<< ". Returning nullptr!" << std::endl;
|
||||
sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden. "
|
||||
"Returning nullptr!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("HasLocalDataPoolIF::getPoolObjectHandle: "
|
||||
"Not overriden. Returning nullptr!\n");
|
||||
|
@@ -5,12 +5,12 @@
|
||||
#include "internal/LocalPoolDataSetAttorney.h"
|
||||
#include "internal/HasLocalDpIFManagerAttorney.h"
|
||||
|
||||
#include "../housekeeping/HousekeepingPacketUpdate.h"
|
||||
#include "../housekeeping/HousekeepingSetPacket.h"
|
||||
#include "../housekeeping/HousekeepingSnapshot.h"
|
||||
#include "../housekeeping/AcceptsHkPacketsIF.h"
|
||||
#include "../timemanager/CCSDSTime.h"
|
||||
#include "../ipc/MutexFactory.h"
|
||||
#include "../ipc/MutexHelper.h"
|
||||
#include "../ipc/MutexGuard.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
|
||||
#include <array>
|
||||
@@ -38,19 +38,23 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQue
|
||||
hkQueue = queueToUse;
|
||||
}
|
||||
|
||||
LocalDataPoolManager::~LocalDataPoolManager() {}
|
||||
LocalDataPoolManager::~LocalDataPoolManager() {
|
||||
if(mutex != nullptr) {
|
||||
MutexFactory::instance()->deleteMutex(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
|
||||
if(queueToUse == nullptr) {
|
||||
// error, all destinations invalid
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR,
|
||||
"initialize", QUEUE_OR_DESTINATION_INVALID);
|
||||
/* Error, all destinations invalid */
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize",
|
||||
QUEUE_OR_DESTINATION_INVALID);
|
||||
}
|
||||
hkQueue = queueToUse;
|
||||
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if(ipcStore == nullptr) {
|
||||
// error, all destinations invalid
|
||||
/* Error, all destinations invalid */
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR,
|
||||
"initialize", HasReturnvaluesIF::RETURN_FAILED,
|
||||
"Could not set IPC store.");
|
||||
@@ -98,11 +102,11 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::performHkOperation() {
|
||||
ReturnValue_t status = HasReturnvaluesIF::RETURN_OK;
|
||||
for(auto& receiver: hkReceiversMap) {
|
||||
for(auto& receiver: hkReceivers) {
|
||||
switch(receiver.reportingType) {
|
||||
case(ReportingType::PERIODIC): {
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
// Periodic packets shall only be generated from datasets.
|
||||
/* Periodic packets shall only be generated from datasets */
|
||||
continue;
|
||||
}
|
||||
performPeriodicHkGeneration(receiver);
|
||||
@@ -132,13 +136,16 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() {
|
||||
ReturnValue_t LocalDataPoolManager::handleHkUpdate(HkReceiver& receiver,
|
||||
ReturnValue_t& status) {
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
// Update packets shall only be generated from datasets.
|
||||
/* Update packets shall only be generated from datasets. */
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
|
||||
receiver.dataId.sid);
|
||||
if(dataSet == nullptr) {
|
||||
return DATASET_NOT_FOUND;
|
||||
}
|
||||
if(dataSet->hasChanged()) {
|
||||
// prepare and send update notification
|
||||
/* Prepare and send update notification */
|
||||
ReturnValue_t result = generateHousekeepingPacket(
|
||||
receiver.dataId.sid, dataSet, true);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@@ -156,19 +163,17 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
LocalPoolObjectBase* poolObj = HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner,
|
||||
receiver.dataId.localPoolId);
|
||||
//LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(receiver.dataId.localPoolId);
|
||||
if(poolObj == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"handleNotificationUpdate", POOLOBJECT_NOT_FOUND);
|
||||
return POOLOBJECT_NOT_FOUND;
|
||||
}
|
||||
if(poolObj->hasChanged()) {
|
||||
// prepare and send update notification.
|
||||
/* Prepare and send update notification. */
|
||||
CommandMessage notification;
|
||||
HousekeepingMessage::setUpdateNotificationVariableCommand(¬ification,
|
||||
receiver.dataId.localPoolId);
|
||||
ReturnValue_t result = hkQueue->sendMessage(
|
||||
receiver.destinationQueue, ¬ification);
|
||||
gp_id_t(owner->getObjectId(), receiver.dataId.localPoolId));
|
||||
ReturnValue_t result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
@@ -185,10 +190,10 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive
|
||||
return DATASET_NOT_FOUND;
|
||||
}
|
||||
if(dataSet->hasChanged()) {
|
||||
// prepare and send update notification
|
||||
/* Prepare and send update notification */
|
||||
CommandMessage notification;
|
||||
HousekeepingMessage::setUpdateNotificationSetCommand(
|
||||
¬ification, receiver.dataId.sid);
|
||||
HousekeepingMessage::setUpdateNotificationSetCommand(¬ification,
|
||||
receiver.dataId.sid);
|
||||
ReturnValue_t result = hkQueue->sendMessage(
|
||||
receiver.destinationQueue, ¬ification);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@@ -198,8 +203,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive
|
||||
}
|
||||
}
|
||||
if(toReset != nullptr) {
|
||||
handleChangeResetLogic(receiver.dataType,
|
||||
receiver.dataId, toReset);
|
||||
handleChangeResetLogic(receiver.dataType, receiver.dataId, toReset);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
@@ -207,7 +211,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive
|
||||
ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
|
||||
HkReceiver& receiver, ReturnValue_t& status) {
|
||||
MarkChangedIF* toReset = nullptr;
|
||||
// check whether data has changed and send messages in case it has.
|
||||
/* Check whether data has changed and send messages in case it has */
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
LocalPoolObjectBase* poolObj = HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner,
|
||||
receiver.dataId.localPoolId);
|
||||
@@ -221,14 +225,14 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
// prepare and send update snapshot.
|
||||
/* Prepare and send update snapshot */
|
||||
timeval now;
|
||||
Clock::getClock_timeval(&now);
|
||||
CCSDSTime::CDS_short cds;
|
||||
CCSDSTime::convertToCcsds(&cds, &now);
|
||||
HousekeepingPacketUpdate updatePacket(reinterpret_cast<uint8_t*>(&cds),
|
||||
sizeof(cds), HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner,
|
||||
receiver.dataId.localPoolId));
|
||||
HousekeepingSnapshot updatePacket(reinterpret_cast<uint8_t*>(&cds), sizeof(cds),
|
||||
HasLocalDpIFManagerAttorney::getPoolObjectHandle(
|
||||
owner,receiver.dataId.localPoolId));
|
||||
|
||||
store_address_t storeId;
|
||||
ReturnValue_t result = addUpdateToStore(updatePacket, storeId);
|
||||
@@ -238,7 +242,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
|
||||
|
||||
CommandMessage notification;
|
||||
HousekeepingMessage::setUpdateSnapshotVariableCommand(¬ification,
|
||||
receiver.dataId.localPoolId, storeId);
|
||||
gp_id_t(owner->getObjectId(), receiver.dataId.localPoolId), storeId);
|
||||
result = hkQueue->sendMessage(receiver.destinationQueue,
|
||||
¬ification);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@@ -259,12 +263,12 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
// prepare and send update snapshot.
|
||||
/* Prepare and send update snapshot */
|
||||
timeval now;
|
||||
Clock::getClock_timeval(&now);
|
||||
CCSDSTime::CDS_short cds;
|
||||
CCSDSTime::convertToCcsds(&cds, &now);
|
||||
HousekeepingPacketUpdate updatePacket(reinterpret_cast<uint8_t*>(&cds),
|
||||
HousekeepingSnapshot updatePacket(reinterpret_cast<uint8_t*>(&cds),
|
||||
sizeof(cds), HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
|
||||
receiver.dataId.sid));
|
||||
|
||||
@@ -292,7 +296,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
|
||||
}
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::addUpdateToStore(
|
||||
HousekeepingPacketUpdate& updatePacket, store_address_t& storeId) {
|
||||
HousekeepingSnapshot& updatePacket, store_address_t& storeId) {
|
||||
size_t updatePacketSize = updatePacket.getSerializedSize();
|
||||
uint8_t *storePtr = nullptr;
|
||||
ReturnValue_t result = ipcStore->getFreeElement(&storeId,
|
||||
@@ -309,7 +313,7 @@ ReturnValue_t LocalDataPoolManager::addUpdateToStore(
|
||||
void LocalDataPoolManager::handleChangeResetLogic(
|
||||
DataType type, DataId dataId, MarkChangedIF* toReset) {
|
||||
if(hkUpdateResetList == nullptr) {
|
||||
// config error!
|
||||
/* Config error */
|
||||
return;
|
||||
}
|
||||
HkUpdateResetList& listRef = *hkUpdateResetList;
|
||||
@@ -326,16 +330,16 @@ void LocalDataPoolManager::handleChangeResetLogic(
|
||||
continue;
|
||||
}
|
||||
|
||||
// only one update recipient, we can reset changes status immediately.
|
||||
/* Only one update recipient, we can reset changes status immediately */
|
||||
if(changeInfo.updateCounter <= 1) {
|
||||
toReset->setChanged(false);
|
||||
}
|
||||
// All recipients have been notified, reset the changed flag.
|
||||
if(changeInfo.currentUpdateCounter <= 1) {
|
||||
/* All recipients have been notified, reset the changed flag */
|
||||
else if(changeInfo.currentUpdateCounter <= 1) {
|
||||
toReset->setChanged(false);
|
||||
changeInfo.currentUpdateCounter = 0;
|
||||
}
|
||||
// Not all recipiens have been notified yet, decrement.
|
||||
/* Not all recipiens have been notified yet, decrement */
|
||||
else {
|
||||
changeInfo.currentUpdateCounter--;
|
||||
}
|
||||
@@ -371,20 +375,19 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid,
|
||||
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
|
||||
|
||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
||||
if(dataSet != nullptr) {
|
||||
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enableReporting);
|
||||
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
|
||||
LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, collectionInterval,
|
||||
owner->getPeriodicOperationFrequency(), isDiagnostics);
|
||||
owner->getPeriodicOperationFrequency());
|
||||
}
|
||||
|
||||
hkReceiversMap.push_back(hkReceiver);
|
||||
hkReceivers.push_back(hkReceiver);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::subscribeForUpdatePackets(sid_t sid,
|
||||
ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid,
|
||||
bool isDiagnostics, bool reportingEnabled,
|
||||
object_id_t packetDestination) {
|
||||
AcceptsHkPacketsIF* hkReceiverObject =
|
||||
@@ -402,19 +405,18 @@ ReturnValue_t LocalDataPoolManager::subscribeForUpdatePackets(sid_t sid,
|
||||
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
|
||||
|
||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
||||
if(dataSet != nullptr) {
|
||||
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true);
|
||||
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
|
||||
}
|
||||
|
||||
hkReceiversMap.push_back(hkReceiver);
|
||||
hkReceivers.push_back(hkReceiver);
|
||||
|
||||
handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::subscribeForSetUpdateMessages(
|
||||
ReturnValue_t LocalDataPoolManager::subscribeForSetUpdateMessage(
|
||||
const uint32_t setId, object_id_t destinationObject,
|
||||
MessageQueueId_t targetQueueId, bool generateSnapshot) {
|
||||
struct HkReceiver hkReceiver;
|
||||
@@ -429,13 +431,13 @@ ReturnValue_t LocalDataPoolManager::subscribeForSetUpdateMessages(
|
||||
hkReceiver.reportingType = ReportingType::UPDATE_NOTIFICATION;
|
||||
}
|
||||
|
||||
hkReceiversMap.push_back(hkReceiver);
|
||||
hkReceivers.push_back(hkReceiver);
|
||||
|
||||
handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::subscribeForVariableUpdateMessages(
|
||||
ReturnValue_t LocalDataPoolManager::subscribeForVariableUpdateMessage(
|
||||
const lp_id_t localPoolId, object_id_t destinationObject,
|
||||
MessageQueueId_t targetQueueId, bool generateSnapshot) {
|
||||
struct HkReceiver hkReceiver;
|
||||
@@ -450,7 +452,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForVariableUpdateMessages(
|
||||
hkReceiver.reportingType = ReportingType::UPDATE_NOTIFICATION;
|
||||
}
|
||||
|
||||
hkReceiversMap.push_back(hkReceiver);
|
||||
hkReceivers.push_back(hkReceiver);
|
||||
|
||||
handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
@@ -520,11 +522,19 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
||||
}
|
||||
|
||||
case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): {
|
||||
return generateSetStructurePacket(sid, true);
|
||||
result = generateSetStructurePacket(sid, true);
|
||||
if(result == HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): {
|
||||
return generateSetStructurePacket(sid, false);
|
||||
result = generateSetStructurePacket(sid, false);
|
||||
if(result == HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(HousekeepingMessage::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL):
|
||||
case(HousekeepingMessage::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL): {
|
||||
@@ -544,41 +554,49 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
||||
case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT):
|
||||
case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): {
|
||||
LocalPoolDataSetBase* dataSet =HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
||||
if(command == HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT
|
||||
and LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
|
||||
return WRONG_HK_PACKET_TYPE;
|
||||
result = WRONG_HK_PACKET_TYPE;
|
||||
break;
|
||||
}
|
||||
else if(command == HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT
|
||||
and not LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
|
||||
return WRONG_HK_PACKET_TYPE;
|
||||
result = WRONG_HK_PACKET_TYPE;
|
||||
break;
|
||||
}
|
||||
return generateHousekeepingPacket(HousekeepingMessage::getSid(message),
|
||||
dataSet, true);
|
||||
}
|
||||
|
||||
// Notification handling.
|
||||
/* Notification handling */
|
||||
case(HousekeepingMessage::UPDATE_NOTIFICATION_SET): {
|
||||
owner->handleChangedDataset(sid);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE): {
|
||||
lp_id_t locPoolId = HousekeepingMessage::
|
||||
getUpdateNotificationVariableCommand(message);
|
||||
owner->handleChangedPoolVariable(locPoolId);
|
||||
gp_id_t globPoolId = HousekeepingMessage::getUpdateNotificationVariableCommand(message);
|
||||
owner->handleChangedPoolVariable(globPoolId);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case(HousekeepingMessage::UPDATE_SNAPSHOT_SET): {
|
||||
store_address_t storeId;
|
||||
HousekeepingMessage::getUpdateSnapshotSetCommand(message, &storeId);
|
||||
owner->handleChangedDataset(sid, storeId);
|
||||
bool clearMessage = true;
|
||||
owner->handleChangedDataset(sid, storeId, &clearMessage);
|
||||
if(clearMessage) {
|
||||
message->clear();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE): {
|
||||
store_address_t storeId;
|
||||
lp_id_t localPoolId = HousekeepingMessage::
|
||||
getUpdateSnapshotVariableCommand(message, &storeId);
|
||||
owner->handleChangedPoolVariable(localPoolId, storeId);
|
||||
gp_id_t globPoolId = HousekeepingMessage::getUpdateSnapshotVariableCommand(message,
|
||||
&storeId);
|
||||
bool clearMessage = true;
|
||||
owner->handleChangedPoolVariable(globPoolId, storeId, &clearMessage);
|
||||
if(clearMessage) {
|
||||
message->clear();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@@ -621,7 +639,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||
LocalPoolDataSetBase* dataSet, bool forDownlink,
|
||||
MessageQueueId_t destination) {
|
||||
if(dataSet == nullptr) {
|
||||
// Configuration error.
|
||||
/* Configuration error. */
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"generateHousekeepingPacket",
|
||||
DATASET_NOT_FOUND);
|
||||
@@ -637,7 +655,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||
return result;
|
||||
}
|
||||
|
||||
// and now we set a HK message and send it the HK packet destination.
|
||||
/* Now we set a HK message and send it the HK packet destination. */
|
||||
CommandMessage hkMessage;
|
||||
if(LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
|
||||
HousekeepingMessage::setHkDiagnosticsReply(&hkMessage, sid, storeId);
|
||||
@@ -647,7 +665,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||
}
|
||||
|
||||
if(hkQueue == nullptr) {
|
||||
// error, no queue available to send packet with.
|
||||
/* Error, no queue available to send packet with. */
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"generateHousekeepingPacket",
|
||||
QUEUE_OR_DESTINATION_INVALID);
|
||||
@@ -655,7 +673,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||
}
|
||||
if(destination == MessageQueueIF::NO_QUEUE) {
|
||||
if(hkDestinationId == MessageQueueIF::NO_QUEUE) {
|
||||
// error, all destinations invalid
|
||||
/* Error, all destinations invalid */
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"generateHousekeepingPacket",
|
||||
QUEUE_OR_DESTINATION_INVALID);
|
||||
@@ -693,7 +711,6 @@ void LocalDataPoolManager::setNonDiagnosticIntervalFactor(
|
||||
|
||||
void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
|
||||
sid_t sid = receiver.dataId.sid;
|
||||
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||
if(dataSet == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
@@ -710,24 +727,23 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
|
||||
LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
|
||||
|
||||
if(periodicHelper == nullptr) {
|
||||
// Configuration error.
|
||||
/* Configuration error */
|
||||
return;
|
||||
}
|
||||
|
||||
if(periodicHelper->checkOpNecessary()) {
|
||||
if(not periodicHelper->checkOpNecessary()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ReturnValue_t result = generateHousekeepingPacket(
|
||||
sid, dataSet, true);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
// configuration error
|
||||
/* Configuration error */
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalDataPoolManager::performHkOperation: "
|
||||
<< "HK generation failed." << std::endl;
|
||||
sif::warning << "LocalDataPoolManager::performHkOperation: HK generation failed." <<
|
||||
std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalDataPoolManager::performHkOperation: "
|
||||
"HK generation failed.\n");
|
||||
sif::printWarning("LocalDataPoolManager::performHkOperation: HK generation failed.\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -735,8 +751,13 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid,
|
||||
bool enable, bool isDiagnostics) {
|
||||
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||
if(dataSet == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "togglePeriodicGeneration",
|
||||
DATASET_NOT_FOUND);
|
||||
return DATASET_NOT_FOUND;
|
||||
}
|
||||
|
||||
if((LocalPoolDataSetAttorney::isDiagnostics(*dataSet) and not isDiagnostics) or
|
||||
(not LocalPoolDataSetAttorney::isDiagnostics(*dataSet) and isDiagnostics)) {
|
||||
return WRONG_HK_PACKET_TYPE;
|
||||
@@ -753,8 +774,13 @@ ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid,
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid,
|
||||
float newCollectionInterval, bool isDiagnostics) {
|
||||
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||
if(dataSet == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "changeCollectionInterval",
|
||||
DATASET_NOT_FOUND);
|
||||
return DATASET_NOT_FOUND;
|
||||
}
|
||||
|
||||
bool targetIsDiagnostics = LocalPoolDataSetAttorney::isDiagnostics(*dataSet);
|
||||
if((targetIsDiagnostics and not isDiagnostics) or
|
||||
(not targetIsDiagnostics and isDiagnostics)) {
|
||||
@@ -765,7 +791,7 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid,
|
||||
LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
|
||||
|
||||
if(periodicHelper == nullptr) {
|
||||
// config error
|
||||
/* Configuration error, set might not have a corresponding pool manager */
|
||||
return PERIODIC_HELPER_INVALID;
|
||||
}
|
||||
|
||||
@@ -775,13 +801,11 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid,
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
|
||||
bool isDiagnostics) {
|
||||
// Get and check dataset first.
|
||||
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
||||
/* Get and check dataset first. */
|
||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||
if(dataSet == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"performPeriodicHkGeneration",
|
||||
DATASET_NOT_FOUND);
|
||||
"performPeriodicHkGeneration", DATASET_NOT_FOUND);
|
||||
return DATASET_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -838,8 +862,12 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
|
||||
}
|
||||
|
||||
void LocalDataPoolManager::clearReceiversList() {
|
||||
// clear the vector completely and releases allocated memory.
|
||||
HkReceivers().swap(hkReceiversMap);
|
||||
/* Clear the vector completely and releases allocated memory. */
|
||||
HkReceivers().swap(hkReceivers);
|
||||
/* Also clear the reset helper if it exists */
|
||||
if(hkUpdateResetList != nullptr) {
|
||||
HkUpdateResetList().swap(*hkUpdateResetList);
|
||||
}
|
||||
}
|
||||
|
||||
MutexIF* LocalDataPoolManager::getLocalPoolMutex() {
|
||||
@@ -848,11 +876,11 @@ MutexIF* LocalDataPoolManager::getLocalPoolMutex() {
|
||||
|
||||
object_id_t LocalDataPoolManager::getCreatorObjectId() const {
|
||||
return owner->getObjectId();
|
||||
//return owner->getObjectId();
|
||||
}
|
||||
|
||||
void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType,
|
||||
const char* functionName, ReturnValue_t error, const char* errorPrint) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
if(errorPrint == nullptr) {
|
||||
if(error == DATASET_NOT_FOUND) {
|
||||
errorPrint = "Dataset not found";
|
||||
@@ -881,31 +909,34 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType,
|
||||
errorPrint = "Unknown error";
|
||||
}
|
||||
}
|
||||
object_id_t objectId = 0xffffffff;
|
||||
if(owner != nullptr) {
|
||||
objectId = owner->getObjectId();
|
||||
}
|
||||
|
||||
if(outputType == sif::OutputTypes::OUT_WARNING) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalDataPoolManager::" << functionName
|
||||
<< ": Object ID " << std::setw(8) << std::setfill('0')
|
||||
<< std::hex << owner->getObjectId() << " | " << errorPrint
|
||||
<< std::dec << std::setfill(' ') << std::endl;
|
||||
sif::warning << "LocalDataPoolManager::" << functionName << ": Object ID 0x" <<
|
||||
std::setw(8) << std::setfill('0') << std::hex << objectId << " | " << errorPrint <<
|
||||
std::dec << std::setfill(' ') << std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
|
||||
owner->getObjectId(), errorPrint);
|
||||
#endif
|
||||
functionName, objectId, errorPrint);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
}
|
||||
else if(outputType == sif::OutputTypes::OUT_ERROR) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalDataPoolManager::" << functionName
|
||||
<< ": Object ID " << std::setw(8) << std::setfill('0')
|
||||
<< std::hex << owner->getObjectId() << " | " << errorPrint
|
||||
<< std::dec << std::setfill(' ') << std::endl;
|
||||
sif::error << "LocalDataPoolManager::" << functionName << ": Object ID 0x" <<
|
||||
std::setw(8) << std::setfill('0') << std::hex << objectId << " | " << errorPrint <<
|
||||
std::dec << std::setfill(' ') << std::endl;
|
||||
#else
|
||||
sif::printError("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
|
||||
owner->getObjectId(), errorPrint);
|
||||
#endif
|
||||
functionName, objectId, errorPrint);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
}
|
||||
#endif /* #if FSFW_VERBOSE_LEVEL >= 1 */
|
||||
}
|
||||
|
||||
LocalDataPoolManager* LocalDataPoolManager::getHkManagerHandle() {
|
||||
LocalDataPoolManager* LocalDataPoolManager::getPoolManagerHandle() {
|
||||
return this;
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#include "../ipc/MutexIF.h"
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
#include "../ipc/MutexHelper.h"
|
||||
#include "../ipc/MutexGuard.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@@ -24,7 +24,7 @@ void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
class LocalPoolDataSetBase;
|
||||
class HousekeepingPacketUpdate;
|
||||
class HousekeepingSnapshot;
|
||||
class HasLocalDataPoolIF;
|
||||
class LocalDataPool;
|
||||
|
||||
@@ -52,7 +52,8 @@ class LocalDataPool;
|
||||
* Each pool entry has a valid state too.
|
||||
* @author R. Mueller
|
||||
*/
|
||||
class LocalDataPoolManager: public ProvidesDataPoolSubscriptionIF,
|
||||
class LocalDataPoolManager:
|
||||
public ProvidesDataPoolSubscriptionIF,
|
||||
public AccessPoolManagerIF {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
//! Some classes using the pool manager directly need to access class internals of the
|
||||
@@ -62,7 +63,6 @@ public:
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER;
|
||||
|
||||
static constexpr ReturnValue_t QUEUE_OR_DESTINATION_INVALID = MAKE_RETURN_CODE(0);
|
||||
|
||||
static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(1);
|
||||
static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(2);
|
||||
static constexpr ReturnValue_t PERIODIC_HELPER_INVALID = MAKE_RETURN_CODE(3);
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
* @param packetDestination
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t subscribeForUpdatePackets(sid_t sid, bool reportingEnabled,
|
||||
ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled,
|
||||
bool isDiagnostics,
|
||||
object_id_t packetDestination = defaultHkDestination) override;
|
||||
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
* Otherwise, only an notification message is sent.
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t subscribeForSetUpdateMessages(const uint32_t setId,
|
||||
ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId,
|
||||
object_id_t destinationObject,
|
||||
MessageQueueId_t targetQueueId,
|
||||
bool generateSnapshot) override;
|
||||
@@ -174,13 +174,11 @@ public:
|
||||
* Otherwise, only an notification message is sent.
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t subscribeForVariableUpdateMessages(const lp_id_t localPoolId,
|
||||
ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId,
|
||||
object_id_t destinationObject,
|
||||
MessageQueueId_t targetQueueId,
|
||||
bool generateSnapshot) override;
|
||||
|
||||
MutexIF* getLocalPoolMutex() override;
|
||||
|
||||
/**
|
||||
* Non-Diagnostics packets usually have a lower minimum sampling frequency
|
||||
* than diagnostic packets.
|
||||
@@ -243,12 +241,9 @@ public:
|
||||
UPDATE_SNAPSHOT,
|
||||
};
|
||||
|
||||
/**
|
||||
* Different data types are possible in the HK receiver map.
|
||||
* For example, updates can be requested for full datasets or
|
||||
* for single pool variables. Periodic reporting is only possible for
|
||||
* data sets.
|
||||
*/
|
||||
/** Different data types are possible in the HK receiver map. For example, updates can be
|
||||
requested for full datasets or for single pool variables. Periodic reporting is only possible
|
||||
for data sets. */
|
||||
enum class DataType: uint8_t {
|
||||
LOCAL_POOL_VARIABLE,
|
||||
DATA_SET
|
||||
@@ -267,11 +262,22 @@ public:
|
||||
|
||||
object_id_t getCreatorObjectId() const;
|
||||
|
||||
virtual LocalDataPoolManager* getHkManagerHandle() override;
|
||||
private:
|
||||
/**
|
||||
* Get the pointer to the mutex. Can be used to lock the data pool
|
||||
* externally. Use with care and don't forget to unlock locked mutexes!
|
||||
* For now, only friend classes can accss this function.
|
||||
* @return
|
||||
*/
|
||||
MutexIF* getMutexHandle();
|
||||
|
||||
virtual LocalDataPoolManager* getPoolManagerHandle() override;
|
||||
|
||||
protected:
|
||||
|
||||
/** Core data structure for the actual pool data */
|
||||
localpool::DataPool localPoolMap;
|
||||
//! Every housekeeping data manager has a mutex to protect access
|
||||
//! to it's data pool.
|
||||
/** Every housekeeping data manager has a mutex to protect access
|
||||
to it's data pool. */
|
||||
MutexIF* mutex = nullptr;
|
||||
|
||||
/** The class which actually owns the manager (and its datapool). */
|
||||
@@ -304,7 +310,7 @@ private:
|
||||
/** This vector will contain the list of HK receivers. */
|
||||
using HkReceivers = std::vector<struct HkReceiver>;
|
||||
|
||||
HkReceivers hkReceiversMap;
|
||||
HkReceivers hkReceivers;
|
||||
|
||||
struct HkUpdateResetHelper {
|
||||
DataType dataType = DataType::DATA_SET;
|
||||
@@ -314,7 +320,8 @@ private:
|
||||
};
|
||||
|
||||
using HkUpdateResetList = std::vector<struct HkUpdateResetHelper>;
|
||||
// Will only be created when needed.
|
||||
/** This list is used to manage creating multiple update packets and only resetting
|
||||
the update flag if all of them were created. Will only be created when needed. */
|
||||
HkUpdateResetList* hkUpdateResetList = nullptr;
|
||||
|
||||
/** This is the map holding the actual data. Should only be initialized
|
||||
@@ -333,28 +340,19 @@ private:
|
||||
|
||||
/** Global IPC store is used to store all packets. */
|
||||
StorageManagerIF* ipcStore = nullptr;
|
||||
/**
|
||||
* Get the pointer to the mutex. Can be used to lock the data pool
|
||||
* externally. Use with care and don't forget to unlock locked mutexes!
|
||||
* For now, only friend classes can accss this function.
|
||||
* @return
|
||||
*/
|
||||
MutexIF* getMutexHandle();
|
||||
|
||||
/**
|
||||
* Read a variable by supplying its local pool ID and assign the pool
|
||||
* entry to the supplied PoolEntry pointer. The type of the pool entry
|
||||
* is deduced automatically. This call is not thread-safe!
|
||||
* For now, only friend classes like LocalPoolVar may access this
|
||||
* function.
|
||||
* For now, only classes designated by the LocalDpManagerAttorney may use this function.
|
||||
* @tparam T Type of the pool entry
|
||||
* @param localPoolId Pool ID of the variable to read
|
||||
* @param poolVar [out] Corresponding pool entry will be assigned to the
|
||||
* supplied pointer.
|
||||
* @return
|
||||
*/
|
||||
template <class T> ReturnValue_t fetchPoolEntry(lp_id_t localPoolId,
|
||||
PoolEntry<T> **poolEntry);
|
||||
template <class T> ReturnValue_t fetchPoolEntry(lp_id_t localPoolId, PoolEntry<T> **poolEntry);
|
||||
|
||||
/**
|
||||
* This function is used to fill the local data pool map with pool
|
||||
@@ -364,15 +362,15 @@ private:
|
||||
*/
|
||||
ReturnValue_t initializeHousekeepingPoolEntriesOnce();
|
||||
|
||||
ReturnValue_t serializeHkPacketIntoStore(
|
||||
HousekeepingPacketDownlink& hkPacket,
|
||||
MutexIF* getLocalPoolMutex() override;
|
||||
|
||||
ReturnValue_t serializeHkPacketIntoStore(HousekeepingPacketDownlink& hkPacket,
|
||||
store_address_t& storeId, bool forDownlink, size_t* serializedSize);
|
||||
|
||||
void performPeriodicHkGeneration(HkReceiver& hkReceiver);
|
||||
ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable,
|
||||
ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable, bool isDiagnostics);
|
||||
ReturnValue_t changeCollectionInterval(sid_t sid, float newCollectionInterval,
|
||||
bool isDiagnostics);
|
||||
ReturnValue_t changeCollectionInterval(sid_t sid,
|
||||
float newCollectionInterval, bool isDiagnostics);
|
||||
ReturnValue_t generateSetStructurePacket(sid_t sid, bool isDiagnostics);
|
||||
|
||||
void handleHkUpdateResetListInsertion(DataType dataType, DataId dataId);
|
||||
@@ -380,35 +378,33 @@ private:
|
||||
DataId dataId, MarkChangedIF* toReset);
|
||||
void resetHkUpdateResetHelper();
|
||||
|
||||
ReturnValue_t handleHkUpdate(HkReceiver& hkReceiver,
|
||||
ReturnValue_t& status);
|
||||
ReturnValue_t handleNotificationUpdate(HkReceiver& hkReceiver,
|
||||
ReturnValue_t& status);
|
||||
ReturnValue_t handleNotificationSnapshot(HkReceiver& hkReceiver,
|
||||
ReturnValue_t& status);
|
||||
ReturnValue_t addUpdateToStore(HousekeepingPacketUpdate& updatePacket,
|
||||
store_address_t& storeId);
|
||||
ReturnValue_t handleHkUpdate(HkReceiver& hkReceiver, ReturnValue_t& status);
|
||||
ReturnValue_t handleNotificationUpdate(HkReceiver& hkReceiver, ReturnValue_t& status);
|
||||
ReturnValue_t handleNotificationSnapshot(HkReceiver& hkReceiver, ReturnValue_t& status);
|
||||
ReturnValue_t addUpdateToStore(HousekeepingSnapshot& updatePacket, store_address_t& storeId);
|
||||
|
||||
void printWarningOrError(sif::OutputTypes outputType,
|
||||
const char* functionName,
|
||||
void printWarningOrError(sif::OutputTypes outputType, const char* functionName,
|
||||
ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED,
|
||||
const char* errorPrint = nullptr);
|
||||
};
|
||||
|
||||
|
||||
template<class T> inline
|
||||
ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId,
|
||||
PoolEntry<T> **poolEntry) {
|
||||
ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, PoolEntry<T> **poolEntry) {
|
||||
if(poolEntry == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
auto poolIter = localPoolMap.find(localPoolId);
|
||||
if (poolIter == localPoolMap.end()) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR, "fetchPoolEntry",
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "fetchPoolEntry",
|
||||
localpool::POOL_ENTRY_NOT_FOUND);
|
||||
return localpool::POOL_ENTRY_NOT_FOUND;
|
||||
}
|
||||
|
||||
*poolEntry = dynamic_cast< PoolEntry<T>* >(poolIter->second);
|
||||
if(*poolEntry == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR, "fetchPoolEntry",
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "fetchPoolEntry",
|
||||
localpool::POOL_ENTRY_TYPE_CONFLICT);
|
||||
return localpool::POOL_ENTRY_TYPE_CONFLICT;
|
||||
}
|
||||
|
@@ -4,11 +4,26 @@
|
||||
#include "LocalPoolDataSetBase.h"
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* @brief This dataset type can be used to group related pool variables if the number of
|
||||
* variables should not be fixed.
|
||||
* @details
|
||||
* This will is the primary data structure to organize pool variables into
|
||||
* sets which can be accessed via the housekeeping service interface or
|
||||
* which can be sent to other software objects.
|
||||
*
|
||||
* It is recommended to read the documentation of the LocalPoolDataSetBase
|
||||
* class for more information on how this class works and how to use it.
|
||||
* @tparam capacity Capacity of the static dataset, which is usually known
|
||||
* beforehand.
|
||||
*/
|
||||
class LocalDataSet: public LocalPoolDataSetBase {
|
||||
public:
|
||||
LocalDataSet(HasLocalDataPoolIF* hkOwner, uint32_t setId,
|
||||
const size_t maxSize);
|
||||
|
||||
LocalDataSet(sid_t sid, const size_t maxSize);
|
||||
|
||||
virtual~ LocalDataSet();
|
||||
|
||||
//! Copying forbidden for now.
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "internal/HasLocalDpIFUserAttorney.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../globalfunctions/bitutility.h"
|
||||
#include "../datapoollocal/LocalDataPoolManager.h"
|
||||
#include "../housekeeping/PeriodicHousekeepingHelper.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
@@ -28,21 +29,20 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
||||
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
|
||||
if(accessor != nullptr) {
|
||||
poolManager = accessor->getHkManagerHandle();
|
||||
poolManager = accessor->getPoolManagerHandle();
|
||||
mutexIfSingleDataCreator = accessor->getLocalPoolMutex();
|
||||
}
|
||||
|
||||
this->sid.objectId = hkOwner->getObjectId();
|
||||
this->sid.ownerSetId = setId;
|
||||
|
||||
// Data creators get a periodic helper for periodic HK data generation.
|
||||
/* Data creators get a periodic helper for periodic HK data generation. */
|
||||
if(periodicHandling) {
|
||||
periodicHelper = new PeriodicHousekeepingHelper(this);
|
||||
}
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid,
|
||||
PoolVariableIF** registeredVariablesArray,
|
||||
LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables):
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
|
||||
@@ -51,14 +51,14 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid,
|
||||
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
if(accessor != nullptr) {
|
||||
mutexIfSingleDataCreator = accessor->getLocalPoolMutex();
|
||||
poolManager = accessor->getPoolManagerHandle();
|
||||
}
|
||||
}
|
||||
|
||||
this->sid = sid;
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase::LocalPoolDataSetBase(
|
||||
PoolVariableIF **registeredVariablesArray,
|
||||
LocalPoolDataSetBase::LocalPoolDataSetBase(PoolVariableIF **registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables, bool protectEveryReadCommitCall):
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
this->setReadCommitProtectionBehaviour(protectEveryReadCommitCall);
|
||||
@@ -66,9 +66,19 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(
|
||||
|
||||
|
||||
LocalPoolDataSetBase::~LocalPoolDataSetBase() {
|
||||
/* We only delete objects which were created in the class constructor */
|
||||
if(periodicHelper != nullptr) {
|
||||
delete periodicHelper;
|
||||
}
|
||||
/* In case set was read but not comitted, we commit all variables with an invalid state */
|
||||
if(state == States::STATE_SET_WAS_READ) {
|
||||
for (uint16_t count = 0; count < fillCount; count++) {
|
||||
if(registeredVariables[count] != nullptr) {
|
||||
registeredVariables[count]->setValid(false);
|
||||
registeredVariables[count]->commit(MutexIF::TimeoutType::WAITING, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t LocalPoolDataSetBase::lockDataPool(
|
||||
@@ -83,16 +93,25 @@ ReturnValue_t LocalPoolDataSetBase::lockDataPool(
|
||||
ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer(uint8_t **buffer,
|
||||
size_t *size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);
|
||||
uint8_t validityMask[validityMaskSize];
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
const uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);
|
||||
uint8_t* validityPtr = nullptr;
|
||||
#ifdef _MSC_VER
|
||||
/* Use a std::vector here because MSVC will (rightly) not create a fixed size array
|
||||
with a non constant size specifier */
|
||||
std::vector<uint8_t> validityMask(validityMaskSize);
|
||||
validityPtr = validityMask.data();
|
||||
#else
|
||||
uint8_t validityMask[validityMaskSize] = {0};
|
||||
validityPtr = validityMask;
|
||||
#endif
|
||||
uint8_t validBufferIndex = 0;
|
||||
uint8_t validBufferIndexBit = 0;
|
||||
for (uint16_t count = 0; count < fillCount; count++) {
|
||||
if(registeredVariables[count]->isValid()) {
|
||||
// set validity buffer here.
|
||||
this->bitSetter(validityMask + validBufferIndex,
|
||||
validBufferIndexBit);
|
||||
/* Set bit at correct position */
|
||||
bitutil::bitSet(validityPtr + validBufferIndex, validBufferIndexBit);
|
||||
}
|
||||
if(validBufferIndexBit == 7) {
|
||||
validBufferIndex ++;
|
||||
validBufferIndexBit = 0;
|
||||
@@ -100,7 +119,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer(uint8_t **buffer
|
||||
else {
|
||||
validBufferIndexBit ++;
|
||||
}
|
||||
}
|
||||
|
||||
result = registeredVariables[count]->serialize(buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@@ -112,7 +131,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer(uint8_t **buffer
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
// copy validity buffer to end
|
||||
std::memcpy(*buffer, validityMask, validityMaskSize);
|
||||
std::memcpy(*buffer, validityPtr, validityMaskSize);
|
||||
*size += validityMaskSize;
|
||||
return result;
|
||||
}
|
||||
@@ -137,7 +156,7 @@ ReturnValue_t LocalPoolDataSetBase::deSerializeWithValidityBuffer(
|
||||
uint8_t validBufferIndexBit = 0;
|
||||
for (uint16_t count = 0; count < fillCount; count++) {
|
||||
// set validity buffer here.
|
||||
bool nextVarValid = this->bitGetter(*buffer +
|
||||
bool nextVarValid = bitutil::bitGet(*buffer +
|
||||
validBufferIndex, validBufferIndexBit);
|
||||
registeredVariables[count]->setValid(nextVarValid);
|
||||
|
||||
@@ -162,7 +181,7 @@ ReturnValue_t LocalPoolDataSetBase::unlockDataPool() {
|
||||
ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer,
|
||||
size_t* size, size_t maxSize,SerializeIF::Endianness streamEndianness,
|
||||
bool serializeFillCount) const {
|
||||
// Serialize as uint8_t
|
||||
/* Serialize fill count as uint8_t */
|
||||
uint8_t fillCount = this->fillCount;
|
||||
if(serializeFillCount) {
|
||||
SerializeAdapter::serialize(&fillCount, buffer, size, maxSize,
|
||||
@@ -235,21 +254,6 @@ ReturnValue_t LocalPoolDataSetBase::serialize(uint8_t **buffer, size_t *size,
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const {
|
||||
if(position > 7) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolDataSetBase::bitSetter: Invalid position!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalPoolDataSetBase::bitSetter: "
|
||||
"Invalid position!\n\r");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
*byte |= 1 << shiftNumber;
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::setDiagnostic(bool isDiagnostics) {
|
||||
this->diagnostic = isDiagnostics;
|
||||
}
|
||||
@@ -266,11 +270,9 @@ bool LocalPoolDataSetBase::getReportingEnabled() const {
|
||||
return reportingEnabled;
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::initializePeriodicHelper(
|
||||
float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
||||
bool isDiagnostics, uint8_t nonDiagIntervalFactor) {
|
||||
periodicHelper->initialize(collectionInterval, minimumPeriodicInterval,
|
||||
isDiagnostics, nonDiagIntervalFactor);
|
||||
void LocalPoolDataSetBase::initializePeriodicHelper(float collectionInterval,
|
||||
dur_millis_t minimumPeriodicInterval, uint8_t nonDiagIntervalFactor) {
|
||||
periodicHelper->initialize(collectionInterval, minimumPeriodicInterval, nonDiagIntervalFactor);
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::setChanged(bool changed) {
|
||||
@@ -285,19 +287,6 @@ sid_t LocalPoolDataSetBase::getSid() const {
|
||||
return sid;
|
||||
}
|
||||
|
||||
bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte,
|
||||
uint8_t position) const {
|
||||
if(position > 7) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "Pool Raw Access: Bit setting invalid position"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
return *byte & (1 << shiftNumber);
|
||||
}
|
||||
|
||||
bool LocalPoolDataSetBase::isValid() const {
|
||||
return this->valid;
|
||||
}
|
||||
@@ -317,3 +306,18 @@ object_id_t LocalPoolDataSetBase::getCreatorObjectId() {
|
||||
}
|
||||
return objects::NO_OBJECT;
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::setAllVariablesReadOnly() {
|
||||
for(size_t idx = 0; idx < this->getFillCount(); idx++) {
|
||||
registeredVariables[idx]->setReadWriteMode(pool_rwm_t::VAR_READ);
|
||||
}
|
||||
}
|
||||
|
||||
float LocalPoolDataSetBase::getCollectionInterval() const {
|
||||
if(periodicHelper != nullptr) {
|
||||
return periodicHelper->getCollectionIntervalInSeconds();
|
||||
}
|
||||
else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Constructor for users of the local pool data, which need
|
||||
* to access data created by one (!) HK manager.
|
||||
* to access data created by one HK manager.
|
||||
* @details
|
||||
* Unlike the first constructor, no component for periodic handling
|
||||
* will be initiated.
|
||||
@@ -103,6 +103,18 @@ public:
|
||||
*/
|
||||
~LocalPoolDataSetBase();
|
||||
|
||||
/* The copy constructor and assingment constructor are forbidden for now.
|
||||
The use-cases are limited and the first step would be to implement them properly for the
|
||||
base class */
|
||||
LocalPoolDataSetBase(const LocalPoolDataSetBase& otherSet) = delete;
|
||||
const LocalPoolDataSetBase& operator=(const LocalPoolDataSetBase& otherSet) = delete;
|
||||
|
||||
/**
|
||||
* Helper functions used to set all currently contained variables to read-only.
|
||||
* It is recommended to call this in set constructors intended to be used
|
||||
* by data consumers to prevent accidentally changing pool data.
|
||||
*/
|
||||
void setAllVariablesReadOnly();
|
||||
void setValidityBufferGeneration(bool withValidityBuffer);
|
||||
|
||||
sid_t getSid() const;
|
||||
@@ -153,6 +165,17 @@ public:
|
||||
bool hasChanged() const override;
|
||||
|
||||
object_id_t getCreatorObjectId();
|
||||
|
||||
bool getReportingEnabled() const;
|
||||
|
||||
/**
|
||||
* Returns the current periodic HK generation interval this set
|
||||
* belongs to a HK manager and the interval is not 0. Otherwise,
|
||||
* returns 0.0
|
||||
* @return
|
||||
*/
|
||||
float getCollectionInterval() const;
|
||||
|
||||
protected:
|
||||
sid_t sid;
|
||||
//! This mutex is used if the data is created by one object only.
|
||||
@@ -167,11 +190,9 @@ protected:
|
||||
*/
|
||||
bool reportingEnabled = false;
|
||||
void setReportingEnabled(bool enabled);
|
||||
bool getReportingEnabled() const;
|
||||
|
||||
void initializePeriodicHelper(float collectionInterval,
|
||||
dur_millis_t minimumPeriodicInterval,
|
||||
bool isDiagnostics, uint8_t nonDiagIntervalFactor = 5);
|
||||
void initializePeriodicHelper(float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
||||
uint8_t nonDiagIntervalFactor = 5);
|
||||
|
||||
/**
|
||||
* If the valid state of a dataset is always relevant to the whole
|
||||
@@ -211,13 +232,6 @@ protected:
|
||||
*/
|
||||
ReturnValue_t unlockDataPool() override;
|
||||
|
||||
/**
|
||||
* Set n-th bit of a byte, with n being the position from 0
|
||||
* (most significant bit) to 7 (least significant bit)
|
||||
*/
|
||||
void bitSetter(uint8_t* byte, uint8_t position) const;
|
||||
bool bitGetter(const uint8_t* byte, uint8_t position) const;
|
||||
|
||||
PeriodicHousekeepingHelper* periodicHelper = nullptr;
|
||||
LocalDataPoolManager* poolManager = nullptr;
|
||||
|
||||
|
@@ -1,10 +1,12 @@
|
||||
#include "LocalPoolObjectBase.h"
|
||||
#include "LocalDataPoolManager.h"
|
||||
#include "internal/HasLocalDpIFUserAttorney.h"
|
||||
#include "AccessLocalPoolF.h"
|
||||
#include "HasLocalDataPoolIF.h"
|
||||
#include "internal/HasLocalDpIFUserAttorney.h"
|
||||
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
|
||||
LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
|
||||
DataSetIF* dataSet, pool_rwm_t setReadWriteMode):
|
||||
localPoolId(poolId), readWriteMode(setReadWriteMode) {
|
||||
@@ -22,7 +24,7 @@ LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkO
|
||||
return;
|
||||
}
|
||||
AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
hkManager = poolManAccessor->getHkManagerHandle();
|
||||
hkManager = poolManAccessor->getPoolManagerHandle();
|
||||
|
||||
if (dataSet != nullptr) {
|
||||
dataSet->registerVariable(this);
|
||||
@@ -35,22 +37,27 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
|
||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
|
||||
<< "which is the NO_PARAMETER value!" << std::endl;
|
||||
"which is the NO_PARAMETER value!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
|
||||
"which is the NO_PARAMETER value!\n");
|
||||
#endif
|
||||
}
|
||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(poolOwner);
|
||||
if(hkOwner == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPoolVariable: The supplied pool owner did not "
|
||||
<< "implement the correct interface"
|
||||
<< " HasLocalDataPoolIF!" << std::endl;
|
||||
sif::error << "LocalPoolVariable: The supplied pool owner did not implement the correct "
|
||||
"interface HasLocalDataPoolIF!" << std::endl;
|
||||
#else
|
||||
sif::printError( "LocalPoolVariable: The supplied pool owner did not implement the correct "
|
||||
"interface HasLocalDataPoolIF!\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
if(accessor != nullptr) {
|
||||
hkManager = accessor->getHkManagerHandle();
|
||||
hkManager = accessor->getPoolManagerHandle();
|
||||
}
|
||||
|
||||
if(dataSet != nullptr) {
|
||||
@@ -93,6 +100,10 @@ void LocalPoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) {
|
||||
void LocalPoolObjectBase::reportReadCommitError(const char* variableType,
|
||||
ReturnValue_t error, bool read, object_id_t objectId, lp_id_t lpId) {
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
const char* variablePrintout = variableType;
|
||||
if(variablePrintout == nullptr) {
|
||||
variablePrintout = "Unknown Type";
|
||||
}
|
||||
const char* type = nullptr;
|
||||
if(read) {
|
||||
type = "read";
|
||||
@@ -119,12 +130,12 @@ void LocalPoolObjectBase::reportReadCommitError(const char* variableType,
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << variableType << ": " << type << " call | " << errMsg << " | Owner: 0x"
|
||||
sif::warning << variablePrintout << ": " << type << " call | " << errMsg << " | Owner: 0x"
|
||||
<< std::hex << std::setw(8) << std::setfill('0') << objectId << std::dec
|
||||
<< " LPID: " << lpId << std::endl;
|
||||
#else
|
||||
sif::printWarning("%s: %s call | %s | Owner: 0x%08x LPID: %lu\n",
|
||||
variableType, type, errMsg, objectId, lpId);
|
||||
variablePrintout, type, errMsg, objectId, lpId);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
||||
}
|
||||
|
@@ -20,12 +20,10 @@ class LocalPoolObjectBase: public PoolVariableIF,
|
||||
public HasReturnvaluesIF,
|
||||
public MarkChangedIF {
|
||||
public:
|
||||
LocalPoolObjectBase(lp_id_t poolId,
|
||||
HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet,
|
||||
LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet,
|
||||
pool_rwm_t setReadWriteMode);
|
||||
|
||||
LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
|
||||
DataSetIF* dataSet = nullptr,
|
||||
LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr,
|
||||
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
|
||||
|
||||
void setReadWriteMode(pool_rwm_t newReadWriteMode);
|
||||
|
@@ -26,9 +26,18 @@ inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId,
|
||||
template<typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::read(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
MutexHelper(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
if(hkManager == nullptr) {
|
||||
return readWithoutLock();
|
||||
}
|
||||
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
|
||||
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = readWithoutLock();
|
||||
mutex->unlockMutex();
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
||||
@@ -43,7 +52,6 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
||||
PoolEntry<T>* poolEntry = nullptr;
|
||||
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
||||
&poolEntry);
|
||||
//ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
|
||||
if(result != RETURN_OK) {
|
||||
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
|
||||
reportReadCommitError("LocalPoolVariable", result,
|
||||
@@ -51,15 +59,6 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Actually this should never happen..
|
||||
// if(poolEntry->address == nullptr) {
|
||||
// result = PoolVariableIF::INVALID_POOL_ENTRY;
|
||||
// object_id_t ownerObjectId = hkManager->getOwner()->getObjectId();
|
||||
// reportReadCommitError("LocalPoolVariable", result,
|
||||
// false, ownerObjectId, localPoolId);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
this->value = *(poolEntry->getDataPtr());
|
||||
this->valid = poolEntry->getValid();
|
||||
return RETURN_OK;
|
||||
@@ -75,9 +74,18 @@ inline ReturnValue_t LocalPoolVariable<T>::commit(bool setValid,
|
||||
template<typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::commit(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
MutexHelper(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
if(hkManager == nullptr) {
|
||||
return commitWithoutLock();
|
||||
}
|
||||
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
|
||||
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = commitWithoutLock();
|
||||
mutex->unlockMutex();
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
||||
@@ -90,7 +98,6 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
||||
}
|
||||
|
||||
PoolEntry<T>* poolEntry = nullptr;
|
||||
//ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
|
||||
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
||||
&poolEntry);
|
||||
if(result != RETURN_OK) {
|
||||
|
@@ -77,8 +77,7 @@ public:
|
||||
* @param dataSet
|
||||
* @param setReadWriteMode
|
||||
*/
|
||||
LocalPoolVector(gp_id_t globalPoolId,
|
||||
DataSetIF* dataSet = nullptr,
|
||||
LocalPoolVector(gp_id_t globalPoolId, DataSetIF* dataSet = nullptr,
|
||||
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
|
||||
|
||||
/**
|
||||
@@ -87,7 +86,7 @@ public:
|
||||
* The user can work on this attribute just like he would on a local
|
||||
* array of this type.
|
||||
*/
|
||||
T value[vectorSize];
|
||||
T value[vectorSize]= {};
|
||||
/**
|
||||
* @brief The classes destructor is empty.
|
||||
* @details If commit() was not called, the local value is
|
||||
|
@@ -16,7 +16,6 @@ inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner,
|
||||
lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
||||
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId,
|
||||
DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||
@@ -26,7 +25,7 @@ inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId,
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
MutexHelper(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
return readWithoutLock();
|
||||
}
|
||||
template<typename T, uint16_t vectorSize>
|
||||
@@ -65,7 +64,7 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
MutexHelper(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
return commitWithoutLock();
|
||||
}
|
||||
|
||||
|
@@ -17,12 +17,8 @@ public:
|
||||
* to generate housekeeping packets which are downlinked directly.
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid,
|
||||
bool enableReporting,
|
||||
float collectionInterval, bool isDiagnostics,
|
||||
object_id_t packetDestination) = 0;
|
||||
|
||||
|
||||
virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting,
|
||||
float collectionInterval, bool isDiagnostics, object_id_t packetDestination) = 0;
|
||||
/**
|
||||
* @brief Subscribe for the generation of packets if the dataset
|
||||
* is marked as changed.
|
||||
@@ -33,12 +29,8 @@ public:
|
||||
* @param packetDestination
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t subscribeForUpdatePackets(sid_t sid,
|
||||
bool reportingEnabled,
|
||||
bool isDiagnostics,
|
||||
object_id_t packetDestination) = 0;
|
||||
|
||||
|
||||
virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled,
|
||||
bool isDiagnostics, object_id_t packetDestination) = 0;
|
||||
/**
|
||||
* @brief Subscribe for a notification message which will be sent
|
||||
* if a dataset has changed.
|
||||
@@ -46,18 +38,16 @@ public:
|
||||
* This subscription mechanism will generally be used internally by
|
||||
* other software components.
|
||||
* @param setId Set ID of the set to receive update messages from.
|
||||
* @param destinationObject
|
||||
* @param targetQueueId
|
||||
* @param generateSnapshot If this is set to true, a copy of the current
|
||||
* data with a timestamp will be generated and sent via message.
|
||||
* @param destinationObject Object ID of the receiver.
|
||||
* @param targetQueueId Receiver queue ID
|
||||
* @param generateSnapshot If this is set to true, a copy of the current data with a
|
||||
* timestamp will be generated and sent via message.
|
||||
* Otherwise, only an notification message is sent.
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t subscribeForSetUpdateMessages(const uint32_t setId,
|
||||
object_id_t destinationObject,
|
||||
MessageQueueId_t targetQueueId,
|
||||
virtual ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId,
|
||||
object_id_t destinationObject, MessageQueueId_t targetQueueId,
|
||||
bool generateSnapshot) = 0;
|
||||
|
||||
/**
|
||||
* @brief Subscribe for an notification message which will be sent if a
|
||||
* pool variable has changed.
|
||||
@@ -65,19 +55,16 @@ public:
|
||||
* This subscription mechanism will generally be used internally by
|
||||
* other software components.
|
||||
* @param localPoolId Pool ID of the pool variable
|
||||
* @param destinationObject
|
||||
* @param targetQueueId
|
||||
* @param generateSnapshot If this is set to true, a copy of the current
|
||||
* data with a timestamp will be generated and sent via message.
|
||||
* Otherwise, only an notification message is sent.
|
||||
* @param destinationObject Object ID of the receiver
|
||||
* @param targetQueueId Receiver queue ID
|
||||
* @param generateSnapshot If this is set to true, a copy of the current data with a
|
||||
* timestamp will be generated and sent via message. Otherwise,
|
||||
* only an notification message is sent.
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t subscribeForVariableUpdateMessages(
|
||||
const lp_id_t localPoolId,
|
||||
object_id_t destinationObject,
|
||||
MessageQueueId_t targetQueueId,
|
||||
virtual ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId,
|
||||
object_id_t destinationObject, MessageQueueId_t targetQueueId,
|
||||
bool generateSnapshot) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ */
|
||||
|
@@ -1,16 +1,37 @@
|
||||
#include "SharedLocalDataSet.h"
|
||||
|
||||
|
||||
SharedLocalDataSet::SharedLocalDataSet(object_id_t objectId, sid_t sid,
|
||||
const size_t maxSize): SystemObject(objectId),
|
||||
LocalPoolDataSetBase(sid, nullptr, maxSize) {
|
||||
LocalPoolDataSetBase(sid, nullptr, maxSize), poolVarVector(maxSize) {
|
||||
this->setContainer(poolVarVector.data());
|
||||
datasetLock = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
ReturnValue_t SharedLocalDataSet::lockDataset(dur_millis_t mutexTimeout) {
|
||||
return datasetLock->lockMutex(MutexIF::TimeoutType::WAITING, mutexTimeout);
|
||||
SharedLocalDataSet::SharedLocalDataSet(object_id_t objectId,
|
||||
HasLocalDataPoolIF *owner, uint32_t setId,
|
||||
const size_t maxSize): SystemObject(objectId),
|
||||
LocalPoolDataSetBase(owner, setId, nullptr, maxSize), poolVarVector(maxSize) {
|
||||
this->setContainer(poolVarVector.data());
|
||||
datasetLock = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
ReturnValue_t SharedLocalDataSet::lockDataset(MutexIF::TimeoutType timeoutType,
|
||||
dur_millis_t mutexTimeout) {
|
||||
if(datasetLock != nullptr) {
|
||||
return datasetLock->lockMutex(timeoutType, mutexTimeout);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
|
||||
SharedLocalDataSet::~SharedLocalDataSet() {
|
||||
MutexFactory::instance()->deleteMutex(datasetLock);
|
||||
}
|
||||
|
||||
ReturnValue_t SharedLocalDataSet::unlockDataset() {
|
||||
if(datasetLock != nullptr) {
|
||||
return datasetLock->unlockMutex();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
@@ -11,16 +11,22 @@
|
||||
* multiple threads. It provides a lock in addition to all other functionalities provided
|
||||
* by the LocalPoolDataSetBase class.
|
||||
*
|
||||
* TODO: override and protect read, commit and some other calls used by pool manager.
|
||||
* The user is completely responsible for lockingand unlocking the dataset when using the
|
||||
* shared dataset.
|
||||
*/
|
||||
class SharedLocalDataSet:
|
||||
public SystemObject,
|
||||
public LocalPoolDataSetBase,
|
||||
public SharedDataSetIF {
|
||||
public:
|
||||
SharedLocalDataSet(object_id_t objectId, sid_t sid,
|
||||
SharedLocalDataSet(object_id_t objectId, HasLocalDataPoolIF* owner, uint32_t setId,
|
||||
const size_t maxSize);
|
||||
ReturnValue_t lockDataset(dur_millis_t mutexTimeout) override;
|
||||
SharedLocalDataSet(object_id_t objectId, sid_t sid, const size_t maxSize);
|
||||
|
||||
virtual~ SharedLocalDataSet();
|
||||
|
||||
ReturnValue_t lockDataset(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
||||
dur_millis_t mutexTimeout = 20) override;
|
||||
ReturnValue_t unlockDataset() override;
|
||||
private:
|
||||
|
||||
|
@@ -2,11 +2,15 @@
|
||||
#define FSFW_DATAPOOLLOCAL_STATICLOCALDATASET_H_
|
||||
|
||||
#include "LocalPoolDataSetBase.h"
|
||||
#include "LocalPoolVariable.h"
|
||||
#include "LocalPoolVector.h"
|
||||
|
||||
#include "../objectmanager/SystemObjectIF.h"
|
||||
#include <array>
|
||||
|
||||
/**
|
||||
* @brief This local dataset type is created on the stack.
|
||||
* @brief This dataset type can be used to group related pool variables if the number of
|
||||
* variables is fixed.
|
||||
* @details
|
||||
* This will is the primary data structure to organize pool variables into
|
||||
* sets which can be accessed via the housekeeping service interface or
|
||||
|
12
datapoollocal/datapoollocal.h
Normal file
12
datapoollocal/datapoollocal.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_
|
||||
#define FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_
|
||||
|
||||
/* Collected related headers */
|
||||
#include "LocalPoolVariable.h"
|
||||
#include "LocalPoolVector.h"
|
||||
#include "StaticLocalDataSet.h"
|
||||
#include "LocalDataSet.h"
|
||||
#include "SharedLocalDataSet.h"
|
||||
|
||||
|
||||
#endif /* FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_ */
|
@@ -24,7 +24,6 @@ private:
|
||||
return manager.getMutexHandle();
|
||||
}
|
||||
|
||||
|
||||
template<typename T> friend class LocalPoolVariable;
|
||||
template<typename T, uint16_t vecSize> friend class LocalPoolVector;
|
||||
};
|
||||
|
@@ -14,9 +14,8 @@ private:
|
||||
}
|
||||
|
||||
static void initializePeriodicHelper(LocalPoolDataSetBase& set, float collectionInterval,
|
||||
uint32_t minimumPeriodicIntervalMs,
|
||||
bool isDiagnostics, uint8_t nonDiagIntervalFactor = 5) {
|
||||
set.initializePeriodicHelper(collectionInterval, minimumPeriodicIntervalMs, isDiagnostics,
|
||||
uint32_t minimumPeriodicIntervalMs, uint8_t nonDiagIntervalFactor = 5) {
|
||||
set.initializePeriodicHelper(collectionInterval, minimumPeriodicIntervalMs,
|
||||
nonDiagIntervalFactor);
|
||||
}
|
||||
|
||||
|
@@ -21,8 +21,8 @@ static constexpr uint8_t INTERFACE_ID = CLASS_ID::LOCAL_POOL_OWNER_IF;
|
||||
static constexpr ReturnValue_t POOL_ENTRY_NOT_FOUND = MAKE_RETURN_CODE(0x00);
|
||||
static constexpr ReturnValue_t POOL_ENTRY_TYPE_CONFLICT = MAKE_RETURN_CODE(0x01);
|
||||
|
||||
//! This is the core data structure of the local data pools. Users should insert all desired
|
||||
//! pool variables, using the std::map interface.
|
||||
/** This is the core data structure of the local data pools. Users should insert all desired
|
||||
pool variables, using the std::map interface. */
|
||||
using DataPool = std::map<lp_id_t, PoolEntryIF*>;
|
||||
using DataPoolMapIter = DataPool::iterator;
|
||||
|
||||
@@ -96,11 +96,11 @@ union gp_id_t {
|
||||
return raw == INVALID_GPID;
|
||||
}
|
||||
|
||||
bool operator==(const sid_t& other) const {
|
||||
bool operator==(const gp_id_t& other) const {
|
||||
return raw == other.raw;
|
||||
}
|
||||
|
||||
bool operator!=(const sid_t& other) const {
|
||||
bool operator!=(const gp_id_t& other) const {
|
||||
return not (raw == other.raw);
|
||||
}
|
||||
};
|
||||
|
@@ -40,6 +40,13 @@
|
||||
//! Specify whether a special mode store is used for Subsystem components.
|
||||
#define FSFW_USE_MODESTORE 0
|
||||
|
||||
//! Defines if the real time scheduler for linux should be used.
|
||||
//! If set to 0, this will also disable priority settings for linux
|
||||
//! as most systems will not allow to set nice values without privileges
|
||||
//! For embedded linux system set this to 1.
|
||||
//! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run
|
||||
#define FSFW_USE_REALTIME_FOR_LINUX 1
|
||||
|
||||
namespace fsfwconfig {
|
||||
//! Default timestamp size. The default timestamp will be an eight byte CDC
|
||||
//! short timestamp.
|
||||
@@ -52,11 +59,12 @@ static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
|
||||
|
||||
//! Defines the FIFO depth of each commanding service base which
|
||||
//! also determines how many commands a CSB service can handle in one cycle
|
||||
//! simulataneously. This will increase the required RAM for
|
||||
//! simultaneously. This will increase the required RAM for
|
||||
//! each CSB service !
|
||||
static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
|
||||
|
||||
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
|
||||
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FSFWCONFIG_H_ */
|
||||
|
@@ -24,6 +24,13 @@
|
||||
* 1. check logic when active-> checkChildrenStateOn
|
||||
* 2. transition logic to change the mode -> commandChildren
|
||||
*
|
||||
* Important:
|
||||
*
|
||||
* The implementation must call registerChild(object_id_t child)
|
||||
* for all commanded children during initialization.
|
||||
* The implementation must call the initialization function of the base class.
|
||||
* (This will call the function in SubsystemBase)
|
||||
*
|
||||
*/
|
||||
class AssemblyBase: public SubsystemBase {
|
||||
public:
|
||||
@@ -41,9 +48,6 @@ public:
|
||||
virtual ~AssemblyBase();
|
||||
|
||||
protected:
|
||||
|
||||
// SHOULDDO: Change that OVERWRITE_HEALTH may be returned
|
||||
// (or return internalState directly?)
|
||||
/**
|
||||
* Command children to reach [mode,submode] combination
|
||||
* Can be done by setting #commandsOutstanding correctly,
|
||||
@@ -68,6 +72,18 @@ protected:
|
||||
virtual ReturnValue_t checkChildrenStateOn(Mode_t wantedMode,
|
||||
Submode_t wantedSubmode) = 0;
|
||||
|
||||
/**
|
||||
* Check whether a combination of mode and submode is valid.
|
||||
*
|
||||
* Ground Controller like precise return values from HasModesIF.
|
||||
* So, please return any of them.
|
||||
*
|
||||
* @param mode The targeted mode
|
||||
* @param submode The targeted submmode
|
||||
* @return Any information why this combination is invalid from HasModesIF
|
||||
* like HasModesIF::INVALID_SUBMODE.
|
||||
* On success return HasReturnvaluesIF::RETURN_OK
|
||||
*/
|
||||
virtual ReturnValue_t isModeCombinationValid(Mode_t mode,
|
||||
Submode_t submode) = 0;
|
||||
|
||||
|
@@ -17,16 +17,15 @@ object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
|
||||
object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT;
|
||||
object_id_t DeviceHandlerBase::defaultFdirParentId = objects::NO_OBJECT;
|
||||
|
||||
DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId,
|
||||
object_id_t deviceCommunication, CookieIF * comCookie,
|
||||
FailureIsolationBase* fdirInstance, size_t cmdQueueSize) :
|
||||
DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication,
|
||||
CookieIF* comCookie, FailureIsolationBase* fdirInstance, size_t cmdQueueSize):
|
||||
SystemObject(setObjectId), mode(MODE_OFF), submode(SUBMODE_NONE),
|
||||
wiretappingMode(OFF), storedRawData(StorageManagerIF::INVALID_ADDRESS),
|
||||
deviceCommunicationId(deviceCommunication), comCookie(comCookie),
|
||||
healthHelper(this,setObjectId), modeHelper(this), parameterHelper(this),
|
||||
actionHelper(this, nullptr), poolManager(this, nullptr),
|
||||
childTransitionFailure(RETURN_OK), fdirInstance(fdirInstance),
|
||||
hkSwitcher(this), defaultFDIRUsed(fdirInstance == nullptr),
|
||||
defaultFDIRUsed(fdirInstance == nullptr),
|
||||
switchOffWasReported(false), childTransitionDelay(5000),
|
||||
transitionSourceMode(_MODE_POWER_DOWN),
|
||||
transitionSourceSubMode(SUBMODE_NONE) {
|
||||
@@ -80,7 +79,6 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
|
||||
checkSwitchState();
|
||||
decrementDeviceReplyMap();
|
||||
fdirInstance->checkForFailures();
|
||||
hkSwitcher.performOperation();
|
||||
performOperationHook();
|
||||
return RETURN_OK;
|
||||
}
|
||||
@@ -92,7 +90,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
|
||||
switch (getComAction()) {
|
||||
case CommunicationAction::SEND_WRITE:
|
||||
if (cookieInfo.state == COOKIE_UNUSED) {
|
||||
// if no external command was specified, build internal command.
|
||||
/* If no external command was specified, build internal command. */
|
||||
buildInternalCommand();
|
||||
}
|
||||
doSendWrite();
|
||||
@@ -105,8 +103,8 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
|
||||
break;
|
||||
case CommunicationAction::GET_READ:
|
||||
doGetRead();
|
||||
// This will be performed after datasets have been updated by the
|
||||
// custom device implementation.
|
||||
/* This will be performed after datasets have been updated by the
|
||||
custom device implementation. */
|
||||
poolManager.performHkOperation();
|
||||
break;
|
||||
default:
|
||||
@@ -205,11 +203,6 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = hkSwitcher.initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = poolManager.initialize(commandQueue);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@@ -315,6 +308,14 @@ void DeviceHandlerBase::doStateMachine() {
|
||||
uint32_t currentUptime;
|
||||
Clock::getUptime(¤tUptime);
|
||||
if (currentUptime - timeoutStart >= childTransitionDelay) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1 && FSFW_OBJ_EVENT_TRANSLATION == 0
|
||||
char printout[60];
|
||||
sprintf(printout, "Transition timeout (%lu) occured !",
|
||||
static_cast<unsigned long>(childTransitionDelay));
|
||||
/* Common configuration error for development, so print it */
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "doStateMachine",
|
||||
RETURN_FAILED, printout);
|
||||
#endif
|
||||
triggerEvent(MODE_TRANSITION_FAILED, childTransitionFailure, 0);
|
||||
setMode(transitionSourceMode, transitionSourceSubMode);
|
||||
break;
|
||||
@@ -442,8 +443,7 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId,
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t DeviceHandlerBase::insertInCommandMap(
|
||||
DeviceCommandId_t deviceCommand) {
|
||||
ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceCommand) {
|
||||
DeviceCommandInfo info;
|
||||
info.expectedReplies = 0;
|
||||
info.isExecuting = false;
|
||||
@@ -456,6 +456,15 @@ ReturnValue_t DeviceHandlerBase::insertInCommandMap(
|
||||
}
|
||||
}
|
||||
|
||||
size_t DeviceHandlerBase::getNextReplyLength(DeviceCommandId_t commandId){
|
||||
DeviceReplyIter iter = deviceReplyMap.find(commandId);
|
||||
if(iter != deviceReplyMap.end()) {
|
||||
return iter->second.replyLen;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceReply,
|
||||
uint16_t delayCycles, uint16_t maxDelayCycles, bool periodic) {
|
||||
auto replyIter = deviceReplyMap.find(deviceReply);
|
||||
@@ -506,7 +515,8 @@ void DeviceHandlerBase::setTransition(Mode_t modeTo, Submode_t submodeTo) {
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
|
||||
changeHK(mode, submode, false);
|
||||
/* TODO: This will probably be done by the LocalDataPoolManager now */
|
||||
//changeHK(mode, submode, false);
|
||||
submode = newSubmode;
|
||||
mode = newMode;
|
||||
modeChanged();
|
||||
@@ -529,7 +539,8 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
|
||||
}
|
||||
|
||||
}
|
||||
changeHK(mode, submode, true);
|
||||
/* TODO: This will probably be done by the LocalDataPoolManager now */
|
||||
//changeHK(mode, submode, true);
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::setMode(Mode_t newMode) {
|
||||
@@ -564,7 +575,7 @@ void DeviceHandlerBase::replyToCommand(ReturnValue_t status,
|
||||
if (cookieInfo.pendingCommand->second.sendReplyTo != NO_COMMANDER) {
|
||||
MessageQueueId_t queueId = cookieInfo.pendingCommand->second.sendReplyTo;
|
||||
if (status == NO_REPLY_EXPECTED) {
|
||||
actionHelper.finish(queueId, cookieInfo.pendingCommand->first,
|
||||
actionHelper.finish(true, queueId, cookieInfo.pendingCommand->first,
|
||||
RETURN_OK);
|
||||
} else {
|
||||
actionHelper.step(1, queueId, cookieInfo.pendingCommand->first,
|
||||
@@ -587,7 +598,11 @@ void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter,
|
||||
// Check if it was transition or internal command.
|
||||
// Don't send any replies in that case.
|
||||
if (info->sendReplyTo != NO_COMMANDER) {
|
||||
actionHelper.finish(info->sendReplyTo, iter->first, status);
|
||||
bool success = false;
|
||||
if(status == HasReturnvaluesIF::RETURN_OK) {
|
||||
success = true;
|
||||
}
|
||||
actionHelper.finish(success, info->sendReplyTo, iter->first, status);
|
||||
}
|
||||
info->isExecuting = false;
|
||||
}
|
||||
@@ -640,16 +655,12 @@ void DeviceHandlerBase::doGetWrite() {
|
||||
void DeviceHandlerBase::doSendRead() {
|
||||
ReturnValue_t result;
|
||||
|
||||
size_t requestLen = 0;
|
||||
size_t replyLen = 0;
|
||||
if(cookieInfo.pendingCommand != deviceCommandMap.end()) {
|
||||
DeviceReplyIter iter = deviceReplyMap.find(
|
||||
cookieInfo.pendingCommand->first);
|
||||
if(iter != deviceReplyMap.end()) {
|
||||
requestLen = iter->second.replyLen;
|
||||
}
|
||||
replyLen = getNextReplyLength(cookieInfo.pendingCommand->first);
|
||||
}
|
||||
|
||||
result = communicationInterface->requestReceiveMessage(comCookie, requestLen);
|
||||
result = communicationInterface->requestReceiveMessage(comCookie, replyLen);
|
||||
|
||||
if (result == RETURN_OK) {
|
||||
cookieInfo.state = COOKIE_READ_SENT;
|
||||
@@ -706,13 +717,11 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
DeviceCommandId_t foundId = DeviceHandlerIF::NO_COMMAND_ID;
|
||||
size_t foundLen = 0;
|
||||
// The loop may not execute more often than the number of received bytes
|
||||
// (worst case). This approach avoids infinite loops due to buggy
|
||||
// scanForReply routines.
|
||||
/* The loop may not execute more often than the number of received bytes
|
||||
(worst case). This approach avoids infinite loops due to buggy scanForReply routines. */
|
||||
uint32_t remainingLength = receivedDataLen;
|
||||
for (uint32_t count = 0; count < receivedDataLen; count++) {
|
||||
result = scanForReply(receivedData, remainingLength, &foundId,
|
||||
&foundLen);
|
||||
result = scanForReply(receivedData, remainingLength, &foundId, &foundLen);
|
||||
switch (result) {
|
||||
case RETURN_OK:
|
||||
handleReply(receivedData, foundId, foundLen);
|
||||
@@ -795,9 +804,9 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData,
|
||||
replyToReply(iter, result);
|
||||
}
|
||||
else {
|
||||
// Other completion failure messages are created by timeout.
|
||||
// Powering down the device might take some time during which periodic
|
||||
// replies may still come in.
|
||||
/* Other completion failure messages are created by timeout.
|
||||
Powering down the device might take some time during which periodic
|
||||
replies may still come in. */
|
||||
if (mode != _MODE_WAIT_OFF) {
|
||||
triggerEvent(DEVICE_UNREQUESTED_REPLY, foundId);
|
||||
}
|
||||
@@ -1202,61 +1211,62 @@ ReturnValue_t DeviceHandlerBase::letChildHandleMessage(
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::handleDeviceTM(SerializeIF* data,
|
||||
DeviceCommandId_t replyId, bool neverInDataPool, bool forceDirectTm) {
|
||||
void DeviceHandlerBase::handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId,
|
||||
bool forceDirectTm) {
|
||||
if(dataSet == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId);
|
||||
if (iter == deviceReplyMap.end()) {
|
||||
triggerEvent(DEVICE_UNKNOWN_REPLY, replyId);
|
||||
return;
|
||||
}
|
||||
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, data);
|
||||
//replies to a command
|
||||
|
||||
/* Regular replies to a command */
|
||||
if (iter->second.command != deviceCommandMap.end())
|
||||
{
|
||||
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
|
||||
|
||||
if (queueId != NO_COMMANDER) {
|
||||
//This may fail, but we'll ignore the fault.
|
||||
actionHelper.reportData(queueId, replyId, data);
|
||||
/* This may fail, but we'll ignore the fault. */
|
||||
actionHelper.reportData(queueId, replyId, dataSet);
|
||||
}
|
||||
|
||||
//This check should make sure we get any TM but don't get anything doubled.
|
||||
/* This check should make sure we get any TM but don't get anything doubled. */
|
||||
if (wiretappingMode == TM && (requestedRawTraffic != queueId)) {
|
||||
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
|
||||
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
|
||||
}
|
||||
|
||||
else if (forceDirectTm and (defaultRawReceiver != queueId) and
|
||||
(defaultRawReceiver != MessageQueueIF::NO_QUEUE))
|
||||
{
|
||||
// hiding of sender needed so the service will handle it as
|
||||
// unexpected Data, no matter what state (progress or completed)
|
||||
// it is in
|
||||
actionHelper.reportData(defaultRawReceiver, replyId, &wrapper,
|
||||
true);
|
||||
actionHelper.reportData(defaultRawReceiver, replyId, dataSet, true);
|
||||
}
|
||||
}
|
||||
//unrequested/aperiodic replies
|
||||
/* Unrequested or aperiodic replies */
|
||||
else
|
||||
{
|
||||
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
|
||||
if (wiretappingMode == TM) {
|
||||
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
|
||||
}
|
||||
else if (forceDirectTm and defaultRawReceiver !=
|
||||
MessageQueueIF::NO_QUEUE)
|
||||
if (forceDirectTm and defaultRawReceiver != MessageQueueIF::NO_QUEUE)
|
||||
{
|
||||
// sid_t setSid = sid_t(this->getObjectId(), replyId);
|
||||
// LocalPoolDataSetBase* dataset = getDataSetHandle(setSid);
|
||||
// if(dataset != nullptr) {
|
||||
// poolManager.generateHousekeepingPacket(setSid, dataset, true);
|
||||
// }
|
||||
|
||||
// hiding of sender needed so the service will handle it as
|
||||
// unexpected Data, no matter what state (progress or completed)
|
||||
// it is in
|
||||
actionHelper.reportData(defaultRawReceiver, replyId, &wrapper,
|
||||
true);
|
||||
}
|
||||
}
|
||||
//Try to cast to GlobDataSet and commit data.
|
||||
if (not neverInDataPool) {
|
||||
LocalPoolDataSetBase* dataSet =
|
||||
dynamic_cast<LocalPoolDataSetBase*>(data);
|
||||
if (dataSet != nullptr) {
|
||||
dataSet->setValidity(true, true);
|
||||
dataSet->commit();
|
||||
actionHelper.reportData(defaultRawReceiver, replyId, &wrapper, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1285,18 +1295,17 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId,
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::buildInternalCommand(void) {
|
||||
//Neither Raw nor Direct could build a command
|
||||
/* Neither raw nor direct could build a command */
|
||||
ReturnValue_t result = NOTHING_TO_SEND;
|
||||
DeviceCommandId_t deviceCommandId = NO_COMMAND_ID;
|
||||
if (mode == MODE_NORMAL) {
|
||||
result = buildNormalDeviceCommand(&deviceCommandId);
|
||||
if (result == BUSY) {
|
||||
// so we can track misconfigurations
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"buildInternalCommand",
|
||||
HasReturnvaluesIF::RETURN_FAILED,
|
||||
"Busy.");
|
||||
result = NOTHING_TO_SEND; //no need to report this
|
||||
/* So we can track misconfigurations */
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "buildInternalCommand",
|
||||
HasReturnvaluesIF::RETURN_FAILED, "Busy.");
|
||||
/* No need to report this */
|
||||
result = NOTHING_TO_SEND;
|
||||
}
|
||||
}
|
||||
else if (mode == MODE_RAW) {
|
||||
@@ -1318,7 +1327,8 @@ void DeviceHandlerBase::buildInternalCommand(void) {
|
||||
deviceCommandId);
|
||||
if (iter == deviceCommandMap.end()) {
|
||||
result = COMMAND_NOT_SUPPORTED;
|
||||
} else if (iter->second.isExecuting) {
|
||||
}
|
||||
else if (iter->second.isExecuting) {
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
char output[36];
|
||||
sprintf(output, "Command 0x%08x is executing",
|
||||
@@ -1378,11 +1388,11 @@ void DeviceHandlerBase::forwardEvent(Event event, uint32_t parameter1,
|
||||
void DeviceHandlerBase::doOffActivity() {
|
||||
}
|
||||
|
||||
ReturnValue_t DeviceHandlerBase::getParameter(uint8_t domainId,
|
||||
uint16_t parameterId, ParameterWrapper* parameterWrapper,
|
||||
const ParameterWrapper* newValues, uint16_t startAtIndex) {
|
||||
ReturnValue_t result = fdirInstance->getParameter(domainId, parameterId,
|
||||
parameterWrapper, newValues, startAtIndex);
|
||||
ReturnValue_t DeviceHandlerBase::getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||
ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues,
|
||||
uint16_t startAtIndex) {
|
||||
ReturnValue_t result = fdirInstance->getParameter(domainId, uniqueId, parameterWrapper,
|
||||
newValues, startAtIndex);
|
||||
if (result != INVALID_DOMAIN_ID) {
|
||||
return result;
|
||||
}
|
||||
@@ -1406,14 +1416,10 @@ bool DeviceHandlerBase::commandIsExecuting(DeviceCommandId_t commandId) {
|
||||
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) {
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task){
|
||||
executingTask = task;
|
||||
}
|
||||
|
||||
// Default implementations empty.
|
||||
void DeviceHandlerBase::debugInterface(uint8_t positionTracker,
|
||||
object_id_t objectId, uint32_t parameter) {}
|
||||
|
||||
@@ -1490,7 +1496,7 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType,
|
||||
if(errorCode == ObjectManagerIF::CHILD_INIT_FAILED) {
|
||||
errorPrint = "Initialization error";
|
||||
}
|
||||
if(errorCode == HasReturnvaluesIF::RETURN_FAILED) {
|
||||
else if(errorCode == HasReturnvaluesIF::RETURN_FAILED) {
|
||||
if(errorType == sif::OutputTypes::OUT_WARNING) {
|
||||
errorPrint = "Generic Warning";
|
||||
}
|
||||
@@ -1502,27 +1508,29 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType,
|
||||
errorPrint = "Unknown error";
|
||||
}
|
||||
}
|
||||
if(functionName == nullptr) {
|
||||
functionName = "unknown function";
|
||||
}
|
||||
|
||||
if(errorType == sif::OutputTypes::OUT_WARNING) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "DeviceHandlerBase::" << functionName << ": Object ID "
|
||||
<< std::hex << std::setw(8) << std::setfill('0')
|
||||
<< this->getObjectId() << " | " << errorPrint << std::dec
|
||||
<< std::setfill(' ') << std::endl;
|
||||
sif::warning << "DeviceHandlerBase::" << functionName << ": Object ID 0x" << std::hex <<
|
||||
std::setw(8) << std::setfill('0') << this->getObjectId() << " | " << errorPrint <<
|
||||
std::dec << std::setfill(' ') << std::endl;
|
||||
#else
|
||||
sif::printWarning("DeviceHandlerBase::%s: Object ID 0x%08x | %s\n",
|
||||
this->getObjectId(), errorPrint);
|
||||
functionName, this->getObjectId(), errorPrint);
|
||||
#endif
|
||||
}
|
||||
else if(errorType == sif::OutputTypes::OUT_ERROR) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "DeviceHandlerBase::" << functionName << ": Object ID "
|
||||
sif::error << "DeviceHandlerBase::" << functionName << ": Object ID 0x"
|
||||
<< std::hex << std::setw(8) << std::setfill('0')
|
||||
<< this->getObjectId() << " | " << errorPrint << std::dec
|
||||
<< std::setfill(' ') << std::endl;
|
||||
#else
|
||||
sif::printError("DeviceHandlerBase::%s: Object ID 0x%08x | %s\n",
|
||||
this->getObjectId(), errorPrint);
|
||||
functionName, this->getObjectId(), errorPrint);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1531,3 +1539,11 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType,
|
||||
LocalDataPoolManager* DeviceHandlerBase::getHkManagerHandle() {
|
||||
return &poolManager;
|
||||
}
|
||||
|
||||
MessageQueueId_t DeviceHandlerBase::getCommanderId(DeviceCommandId_t replyId) const {
|
||||
auto commandIter = deviceCommandMap.find(replyId);
|
||||
if(commandIter == deviceCommandMap.end()) {
|
||||
return MessageQueueIF::NO_QUEUE;
|
||||
}
|
||||
return commandIter->second.sendReplyTo;
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include "../action/ActionHelper.h"
|
||||
#include "../health/HealthHelper.h"
|
||||
#include "../parameters/ParameterHelper.h"
|
||||
#include "../datapool/HkSwitchHelper.h"
|
||||
#include "../datapoollocal/HasLocalDataPoolIF.h"
|
||||
#include "../datapoollocal/LocalDataPoolManager.h"
|
||||
|
||||
@@ -148,8 +147,7 @@ public:
|
||||
* 4. Decrements counter for timeout of replies by calling
|
||||
* decrementDeviceReplyMap()
|
||||
* 5. Performs FDIR check for failures
|
||||
* 6. Calls hkSwitcher.performOperation()
|
||||
* 7. If the device mode is MODE_OFF, return RETURN_OK.
|
||||
* 6. If the device mode is MODE_OFF, return RETURN_OK.
|
||||
* Otherwise, perform the Action property and performs depending
|
||||
* on value specified by input value counter (incremented in PST).
|
||||
* The child class tells base class what to do by setting this value.
|
||||
@@ -189,6 +187,37 @@ public:
|
||||
/** Destructor. */
|
||||
virtual ~DeviceHandlerBase();
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of ExecutableObjectIF function
|
||||
* Used to setup the reference of the task, that executes this component
|
||||
* @param task_ Pointer to the taskIF of this task
|
||||
*/
|
||||
virtual void setTaskIF(PeriodicTaskIF* task_) override;
|
||||
virtual MessageQueueId_t getCommandQueue(void) const override;
|
||||
|
||||
/** Explicit interface implementation of getObjectId */
|
||||
virtual object_id_t getObjectId() const override;
|
||||
|
||||
/**
|
||||
* @param parentQueueId
|
||||
*/
|
||||
virtual void setParentQueue(MessageQueueId_t parentQueueId);
|
||||
|
||||
/** @brief Implementation required for HasActionIF */
|
||||
ReturnValue_t executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t* data,
|
||||
size_t size) override;
|
||||
|
||||
Mode_t getTransitionSourceMode() const;
|
||||
Submode_t getTransitionSourceSubMode() const;
|
||||
virtual void getMode(Mode_t *mode, Submode_t *submode);
|
||||
HealthState getHealth();
|
||||
ReturnValue_t setHealth(HealthState health);
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
|
||||
uint16_t startAtIndex) override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief This is used to let the child class handle the transition from
|
||||
@@ -216,7 +245,6 @@ protected:
|
||||
* for a failed transition
|
||||
*/
|
||||
virtual void doStartUp() = 0;
|
||||
|
||||
/**
|
||||
* @brief This is used to let the child class handle the transition
|
||||
* from mode @c _MODE_SHUT_DOWN to @c _MODE_POWER_DOWN
|
||||
@@ -242,6 +270,7 @@ protected:
|
||||
*/
|
||||
virtual void doShutDown() = 0;
|
||||
|
||||
/* Command handling */
|
||||
/**
|
||||
* Build the device command to send for normal mode.
|
||||
*
|
||||
@@ -262,7 +291,6 @@ protected:
|
||||
* - Anything else triggers an even with the returnvalue as a parameter.
|
||||
*/
|
||||
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) = 0;
|
||||
|
||||
/**
|
||||
* Build the device command to send for a transitional mode.
|
||||
*
|
||||
@@ -286,29 +314,35 @@ protected:
|
||||
* - Anything else triggers an even with the returnvalue as a parameter
|
||||
*/
|
||||
virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) = 0;
|
||||
|
||||
/**
|
||||
* @brief Build a device command packet from data supplied by a
|
||||
* direct command.
|
||||
*
|
||||
* @brief Build a device command packet from data supplied by a direct
|
||||
* command (PUS Service 8)
|
||||
* @details
|
||||
* #rawPacket and #rawPacketLen should be set by this method to the packet
|
||||
* to be sent. The existence of the command in the command map and the
|
||||
* command size check against 0 are done by the base class.
|
||||
* This will be called if an functional command via PUS Service 8 is received and is
|
||||
* the primary interface for functional command instead of #executeAction for users. The
|
||||
* supplied ActionId_t action ID will be converted to a DeviceCommandId_t command ID after
|
||||
* an internal check whether the action ID is a key in the device command map.
|
||||
*
|
||||
* @param deviceCommand the command to build, already checked against
|
||||
* deviceCommandMap
|
||||
* @param commandData pointer to the data from the direct command
|
||||
* @param commandDataLen length of commandData
|
||||
* #rawPacket and #rawPacketLen should be set by this method to the packet to be sent.
|
||||
* The existence of the command in the command map and the command size check against 0 are
|
||||
* done by the base class.
|
||||
*
|
||||
* @param deviceCommand The command to build, already checked against deviceCommandMap
|
||||
* @param commandData Pointer to the data from the direct command
|
||||
* @param commandDataLen Length of commandData
|
||||
* @return
|
||||
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen
|
||||
* have been set.
|
||||
* - Anything else triggers an event with the
|
||||
* returnvalue as a parameter
|
||||
* - @c HasActionsIF::EXECUTION_COMPLETE to generate a finish reply immediately. This can
|
||||
* be used if no reply is expected. Otherwise, the developer can call #actionHelper.finish
|
||||
* to finish the command handling.
|
||||
* - Anything else triggers an event with the return code as a parameter as well as a
|
||||
* step reply failed with the return code
|
||||
*/
|
||||
virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t * commandData, size_t commandDataLen) = 0;
|
||||
|
||||
/* Reply handling */
|
||||
/**
|
||||
* @brief Scans a buffer for a valid reply.
|
||||
* @details
|
||||
@@ -344,7 +378,6 @@ protected:
|
||||
*/
|
||||
virtual ReturnValue_t scanForReply(const uint8_t *start, size_t len,
|
||||
DeviceCommandId_t *foundId, size_t *foundLen) = 0;
|
||||
|
||||
/**
|
||||
* @brief Interpret a reply from the device.
|
||||
* @details
|
||||
@@ -366,10 +399,19 @@ protected:
|
||||
*/
|
||||
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t *packet) = 0;
|
||||
|
||||
MessageQueueId_t getCommanderId(DeviceCommandId_t replyId) const;
|
||||
/**
|
||||
* @brief fill the #DeviceCommandMap and #DeviceReplyMap
|
||||
* called by the initialize() of the base class
|
||||
* Helper function to get pending command. This is useful for devices
|
||||
* like SPI sensors to identify the last sent command.
|
||||
* This only returns the command sent in the last SEND_WRITE cycle.
|
||||
* @return
|
||||
*/
|
||||
DeviceCommandId_t getPendingCommand() const;
|
||||
|
||||
/* Specifying commands and replies */
|
||||
/**
|
||||
* @brief Fill the #DeviceCommandMap and #DeviceReplyMap called by the #initialize
|
||||
* of the base class
|
||||
* @details
|
||||
* This is used to let the base class know which replies are expected.
|
||||
* There are different scenarios regarding this:
|
||||
@@ -399,7 +441,6 @@ protected:
|
||||
* handled by returning @c APERIODIC_REPLY in scanForReply().
|
||||
*/
|
||||
virtual void fillCommandAndReplyMap() = 0;
|
||||
|
||||
/**
|
||||
* This is a helper method to facilitate inserting entries in the command map.
|
||||
* @param deviceCommand Identifier of the command to add.
|
||||
@@ -417,7 +458,6 @@ protected:
|
||||
LocalPoolDataSetBase* replyDataSet = nullptr,
|
||||
size_t replyLen = 0, bool periodic = false,
|
||||
bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0);
|
||||
|
||||
/**
|
||||
* @brief This is a helper method to insert replies in the reply map.
|
||||
* @param deviceCommand Identifier of the reply to add.
|
||||
@@ -439,6 +479,19 @@ protected:
|
||||
* - @c RETURN_FAILED else.
|
||||
*/
|
||||
ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand);
|
||||
|
||||
/**
|
||||
* @brief This function returns the reply length of the next reply to read.
|
||||
*
|
||||
* @param deviceCommand The command which triggered the device reply.
|
||||
*
|
||||
* @details The default implementation assumes only one reply is triggered by the command. In
|
||||
* case the command triggers multiple replies (e.g. one acknowledgment, one data,
|
||||
* and one execution status reply), this function can be overwritten to get the
|
||||
* reply length of the next reply to read.
|
||||
*/
|
||||
virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand);
|
||||
|
||||
/**
|
||||
* @brief This is a helper method to facilitate updating entries
|
||||
* in the reply map.
|
||||
@@ -457,25 +510,14 @@ protected:
|
||||
ReturnValue_t updateReplyMapEntry(DeviceCommandId_t deviceReply,
|
||||
uint16_t delayCycles, uint16_t maxDelayCycles,
|
||||
bool periodic = false);
|
||||
|
||||
/**
|
||||
* @brief Can be used to set the dataset corresponding to a reply ID manually.
|
||||
* @details
|
||||
* Used by the local data pool manager.
|
||||
*/
|
||||
ReturnValue_t setReplyDataset(DeviceCommandId_t replyId,
|
||||
LocalPoolDataSetBase* dataset);
|
||||
|
||||
/**
|
||||
* @brief Can be implemented by child handler to
|
||||
* perform debugging
|
||||
* @details Example: Calling this in performOperation
|
||||
* to track values like mode.
|
||||
* @param positionTracker Provide the child handler a way to know
|
||||
* where the debugInterface was called
|
||||
* @param objectId Provide the child handler object Id to
|
||||
* specify actions for spefic devices
|
||||
* @param parameter Supply a parameter of interest
|
||||
* Please delete all debugInterface calls in DHB after debugging is finished !
|
||||
*/
|
||||
virtual void debugInterface(uint8_t positionTracker = 0,
|
||||
object_id_t objectId = 0, uint32_t parameter = 0);
|
||||
|
||||
/**
|
||||
* Get the time needed to transit from modeFrom to modeTo.
|
||||
*
|
||||
@@ -494,6 +536,73 @@ protected:
|
||||
*/
|
||||
virtual uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) = 0;
|
||||
|
||||
/* Functions used by the local data pool manager */
|
||||
/**
|
||||
* This function is used to initialize the local housekeeping pool
|
||||
* entries. The default implementation leaves the pool empty.
|
||||
* @param localDataPoolMap
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
/**
|
||||
* @brief Set all datapool variables that are update periodically in
|
||||
* normal mode invalid
|
||||
* @details
|
||||
* The default implementation will set all datasets which have been added
|
||||
* in #fillCommandAndReplyMap to invalid. It will also set all pool
|
||||
* variables inside the dataset to invalid. The user can override this
|
||||
* method optionally.
|
||||
*/
|
||||
virtual void setNormalDatapoolEntriesInvalid();
|
||||
/**
|
||||
* @brief Get the dataset handle for a given SID.
|
||||
* @details
|
||||
* The default implementation will use the deviceCommandMap to look for the corresponding
|
||||
* dataset handle. The user can override this function if this is not desired.
|
||||
* @param sid
|
||||
* @return
|
||||
*/
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
|
||||
/* HasModesIF overrides */
|
||||
virtual void startTransition(Mode_t mode, Submode_t submode) override;
|
||||
virtual void setToExternalControl() override;
|
||||
virtual void announceMode(bool recursive) override;
|
||||
/**
|
||||
* @brief Set the device handler mode
|
||||
* @details
|
||||
* Sets #timeoutStart with every call Also sets #transitionTargetMode if necessary so
|
||||
* transitional states can be entered from everywhere without breaking the state machine
|
||||
* (which relies on a correct #transitionTargetMode).
|
||||
* The submode is left unchanged.
|
||||
*
|
||||
* @param newMode
|
||||
*/
|
||||
void setMode(Mode_t newMode);
|
||||
/**
|
||||
* @overload
|
||||
* @param submode
|
||||
*/
|
||||
void setMode(Mode_t newMode, Submode_t submode);
|
||||
/**
|
||||
* @brief Should be implemented properly by child class.
|
||||
* @param mode
|
||||
* @param submode
|
||||
* @return
|
||||
* - @c RETURN_OK if valid
|
||||
* - @c RETURN_FAILED if invalid
|
||||
*/
|
||||
virtual ReturnValue_t isModeCombinationValid(Mode_t mode,
|
||||
Submode_t submode);
|
||||
/**
|
||||
* @brief Notify child about mode change.
|
||||
* @details
|
||||
* Can be overriden to be used like a callback.
|
||||
*/
|
||||
virtual void modeChanged();
|
||||
|
||||
/* Power handling functions */
|
||||
/**
|
||||
* Return the switches connected to the device.
|
||||
*
|
||||
@@ -509,82 +618,60 @@ protected:
|
||||
uint8_t *numberOfSwitches);
|
||||
|
||||
/**
|
||||
* This function is used to initialize the local housekeeping pool
|
||||
* entries. The default implementation leaves the pool empty.
|
||||
* @param localDataPoolMap
|
||||
* @return
|
||||
* @brief Helper function to report a missed reply
|
||||
* @details Can be overwritten by children to act on missed replies or to fake reporting Id.
|
||||
* @param id of the missed reply
|
||||
*/
|
||||
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
|
||||
/**
|
||||
* Required for HasLocalDataPoolIF, return a handle to the local pool manager.
|
||||
* @return
|
||||
*/
|
||||
LocalDataPoolManager* getHkManagerHandle() override;
|
||||
virtual void missedReply(DeviceCommandId_t id);
|
||||
|
||||
/* Miscellaneous functions */
|
||||
/**
|
||||
* @brief Hook function for child handlers which is called once per
|
||||
* performOperation(). Default implementation is empty.
|
||||
*/
|
||||
virtual void performOperationHook();
|
||||
|
||||
public:
|
||||
/** Explicit interface implementation of getObjectId */
|
||||
virtual object_id_t getObjectId() const override;
|
||||
|
||||
/**
|
||||
* @param parentQueueId
|
||||
* @brief Can be implemented by child handler to
|
||||
* perform debugging
|
||||
* @details Example: Calling this in performOperation
|
||||
* to track values like mode.
|
||||
* @param positionTracker Provide the child handler a way to know
|
||||
* where the debugInterface was called
|
||||
* @param objectId Provide the child handler object Id to
|
||||
* specify actions for spefic devices
|
||||
* @param parameter Supply a parameter of interest
|
||||
* Please delete all debugInterface calls in DHB after debugging is finished !
|
||||
*/
|
||||
virtual void setParentQueue(MessageQueueId_t parentQueueId);
|
||||
|
||||
/** @brief Implementation required for HasActionIF */
|
||||
ReturnValue_t executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t* data,
|
||||
size_t size) override;
|
||||
|
||||
Mode_t getTransitionSourceMode() const;
|
||||
Submode_t getTransitionSourceSubMode() const;
|
||||
virtual void getMode(Mode_t *mode, Submode_t *submode);
|
||||
HealthState getHealth();
|
||||
ReturnValue_t setHealth(HealthState health);
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) override;
|
||||
/**
|
||||
* Implementation of ExecutableObjectIF function
|
||||
*
|
||||
* Used to setup the reference of the task, that executes this component
|
||||
* @param task_ Pointer to the taskIF of this task
|
||||
*/
|
||||
virtual void setTaskIF(PeriodicTaskIF* task_);
|
||||
virtual MessageQueueId_t getCommandQueue(void) const;
|
||||
virtual void debugInterface(uint8_t positionTracker = 0,
|
||||
object_id_t objectId = 0, uint32_t parameter = 0);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The Returnvalues id of this class, required by HasReturnvaluesIF
|
||||
*/
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE;
|
||||
|
||||
static const ReturnValue_t INVALID_CHANNEL = MAKE_RETURN_CODE(0xA0);
|
||||
// Returnvalues for scanForReply()
|
||||
static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(0xB0); //!< This is used to specify for replies from a device which are not replies to requests
|
||||
static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(0xB1); //!< Ignore parts of the received packet
|
||||
static const ReturnValue_t IGNORE_FULL_PACKET = MAKE_RETURN_CODE(0xB2); //!< Ignore full received packet
|
||||
// Returnvalues for command building
|
||||
static const ReturnValue_t NOTHING_TO_SEND = MAKE_RETURN_CODE(0xC0); //!< Return this if no command sending in required
|
||||
/* Return codes for scanForReply */
|
||||
//! This is used to specify for replies from a device which are not replies to requests
|
||||
static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(0xB0);
|
||||
//! Ignore parts of the received packet
|
||||
static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(0xB1);
|
||||
//! Ignore full received packet
|
||||
static const ReturnValue_t IGNORE_FULL_PACKET = MAKE_RETURN_CODE(0xB2);
|
||||
/* Return codes for command building */
|
||||
//! Return this if no command sending in required
|
||||
static const ReturnValue_t NOTHING_TO_SEND = MAKE_RETURN_CODE(0xC0);
|
||||
static const ReturnValue_t COMMAND_MAP_ERROR = MAKE_RETURN_CODE(0xC2);
|
||||
// Returnvalues for getSwitches()
|
||||
// Return codes for getSwitches */
|
||||
static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(0xD0);
|
||||
// Mode handling error Codes
|
||||
/* Mode handling error Codes */
|
||||
static const ReturnValue_t CHILD_TIMEOUT = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t SWITCH_FAILED = MAKE_RETURN_CODE(0xE1);
|
||||
|
||||
static const MessageQueueId_t NO_COMMANDER = 0;
|
||||
|
||||
/** Pointer to the raw packet that will be sent.*/
|
||||
//! Pointer to the raw packet that will be sent.
|
||||
uint8_t *rawPacket = nullptr;
|
||||
/** Size of the #rawPacket. */
|
||||
//! Size of the #rawPacket.
|
||||
uint32_t rawPacketLen = 0;
|
||||
|
||||
/**
|
||||
@@ -642,15 +729,15 @@ protected:
|
||||
/** Cookie used for communication */
|
||||
CookieIF * comCookie;
|
||||
|
||||
/** Health helper for HasHealthIF */
|
||||
/* Health helper for HasHealthIF */
|
||||
HealthHelper healthHelper;
|
||||
/** Mode helper for HasModesIF */
|
||||
/* Mode helper for HasModesIF */
|
||||
ModeHelper modeHelper;
|
||||
/** Parameter helper for ReceivesParameterMessagesIF */
|
||||
/* Parameter helper for ReceivesParameterMessagesIF */
|
||||
ParameterHelper parameterHelper;
|
||||
/** Action helper for HasActionsIF */
|
||||
/* Action helper for HasActionsIF */
|
||||
ActionHelper actionHelper;
|
||||
/** Housekeeping Manager */
|
||||
/* Housekeeping Manager */
|
||||
LocalDataPoolManager poolManager;
|
||||
|
||||
/**
|
||||
@@ -733,88 +820,41 @@ protected:
|
||||
* default class is instantiated. */
|
||||
FailureIsolationBase* fdirInstance;
|
||||
|
||||
HkSwitchHelper hkSwitcher;
|
||||
//! To correctly delete the default instance.
|
||||
bool defaultFDIRUsed;
|
||||
|
||||
bool defaultFDIRUsed; //!< To correctly delete the default instance.
|
||||
//! Indicates if SWITCH_WENT_OFF was already thrown.
|
||||
bool switchOffWasReported;
|
||||
|
||||
bool switchOffWasReported; //!< Indicates if SWITCH_WENT_OFF was already thrown.
|
||||
|
||||
//! Pointer to the task which executes this component, is invalid
|
||||
//! before setTaskIF was called.
|
||||
/** Pointer to the task which executes this component,
|
||||
is invalid before setTaskIF was called. */
|
||||
PeriodicTaskIF* executingTask = nullptr;
|
||||
|
||||
//!< Object which switches power on and off.
|
||||
//! Object which switches power on and off.
|
||||
static object_id_t powerSwitcherId;
|
||||
|
||||
//!< Object which receives RAW data by default.
|
||||
//! Object which receives RAW data by default.
|
||||
static object_id_t rawDataReceiverId;
|
||||
|
||||
//!< Object which may be the root cause of an identified fault.
|
||||
//! Object which may be the root cause of an identified fault.
|
||||
static object_id_t defaultFdirParentId;
|
||||
|
||||
/**
|
||||
* @brief Set all datapool variables that are update periodically in
|
||||
* normal mode invalid
|
||||
* @details
|
||||
* The default implementation will set all datasets which have been added
|
||||
* in #fillCommandAndReplyMap to invalid. It will also set all pool
|
||||
* variables inside the dataset to invalid. The user can override this
|
||||
* method optionally.
|
||||
*/
|
||||
virtual void setNormalDatapoolEntriesInvalid();
|
||||
|
||||
/**
|
||||
* Helper function to get pending command. This is useful for devices
|
||||
* like SPI sensors to identify the last sent command.
|
||||
* This only returns the command sent in the last SEND_WRITE cycle.
|
||||
* @return
|
||||
*/
|
||||
DeviceCommandId_t getPendingCommand() const;
|
||||
|
||||
/**
|
||||
* Helper function to report a missed reply
|
||||
*
|
||||
* Can be overwritten by children to act on missed replies or to fake
|
||||
* reporting Id.
|
||||
*
|
||||
* @param id of the missed reply
|
||||
*/
|
||||
virtual void missedReply(DeviceCommandId_t id);
|
||||
|
||||
/**
|
||||
* Send a reply to a received device handler command.
|
||||
* @brief Send a reply to a received device handler command.
|
||||
*
|
||||
* This also resets #DeviceHandlerCommand to 0.
|
||||
*
|
||||
* @param reply the reply type
|
||||
* @param parameter parameter for the reply
|
||||
*/
|
||||
void replyReturnvalueToCommand(ReturnValue_t status,
|
||||
uint32_t parameter = 0);
|
||||
|
||||
void replyReturnvalueToCommand(ReturnValue_t status, uint32_t parameter = 0);
|
||||
/**
|
||||
* TODO: Whats the difference between this and the upper command?
|
||||
* @param status
|
||||
* @param parameter
|
||||
*/
|
||||
void replyToCommand(ReturnValue_t status, uint32_t parameter = 0);
|
||||
|
||||
/**
|
||||
* Set the device handler mode
|
||||
*
|
||||
* Sets #timeoutStart with every call.
|
||||
*
|
||||
* Sets #transitionTargetMode if necessary so transitional states can be
|
||||
* entered from everywhere without breaking the state machine
|
||||
* (which relies on a correct #transitionTargetMode).
|
||||
*
|
||||
* The submode is left unchanged.
|
||||
*
|
||||
* @param newMode
|
||||
*/
|
||||
void setMode(Mode_t newMode);
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param submode
|
||||
*/
|
||||
void setMode(Mode_t newMode, Submode_t submode);
|
||||
|
||||
/**
|
||||
* Do the transition to the main modes (MODE_ON, MODE_NORMAL and MODE_RAW).
|
||||
*
|
||||
@@ -856,16 +896,6 @@ protected:
|
||||
*/
|
||||
virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom);
|
||||
|
||||
/**
|
||||
* @param mode
|
||||
* @param submode
|
||||
* @return
|
||||
* - @c RETURN_OK if valid
|
||||
* - @c RETURN_FAILED if invalid
|
||||
*/
|
||||
virtual ReturnValue_t isModeCombinationValid(Mode_t mode,
|
||||
Submode_t submode);
|
||||
|
||||
/**
|
||||
* Get the communication action for the current step.
|
||||
* The step number can be read from #pstStep.
|
||||
@@ -874,27 +904,28 @@ protected:
|
||||
virtual CommunicationAction getComAction();
|
||||
|
||||
/**
|
||||
* Build the device command to send for raw mode.
|
||||
*
|
||||
* This is only called in @c MODE_RAW. It is for the rare case that in
|
||||
* raw mode packets are to be sent by the handler itself. It is NOT needed
|
||||
* for the raw commanding service. Its only current use is in the STR
|
||||
* handler which gets its raw packets from a different source.
|
||||
* Also it can be used for transitional commands, to get the device ready
|
||||
* for @c MODE_RAW
|
||||
*
|
||||
* As it is almost never used, there is a default implementation
|
||||
* returning @c NOTHING_TO_SEND.
|
||||
*
|
||||
* #rawPacket and #rawPacketLen must be set by this method to the packet
|
||||
* to be sent.
|
||||
*
|
||||
* @param[out] id the device command id built
|
||||
* @return
|
||||
* - @c RETURN_OK when a command is to be sent
|
||||
* - not @c NOTHING_TO_SEND when no command is to be sent
|
||||
* Checks state of switches in conjunction with mode and triggers an event
|
||||
* if they don't fit.
|
||||
*/
|
||||
virtual ReturnValue_t buildChildRawCommand();
|
||||
virtual void checkSwitchState();
|
||||
|
||||
/**
|
||||
* Reserved for the rare case where a device needs to perform additional
|
||||
* operation cyclically in OFF mode.
|
||||
*/
|
||||
virtual void doOffActivity();
|
||||
|
||||
/**
|
||||
* Reserved for the rare case where a device needs to perform additional
|
||||
* operation cyclically in ON mode.
|
||||
*/
|
||||
virtual void doOnActivity();
|
||||
|
||||
/**
|
||||
* Required for HasLocalDataPoolIF, return a handle to the local pool manager.
|
||||
* @return
|
||||
*/
|
||||
LocalDataPoolManager* getHkManagerHandle() override;
|
||||
|
||||
/**
|
||||
* Returns the delay cycle count of a reply.
|
||||
@@ -906,24 +937,6 @@ protected:
|
||||
*/
|
||||
uint8_t getReplyDelayCycles(DeviceCommandId_t deviceCommand);
|
||||
|
||||
/**
|
||||
* Construct a command reply containing a raw reply.
|
||||
*
|
||||
* It gets space in the #IPCStore, copies data there, then sends a raw reply
|
||||
* containing the store address.
|
||||
*
|
||||
* This method is virtual, as devices can have different channels to send
|
||||
* raw replies
|
||||
*
|
||||
* @param data data to send
|
||||
* @param len length of @c data
|
||||
* @param sendTo the messageQueueId of the one to send to
|
||||
* @param isCommand marks the raw data as a command, the message then
|
||||
* will be of type raw_command
|
||||
*/
|
||||
virtual void replyRawData(const uint8_t *data, size_t len,
|
||||
MessageQueueId_t sendTo, bool isCommand = false);
|
||||
|
||||
/**
|
||||
* Calls replyRawData() with #defaultRawReceiver, but checks if wiretapping
|
||||
* is active and if so, does not send the data as the wiretapping will have
|
||||
@@ -931,11 +944,6 @@ protected:
|
||||
*/
|
||||
void replyRawReplyIfnotWiretapped(const uint8_t *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Notify child about mode change.
|
||||
*/
|
||||
virtual void modeChanged(void);
|
||||
|
||||
/**
|
||||
* Enable the reply checking for a command
|
||||
*
|
||||
@@ -959,10 +967,49 @@ protected:
|
||||
* - NO_REPLY_EXPECTED if there was no reply found. This is not an
|
||||
* error case as many commands do not expect a reply.
|
||||
*/
|
||||
virtual ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator cmd,
|
||||
virtual ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
||||
uint8_t expectedReplies = 1, bool useAlternateId = false,
|
||||
DeviceCommandId_t alternateReplyID = 0);
|
||||
|
||||
/**
|
||||
* @brief Build the device command to send for raw mode.
|
||||
* @details
|
||||
* This is only called in @c MODE_RAW. It is for the rare case that in
|
||||
* raw mode packets are to be sent by the handler itself. It is NOT needed
|
||||
* for the raw commanding service. Its only current use is in the STR
|
||||
* handler which gets its raw packets from a different source.
|
||||
* Also it can be used for transitional commands, to get the device ready
|
||||
* for @c MODE_RAW
|
||||
*
|
||||
* As it is almost never used, there is a default implementation
|
||||
* returning @c NOTHING_TO_SEND.
|
||||
*
|
||||
* #rawPacket and #rawPacketLen must be set by this method to the packet
|
||||
* to be sent.
|
||||
*
|
||||
* @param[out] id the device command id built
|
||||
* @return
|
||||
* - @c RETURN_OK when a command is to be sent
|
||||
* - not @c NOTHING_TO_SEND when no command is to be sent
|
||||
*/
|
||||
virtual ReturnValue_t buildChildRawCommand();
|
||||
|
||||
/**
|
||||
* @brief Construct a command reply containing a raw reply.
|
||||
* @details
|
||||
* It gets space in the #IPCStore, copies data there, then sends a raw reply
|
||||
* containing the store address. This method is virtual, as devices can have different channels
|
||||
* to send raw replies
|
||||
*
|
||||
* @param data data to send
|
||||
* @param len length of @c data
|
||||
* @param sendTo the messageQueueId of the one to send to
|
||||
* @param isCommand marks the raw data as a command, the message then
|
||||
* will be of type raw_command
|
||||
*/
|
||||
virtual void replyRawData(const uint8_t *data, size_t len,
|
||||
MessageQueueId_t sendTo, bool isCommand = false);
|
||||
|
||||
/**
|
||||
* Get the state of the PCDU switches in the local datapool
|
||||
* @return
|
||||
@@ -972,12 +1019,7 @@ protected:
|
||||
* #switches are off
|
||||
* - @c PowerSwitchIF::RETURN_FAILED if an error occured
|
||||
*/
|
||||
ReturnValue_t getStateOfSwitches(void);
|
||||
|
||||
/**
|
||||
* build a list of sids and pass it to the #hkSwitcher
|
||||
*/
|
||||
virtual void changeHK(Mode_t mode, Submode_t submode, bool enable);
|
||||
ReturnValue_t getStateOfSwitches();
|
||||
|
||||
/**
|
||||
* Children can overwrite this function to suppress checking of the
|
||||
@@ -995,17 +1037,14 @@ protected:
|
||||
|
||||
bool isAwaitingReply();
|
||||
|
||||
void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t commandId,
|
||||
bool neverInDataPool = false, bool forceDirectTm = false);
|
||||
void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId,
|
||||
bool forceDirectTm = false);
|
||||
// void handleDeviceTM(uint8_t* data, size_t dataSize, DeviceCommandId_t replyId,
|
||||
// bool forceDirectTm);
|
||||
|
||||
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode);
|
||||
|
||||
/* HasModesIF overrides */
|
||||
virtual void startTransition(Mode_t mode, Submode_t submode) override;
|
||||
virtual void setToExternalControl() override;
|
||||
virtual void announceMode(bool recursive) override;
|
||||
|
||||
virtual ReturnValue_t letChildHandleMessage(CommandMessage *message);
|
||||
|
||||
/**
|
||||
@@ -1023,23 +1062,6 @@ protected:
|
||||
*/
|
||||
virtual void forwardEvent(Event event, uint32_t parameter1 = 0,
|
||||
uint32_t parameter2 = 0) const;
|
||||
/**
|
||||
* Checks state of switches in conjunction with mode and triggers an event
|
||||
* if they don't fit.
|
||||
*/
|
||||
virtual void checkSwitchState();
|
||||
|
||||
/**
|
||||
* Reserved for the rare case where a device needs to perform additional
|
||||
* operation cyclically in OFF mode.
|
||||
*/
|
||||
virtual void doOffActivity();
|
||||
|
||||
/**
|
||||
* Reserved for the rare case where a device needs to perform additional
|
||||
* operation cyclically in ON mode.
|
||||
*/
|
||||
virtual void doOnActivity();
|
||||
|
||||
/**
|
||||
* Checks if current mode is transitional mode.
|
||||
@@ -1062,6 +1084,7 @@ protected:
|
||||
* @param onOff on == @c SWITCH_ON; off != @c SWITCH_ON
|
||||
*/
|
||||
void commandSwitch(ReturnValue_t onOff);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -1151,7 +1174,6 @@ private:
|
||||
|
||||
void buildRawDeviceCommand(CommandMessage* message);
|
||||
void buildInternalCommand(void);
|
||||
|
||||
/**
|
||||
* Decrement the counter for the timout of replies.
|
||||
*
|
||||
@@ -1159,7 +1181,6 @@ private:
|
||||
* reply has timed out (that means a reply was expected but not received).
|
||||
*/
|
||||
void decrementDeviceReplyMap(void);
|
||||
|
||||
/**
|
||||
* Convenience function to handle a reply.
|
||||
*
|
||||
@@ -1174,8 +1195,8 @@ private:
|
||||
* @foundLen the length of the packet
|
||||
*/
|
||||
void handleReply(const uint8_t *data, DeviceCommandId_t id, uint32_t foundLen);
|
||||
|
||||
void replyToReply(DeviceReplyMap::iterator iter, ReturnValue_t status);
|
||||
|
||||
/**
|
||||
* Build and send a command to the device.
|
||||
*
|
||||
@@ -1190,7 +1211,6 @@ private:
|
||||
* sends the command via RMAP.
|
||||
*/
|
||||
void doSendWrite(void);
|
||||
|
||||
/**
|
||||
* Check if the RMAP sendWrite action was successful.
|
||||
*
|
||||
@@ -1200,7 +1220,6 @@ private:
|
||||
* - if the action was successful, the reply timout counter is initialized
|
||||
*/
|
||||
void doGetWrite(void);
|
||||
|
||||
/**
|
||||
* Send a RMAP getRead command.
|
||||
*
|
||||
@@ -1208,7 +1227,6 @@ private:
|
||||
* This is always executed, independently from the current mode.
|
||||
*/
|
||||
void doSendRead(void);
|
||||
|
||||
/**
|
||||
* Check the getRead reply and the contained data.
|
||||
*
|
||||
@@ -1238,14 +1256,12 @@ private:
|
||||
void setTransition(Mode_t modeTo, Submode_t submodeTo);
|
||||
|
||||
/**
|
||||
* calls the right child function for the transitional submodes
|
||||
* Calls the right child function for the transitional submodes
|
||||
*/
|
||||
void callChildStatemachine();
|
||||
|
||||
ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message);
|
||||
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
|
||||
virtual dur_millis_t getPeriodicOperationFrequency() const override;
|
||||
|
||||
void parseReply(const uint8_t* receivedData,
|
||||
@@ -1254,6 +1270,13 @@ private:
|
||||
void handleTransitionToOnMode(Mode_t commandedMode,
|
||||
Submode_t commandedSubmode);
|
||||
|
||||
/**
|
||||
* Generic internal printer function which also handles printing the object ID.
|
||||
* @param errorType
|
||||
* @param functionName
|
||||
* @param errorCode
|
||||
* @param errorPrint
|
||||
*/
|
||||
void printWarningOrError(sif::OutputTypes errorType,
|
||||
const char* functionName,
|
||||
ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED,
|
||||
|
@@ -209,20 +209,20 @@ void DeviceHandlerFailureIsolation::startRecovery(Event reason) {
|
||||
}
|
||||
|
||||
ReturnValue_t DeviceHandlerFailureIsolation::getParameter(uint8_t domainId,
|
||||
uint16_t parameterId, ParameterWrapper* parameterWrapper,
|
||||
uint8_t uniqueId, ParameterWrapper* parameterWrapper,
|
||||
const ParameterWrapper* newValues, uint16_t startAtIndex) {
|
||||
ReturnValue_t result = strangeReplyCount.getParameter(domainId, parameterId,
|
||||
ReturnValue_t result = strangeReplyCount.getParameter(domainId, uniqueId,
|
||||
parameterWrapper, newValues, startAtIndex);
|
||||
if (result != INVALID_DOMAIN_ID) {
|
||||
return result;
|
||||
}
|
||||
result = missedReplyCount.getParameter(domainId, parameterId,
|
||||
parameterWrapper, newValues, startAtIndex);
|
||||
result = missedReplyCount.getParameter(domainId, uniqueId, parameterWrapper, newValues,
|
||||
startAtIndex);
|
||||
if (result != INVALID_DOMAIN_ID) {
|
||||
return result;
|
||||
}
|
||||
result = recoveryCounter.getParameter(domainId, parameterId,
|
||||
parameterWrapper, newValues, startAtIndex);
|
||||
result = recoveryCounter.getParameter(domainId, uniqueId, parameterWrapper, newValues,
|
||||
startAtIndex);
|
||||
if (result != INVALID_DOMAIN_ID) {
|
||||
return result;
|
||||
}
|
||||
|
@@ -17,9 +17,9 @@ public:
|
||||
ReturnValue_t initialize();
|
||||
void triggerEvent(Event event, uint32_t parameter1 = 0,
|
||||
uint32_t parameter2 = 0);bool isFdirActionInProgress();
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex);
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
|
||||
uint16_t startAtIndex);
|
||||
|
||||
protected:
|
||||
FaultCounter strangeReplyCount;
|
||||
|
@@ -16,9 +16,9 @@ ReturnValue_t HealthDevice::performOperation(uint8_t opCode) {
|
||||
CommandMessage command;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
healthHelper.handleHealthCommand(&command);
|
||||
result = healthHelper.handleHealthCommand(&command);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t HealthDevice::initialize() {
|
||||
|
@@ -1,3 +1,172 @@
|
||||
## Local Data Pools
|
||||
## Local Data Pools Developer Information
|
||||
|
||||
The following text is targeted towards mission software developers which would like
|
||||
to use the local data pools provided by the FSFW to store data like sensor values so they can be
|
||||
used by other software objects like controllers as well. If a custom class should have a local
|
||||
pool which can be used by other software objects as well, following steps have to be performed:
|
||||
|
||||
1. Create a `LocalDataPoolManager` member object in the custom class
|
||||
2. Implement the `HasLocalDataPoolIF` with specifies the interface between the local pool manager
|
||||
and the class owning the local pool.
|
||||
|
||||
The local data pool manager is also able to process housekeeping service requests in form
|
||||
of messages, generate periodic housekeeping packet, generate notification and snapshots of changed
|
||||
variables and datasets and process notifications and snapshots coming from other objects.
|
||||
The two former tasks are related to the external interface using telemetry and telecommands (TMTC)
|
||||
while the later two are related to data consumers like controllers only acting on data change
|
||||
detected by the data creator instead of checking the data manually each cycle. Two important
|
||||
framework classes `DeviceHandlerBase` and `ExtendedControllerBase` already perform the two steps
|
||||
shown above so the steps required are altered slightly.
|
||||
|
||||
### Storing and Accessing pool data
|
||||
|
||||
The pool manager is responsible for thread-safe access of the pool data, but the actual
|
||||
access to the pool data from the point of view of a mission software developer happens via proxy
|
||||
classes like pool variable classes. These classes store a copy
|
||||
of the pool variable with the matching datatype and copy the actual data from the local pool
|
||||
on a `read` call. Changed variables can then be written to the local pool with a `commit` call.
|
||||
The `read` and `commit` calls are thread-safe and can be called concurrently from data creators
|
||||
and data consumers. Generally, a user will create a dataset class which in turn groups all
|
||||
cohesive pool variables. These sets simply iterator over the list of variables and call the
|
||||
`read` and `commit` functions of each variable. The following diagram shows the
|
||||
high-level architecture of the local data pools.
|
||||
|
||||
<img align="center" src="./images/PoolArchitecture.png" width="50%"> <br>
|
||||
|
||||
An example is shown for using the local data pools with a Gyroscope.
|
||||
For example, the following code shows an implementation to access data from a Gyroscope taken
|
||||
from the SOURCE CubeSat project:
|
||||
|
||||
```cpp
|
||||
class GyroPrimaryDataset: public StaticLocalDataSet<3 * sizeof(float)> {
|
||||
public:
|
||||
/**
|
||||
* Constructor for data users
|
||||
* @param gyroId
|
||||
*/
|
||||
GyroPrimaryDataset(object_id_t gyroId):
|
||||
StaticLocalDataSet(sid_t(gyroId, gyrodefs::GYRO_DATA_SET_ID)) {
|
||||
setAllVariablesReadOnly();
|
||||
}
|
||||
|
||||
lp_var_t<float> angVelocityX = lp_var_t<float>(sid.objectId,
|
||||
gyrodefs::ANGULAR_VELOCITY_X, this);
|
||||
lp_var_t<float> angVelocityY = lp_var_t<float>(sid.objectId,
|
||||
gyrodefs::ANGULAR_VELOCITY_Y, this);
|
||||
lp_var_t<float> angVelocityZ = lp_var_t<float>(sid.objectId,
|
||||
gyrodefs::ANGULAR_VELOCITY_Z, this);
|
||||
private:
|
||||
|
||||
friend class GyroHandler;
|
||||
/**
|
||||
* Constructor for data creator
|
||||
* @param hkOwner
|
||||
*/
|
||||
GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner):
|
||||
StaticLocalDataSet(hkOwner, gyrodefs::GYRO_DATA_SET_ID) {}
|
||||
};
|
||||
```
|
||||
|
||||
There is a public constructor for users which sets all variables to read-only and there is a
|
||||
constructor for the GyroHandler data creator by marking it private and declaring the `GyroHandler`
|
||||
as a friend class. Both the atittude controller and the `GyroHandler` can now
|
||||
use the same class definition to access the pool variables with `read` and `commit` semantics
|
||||
in a thread-safe way. Generally, each class requiring access will have the set class as a member
|
||||
class. The data creator will also be generally a `DeviceHandlerBase` subclass and some additional
|
||||
steps are necessary to expose the set for housekeeping purposes.
|
||||
|
||||
### Using the local data pools in a `DeviceHandlerBase` subclass
|
||||
|
||||
It is very common to store data generated by devices like a sensor into a pool which can
|
||||
then be used by other objects. Therefore, the `DeviceHandlerBase` already has a
|
||||
local pool. Using the aforementioned example, our `GyroHandler` will now have the set class
|
||||
as a member:
|
||||
|
||||
```cpp
|
||||
class GyroHandler: ... {
|
||||
|
||||
public:
|
||||
...
|
||||
private:
|
||||
...
|
||||
GyroPrimaryDataset gyroData;
|
||||
...
|
||||
};
|
||||
```
|
||||
|
||||
The constructor used for the creators expects the owner class as a parameter, so we initialize
|
||||
the object in the `GyroHandler` constructor like this:
|
||||
|
||||
```cpp
|
||||
GyroHandler::GyroHandler(object_id_t objectId, object_id_t comIF,
|
||||
CookieIF *comCookie, uint8_t switchId):
|
||||
DeviceHandlerBase(objectId, comIF, comCookie), switchId(switchId),
|
||||
gyroData(this) {}
|
||||
```
|
||||
|
||||
We need to assign the set to a reply ID used in the `DeviceHandlerBase`.
|
||||
The combination of the `GyroHandler` object ID and the reply ID will be the 64-bit structure ID
|
||||
`sid_t` and is used to globally identify the set, for example when requesting housekeeping data or
|
||||
generating update messages. We need to assign our custom set class in some way so that the local
|
||||
pool manager can access the custom data sets as well.
|
||||
By default, the `getDataSetHandle` will take care of this tasks. The default implementation for a
|
||||
`DeviceHandlerBase` subclass will use the internal command map to retrieve
|
||||
a handle to a dataset from a given reply ID. Therefore,
|
||||
we assign the set in the `fillCommandAndReplyMap` function:
|
||||
|
||||
```cpp
|
||||
void GyroHandler::fillCommandAndReplyMap() {
|
||||
...
|
||||
this->insertInCommandAndReplyMap(gyrodefs::GYRO_DATA, 3, &gyroData);
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Now, we need to create the actual pool entries as well, using the `initializeLocalDataPool`
|
||||
function. Here, we also immediately subscribe for periodic housekeeping packets
|
||||
with an interval of 4 seconds. They are still disabled in this example and can be enabled
|
||||
with a housekeeping service command.
|
||||
|
||||
```cpp
|
||||
ReturnValue_t GyroHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) {
|
||||
localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_X,
|
||||
new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_Y,
|
||||
new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_Z,
|
||||
new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(gyrodefs::GENERAL_CONFIG_REG42,
|
||||
new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(gyrodefs::RANGE_CONFIG_REG43,
|
||||
new PoolEntry<uint8_t>({0}));
|
||||
|
||||
poolManager.subscribeForPeriodicPacket(gyroData.getSid(), false, 4.0, false);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
```
|
||||
|
||||
Now, if we receive some sensor data and converted them into the right format,
|
||||
we can write it into the pool like this, using a guard class to ensure the set is commited back
|
||||
in any case:
|
||||
|
||||
```cpp
|
||||
PoolReadGuard readHelper(&gyroData);
|
||||
if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
|
||||
if(not gyroData.isValid()) {
|
||||
gyroData.setValidity(true, true);
|
||||
}
|
||||
|
||||
gyroData.angVelocityX = angularVelocityX;
|
||||
gyroData.angVelocityY = angularVelocityY;
|
||||
gyroData.angVelocityZ = angularVelocityZ;
|
||||
}
|
||||
```
|
||||
|
||||
The guard class will commit the changed data on destruction automatically.
|
||||
|
||||
### Using the local data pools in a `ExtendedControllerBase` subclass
|
||||
|
||||
Coming soon
|
||||
|
||||
|
||||
|
3
doc/doxy/.gitignore
vendored
Normal file
3
doc/doxy/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
html
|
||||
latex
|
||||
rtf
|
2609
doc/doxy/OPUS.doxyfile
Normal file
2609
doc/doxy/OPUS.doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
BIN
doc/images/PoolArchitecture.png
Normal file
BIN
doc/images/PoolArchitecture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
@@ -6,6 +6,7 @@
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../ipc/MutexFactory.h"
|
||||
|
||||
MessageQueueId_t EventManagerIF::eventmanagerQueue = MessageQueueIF::NO_QUEUE;
|
||||
|
||||
// If one checks registerListener calls, there are around 40 (to max 50)
|
||||
// objects registering for certain events.
|
||||
|
@@ -1,11 +1,12 @@
|
||||
#ifndef EVENTMANAGERIF_H_
|
||||
#define EVENTMANAGERIF_H_
|
||||
#ifndef FSFW_EVENTS_EVENTMANAGERIF_H_
|
||||
#define FSFW_EVENTS_EVENTMANAGERIF_H_
|
||||
|
||||
#include "EventMessage.h"
|
||||
#include "eventmatching/eventmatching.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
|
||||
class EventManagerIF {
|
||||
public:
|
||||
@@ -41,11 +42,19 @@ public:
|
||||
|
||||
static void triggerEvent(EventMessage* message,
|
||||
MessageQueueId_t sentFrom = 0) {
|
||||
static MessageQueueId_t eventmanagerQueue = MessageQueueIF::NO_QUEUE;
|
||||
if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) {
|
||||
EventManagerIF *eventmanager = objectManager->get<EventManagerIF>(
|
||||
objects::EVENT_MANAGER);
|
||||
if (eventmanager == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "EventManagerIF::triggerEvent: EventManager invalid or not found!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning("EventManagerIF::triggerEvent: "
|
||||
"EventManager invalid or not found!");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
return;
|
||||
}
|
||||
eventmanagerQueue = eventmanager->getEventReportQueue();
|
||||
@@ -53,6 +62,10 @@ public:
|
||||
MessageQueueSenderIF::sendMessage(eventmanagerQueue, message, sentFrom);
|
||||
}
|
||||
|
||||
private:
|
||||
//! Initialized by EventManager (C++11 does not allow header-only static member initialization).
|
||||
static MessageQueueId_t eventmanagerQueue;
|
||||
|
||||
};
|
||||
|
||||
#endif /* EVENTMANAGERIF_H_ */
|
||||
#endif /* FSFW_EVENTS_EVENTMANAGERIF_H_ */
|
||||
|
@@ -109,6 +109,6 @@ bool EventMessage::isClearedEventMessage() {
|
||||
return getEvent() == INVALID_EVENT;
|
||||
}
|
||||
|
||||
size_t EventMessage::getMinimumMessageSize() {
|
||||
size_t EventMessage::getMinimumMessageSize() const {
|
||||
return EVENT_MESSAGE_SIZE;
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ public:
|
||||
|
||||
protected:
|
||||
static const Event INVALID_EVENT = 0;
|
||||
virtual size_t getMinimumMessageSize();
|
||||
virtual size_t getMinimumMessageSize() const override;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -58,14 +58,14 @@ FaultCounter::FaultCounter() :
|
||||
parameterDomain(0), timer(), faultCount(0), failureThreshold(0) {
|
||||
}
|
||||
|
||||
ReturnValue_t FaultCounter::getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ReturnValue_t FaultCounter::getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||
ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues,
|
||||
uint16_t startAtIndex) {
|
||||
if (domainId != parameterDomain) {
|
||||
return INVALID_DOMAIN_ID;
|
||||
}
|
||||
|
||||
switch (parameterId) {
|
||||
switch (uniqueId) {
|
||||
case 0:
|
||||
parameterWrapper->set(failureThreshold);
|
||||
break;
|
||||
|
@@ -23,7 +23,7 @@ public:
|
||||
void setFailureThreshold(uint32_t failureThreshold);
|
||||
void setFaultDecrementTimeMs(uint32_t timeMs);
|
||||
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex);
|
||||
|
||||
|
@@ -7,6 +7,7 @@ target_sources(${LIB_FSFW_NAME}
|
||||
PeriodicOperationDivider.cpp
|
||||
timevalOperations.cpp
|
||||
Type.cpp
|
||||
bitutility.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(math)
|
@@ -2,16 +2,21 @@
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include <bitset>
|
||||
|
||||
|
||||
void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
|
||||
bool printInfo, size_t maxCharPerLine) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
if(printInfo) {
|
||||
sif::info << "Printing data with size " << size << ": ";
|
||||
sif::info << "Printing data with size " << size << ": " << std::endl;
|
||||
}
|
||||
sif::info << "[";
|
||||
#else
|
||||
sif::printInfo("Printing data with size %zu: [", size);
|
||||
#endif
|
||||
#if FSFW_NO_C99_IO == 1
|
||||
sif::printInfo("Printing data with size %lu: \n", static_cast<unsigned long>(size));
|
||||
#else
|
||||
sif::printInfo("Printing data with size %zu: \n", size);
|
||||
#endif /* FSFW_NO_C99_IO == 1 */
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
|
||||
if(type == OutputType::HEX) {
|
||||
arrayprinter::printHex(data, size, maxCharPerLine);
|
||||
}
|
||||
@@ -26,52 +31,99 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
|
||||
void arrayprinter::printHex(const uint8_t *data, size_t size,
|
||||
size_t maxCharPerLine) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << std::hex;
|
||||
if(sif::info.crAdditionEnabled()) {
|
||||
std::cout << "\r" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "[" << std::hex;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
sif::info << "0x" << static_cast<int>(data[i]);
|
||||
std::cout << "0x" << static_cast<int>(data[i]);
|
||||
if(i < size - 1) {
|
||||
sif::info << " , ";
|
||||
if(i > 0 and i % maxCharPerLine == 0) {
|
||||
sif::info << std::endl;
|
||||
std::cout << " , ";
|
||||
if(i > 0 and (i + 1) % maxCharPerLine == 0) {
|
||||
std::cout << std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
sif::info << std::dec;
|
||||
sif::info << "]" << std::endl;
|
||||
std::cout << std::dec;
|
||||
std::cout << "]" << std::endl;
|
||||
#else
|
||||
// how much memory to reserve for printout?
|
||||
// General format: 0x01, 0x02, 0x03 so it is number of chars times 6
|
||||
// plus line break plus small safety margin.
|
||||
char printBuffer[(size + 1) * 7 + 1] = {};
|
||||
size_t currentPos = 0;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
// To avoid buffer overflows.
|
||||
if(sizeof(printBuffer) - currentPos <= 7) {
|
||||
break;
|
||||
}
|
||||
|
||||
currentPos += snprintf(printBuffer + currentPos, 6, "0x%02x", data[i]);
|
||||
if(i < size - 1) {
|
||||
currentPos += sprintf(printBuffer + currentPos, ", ");
|
||||
if(i > 0 and (i + 1) % maxCharPerLine == 0) {
|
||||
currentPos += sprintf(printBuffer + currentPos, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
printf("[%s]\n", printBuffer);
|
||||
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
||||
#endif
|
||||
}
|
||||
|
||||
void arrayprinter::printDec(const uint8_t *data, size_t size,
|
||||
size_t maxCharPerLine) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << std::dec;
|
||||
if(sif::info.crAdditionEnabled()) {
|
||||
std::cout << "\r" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "[" << std::dec;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
sif::info << static_cast<int>(data[i]);
|
||||
std::cout << static_cast<int>(data[i]);
|
||||
if(i < size - 1){
|
||||
sif::info << " , ";
|
||||
if(i > 0 and i % maxCharPerLine == 0) {
|
||||
sif::info << std::endl;
|
||||
std::cout << " , ";
|
||||
if(i > 0 and (i + 1) % maxCharPerLine == 0) {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
sif::info << "]" << std::endl;
|
||||
std::cout << "]" << std::endl;
|
||||
#else
|
||||
// how much memory to reserve for printout?
|
||||
// General format: 32, 243, -12 so it is number of chars times 5
|
||||
// plus line break plus small safety margin.
|
||||
char printBuffer[(size + 1) * 5 + 1] = {};
|
||||
size_t currentPos = 0;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
// To avoid buffer overflows.
|
||||
if(sizeof(printBuffer) - currentPos <= 5) {
|
||||
break;
|
||||
}
|
||||
|
||||
currentPos += snprintf(printBuffer + currentPos, 3, "%d", data[i]);
|
||||
if(i < size - 1) {
|
||||
currentPos += sprintf(printBuffer + currentPos, ", ");
|
||||
if(i > 0 and (i + 1) % maxCharPerLine == 0) {
|
||||
currentPos += sprintf(printBuffer + currentPos, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
printf("[%s]\n", printBuffer);
|
||||
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
||||
#endif
|
||||
}
|
||||
|
||||
void arrayprinter::printBin(const uint8_t *data, size_t size) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "\n" << std::flush;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
sif::info << "Byte " << i + 1 << ": 0b"<<
|
||||
std::bitset<8>(data[i]) << ",\n" << std::flush;
|
||||
sif::info << "Byte " << i + 1 << ": 0b" << std::bitset<8>(data[i]) << std::endl;
|
||||
}
|
||||
sif::info << "]" << std::endl;
|
||||
#else
|
||||
// how much memory to reserve for printout?
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
sif::printInfo("Byte %d: 0b" BYTE_TO_BINARY_PATTERN "\n", i + 1, BYTE_TO_BINARY(data[i]));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#ifndef FRAMEWORK_GLOBALFUNCTIONS_ARRAYPRINTER_H_
|
||||
#define FRAMEWORK_GLOBALFUNCTIONS_ARRAYPRINTER_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
@@ -10,11 +11,15 @@ enum class OutputType {
|
||||
};
|
||||
|
||||
namespace arrayprinter {
|
||||
|
||||
|
||||
|
||||
void print(const uint8_t* data, size_t size, OutputType type = OutputType::HEX,
|
||||
bool printInfo = true, size_t maxCharPerLine = 12);
|
||||
void printHex(const uint8_t* data, size_t size, size_t maxCharPerLine = 12);
|
||||
void printDec(const uint8_t* data, size_t size, size_t maxCharPerLine = 12);
|
||||
bool printInfo = true, size_t maxCharPerLine = 10);
|
||||
void printHex(const uint8_t* data, size_t size, size_t maxCharPerLine = 10);
|
||||
void printDec(const uint8_t* data, size_t size, size_t maxCharPerLine = 10);
|
||||
void printBin(const uint8_t* data, size_t size);
|
||||
|
||||
}
|
||||
|
||||
#endif /* FRAMEWORK_GLOBALFUNCTIONS_ARRAYPRINTER_H_ */
|
||||
|
33
globalfunctions/bitutility.cpp
Normal file
33
globalfunctions/bitutility.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "bitutility.h"
|
||||
|
||||
void bitutil::bitSet(uint8_t *byte, uint8_t position) {
|
||||
if(position > 7) {
|
||||
return;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
*byte |= 1 << shiftNumber;
|
||||
}
|
||||
|
||||
void bitutil::bitToggle(uint8_t *byte, uint8_t position) {
|
||||
if(position > 7) {
|
||||
return;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
*byte ^= 1 << shiftNumber;
|
||||
}
|
||||
|
||||
void bitutil::bitClear(uint8_t *byte, uint8_t position) {
|
||||
if(position > 7) {
|
||||
return;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
*byte &= ~(1 << shiftNumber);
|
||||
}
|
||||
|
||||
bool bitutil::bitGet(const uint8_t *byte, uint8_t position) {
|
||||
if(position > 7) {
|
||||
return false;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
return *byte & (1 << shiftNumber);
|
||||
}
|
18
globalfunctions/bitutility.h
Normal file
18
globalfunctions/bitutility.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef FSFW_GLOBALFUNCTIONS_BITUTIL_H_
|
||||
#define FSFW_GLOBALFUNCTIONS_BITUTIL_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace bitutil {
|
||||
|
||||
/* Helper functions for manipulating the individual bits of a byte.
|
||||
Position refers to n-th bit of a byte, going from 0 (most significant bit) to
|
||||
7 (least significant bit) */
|
||||
void bitSet(uint8_t* byte, uint8_t position);
|
||||
void bitToggle(uint8_t* byte, uint8_t position);
|
||||
void bitClear(uint8_t* byte, uint8_t position);
|
||||
bool bitGet(const uint8_t* byte, uint8_t position);
|
||||
|
||||
}
|
||||
|
||||
#endif /* FSFW_GLOBALFUNCTIONS_BITUTIL_H_ */
|
@@ -1,5 +1,5 @@
|
||||
#include "HealthTable.h"
|
||||
#include "../ipc/MutexHelper.h"
|
||||
#include "../ipc/MutexGuard.h"
|
||||
#include "../ipc/MutexFactory.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
|
||||
@@ -31,7 +31,7 @@ ReturnValue_t HealthTable::registerObject(object_id_t object,
|
||||
|
||||
void HealthTable::setHealth(object_id_t object,
|
||||
HasHealthIF::HealthState newState) {
|
||||
MutexHelper(mutex, timeoutType, mutexTimeoutMs);
|
||||
MutexGuard(mutex, timeoutType, mutexTimeoutMs);
|
||||
HealthMap::iterator iter = healthMap.find(object);
|
||||
if (iter != healthMap.end()) {
|
||||
iter->second = newState;
|
||||
@@ -40,7 +40,7 @@ void HealthTable::setHealth(object_id_t object,
|
||||
|
||||
HasHealthIF::HealthState HealthTable::getHealth(object_id_t object) {
|
||||
HasHealthIF::HealthState state = HasHealthIF::HEALTHY;
|
||||
MutexHelper(mutex, timeoutType, mutexTimeoutMs);
|
||||
MutexGuard(mutex, timeoutType, mutexTimeoutMs);
|
||||
HealthMap::iterator iter = healthMap.find(object);
|
||||
if (iter != healthMap.end()) {
|
||||
state = iter->second;
|
||||
@@ -49,7 +49,7 @@ HasHealthIF::HealthState HealthTable::getHealth(object_id_t object) {
|
||||
}
|
||||
|
||||
bool HealthTable::hasHealth(object_id_t object) {
|
||||
MutexHelper(mutex, timeoutType, mutexTimeoutMs);
|
||||
MutexGuard(mutex, timeoutType, mutexTimeoutMs);
|
||||
HealthMap::iterator iter = healthMap.find(object);
|
||||
if (iter != healthMap.end()) {
|
||||
return true;
|
||||
@@ -58,35 +58,51 @@ bool HealthTable::hasHealth(object_id_t object) {
|
||||
}
|
||||
|
||||
size_t HealthTable::getPrintSize() {
|
||||
MutexHelper(mutex, timeoutType, mutexTimeoutMs);
|
||||
MutexGuard(mutex, timeoutType, mutexTimeoutMs);
|
||||
uint32_t size = healthMap.size() * sizeof(object_id_t) +
|
||||
sizeof(HasHealthIF::HealthState) + sizeof(uint16_t);
|
||||
return size;
|
||||
}
|
||||
|
||||
void HealthTable::printAll(uint8_t* pointer, size_t maxSize) {
|
||||
MutexHelper(mutex, timeoutType, mutexTimeoutMs);
|
||||
MutexGuard(mutex, timeoutType, mutexTimeoutMs);
|
||||
size_t size = 0;
|
||||
uint16_t count = healthMap.size();
|
||||
SerializeAdapter::serialize(&count,
|
||||
ReturnValue_t result = SerializeAdapter::serialize(&count,
|
||||
&pointer, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "HealthTable::printAll: Serialization of health table failed" << std::endl;
|
||||
#else
|
||||
sif::printWarning("HealthTable::printAll: Serialization of health table failed\n");
|
||||
#endif
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
return;
|
||||
}
|
||||
for (const auto& health: healthMap) {
|
||||
SerializeAdapter::serialize(&health.first,
|
||||
result = SerializeAdapter::serialize(&health.first,
|
||||
&pointer, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
uint8_t healthValue = health.second;
|
||||
SerializeAdapter::serialize(&healthValue, &pointer, &size,
|
||||
result = SerializeAdapter::serialize(&healthValue, &pointer, &size,
|
||||
maxSize, SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t HealthTable::iterate(HealthEntry *value, bool reset) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
MutexHelper(mutex, timeoutType, mutexTimeoutMs);
|
||||
MutexGuard(mutex, timeoutType, mutexTimeoutMs);
|
||||
if (reset) {
|
||||
mapIterator = healthMap.begin();
|
||||
}
|
||||
if (mapIterator == healthMap.end()) {
|
||||
result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*value = *mapIterator;
|
||||
mapIterator++;
|
||||
|
@@ -84,15 +84,21 @@ void HousekeepingMessage::setCollectionIntervalModificationCommand(
|
||||
else {
|
||||
command->setCommand(MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL);
|
||||
}
|
||||
command->setParameter3(collectionInterval);
|
||||
|
||||
/* Raw storage of the float in the message. Do not use setParameter3, does
|
||||
implicit conversion to integer type! */
|
||||
std::memcpy(command->getData() + 2 * sizeof(uint32_t), &collectionInterval,
|
||||
sizeof(collectionInterval));
|
||||
|
||||
setSid(command, sid);
|
||||
}
|
||||
|
||||
sid_t HousekeepingMessage::getCollectionIntervalModificationCommand(
|
||||
const CommandMessage* command, float* newCollectionInterval) {
|
||||
|
||||
if(newCollectionInterval != nullptr) {
|
||||
*newCollectionInterval = command->getParameter3();
|
||||
std::memcpy(newCollectionInterval, command->getData() + 2 * sizeof(uint32_t),
|
||||
sizeof(*newCollectionInterval));
|
||||
}
|
||||
|
||||
return getSid(command);
|
||||
@@ -125,8 +131,10 @@ sid_t HousekeepingMessage::getSid(const CommandMessage* message) {
|
||||
return sid;
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setSid(CommandMessage *message, sid_t sid) {
|
||||
std::memcpy(message->getData(), &sid.raw, sizeof(sid.raw));
|
||||
gp_id_t HousekeepingMessage::getGpid(const CommandMessage* message) {
|
||||
gp_id_t globalPoolId;
|
||||
std::memcpy(&globalPoolId.raw, message->getData(), sizeof(globalPoolId.raw));
|
||||
return globalPoolId;
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setHkStuctureReportReply(CommandMessage *reply,
|
||||
@@ -149,7 +157,8 @@ void HousekeepingMessage::clear(CommandMessage* message) {
|
||||
case(DIAGNOSTICS_REPORT):
|
||||
case(HK_DEFINITIONS_REPORT):
|
||||
case(DIAGNOSTICS_DEFINITION_REPORT):
|
||||
case(UPDATE_SNAPSHOT_SET): {
|
||||
case(UPDATE_SNAPSHOT_SET):
|
||||
case(UPDATE_SNAPSHOT_VARIABLE): {
|
||||
store_address_t storeId;
|
||||
getHkDataReply(message, &storeId);
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
@@ -169,22 +178,22 @@ void HousekeepingMessage::setUpdateNotificationSetCommand(
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setUpdateNotificationVariableCommand(
|
||||
CommandMessage *command, lp_id_t localPoolId) {
|
||||
CommandMessage *command, gp_id_t globalPoolId) {
|
||||
command->setCommand(UPDATE_NOTIFICATION_VARIABLE);
|
||||
command->setParameter(localPoolId);
|
||||
setGpid(command, globalPoolId);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setUpdateSnapshotSetCommand(CommandMessage *command,
|
||||
sid_t sid, store_address_t storeId) {
|
||||
command->setCommand(UPDATE_SNAPSHOT_VARIABLE);
|
||||
command->setCommand(UPDATE_SNAPSHOT_SET);
|
||||
setSid(command, sid);
|
||||
command->setParameter3(storeId.raw);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setUpdateSnapshotVariableCommand(
|
||||
CommandMessage *command, lp_id_t localPoolId, store_address_t storeId) {
|
||||
CommandMessage *command, gp_id_t globalPoolId, store_address_t storeId) {
|
||||
command->setCommand(UPDATE_SNAPSHOT_VARIABLE);
|
||||
command->setParameter(localPoolId);
|
||||
setGpid(command, globalPoolId);
|
||||
command->setParameter3(storeId.raw);
|
||||
}
|
||||
|
||||
@@ -193,9 +202,9 @@ sid_t HousekeepingMessage::getUpdateNotificationSetCommand(
|
||||
return getSid(command);
|
||||
}
|
||||
|
||||
lp_id_t HousekeepingMessage::getUpdateNotificationVariableCommand(
|
||||
gp_id_t HousekeepingMessage::getUpdateNotificationVariableCommand(
|
||||
const CommandMessage *command) {
|
||||
return command->getParameter();
|
||||
return getGpid(command);
|
||||
}
|
||||
|
||||
sid_t HousekeepingMessage::getUpdateSnapshotSetCommand(
|
||||
@@ -206,10 +215,18 @@ sid_t HousekeepingMessage::getUpdateSnapshotSetCommand(
|
||||
return getSid(command);
|
||||
}
|
||||
|
||||
lp_id_t HousekeepingMessage::getUpdateSnapshotVariableCommand(
|
||||
gp_id_t HousekeepingMessage::getUpdateSnapshotVariableCommand(
|
||||
const CommandMessage *command, store_address_t *storeId) {
|
||||
if(storeId != nullptr) {
|
||||
*storeId = command->getParameter3();
|
||||
}
|
||||
return command->getParameter();
|
||||
return getGpid(command);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setSid(CommandMessage *message, sid_t sid) {
|
||||
std::memcpy(message->getData(), &sid.raw, sizeof(sid.raw));
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setGpid(CommandMessage *message, gp_id_t globalPoolId) {
|
||||
std::memcpy(message->getData(), &globalPoolId.raw, sizeof(globalPoolId.raw));
|
||||
}
|
||||
|
@@ -75,6 +75,7 @@ public:
|
||||
//static constexpr Command_t UPDATE_HK_REPORT = MAKE_COMMAND_ID(134);
|
||||
|
||||
static sid_t getSid(const CommandMessage* message);
|
||||
static gp_id_t getGpid(const CommandMessage* message);
|
||||
|
||||
/* Housekeeping Interface Messages */
|
||||
|
||||
@@ -123,26 +124,27 @@ public:
|
||||
static void setUpdateNotificationSetCommand(CommandMessage* command,
|
||||
sid_t sid);
|
||||
static void setUpdateNotificationVariableCommand(CommandMessage* command,
|
||||
lp_id_t localPoolId);
|
||||
gp_id_t globalPoolId);
|
||||
|
||||
static void setUpdateSnapshotSetCommand(CommandMessage* command, sid_t sid,
|
||||
store_address_t storeId);
|
||||
static void setUpdateSnapshotVariableCommand(CommandMessage* command,
|
||||
lp_id_t localPoolId, store_address_t storeId);
|
||||
gp_id_t globalPoolId, store_address_t storeId);
|
||||
|
||||
static sid_t getUpdateNotificationSetCommand(const CommandMessage* command);
|
||||
static lp_id_t getUpdateNotificationVariableCommand(
|
||||
static gp_id_t getUpdateNotificationVariableCommand(
|
||||
const CommandMessage* command);
|
||||
|
||||
static sid_t getUpdateSnapshotSetCommand(const CommandMessage* command,
|
||||
store_address_t* storeId);
|
||||
static lp_id_t getUpdateSnapshotVariableCommand(const CommandMessage* command,
|
||||
static gp_id_t getUpdateSnapshotVariableCommand(const CommandMessage* command,
|
||||
store_address_t* storeId);
|
||||
|
||||
/** Utility */
|
||||
static void clear(CommandMessage* message);
|
||||
private:
|
||||
static void setSid(CommandMessage* message, sid_t sid);
|
||||
static void setGpid(CommandMessage* message, gp_id_t globalPoolId);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -10,7 +10,11 @@
|
||||
* which are destined to be downlinked into the store.
|
||||
* @details
|
||||
* The housekeeping packets are stored into the IPC store and forwarded
|
||||
* to the designated housekeeping handler.
|
||||
* to the designated housekeeping handler. The packet will consist of the following fields
|
||||
* - SID (8 byte): Structure ID, with the first 4 bytes being the object ID and the last four
|
||||
* bytes being the set ID
|
||||
* - Housekeeping Data: The rest of the packet will be the serialized housekeeping data. A validity
|
||||
* buffer might be appended at the end, depending on the set configuration.
|
||||
*/
|
||||
class HousekeepingPacketDownlink: public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
|
@@ -1,24 +1,38 @@
|
||||
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
|
||||
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
|
||||
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGSNAPSHOT_H_
|
||||
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGSNAPSHOT_H_
|
||||
|
||||
#include "../serialize/SerialBufferAdapter.h"
|
||||
#include "../serialize/SerialLinkedListAdapter.h"
|
||||
#include "../datapoollocal/LocalPoolDataSetBase.h"
|
||||
#include "../datapoollocal/LocalPoolObjectBase.h"
|
||||
#include "../timemanager/CCSDSTime.h"
|
||||
|
||||
/**
|
||||
* @brief This helper class will be used to serialize and deserialize
|
||||
* update housekeeping packets into the store.
|
||||
* @brief This helper class will be used to serialize and deserialize update housekeeping packets
|
||||
* into the store.
|
||||
*/
|
||||
class HousekeepingPacketUpdate: public SerializeIF {
|
||||
class HousekeepingSnapshot:
|
||||
public SerializeIF {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Update packet constructor for datasets
|
||||
* @param timeStamp
|
||||
* @param timeStampSize
|
||||
* @param hkData
|
||||
* @param hkDataSize
|
||||
* Update packet constructor for datasets.
|
||||
* @param cdsShort If a CSD short timestamp is used, a reference should be
|
||||
* supplied here
|
||||
* @param dataSetPtr Pointer to the dataset instance to serialize or deserialize the
|
||||
* data into
|
||||
*/
|
||||
HousekeepingPacketUpdate(uint8_t* timeStamp, size_t timeStampSize,
|
||||
HousekeepingSnapshot(CCSDSTime::CDS_short* cdsShort, LocalPoolDataSetBase* dataSetPtr):
|
||||
timeStamp(reinterpret_cast<uint8_t*>(cdsShort)),
|
||||
timeStampSize(sizeof(CCSDSTime::CDS_short)), updateData(dataSetPtr) {};
|
||||
|
||||
/**
|
||||
* Update packet constructor for datasets.
|
||||
* @param timeStamp Pointer to the buffer where the timestamp will be stored.
|
||||
* @param timeStampSize Size of the timestamp
|
||||
* @param dataSetPtr Pointer to the dataset instance to deserialize the data into
|
||||
*/
|
||||
HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize,
|
||||
LocalPoolDataSetBase* dataSetPtr):
|
||||
timeStamp(timeStamp), timeStampSize(timeStampSize),
|
||||
updateData(dataSetPtr) {};
|
||||
@@ -29,13 +43,24 @@ public:
|
||||
* @param timeStampSize
|
||||
* @param dataSetPtr
|
||||
*/
|
||||
HousekeepingPacketUpdate(uint8_t* timeStamp, size_t timeStampSize,
|
||||
HousekeepingSnapshot(CCSDSTime::CDS_short* cdsShort, LocalPoolObjectBase* dataSetPtr):
|
||||
timeStamp(reinterpret_cast<uint8_t*>(cdsShort)),
|
||||
timeStampSize(sizeof(CCSDSTime::CDS_short)), updateData(dataSetPtr) {};
|
||||
|
||||
|
||||
/**
|
||||
* Update packet constructor for pool variables.
|
||||
* @param timeStamp
|
||||
* @param timeStampSize
|
||||
* @param dataSetPtr
|
||||
*/
|
||||
HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize,
|
||||
LocalPoolObjectBase* dataSetPtr):
|
||||
timeStamp(timeStamp), timeStampSize(timeStampSize),
|
||||
updateData(dataSetPtr) {};
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
if(timeStamp != nullptr) {
|
||||
/* Endianness will always be MACHINE, so we can simply use memcpy
|
||||
here. */
|
||||
@@ -89,4 +114,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_ */
|
||||
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGSNAPSHOT_H_ */
|
@@ -6,20 +6,18 @@
|
||||
PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(
|
||||
LocalPoolDataSetBase* owner): owner(owner) {}
|
||||
|
||||
|
||||
void PeriodicHousekeepingHelper::initialize(float collectionInterval,
|
||||
dur_millis_t minimumPeriodicInterval, bool isDiagnostics,
|
||||
uint8_t nonDiagIntervalFactor) {
|
||||
dur_millis_t minimumPeriodicInterval, uint8_t nonDiagIntervalFactor) {
|
||||
this->minimumPeriodicInterval = minimumPeriodicInterval;
|
||||
if(not isDiagnostics) {
|
||||
this->minimumPeriodicInterval = this->minimumPeriodicInterval *
|
||||
nonDiagIntervalFactor;
|
||||
}
|
||||
collectionIntervalTicks = intervalSecondsToInterval(collectionInterval);
|
||||
this->nonDiagIntervalFactor = nonDiagIntervalFactor;
|
||||
collectionIntervalTicks = intervalSecondsToIntervalTicks(collectionInterval);
|
||||
/* This will cause a checkOpNecessary call to be true immediately. I think it's okay
|
||||
if a HK packet is generated immediately instead of waiting one generation cycle. */
|
||||
internalTickCounter = collectionIntervalTicks;
|
||||
}
|
||||
|
||||
float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() {
|
||||
return intervalToIntervalSeconds(collectionIntervalTicks);
|
||||
float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() const {
|
||||
return intervalTicksToSeconds(collectionIntervalTicks);
|
||||
}
|
||||
|
||||
bool PeriodicHousekeepingHelper::checkOpNecessary() {
|
||||
@@ -31,19 +29,62 @@ bool PeriodicHousekeepingHelper::checkOpNecessary() {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t PeriodicHousekeepingHelper::intervalSecondsToInterval(
|
||||
uint32_t PeriodicHousekeepingHelper::intervalSecondsToIntervalTicks(
|
||||
float collectionIntervalSeconds) {
|
||||
return std::ceil(collectionIntervalSeconds * 1000
|
||||
/ minimumPeriodicInterval);
|
||||
if(owner == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
bool isDiagnostics = owner->isDiagnostics();
|
||||
|
||||
/* Avoid division by zero */
|
||||
if(minimumPeriodicInterval == 0) {
|
||||
if(isDiagnostics) {
|
||||
/* Perform operation each cycle */
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return nonDiagIntervalFactor;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dur_millis_t intervalInMs = collectionIntervalSeconds * 1000;
|
||||
uint32_t divisor = minimumPeriodicInterval;
|
||||
if(not isDiagnostics) {
|
||||
/* We need to multiply the divisor because non-diagnostics only
|
||||
allow a multiple of the minimum periodic interval */
|
||||
divisor *= nonDiagIntervalFactor;
|
||||
}
|
||||
uint32_t ticks = std::ceil(static_cast<float>(intervalInMs) / divisor);
|
||||
if(not isDiagnostics) {
|
||||
/* Now we need to multiply the calculated ticks with the factor as as well
|
||||
because the minimum tick count to generate a non-diagnostic is the factor itself.
|
||||
|
||||
Example calculation for non-diagnostic with
|
||||
0.4 second interval and 0.2 second task interval.
|
||||
Resultant tick count of 5 is equal to operation each second.
|
||||
|
||||
Examle calculation for non-diagnostic with 2.0 second interval and 0.2 second
|
||||
task interval.
|
||||
Resultant tick count of 10 is equal to operatin every 2 seconds.
|
||||
|
||||
Example calculation for diagnostic with 0.4 second interval and 0.3
|
||||
second task interval. Resulting tick count of 2 is equal to operation
|
||||
every 0.6 seconds. */
|
||||
ticks *= nonDiagIntervalFactor;
|
||||
}
|
||||
return ticks;
|
||||
}
|
||||
}
|
||||
|
||||
float PeriodicHousekeepingHelper::intervalToIntervalSeconds(
|
||||
uint32_t collectionInterval) {
|
||||
return static_cast<float>(collectionInterval *
|
||||
minimumPeriodicInterval);
|
||||
float PeriodicHousekeepingHelper::intervalTicksToSeconds(
|
||||
uint32_t collectionInterval) const {
|
||||
/* Number of ticks times the minimum interval is in milliseconds, so we divide by 1000 to get
|
||||
the value in seconds */
|
||||
return static_cast<float>(collectionInterval * minimumPeriodicInterval / 1000.0);
|
||||
}
|
||||
|
||||
void PeriodicHousekeepingHelper::changeCollectionInterval(
|
||||
float newIntervalSeconds) {
|
||||
collectionIntervalTicks = intervalSecondsToInterval(newIntervalSeconds);
|
||||
collectionIntervalTicks = intervalSecondsToIntervalTicks(newIntervalSeconds);
|
||||
}
|
||||
|
||||
|
@@ -10,18 +10,19 @@ class PeriodicHousekeepingHelper {
|
||||
public:
|
||||
PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner);
|
||||
|
||||
void initialize(float collectionInterval,
|
||||
dur_millis_t minimumPeriodicInterval, bool isDiagnostics,
|
||||
void initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
||||
uint8_t nonDiagIntervalFactor);
|
||||
|
||||
void changeCollectionInterval(float newInterval);
|
||||
float getCollectionIntervalInSeconds();
|
||||
float getCollectionIntervalInSeconds() const;
|
||||
bool checkOpNecessary();
|
||||
|
||||
private:
|
||||
LocalPoolDataSetBase* owner = nullptr;
|
||||
uint8_t nonDiagIntervalFactor = 0;
|
||||
|
||||
uint32_t intervalSecondsToInterval(float collectionIntervalSeconds);
|
||||
float intervalToIntervalSeconds(uint32_t collectionInterval);
|
||||
uint32_t intervalSecondsToIntervalTicks(float collectionIntervalSeconds);
|
||||
float intervalTicksToSeconds(uint32_t collectionInterval) const;
|
||||
|
||||
dur_millis_t minimumPeriodicInterval = 0;
|
||||
uint32_t internalTickCounter = 1;
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../ipc/MutexFactory.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../datapool/PoolReadGuard.h"
|
||||
|
||||
InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId,
|
||||
uint32_t messageQueueDepth): SystemObject(setObjectId),
|
||||
@@ -23,13 +24,17 @@ void InternalErrorReporter::setDiagnosticPrintout(bool enable) {
|
||||
}
|
||||
|
||||
ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
|
||||
internalErrorDataset.read(timeoutType, timeoutMs);
|
||||
CommandMessage message;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&message);
|
||||
if(result != MessageQueueIF::EMPTY) {
|
||||
poolManager.handleHousekeepingMessage(&message);
|
||||
}
|
||||
|
||||
uint32_t newQueueHits = getAndResetQueueHits();
|
||||
uint32_t newTmHits = getAndResetTmHits();
|
||||
uint32_t newStoreHits = getAndResetStoreHits();
|
||||
|
||||
#if FSFW_VERBOSE_LEVEL == 1
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
if(diagnosticPrintout) {
|
||||
if((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
@@ -48,19 +53,17 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
PoolReadGuard readGuard(&internalErrorDataset);
|
||||
if(readGuard.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
|
||||
internalErrorDataset.queueHits.value += newQueueHits;
|
||||
internalErrorDataset.storeHits.value += newStoreHits;
|
||||
internalErrorDataset.tmHits.value += newTmHits;
|
||||
internalErrorDataset.setValidity(true, true);
|
||||
internalErrorDataset.commit(timeoutType, timeoutMs);
|
||||
}
|
||||
}
|
||||
|
||||
poolManager.performHkOperation();
|
||||
|
||||
CommandMessage message;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&message);
|
||||
if(result != MessageQueueIF::EMPTY) {
|
||||
poolManager.handleHousekeepingMessage(&message);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@@ -155,14 +158,11 @@ MessageQueueId_t InternalErrorReporter::getCommandQueue() const {
|
||||
|
||||
ReturnValue_t InternalErrorReporter::initializeLocalDataPool(
|
||||
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
|
||||
localDataPoolMap.emplace(errorPoolIds::TM_HITS,
|
||||
new PoolEntry<uint32_t>());
|
||||
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS,
|
||||
new PoolEntry<uint32_t>());
|
||||
localDataPoolMap.emplace(errorPoolIds::STORE_HITS,
|
||||
new PoolEntry<uint32_t>());
|
||||
poolManager.subscribeForPeriodicPacket(internalErrorSid, false,
|
||||
getPeriodicOperationFrequency(), true);
|
||||
localDataPoolMap.emplace(errorPoolIds::TM_HITS, new PoolEntry<uint32_t>());
|
||||
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, new PoolEntry<uint32_t>());
|
||||
localDataPoolMap.emplace(errorPoolIds::STORE_HITS, new PoolEntry<uint32_t>());
|
||||
poolManager.subscribeForPeriodicPacket(internalErrorSid, false, getPeriodicOperationFrequency(),
|
||||
true);
|
||||
internalErrorDataset.setValidity(true, true);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@@ -17,7 +17,8 @@
|
||||
* All functions were kept virtual so this class can be extended easily
|
||||
* to store custom internal errors (e.g. communication interface errors).
|
||||
*/
|
||||
class InternalErrorReporter: public SystemObject,
|
||||
class InternalErrorReporter:
|
||||
public SystemObject,
|
||||
public ExecutableObjectIF,
|
||||
public InternalErrorReporterIF,
|
||||
public HasLocalDataPoolIF {
|
||||
|
@@ -13,19 +13,21 @@ public:
|
||||
/**
|
||||
* Header consists of sender ID and command ID.
|
||||
*/
|
||||
static constexpr size_t HEADER_SIZE = MessageQueueMessageIF::HEADER_SIZE +
|
||||
sizeof(Command_t);
|
||||
static constexpr size_t HEADER_SIZE = MessageQueueMessageIF::HEADER_SIZE + sizeof(Command_t);
|
||||
/**
|
||||
* This minimum size is derived from the interface requirement to be able
|
||||
* to set a rejected reply, which contains a returnvalue and the initial
|
||||
* command.
|
||||
*/
|
||||
static constexpr size_t MINIMUM_COMMAND_MESSAGE_SIZE =
|
||||
CommandMessageIF::HEADER_SIZE + sizeof(ReturnValue_t) +
|
||||
sizeof(Command_t);
|
||||
static constexpr size_t MINIMUM_COMMAND_MESSAGE_SIZE = CommandMessageIF::HEADER_SIZE +
|
||||
sizeof(ReturnValue_t) + sizeof(Command_t);
|
||||
|
||||
static constexpr Command_t makeCommandId(uint8_t messageId, uint8_t uniqueId) {
|
||||
return ((messageId << 8) | uniqueId);
|
||||
}
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_MESSAGE;
|
||||
static const ReturnValue_t UNKNOWN_COMMAND = MAKE_RETURN_CODE(0x01);
|
||||
static const ReturnValue_t UNKNOWN_COMMAND = MAKE_RETURN_CODE(1);
|
||||
|
||||
static const uint8_t MESSAGE_ID = messagetypes::COMMAND;
|
||||
//! Used internally, shall be ignored
|
||||
|
@@ -27,7 +27,7 @@ public:
|
||||
//! Returned if a reply method was called without partner
|
||||
static const ReturnValue_t NO_REPLY_PARTNER = MAKE_RETURN_CODE(3);
|
||||
//! Returned if the target destination is invalid.
|
||||
static constexpr ReturnValue_t DESTINVATION_INVALID = MAKE_RETURN_CODE(4);
|
||||
static constexpr ReturnValue_t DESTINATION_INVALID = MAKE_RETURN_CODE(4);
|
||||
|
||||
virtual ~MessageQueueIF() {}
|
||||
/**
|
||||
|
@@ -86,3 +86,7 @@ size_t MessageQueueMessage::getMaximumMessageSize() const {
|
||||
return this->MAX_MESSAGE_SIZE;
|
||||
}
|
||||
|
||||
size_t MessageQueueMessage::getMaximumDataSize() const {
|
||||
return this->MAX_DATA_SIZE;
|
||||
}
|
||||
|
||||
|
@@ -139,6 +139,7 @@ public:
|
||||
virtual void setMessageSize(size_t messageSize) override;
|
||||
virtual size_t getMinimumMessageSize() const override;
|
||||
virtual size_t getMaximumMessageSize() const override;
|
||||
virtual size_t getMaximumDataSize() const override;
|
||||
|
||||
/**
|
||||
* @brief This is a debug method that prints the content.
|
||||
|
@@ -72,6 +72,7 @@ public:
|
||||
virtual void setMessageSize(size_t messageSize) = 0;
|
||||
virtual size_t getMinimumMessageSize() const = 0;
|
||||
virtual size_t getMaximumMessageSize() const = 0;
|
||||
virtual size_t getMaximumDataSize() const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
60
ipc/MutexGuard.h
Normal file
60
ipc/MutexGuard.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef FRAMEWORK_IPC_MUTEXGUARD_H_
|
||||
#define FRAMEWORK_IPC_MUTEXGUARD_H_
|
||||
|
||||
#include "MutexFactory.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
|
||||
class MutexGuard {
|
||||
public:
|
||||
MutexGuard(MutexIF* mutex, MutexIF::TimeoutType timeoutType =
|
||||
MutexIF::TimeoutType::BLOCKING, uint32_t timeoutMs = 0):
|
||||
internalMutex(mutex) {
|
||||
if(mutex == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MutexGuard: Passed mutex is invalid!" << std::endl;
|
||||
#else
|
||||
sif::printError("MutexGuard: Passed mutex is invalid!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
return;
|
||||
}
|
||||
result = mutex->lockMutex(timeoutType,
|
||||
timeoutMs);
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
if(result == MutexIF::MUTEX_TIMEOUT) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MutexGuard: Lock of mutex failed with timeout of "
|
||||
<< timeoutMs << " milliseconds!" << std::endl;
|
||||
#else
|
||||
sif::printError("MutexGuard: Lock of mutex failed with timeout of %lu milliseconds\n",
|
||||
timeoutMs);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
|
||||
}
|
||||
else if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MutexGuard: Lock of Mutex failed with code " << result << std::endl;
|
||||
#else
|
||||
sif::printError("MutexGuard: Lock of Mutex failed with code %d\n", result);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
}
|
||||
#else
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
}
|
||||
|
||||
ReturnValue_t getLockResult() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
~MutexGuard() {
|
||||
if(internalMutex != nullptr) {
|
||||
internalMutex->unlockMutex();
|
||||
}
|
||||
}
|
||||
private:
|
||||
MutexIF* internalMutex;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_IPC_MUTEXGUARD_H_ */
|
@@ -1,34 +0,0 @@
|
||||
#ifndef FRAMEWORK_IPC_MUTEXHELPER_H_
|
||||
#define FRAMEWORK_IPC_MUTEXHELPER_H_
|
||||
|
||||
#include "MutexFactory.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
class MutexHelper {
|
||||
public:
|
||||
MutexHelper(MutexIF* mutex, MutexIF::TimeoutType timeoutType =
|
||||
MutexIF::TimeoutType::BLOCKING, uint32_t timeoutMs = 0) :
|
||||
internalMutex(mutex) {
|
||||
ReturnValue_t status = mutex->lockMutex(timeoutType,
|
||||
timeoutMs);
|
||||
if(status == MutexIF::MUTEX_TIMEOUT) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MutexHelper: Lock of mutex failed with timeout of "
|
||||
<< timeoutMs << " milliseconds!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
else if(status != HasReturnvaluesIF::RETURN_OK){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MutexHelper: Lock of Mutex failed with code "
|
||||
<< status << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
~MutexHelper() {
|
||||
internalMutex->unlockMutex();
|
||||
}
|
||||
private:
|
||||
MutexIF* internalMutex;
|
||||
};
|
||||
#endif /* FRAMEWORK_IPC_MUTEXHELPER_H_ */
|
@@ -16,17 +16,27 @@ class HasFileSystemIF {
|
||||
public:
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::FILE_SYSTEM;
|
||||
|
||||
static constexpr ReturnValue_t FILE_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x00);
|
||||
static constexpr ReturnValue_t FILE_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01);
|
||||
static constexpr ReturnValue_t FILE_LOCKED = MAKE_RETURN_CODE(0x02);
|
||||
//! [EXPORT] : P1: Can be file system specific error code
|
||||
static constexpr ReturnValue_t GENERIC_FILE_ERROR = MAKE_RETURN_CODE(0);
|
||||
//! [EXPORT] : File system is currently busy
|
||||
static constexpr ReturnValue_t IS_BUSY = MAKE_RETURN_CODE(1);
|
||||
//! [EXPORT] : Invalid parameters like file name or repository path
|
||||
static constexpr ReturnValue_t INVALID_PARAMETERS = MAKE_RETURN_CODE(2);
|
||||
|
||||
static constexpr ReturnValue_t DIRECTORY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03);
|
||||
static constexpr ReturnValue_t DIRECTORY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x04);
|
||||
static constexpr ReturnValue_t DIRECTORY_NOT_EMPTY = MAKE_RETURN_CODE(0x05);
|
||||
static constexpr ReturnValue_t FILE_DOES_NOT_EXIST = MAKE_RETURN_CODE(5);
|
||||
static constexpr ReturnValue_t FILE_ALREADY_EXISTS = MAKE_RETURN_CODE(6);
|
||||
static constexpr ReturnValue_t FILE_LOCKED = MAKE_RETURN_CODE(7);
|
||||
|
||||
static constexpr ReturnValue_t DIRECTORY_DOES_NOT_EXIST = MAKE_RETURN_CODE(10);
|
||||
static constexpr ReturnValue_t DIRECTORY_ALREADY_EXISTS = MAKE_RETURN_CODE(11);
|
||||
static constexpr ReturnValue_t DIRECTORY_NOT_EMPTY = MAKE_RETURN_CODE(12);
|
||||
|
||||
//! [EXPORT] : P1: Sequence number missing
|
||||
static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_WRITE = MAKE_RETURN_CODE(15);
|
||||
//! [EXPORT] : P1: Sequence number missing
|
||||
static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_READ = MAKE_RETURN_CODE(16);
|
||||
|
||||
|
||||
static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_WRITE = MAKE_RETURN_CODE(0x06); //! P1: Sequence number missing
|
||||
static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_READ = MAKE_RETURN_CODE(0x07); //! P1: Sequence number missing
|
||||
|
||||
virtual ~HasFileSystemIF() {}
|
||||
/**
|
||||
|
@@ -37,16 +37,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
|
||||
uint16_t startAtIndex) {
|
||||
ReturnValue_t result = this->MonitorBase<T>::getParameter(domainId,
|
||||
parameterId, parameterWrapper, newValues, startAtIndex);
|
||||
uniqueId, parameterWrapper, newValues, startAtIndex);
|
||||
//We'll reuse the DOMAIN_ID of MonitorReporter, as we know the parameterIds used there.
|
||||
if (result != this->INVALID_IDENTIFIER_ID) {
|
||||
return result;
|
||||
}
|
||||
switch (parameterId) {
|
||||
switch (uniqueId) {
|
||||
case 10:
|
||||
parameterWrapper->set(this->lowerLimit);
|
||||
break;
|
||||
|
@@ -51,13 +51,13 @@ public:
|
||||
return state;
|
||||
}
|
||||
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
|
||||
uint16_t startAtIndex) {
|
||||
if (domainId != monitorId) {
|
||||
return INVALID_DOMAIN_ID;
|
||||
}
|
||||
switch (parameterId) {
|
||||
switch (uniqueId) {
|
||||
case 0:
|
||||
parameterWrapper->set(this->confirmationLimit);
|
||||
break;
|
||||
|
@@ -10,7 +10,7 @@
|
||||
#include "../serialize/SerialFixedArrayListAdapter.h"
|
||||
#include "../serialize/SerializeElement.h"
|
||||
#include "../serialize/SerialLinkedListAdapter.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../timemanager/TimeStamperIF.h"
|
||||
|
||||
namespace Factory{
|
||||
|
@@ -71,13 +71,13 @@ public:
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
|
||||
uint16_t startAtIndex) {
|
||||
if (domainId != this->domainId) {
|
||||
return INVALID_DOMAIN_ID;
|
||||
}
|
||||
switch (parameterId) {
|
||||
switch (uniqueId) {
|
||||
case 0:
|
||||
parameterWrapper->set(limit);
|
||||
break;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include "ObjectManager.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
#include <iomanip>
|
||||
@@ -75,6 +75,8 @@ void ObjectManager::initialize() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::initialize: Passed produceObjects "
|
||||
"functions is nullptr!" << std::endl;
|
||||
#else
|
||||
sif::printError("ObjectManager::initialize: Passed produceObjects functions is nullptr!\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@@ -5,15 +5,19 @@
|
||||
SystemObject::SystemObject(object_id_t setObjectId, bool doRegister) :
|
||||
objectId(setObjectId), registered(doRegister) {
|
||||
if (registered) {
|
||||
if(objectManager != nullptr) {
|
||||
objectManager->insert(objectId, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SystemObject::~SystemObject() {
|
||||
if (registered) {
|
||||
if(objectManager != nullptr) {
|
||||
objectManager->remove(objectId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object_id_t SystemObject::getObjectId() const {
|
||||
return objectId;
|
||||
|
@@ -1,8 +1,11 @@
|
||||
#ifndef FSFW_OBJECTMANAGER_FRAMEWORKOBJECTS_H_
|
||||
#define FSFW_OBJECTMANAGER_FRAMEWORKOBJECTS_H_
|
||||
|
||||
#include <fsfw/objectmanager/SystemObjectIF.h>
|
||||
|
||||
namespace objects {
|
||||
enum framework_objects {
|
||||
enum framework_objects: object_id_t {
|
||||
FSFW_OBJECTS_START = 0x53000000,
|
||||
// Default verification reporter.
|
||||
PUS_SERVICE_1_VERIFICATION = 0x53000001,
|
||||
PUS_SERVICE_2_DEVICE_ACCESS = 0x53000002,
|
||||
@@ -11,6 +14,7 @@ enum framework_objects {
|
||||
PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008,
|
||||
PUS_SERVICE_9_TIME_MGMT = 0x53000009,
|
||||
PUS_SERVICE_17_TEST = 0x53000017,
|
||||
PUS_SERVICE_20_PARAMETERS = 0x53000020,
|
||||
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
||||
|
||||
//Generic IDs for IPC, modes, health, events
|
||||
@@ -24,6 +28,7 @@ enum framework_objects {
|
||||
TM_STORE = 0x534f0200,
|
||||
TIME_STAMPER = 0x53500010,
|
||||
|
||||
FSFW_OBJECTS_END = 0x53ffffff,
|
||||
NO_OBJECT = 0xFFFFFFFF
|
||||
};
|
||||
}
|
||||
|
@@ -10,10 +10,9 @@ elseif(${OS_FSFW} STREQUAL "host")
|
||||
if (WIN32)
|
||||
add_subdirectory(windows)
|
||||
elseif(UNIX)
|
||||
target_sources(${LIB_FSFW_NAME}
|
||||
PUBLIC
|
||||
linux/TcUnixUdpPollingTask.cpp
|
||||
linux/TmTcUnixUdpBridge.cpp
|
||||
# We still need to pull in some Linux specific sources
|
||||
target_sources(${LIB_FSFW_NAME} PUBLIC
|
||||
linux/tcpipHelpers.cpp
|
||||
)
|
||||
endif ()
|
||||
|
||||
@@ -32,3 +31,5 @@ else()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
add_subdirectory(common)
|
@@ -25,7 +25,8 @@
|
||||
#else
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#if REG_DWORD == REG_DWORD_LITTLE_ENDIAN
|
||||
#define BYTE_ORDER_SYSTEM LITTLE_ENDIAN
|
||||
#else
|
||||
|
@@ -111,7 +111,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
|
||||
|
||||
ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from,
|
||||
timeval* to) {
|
||||
struct tm time_tm;
|
||||
struct tm time_tm = {};
|
||||
|
||||
time_tm.tm_year = from->year - 1900;
|
||||
time_tm.tm_mon = from->month - 1;
|
||||
|
@@ -135,7 +135,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
QueueHandle_t destination = nullptr;
|
||||
|
||||
if(sendTo == MessageQueueIF::NO_QUEUE or sendTo == 0x00) {
|
||||
return MessageQueueIF::DESTINVATION_INVALID;
|
||||
return MessageQueueIF::DESTINATION_INVALID;
|
||||
}
|
||||
else {
|
||||
destination = reinterpret_cast<QueueHandle_t>(sendTo);
|
||||
|
@@ -49,5 +49,11 @@ ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void TaskFactory::printMissedDeadline() {
|
||||
/* TODO: Implement */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
TaskFactory::TaskFactory() {
|
||||
}
|
||||
|
16
osal/common/CMakeLists.txt
Normal file
16
osal/common/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
if(DEFINED WIN32 OR DEFINED UNIX)
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
tcpipCommon.cpp
|
||||
TcpIpBase.cpp
|
||||
UdpTcPollingTask.cpp
|
||||
UdpTmTcBridge.cpp
|
||||
TcpTmTcServer.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
|
||||
wsock32
|
||||
ws2_32
|
||||
)
|
||||
endif()
|
54
osal/common/TcpIpBase.cpp
Normal file
54
osal/common/TcpIpBase.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "TcpIpBase.h"
|
||||
|
||||
#ifdef __unix__
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#endif
|
||||
|
||||
TcpIpBase::TcpIpBase() {
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t TcpIpBase::initialize() {
|
||||
#ifdef _WIN32
|
||||
/* Initiates Winsock DLL. */
|
||||
WSAData wsaData;
|
||||
WORD wVersionRequested = MAKEWORD(2, 2);
|
||||
int err = WSAStartup(wVersionRequested, &wsaData);
|
||||
if (err != 0) {
|
||||
/* Tell the user that we could not find a usable Winsock DLL. */
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: WSAStartup failed with error: " <<
|
||||
err << std::endl;
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
TcpIpBase::~TcpIpBase() {
|
||||
closeSocket(serverSocket);
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
int TcpIpBase::closeSocket(socket_t socket) {
|
||||
#ifdef _WIN32
|
||||
return closesocket(socket);
|
||||
#elif defined(__unix__)
|
||||
return close(socket);
|
||||
#endif
|
||||
}
|
||||
|
||||
int TcpIpBase::getLastSocketError() {
|
||||
#ifdef _WIN32
|
||||
return WSAGetLastError();
|
||||
#elif defined(__unix__)
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
|
50
osal/common/TcpIpBase.h
Normal file
50
osal/common/TcpIpBase.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef FSFW_OSAL_COMMON_TCPIPIF_H_
|
||||
#define FSFW_OSAL_COMMON_TCPIPIF_H_
|
||||
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <winsock2.h>
|
||||
|
||||
#elif defined(__unix__)
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#endif
|
||||
|
||||
class TcpIpBase {
|
||||
protected:
|
||||
|
||||
#ifdef _WIN32
|
||||
static constexpr int SHUT_RECV = SD_RECEIVE;
|
||||
static constexpr int SHUT_SEND = SD_SEND;
|
||||
static constexpr int SHUT_BOTH = SD_BOTH;
|
||||
|
||||
using socket_t = SOCKET;
|
||||
#elif defined(__unix__)
|
||||
using socket_t = int;
|
||||
|
||||
static constexpr int INVALID_SOCKET = -1;
|
||||
static constexpr int SOCKET_ERROR = -1;
|
||||
|
||||
static constexpr int SHUT_RECV = SHUT_RD;
|
||||
static constexpr int SHUT_SEND = SHUT_WR;
|
||||
static constexpr int SHUT_BOTH = SHUT_RDWR;
|
||||
#endif
|
||||
|
||||
TcpIpBase();
|
||||
virtual ~TcpIpBase();
|
||||
|
||||
ReturnValue_t initialize();
|
||||
|
||||
int closeSocket(socket_t socket);
|
||||
|
||||
int getLastSocketError();
|
||||
|
||||
socket_t serverSocket = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* FSFW_OSAL_COMMON_TCPIPIF_H_ */
|
132
osal/common/TcpTmTcServer.cpp
Normal file
132
osal/common/TcpTmTcServer.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
#include "TcpTmTcServer.h"
|
||||
#include "tcpipHelpers.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#elif defined(__unix__)
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
#endif
|
||||
|
||||
const std::string TcpTmTcServer::DEFAULT_TCP_SERVER_PORT = "7301";
|
||||
const std::string TcpTmTcServer::DEFAULT_TCP_CLIENT_PORT = "7302";
|
||||
|
||||
TcpTmTcServer::TcpTmTcServer(object_id_t objectId, object_id_t tmtcUnixUdpBridge,
|
||||
std::string customTcpServerPort):
|
||||
SystemObject(objectId), tcpPort(customTcpServerPort) {
|
||||
if(tcpPort == "") {
|
||||
tcpPort = DEFAULT_TCP_SERVER_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t TcpTmTcServer::initialize() {
|
||||
using namespace tcpip;
|
||||
|
||||
ReturnValue_t result = TcpIpBase::initialize();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
int retval = 0;
|
||||
struct addrinfo *addrResult = nullptr;
|
||||
struct addrinfo hints = {};
|
||||
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
|
||||
retval = getaddrinfo(nullptr, tcpPort.c_str(), &hints, &addrResult);
|
||||
if (retval != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "TcWinTcpServer::TcpTmTcServer: Retrieving address info failed!" <<
|
||||
std::endl;
|
||||
#endif
|
||||
handleError(Protocol::TCP, ErrorSources::GETADDRINFO_CALL);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
/* Open TCP (stream) socket */
|
||||
listenerTcpSocket = socket(addrResult->ai_family, addrResult->ai_socktype,
|
||||
addrResult->ai_protocol);
|
||||
if(listenerTcpSocket == INVALID_SOCKET) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "TcWinTcpServer::TcWinTcpServer: Socket creation failed!" << std::endl;
|
||||
#endif
|
||||
freeaddrinfo(addrResult);
|
||||
handleError(Protocol::TCP, ErrorSources::SOCKET_CALL);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
retval = bind(listenerTcpSocket, addrResult->ai_addr, static_cast<int>(addrResult->ai_addrlen));
|
||||
if(retval == SOCKET_ERROR) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "TcWinTcpServer::TcpTmTcServer: Binding socket failed!" <<
|
||||
std::endl;
|
||||
#endif
|
||||
freeaddrinfo(addrResult);
|
||||
handleError(Protocol::TCP, ErrorSources::BIND_CALL);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
freeaddrinfo(addrResult);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
TcpTmTcServer::~TcpTmTcServer() {
|
||||
closeSocket(listenerTcpSocket);
|
||||
}
|
||||
|
||||
ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) {
|
||||
using namespace tcpip;
|
||||
/* If a connection is accepted, the corresponding socket will be assigned to the new socket */
|
||||
socket_t clientSocket = 0;
|
||||
sockaddr clientSockAddr = {};
|
||||
socklen_t connectorSockAddrLen = 0;
|
||||
int retval = 0;
|
||||
|
||||
/* Listen for connection requests permanently for lifetime of program */
|
||||
while(true) {
|
||||
retval = listen(listenerTcpSocket, currentBacklog);
|
||||
if(retval == SOCKET_ERROR) {
|
||||
handleError(Protocol::TCP, ErrorSources::LISTEN_CALL, 500);
|
||||
continue;
|
||||
}
|
||||
|
||||
clientSocket = accept(listenerTcpSocket, &clientSockAddr, &connectorSockAddrLen);
|
||||
|
||||
if(clientSocket == INVALID_SOCKET) {
|
||||
handleError(Protocol::TCP, ErrorSources::ACCEPT_CALL, 500);
|
||||
closeSocket(clientSocket);
|
||||
continue;
|
||||
};
|
||||
|
||||
retval = recv(clientSocket, reinterpret_cast<char*>(receptionBuffer.data()),
|
||||
receptionBuffer.size(), 0);
|
||||
if(retval > 0) {
|
||||
#if FSFW_TCP_RCV_WIRETAPPING_ENABLED == 1
|
||||
sif::info << "TcpTmTcServer::performOperation: Received " << retval << " bytes."
|
||||
std::endl;
|
||||
#endif
|
||||
handleError(Protocol::TCP, ErrorSources::RECV_CALL, 500);
|
||||
}
|
||||
else if(retval == 0) {
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
/* Done, shut down connection */
|
||||
retval = shutdown(clientSocket, SHUT_SEND);
|
||||
closeSocket(clientSocket);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user