Compare commits

...

172 Commits

Author SHA1 Message Date
d8823f12f1 Merge remote-tracking branch 'upstream/development' into eive/develop 2021-11-19 13:53:55 +01:00
24e45c57d1 removed testcfg file 2021-11-19 13:49:59 +01:00
48af11f03b Merge pull request 'Bugfix' (#25) from mueller/master into eive/develop
Reviewed-on: #25
2021-11-19 13:46:04 +01:00
5d719d0aeb Merge branch 'eive/develop' into mueller/master 2021-11-19 13:21:40 +01:00
c9e3415f01 Merge remote-tracking branch 'upstream/development' into eive/develop 2021-11-19 13:09:54 +01:00
1f7cc7a558 tests running 2021-11-18 19:54:52 +01:00
0a94f84f5a update cmakelists files 2021-11-18 19:52:27 +01:00
400eafcae7 added first unittests space packets
- Also added helper scripts
2021-11-18 19:51:01 +01:00
190848d00e important fix for getter function 2021-11-18 18:52:50 +01:00
15687f6f6e this should have been in the PR.. 2021-10-18 18:21:15 +02:00
e29606a2d0 Merge remote-tracking branch 'upstream/development' into mueller/master 2021-10-18 18:14:50 +02:00
afafab660a Merge branch 'mueller/tcp-keep-open-pr' into mueller/master 2021-10-18 15:07:36 +02:00
3e51e2e094 Merge branch 'mueller/packet-check-printout' into mueller/master 2021-10-18 13:59:35 +02:00
ce6b763219 Merge branch 'mueller/packet-check-printout' into mueller/master 2021-10-17 22:57:05 +02:00
6e507681eb Merge pull request 'Update FSFW' (#24) from mueller/master into eive/develop
Reviewed-on: #24
2021-10-13 17:09:56 +02:00
eba2f87b36 formatting tweak 2021-10-13 15:49:58 +02:00
0dedd8f2a1 Merge branch 'mueller/cmd-executor' into mueller/master 2021-10-11 20:06:10 +02:00
d693817158 added cmakelists source addition 2021-10-11 20:05:11 +02:00
f3dbf68f7c moved command executor 2021-10-11 20:03:29 +02:00
4130dd9e32 using cmakelists from upstream 2021-10-11 19:38:53 +02:00
2e37bd73e2 deleted timer object 2021-10-11 19:35:35 +02:00
ad68802fe4 Merge branch 'develop' into eive/develop 2021-10-11 19:21:48 +02:00
b985bf5167 Merge pull request 'meier/tcpFix' (#23) from meier/tcpFix into eive/develop
Reviewed-on: #23
2021-10-09 13:28:49 +02:00
Jakob Meier
a578f0390b tcp server also parses TCs when client closes connection 2021-10-08 13:51:32 +02:00
Jakob Meier
8e65833d60 added bind call error string 2021-10-08 13:24:51 +02:00
b6e4b1fc72 Merge pull request 'FSFW Update' (#22) from mueller/fsfw-update into eive/develop
Reviewed-on: #22
2021-10-06 17:50:51 +02:00
db801a0ecc removed unneeded static constexpr 2021-10-05 13:17:34 +02:00
3502ddca7f using pus version enum now 2021-10-05 13:14:26 +02:00
2124f36e36 moved store failure to separate function 2021-10-05 12:50:39 +02:00
91f43d00a2 moved store failure to separate function 2021-10-05 12:47:30 +02:00
a8a1148c65 fixes for PUS A stored 2021-10-05 12:39:57 +02:00
94bd4c7b56 using correct version number now 2021-10-05 01:23:56 +02:00
16fb87e02e Merge pull request 'FSFW Update' (#21) from mueller/unittest-fixes into eive/develop
Reviewed-on: #21
2021-09-29 15:45:39 +02:00
7a3dfc2592 Merge branch 'eive/develop' into mueller/unittest-fixes 2021-09-29 11:35:12 +02:00
3d0ce19981 additional options for c ustom main 2021-09-29 10:58:01 +02:00
04cb8e82f1 improvements and fixes 2021-09-29 10:52:21 +02:00
354e158cc1 format fixes 2021-09-29 09:30:50 +02:00
5ee315f8ca put functions in namespace 2021-09-28 17:42:55 +02:00
69922e77c5 this should work for both OSes 2021-09-28 17:38:35 +02:00
01e380c858 windows fixes 2021-09-28 17:36:27 +02:00
6881c6b66a class id renamed 2021-09-28 16:32:43 +02:00
d4bdf314f7 C++11 adaptions 2021-09-28 16:31:53 +02:00
be8623a4f8 delay configurable 2021-09-28 15:32:58 +02:00
304d7e8e32 space packet parser cleaned up, documentation 2021-09-28 15:30:31 +02:00
f2020b2492 removed obsolete empty ctor 2021-09-28 15:12:23 +02:00
5a045d03a5 wiretapping in runtime config now 2021-09-28 15:10:50 +02:00
c7ce568a30 added function to determine space packet ID
from APID
2021-09-28 14:50:50 +02:00
80ccaede02 refactored space packet parser 2021-09-28 14:14:59 +02:00
5fd7a8c9b7 smaller tweaks 2021-09-28 11:03:17 +02:00
254aac51ec cleaning up 2021-09-28 10:57:21 +02:00
9b7da4d9e6 fixing last bugs 2021-09-27 20:00:01 +02:00
71036bf6b1 something wrong with the socket.. 2021-09-27 18:35:50 +02:00
d6b3167922 tcp keep open implementation done 2021-09-27 18:05:45 +02:00
68fe94d594 PusParser integration 2021-09-27 16:15:51 +02:00
62a6e5da0b added PUS again 2021-09-27 16:11:48 +02:00
45c0074bd7 printout improvements 2021-09-27 15:50:23 +02:00
df0adfb33c added new tcp code 2021-09-27 15:35:09 +02:00
ac2b196883 Merge pull request 'Update Linux GPIO' (#20) from mueller/update-linux-gpio into eive/develop
Reviewed-on: #20
2021-09-27 15:28:19 +02:00
98deac1ef1 Merge branch 'mueller/tm-stack-robustness' into mueller/master 2021-09-27 11:07:02 +02:00
ba6cbde28a Increased TM stack robustness
1. More nullptr check
2. returnvalue for inititalize function which can fail
2021-09-27 11:05:26 +02:00
a84c770dfb type improvements and bugfixes 2021-09-27 10:51:31 +02:00
9546495507 improvements for linux libgpioIF 2021-09-27 10:38:47 +02:00
e227b5dead Merge remote-tracking branch 'origin/eive/develop' into mueller/master 2021-09-27 10:09:31 +02:00
9db5f893d7 Merge pull request 'meier/gpioOpenByLineName' (#19) from meier/gpioOpenByLineName into eive/develop
Reviewed-on: #19
2021-09-27 10:09:13 +02:00
4b3e753e19 Merge branch 'eive/develop' into meier/gpioOpenByLineName 2021-09-27 10:08:04 +02:00
36607c8764 Merge branch 'mueller/added-missing-devicehandlers' into mueller/master 2021-09-26 22:45:58 +02:00
b88e6c0713 Merge branch 'mueller/added-missing-devicehandlers' into mueller/master 2021-09-26 22:39:36 +02:00
6ee2c65187 Merge remote-tracking branch 'upstream/development' into mueller/master 2021-09-26 22:21:22 +02:00
2b6c996364 Merge branch 'mueller/devicehandler-package' into mueller/master 2021-09-25 16:42:49 +02:00
dabb488c9d Merge pull request 'MgmLIS3MDLHandler fix in buildTransitionDeviceCommand' (#18) from meier/fixMgmLIS3MDLHandler into eive/develop
Reviewed-on: #18
2021-09-25 16:37:10 +02:00
Jakob Meier
16b125ef6c Merge branch 'meier/fixMgmLIS3MDLHandler' into meier/gpioOpenByLineName 2021-09-24 15:37:49 +02:00
Jakob Meier
10f8a0fd0e MgmLIS3MDLHandler fix in buildTransitionDeviceCommand 2021-09-24 15:33:55 +02:00
Jakob Meier
48a24d7dba removed gpio type GPIO_REGULAR 2021-09-24 10:21:40 +02:00
e0671a395e indentation 2021-09-23 18:14:40 +02:00
665be0d417 better name for wiretapping define 2021-09-23 18:05:17 +02:00
Jakob Meier
e7df520780 fixed merge conflicts 2021-09-23 17:54:41 +02:00
dd610f0d7e Merge branch 'mueller/master' into eive/develop 2021-09-23 17:34:24 +02:00
0987a160c9 new retval for empty slot list 2021-09-23 17:33:45 +02:00
ceeb0c5388 Merge branch 'eive/develop' of https://egit.irs.uni-stuttgart.de/eive/fsfw into eive/develop 2021-09-23 17:14:31 +02:00
91f7184ebb Merge branch 'mueller/master' into eive/develop 2021-09-23 17:14:25 +02:00
e1a85b47c5 tiny tweaks 2021-09-23 17:13:53 +02:00
a3eb870ba0 Corrected comment 2021-09-23 16:45:37 +02:00
ed2263b5f7 Merge pull request 'Improvements for devices' (#17) from mueller/acs-board-improvements into eive/develop
Reviewed-on: #17
2021-09-23 15:59:20 +02:00
dccc2f0ba7 printout fix SpiComIF 2021-09-23 15:57:50 +02:00
350fbc385c small tweak 2021-09-23 15:22:27 +02:00
c9b343ebcd op divider fixes 2021-09-23 15:20:10 +02:00
81c33d2dc6 added functions to set x,y,z limits 2021-09-23 14:56:20 +02:00
29c74283f1 sanity checks 2021-09-22 18:36:53 +02:00
c51d2df43d printout fix 2021-09-22 16:00:18 +02:00
d3b83f3cf9 API made more consistent 2021-09-22 15:02:34 +02:00
60229da670 Merge pull request 'GPIO Refactoring' (#16) from mueller/gpio-refactoring into eive/develop
Reviewed-on: #16
2021-09-22 14:39:53 +02:00
5c56eda610 fix for raspberry pi code 2021-09-22 12:19:30 +02:00
3d1be94e12 more checks and printouts 2021-09-21 19:27:33 +02:00
8e65d2d3fc refactored GPIO components 2021-09-21 17:31:03 +02:00
8374d495fa Merge remote-tracking branch 'origin/eive/develop' into mueller/master 2021-09-21 16:02:41 +02:00
e02879184b Merge pull request 'added option to open gpio by label instead of gpiochip*' (#15) from meier/gpioOpenByLabel into eive/develop
Reviewed-on: #15
2021-09-21 16:01:28 +02:00
Jakob Meier
70a3749dbe added option to open gpio by label instead of gpiochip* 2021-09-20 18:38:18 +02:00
87b68e84be Merge branch 'mueller/master' of https://egit.irs.uni-stuttgart.de/eive/fsfw into mueller/master 2021-09-20 18:33:03 +02:00
7000ba05c5 Merge pull request 'Update EIVE FSFW' (#14) from mueller/master into eive/develop
Reviewed-on: #14
2021-09-20 18:32:47 +02:00
9948c4f31d Merge branch 'eive/develop' into mueller/master 2021-09-20 18:32:28 +02:00
784a0140f4 tweak op divider divisor 2021-09-20 18:31:52 +02:00
635432d7ba missing return 2021-09-20 18:29:57 +02:00
e8050183f4 better printout 2021-09-17 16:52:31 +02:00
7d44aab98e some tweaks for op divider 2021-09-17 13:07:43 +02:00
4489a61a00 Merge pull request 'Update FSFW' (#13) from mueller/update-fsfw into eive/develop
Reviewed-on: #13
2021-09-17 07:55:57 +02:00
b1a56a71cd Added LIS3MDL to FSFW, per op divider tweak 2021-09-16 18:50:20 +02:00
6d0d04ac23 minor bugfix 2021-09-16 17:33:37 +02:00
8f3edc90ba Merge branch 'eive/develop' into mueller/update-fsfw 2021-09-16 11:43:30 +02:00
7b5334ccec Merge remote-tracking branch 'upstream/development' into eive/develop 2021-09-16 11:40:12 +02:00
a58016859b Merge branch 'develop' into mueller/master 2021-09-16 11:38:56 +02:00
0df8d35802 comment format 2021-09-16 11:36:32 +02:00
823c6ec5fc added RM3100 handler 2021-09-16 11:33:50 +02:00
bc6b29e652 use warning instead of debug 2021-09-15 18:48:09 +02:00
d986ab7720 bugfix for TM packet stored PUS C 2021-09-15 18:37:44 +02:00
bdd7d59d82 reverted some changes 2021-09-15 17:05:52 +02:00
edf33cc10a Merge remote-tracking branch 'upstream/development' into mueller/master 2021-09-15 16:57:42 +02:00
6db5011b14 spi and gyro l3g updates 2021-09-15 16:55:24 +02:00
97494a84df Merge remote-tracking branch 'upstream/development' into mueller/master 2021-09-13 10:59:26 +02:00
40adca5f1d set reply recipient 2021-09-08 17:24:33 +02:00
a8167f5431 added another helper function 2021-09-08 17:02:08 +02:00
41f3d7cf9a better name for function 2021-09-08 16:58:30 +02:00
e6e1936293 Merge remote-tracking branch 'origin/mueller/dhb-periodoc-reply-fix' into mueller/master 2021-09-08 16:21:13 +02:00
15f35f200a Merge remote-tracking branch 'origin/mueller/dhb-bugfixes-improvements' into mueller/master 2021-09-08 16:20:42 +02:00
6b20bb197a Merge branch 'development' into mueller/dhb-bugfixes-improvements 2021-09-08 16:20:04 +02:00
215d01b3ca Merge branch 'mueller/dhb-bugfixes-improvements' into mueller/master 2021-09-08 16:09:03 +02:00
dfe49cc1e5 DHB improvements 2021-09-08 16:08:13 +02:00
73eb11f4f1 bugfixes and improvements 2021-09-08 16:01:46 +02:00
924c150af2 Possible bugfix in DHB
The delayCycles variables needs to be initialized differently
for periodic replies.
It is initialized to the maxDelayCycles value now
2021-09-06 12:05:30 +02:00
469eba3ce2 raised limit 2021-09-06 11:35:14 +02:00
fd2916af11 moved TCP cfg 2021-08-23 09:40:02 +02:00
afd375a7f8 minor fix for canonical read handling 2021-08-22 20:24:50 +02:00
5454169e20 UartComIF: set O_NONBLOCK in canonical mode
When using the non-canonical mode, the file descriptor can be opened
in blocking mode because the VTIME and VMIN termios parameters are
used to configure non-blocking mode. However, in canonical mode, the fd needs to be opened with O_NONBLOCK
2021-08-22 19:48:35 +02:00
7d0377845b printout for unknown command 2021-08-20 15:46:34 +02:00
882da68a2f Merge branch 'mueller/unix-file-guard-fix' into mueller/master 2021-08-19 17:17:03 +02:00
04a1fe7f10 Merge pull request 'Update FSFW' (#12) from mueller/update-fsfw into eive/develop
Reviewed-on: #12
2021-08-18 12:47:31 +02:00
5f79f987ae Merge branch 'eive/develop' into mueller/update-fsfw 2021-08-18 11:27:02 +02:00
1183e5739d using upstream action helper
Will be merged upstream soon
2021-08-18 11:23:45 +02:00
e3697d6d8c fixed printout 2021-08-17 19:50:01 +02:00
406b77ea81 moved SPI wiretapping cfg 2021-08-17 16:34:25 +02:00
8a9eb27458 Merge pull request 'FSFW Update' (#11) from mueller/master into eive/develop
Reviewed-on: #11
2021-08-11 13:13:11 +02:00
1ac372cb89 getter function for UDP port 2021-08-09 18:22:22 +02:00
fb36dc4501 More improvements for TCP/UDP port definition 2021-08-09 18:12:25 +02:00
ba5e2ad8bb Cleaning up TCP and UDP code
Same port number used as before, but some inconsistencies fixed
2021-08-09 16:57:24 +02:00
5a6c81130d Merge remote-tracking branch 'upstream/development' into mueller/master 2021-08-09 16:18:38 +02:00
22e29144b6 Merge remote-tracking branch 'origin/eive/develop' into mueller/master 2021-08-09 11:12:37 +02:00
52bff3985f Merge pull request 'set sequence flags in space packet base' (#9) from meier/spacePacketFlag into eive/develop
Reviewed-on: #9
2021-08-09 11:11:46 +02:00
Jakob.Meier
133820f463 Merge branch 'eive/develop' into meier/spacePacketFlag 2021-08-08 15:32:24 +02:00
Jakob.Meier
8d3fceea8f set sequence flags in space packet base 2021-08-08 15:26:18 +02:00
3704d2b829 bugfix 2021-08-05 18:24:56 +02:00
6073abb12d added some utility to timer module 2021-08-05 18:13:01 +02:00
47bec654a0 Merge pull request 'Update EIVE FSFW' (#8) from mueller/master into eive/develop
Reviewed-on: #8
2021-08-05 16:35:23 +02:00
b2c102b2c1 Service Interface and Bugfix
1. Service Interface looks better now
2. Bugfix in CommandExecutor blocking mode
2021-08-05 16:13:22 +02:00
4202205182 getter function for current state 2021-08-05 16:02:17 +02:00
c8472beb5f added new command executor 2021-08-05 15:42:47 +02:00
1a4a85ceb2 Merge branch 'mueller/master' of https://egit.irs.uni-stuttgart.de/eive/fsfw into mueller/master 2021-08-03 18:38:27 +02:00
7922bf76da corrected README 2021-08-03 18:38:18 +02:00
bb88490cc6 Merge remote-tracking branch 'upstream/mueller/restructuring' into mueller/master 2021-08-03 15:55:38 +02:00
296c587e3d additional nullptr check 2021-08-03 15:29:22 +02:00
0ff81294e7 Merge branch 'eive/develop' of https://egit.irs.uni-stuttgart.de/eive/fsfw into eive/develop 2021-08-02 12:49:50 +02:00
b6e243b8b3 var name clarification 2021-08-02 12:49:40 +02:00
3bbcc42d39 Merge pull request 'type missmatch' (#7) from mohr-patch-1 into eive/develop
Reviewed-on: #7
2021-07-26 19:04:06 +02:00
fc4324a2fa type missmatch 2021-07-26 18:35:53 +02:00
54c028f913 naming adaptions 2021-07-26 13:50:45 +02:00
1f6a5e635f naming fixes 2021-07-26 11:46:58 +02:00
c5b4b01362 Merge branch 'mueller/master' into eive/develop 2021-07-24 15:04:01 +02:00
c5420c7b53 bumped subversion 2021-07-24 14:39:43 +02:00
3e422f51bd corrected version number 2021-07-24 13:43:13 +02:00
d1be0f9843 Merge pull request 'Update framework' (#6) from mueller/master into eive/develop
Reviewed-on: #6
2021-07-23 18:26:39 +02:00
Jakob.Meier
b83259592a uart flush function 2021-07-23 18:06:36 +02:00
a7a4e0f219 api consistent now 2021-07-19 19:03:20 +02:00
bdc5f593e2 Merge remote-tracking branch 'upstream/mueller/master' into mueller/master 2021-07-19 18:50:20 +02:00
10f7185e81 added includes 2021-07-19 13:08:40 +02:00
15 changed files with 398 additions and 42 deletions

View File

@@ -4,6 +4,7 @@ endif()
target_sources(${LIB_FSFW_NAME} PRIVATE
UnixFileGuard.cpp
CommandExecutor.cpp
utility.cpp
)

View File

@@ -0,0 +1,210 @@
#include "CommandExecutor.h"
#include "fsfw/serviceinterface.h"
#include "fsfw/container/SimpleRingBuffer.h"
#include "fsfw/container/DynamicFIFO.h"
#include <unistd.h>
#include <cstring>
CommandExecutor::CommandExecutor(const size_t maxSize):
readVec(maxSize) {
waiter.events = POLLIN;
}
ReturnValue_t CommandExecutor::load(std::string command, bool blocking, bool printOutput) {
if(state == States::PENDING) {
return COMMAND_PENDING;
}
currentCmd = command;
this->blocking = blocking;
this->printOutput = printOutput;
if(state == States::IDLE) {
state = States::COMMAND_LOADED;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t CommandExecutor::execute() {
if(state == States::IDLE) {
return NO_COMMAND_LOADED_OR_PENDING;
}
else if(state == States::PENDING) {
return COMMAND_PENDING;
}
currentCmdFile = popen(currentCmd.c_str(), "r");
if(currentCmdFile == nullptr) {
lastError = errno;
return HasReturnvaluesIF::RETURN_FAILED;
}
if(blocking) {
return executeBlocking();
}
else {
currentFd = fileno(currentCmdFile);
waiter.fd = currentFd;
}
state = States::PENDING;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t CommandExecutor::close() {
if(state == States::PENDING) {
// Attempt to close process, irrespective of if it is running or not
if(currentCmdFile != nullptr) {
pclose(currentCmdFile);
}
}
return HasReturnvaluesIF::RETURN_OK;
}
void CommandExecutor::printLastError(std::string funcName) const {
if(lastError != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << funcName << " pclose failed with code " << lastError << ": " <<
strerror(lastError) << std::endl;
#else
sif::printError("%s pclose failed with code %d: %s\n",
funcName, lastError, strerror(lastError));
#endif
}
}
void CommandExecutor::setRingBuffer(SimpleRingBuffer *ringBuffer,
DynamicFIFO<uint16_t>* sizesFifo) {
this->ringBuffer = ringBuffer;
this->sizesFifo = sizesFifo;
}
ReturnValue_t CommandExecutor::check(bool& bytesRead) {
if(blocking) {
return HasReturnvaluesIF::RETURN_OK;
}
switch(state) {
case(States::IDLE):
case(States::COMMAND_LOADED): {
return NO_COMMAND_LOADED_OR_PENDING;
}
case(States::PENDING): {
break;
}
}
int result = poll(&waiter, 1, 0);
switch(result) {
case(0): {
return HasReturnvaluesIF::RETURN_OK;
break;
}
case(1): {
if (waiter.revents & POLLIN) {
ssize_t readBytes = read(currentFd, readVec.data(), readVec.size());
if(readBytes == 0) {
// Should not happen
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "CommandExecutor::check: No bytes read "
"after poll event.." << std::endl;
#else
sif::printWarning("CommandExecutor::check: No bytes read after poll event..\n");
#endif
break;
}
else if(readBytes > 0) {
bytesRead = true;
if(printOutput) {
// It is assumed the command output is line terminated
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << currentCmd << " | " << readVec.data();
#else
sif::printInfo("%s | %s", currentCmd, readVec.data());
#endif
}
if(ringBuffer != nullptr) {
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(
readVec.data()), readBytes);
}
if(sizesFifo != nullptr) {
if(not sizesFifo->full()) {
sizesFifo->insert(readBytes);
}
}
return BYTES_READ;
}
else {
// Should also not happen
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "CommandExecutor::check: Error " << errno << ": " <<
strerror(errno) << std::endl;
#else
sif::printWarning("CommandExecutor::check: Error %d: %s\n", errno, strerror(errno));
#endif
}
}
else if(waiter.revents & POLLERR) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "CommandExecuter::check: Poll error" << std::endl;
#else
sif::printWarning("CommandExecuter::check: Poll error\n");
#endif
return COMMAND_ERROR;
}
else if(waiter.revents & POLLHUP) {
int result = pclose(currentCmdFile);
if(result != 0) {
lastError = result;
return HasReturnvaluesIF::RETURN_FAILED;
}
state = States::IDLE;
currentCmdFile = nullptr;
currentFd = 0;
return EXECUTION_FINISHED;
}
break;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
void CommandExecutor::reset() {
CommandExecutor::close();
currentCmdFile = nullptr;
currentFd = 0;
state = States::IDLE;
}
int CommandExecutor::getLastError() const {
return this->lastError;
}
CommandExecutor::States CommandExecutor::getCurrentState() const {
return state;
}
ReturnValue_t CommandExecutor::executeBlocking() {
while(fgets(readVec.data(), readVec.size(), currentCmdFile) != nullptr) {
std::string output(readVec.data());
if(printOutput) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << currentCmd << " | " << output;
#else
sif::printInfo("%s | %s", currentCmd, output);
#endif
}
if(ringBuffer != nullptr) {
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(output.data()), output.size());
}
if(sizesFifo != nullptr) {
if(not sizesFifo->full()) {
sizesFifo->insert(output.size());
}
}
}
int result = pclose(currentCmdFile);
if(result != 0) {
lastError = result;
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
}

View File

@@ -0,0 +1,134 @@
#ifndef FSFW_SRC_FSFW_OSAL_LINUX_COMMANDEXECUTOR_H_
#define FSFW_SRC_FSFW_OSAL_LINUX_COMMANDEXECUTOR_H_
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/returnvalues/FwClassIds.h"
#include <poll.h>
#include <string>
#include <vector>
class SimpleRingBuffer;
template <typename T> class DynamicFIFO;
/**
* @brief Helper class to execute shell commands in blocking and non-blocking mode
* @details
* This class is able to execute processes by using the Linux popen call. It also has the
* capability of writing the read output of a process into a provided ring buffer.
*
* The executor works by first loading the command which should be executed and specifying
* whether it should be executed blocking or non-blocking. After that, execution can be started
* with the execute command. In blocking mode, the execute command will block until the command
* has finished
*/
class CommandExecutor {
public:
enum class States {
IDLE,
COMMAND_LOADED,
PENDING
};
static constexpr uint8_t CLASS_ID = CLASS_ID::LINUX_OSAL;
//! [EXPORT] : [COMMENT] Execution of the current command has finished
static constexpr ReturnValue_t EXECUTION_FINISHED =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0);
//! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries
//! to load another command but a command is still pending
static constexpr ReturnValue_t COMMAND_PENDING =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1);
//! [EXPORT] : [COMMENT] Some bytes have been read from the executing process
static constexpr ReturnValue_t BYTES_READ =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2);
//! [EXPORT] : [COMMENT] Command execution failed
static constexpr ReturnValue_t COMMAND_ERROR =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3);
//! [EXPORT] : [COMMENT]
static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4);
static constexpr ReturnValue_t PCLOSE_CALL_ERROR =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 6);
/**
* Constructor. Is initialized with maximum size of internal buffer to read data from the
* executed process.
* @param maxSize
*/
CommandExecutor(const size_t maxSize);
/**
* Load a new command which should be executed
* @param command
* @param blocking
* @param printOutput
* @return
*/
ReturnValue_t load(std::string command, bool blocking, bool printOutput = true);
/**
* Execute the loaded command.
* @return
* - In blocking mode, it will return RETURN_FAILED if
* the result of the system call was not 0. The error value can be accessed using
* getLastError
* - In non-blocking mode, this call will start
* the execution and then return RETURN_OK
*/
ReturnValue_t execute();
/**
* Only used in non-blocking mode. Checks the currently running command.
* @param bytesRead Will be set to the number of bytes read, if bytes have been read
* @return
* - BYTES_READ if bytes have been read from the executing process. It is recommended to call
* check again after this
* - RETURN_OK execution is pending, but no bytes have been read from the executing process
* - RETURN_FAILED if execution has failed, error value can be accessed using getLastError
* - EXECUTION_FINISHED if the process was executed successfully
* - COMMAND_ERROR internal poll error
*/
ReturnValue_t check(bool& bytesRead);
/**
* Abort the current command. Should normally not be necessary, check can be used to find
* out whether command execution was successful
* @return RETURN_OK
*/
ReturnValue_t close();
States getCurrentState() const;
int getLastError() const;
void printLastError(std::string funcName) const;
/**
* Assign a ring buffer and a FIFO which will be filled by the executor with the output
* read from the started process
* @param ringBuffer
* @param sizesFifo
*/
void setRingBuffer(SimpleRingBuffer* ringBuffer, DynamicFIFO<uint16_t>* sizesFifo);
/**
* Reset the executor. This calls close internally and then reset the state machine so new
* commands can be loaded and executed
*/
void reset();
private:
std::string currentCmd;
bool blocking = true;
FILE* currentCmdFile = nullptr;
int currentFd = 0;
bool printOutput = true;
std::vector<char> readVec;
struct pollfd waiter {};
SimpleRingBuffer* ringBuffer = nullptr;
DynamicFIFO<uint16_t>* sizesFifo = nullptr;
States state = States::IDLE;
int lastError = 0;
ReturnValue_t executeBlocking();
};
#endif /* FSFW_SRC_FSFW_OSAL_LINUX_COMMANDEXECUTOR_H_ */

View File

@@ -6,6 +6,7 @@ import platform
import sys
import time
import argparse
import webbrowser
from typing import List
@@ -18,6 +19,10 @@ information how to set up the build folder.
def main():
parser = argparse.ArgumentParser(description="Processing arguments for LCOV helper script.")
parser.add_argument(
'-o', '--open', action='store_true', help='Open coverage data in webbrowser'
)
args = parser.parse_args()
build_dir_list = []
if not os.path.isfile('README.md'):
@@ -41,6 +46,8 @@ def main():
print("Multiple build directories found!")
build_directory = determine_build_dir(build_dir_list)
perform_lcov_operation(build_directory)
if os.path.isdir('fsfw-tests_coverage') and args.open:
webbrowser.open('fsfw-tests_coverage/index.html')
def check_for_cmake_build_dir(build_dir_dict: list):

3
scripts/gen-unittest.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
mkdir build-Unittest && cd build-Unittest
cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug ..

View File

@@ -18,6 +18,10 @@
// FSFW core defines
#ifndef FSFW_TCP_RECV_WIRETAPPING_ENABLED
#define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0
#endif
#ifndef FSFW_CPP_OSTREAM_ENABLED
#define FSFW_CPP_OSTREAM_ENABLED 1
#endif /* FSFW_CPP_OSTREAM_ENABLED */

View File

@@ -5,8 +5,7 @@
#include <cstddef>
/**
* @brief Circular buffer implementation, useful for buffering
* into data streams.
* @brief Circular buffer implementation, useful for buffering into data streams.
* @details
* Note that the deleteData() has to be called to increment the read pointer.
* This class allocated dynamically, so
@@ -20,8 +19,8 @@ public:
* @param size
* @param overwriteOld If the ring buffer is overflowing at a write
* operation, the oldest data will be overwritten.
* @param maxExcessBytes These additional bytes will be allocated in addtion
* to the specified size to accomodate contiguous write operations
* @param maxExcessBytes These additional bytes will be allocated in addition
* to the specified size to accommodate continuous write operations
* with getFreeElement.
*
*/
@@ -32,10 +31,10 @@ public:
* @param buffer
* @param size
* @param overwriteOld
* If the ring buffer is overflowing at a write operartion, the oldest data
* If the ring buffer is overflowing at a write operation, the oldest data
* will be overwritten.
* @param maxExcessBytes
* If the buffer can accomodate additional bytes for contigous write
* If the buffer can accommodate additional bytes for contiguous write
* operations with getFreeElement, this is the maximum allowed additional
* size
*/
@@ -48,7 +47,7 @@ public:
* Write to circular buffer and increment write pointer by amount.
* @param data
* @param amount
* @return -@c RETURN_OK if write operation was successfull
* @return -@c RETURN_OK if write operation was successful
* -@c RETURN_FAILED if
*/
ReturnValue_t writeData(const uint8_t* data, size_t amount);
@@ -108,7 +107,7 @@ public:
* Delete data by incrementing read pointer.
* @param amount
* @param deleteRemaining
* If the amount specified is larger than the remaing size to read and this
* If the amount specified is larger than the remaining size to read and this
* is set to true, the remaining amount will be deleted as well
* @param trueAmount [out]
* If deleteRemaining was set to true, the amount deleted will be assigned

View File

@@ -7,7 +7,7 @@
/**
* @brief Base class to implement reconfiguration and failure handling for
* redundant devices by monitoring their modes health states.
* redundant devices by monitoring their modes and health states.
* @details
* Documentation: Dissertation Baetz p.156, 157.
*

View File

@@ -85,9 +85,10 @@ public:
* Called by DHB in the GET_WRITE doGetWrite().
* Get send confirmation that the data in sendMessage() was sent successfully.
* @param cookie
* @return - @c RETURN_OK if data was sent successfull
* - Everything else triggers falure event with
* returnvalue as parameter 1
* @return
* - @c RETURN_OK if data was sent successfully but a reply is expected
* - NO_REPLY_EXPECTED if data was sent successfully and no reply is expected
* - Everything else to indicate failure
*/
virtual ReturnValue_t getSendSuccess(CookieIF *cookie) = 0;

View File

@@ -334,8 +334,7 @@ protected:
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen
* have been set.
* - @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.
* be used if no reply is expected
* - Anything else triggers an event with the return code as a parameter as well as a
* step reply failed with the return code
*/

View File

@@ -120,7 +120,8 @@ public:
static const ReturnValue_t WRONG_MODE_FOR_COMMAND = MAKE_RETURN_CODE(0xA5);
static const ReturnValue_t TIMEOUT = MAKE_RETURN_CODE(0xA6);
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(0xA7);
static const ReturnValue_t NO_REPLY_EXPECTED = MAKE_RETURN_CODE(0xA8); //!< Used to indicate that this is a command-only command.
//!< Used to indicate that this is a command-only command.
static const ReturnValue_t NO_REPLY_EXPECTED = MAKE_RETURN_CODE(0xA8);
static const ReturnValue_t NON_OP_TEMPERATURE = MAKE_RETURN_CODE(0xA9);
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xAA);

View File

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

View File

@@ -285,10 +285,10 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
utility::printUnixErrorGeneric(CLASS_NAME, "sendMessageFromMessageQueue", "EBADF");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "mq_send to: " << sendTo << " sent from "
<< sentFrom << "failed" << std::endl;
sif::warning << "mq_send to " << sendTo << " sent from "
<< sentFrom << " failed" << std::endl;
#else
sif::printWarning("mq_send to: %d sent from %d failed\n", sendTo, sentFrom);
sif::printWarning("mq_send to %d sent from %d failed\n", sendTo, sentFrom);
#endif
return DESTINATION_INVALID;
}

View File

@@ -62,7 +62,8 @@ protected:
struct ChildInfo {
MessageQueueId_t commandQueue;
Mode_t mode;
Submode_t submode;bool healthChanged;
Submode_t submode;
bool healthChanged;
};
Mode_t mode;