From d06eecf9b043a375d0c7b84b0bec472fb9483063 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 7 Mar 2022 15:54:56 +0100 Subject: [PATCH 01/35] small test device handler fixes --- .../fsfw_tests/integration/devices/TestDeviceHandler.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp index 41098723..cd15d6e0 100644 --- a/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp +++ b/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp @@ -208,7 +208,7 @@ ReturnValue_t TestDevice::buildNormalModeCommand(DeviceCommandId_t deviceCommand const uint8_t* commandData, size_t commandDataLen) { if (fullInfoPrintout) { -#if OBSW_VERBOSE_LEVEL >= 3 +#if FSFW_VERBOSE_LEVEL >= 3 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice::buildTestCommand1: Building normal command" << std::endl; #else @@ -351,7 +351,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC switch (pendingCmd) { case (TEST_NORMAL_MODE_CMD): { if (fullInfoPrintout) { -#if OBSW_VERBOSE_LEVEL >= 3 +#if FSFW_VERBOSE_LEVEL >= 3 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice::scanForReply: Reply for normal commnand (ID " << TEST_NORMAL_MODE_CMD << ") received!" << std::endl; @@ -678,7 +678,6 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, int32_t newValue = 0; ReturnValue_t result = newValues->getElement(&newValue, 0, 0); if (result == HasReturnvaluesIF::RETURN_OK) { -#if OBSW_DEVICE_HANDLER_PRINTOUT == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx << "::getParameter: Setting parameter 1 to " @@ -688,7 +687,6 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, sif::printInfo("TestDevice%d::getParameter: Setting parameter 1 to new value %lu\n", deviceIdx, static_cast(newValue)); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* OBSW_DEVICE_HANDLER_PRINTOUT == 1 */ } } parameterWrapper->set(testParameter1); @@ -702,7 +700,6 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, newValues->getElement(newVector + 2, 0, 2) != RETURN_OK) { return HasReturnvaluesIF::RETURN_FAILED; } -#if OBSW_DEVICE_HANDLER_PRINTOUT == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx << "::getParameter: Setting parameter 3 to " @@ -715,7 +712,6 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, "[%f, %f, %f]\n", deviceIdx, newVector[0], newVector[1], newVector[2]); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* OBSW_DEVICE_HANDLER_PRINTOUT == 1 */ } parameterWrapper->setVector(vectorFloatParams2); break; From 5ddac36314bfe5fd617c60baa9380143ae6c0c4f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 7 Mar 2022 16:07:01 +0100 Subject: [PATCH 02/35] GPIO update --- hal/CMakeLists.txt | 1 + hal/src/fsfw_hal/common/gpio/gpioDefinitions.h | 14 +++++++------- hal/src/fsfw_hal/linux/CMakeLists.txt | 2 ++ hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp | 15 ++++++++------- hal/src/fsfw_hal/linux/rpi/GpioRPi.cpp | 2 +- hal/src/fsfw_hal/linux/rpi/GpioRPi.h | 3 ++- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt index 424a012d..7a97ae0f 100644 --- a/hal/CMakeLists.txt +++ b/hal/CMakeLists.txt @@ -9,6 +9,7 @@ option(FSFW_HAL_ADD_LINUX "Add the Linux HAL to the sources. Requires gpiod libr # Linux. The only exception from this is the gpiod library which requires a dedicated installation, # but CMake is able to determine whether this library is installed with find_library. option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add peripheral drivers for embedded Linux" ON) +option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Target implements libgpiod" ON) option(FSFW_HAL_ADD_RASPBERRY_PI "Add Raspberry Pi specific code to the sources" OFF) option(FSFW_HAL_ADD_STM32H7 "Add the STM32H7 HAL to the sources" OFF) diff --git a/hal/src/fsfw_hal/common/gpio/gpioDefinitions.h b/hal/src/fsfw_hal/common/gpio/gpioDefinitions.h index b429449b..eb90629e 100644 --- a/hal/src/fsfw_hal/common/gpio/gpioDefinitions.h +++ b/hal/src/fsfw_hal/common/gpio/gpioDefinitions.h @@ -9,11 +9,11 @@ using gpioId_t = uint16_t; namespace gpio { -enum Levels : uint8_t { LOW = 0, HIGH = 1, NONE = 99 }; +enum class Levels : int { LOW = 0, HIGH = 1, NONE = 99 }; -enum Direction : uint8_t { IN = 0, OUT = 1 }; +enum class Direction : int { IN = 0, OUT = 1 }; -enum GpioOperation { READ, WRITE }; +enum class GpioOperation { READ, WRITE }; enum class GpioTypes { NONE, @@ -80,7 +80,7 @@ class GpiodRegularByChip : public GpiodRegularBase { public: GpiodRegularByChip() : GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, std::string(), gpio::Direction::IN, - gpio::LOW, 0) {} + gpio::Levels::LOW, 0) {} GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_, gpio::Direction direction_, gpio::Levels initValue_) @@ -90,7 +90,7 @@ class GpiodRegularByChip : public GpiodRegularBase { GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_) : GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, consumer_, gpio::Direction::IN, - gpio::LOW, lineNum_), + gpio::Levels::LOW, lineNum_), chipname(chipname_) {} std::string chipname; @@ -106,7 +106,7 @@ class GpiodRegularByLabel : public GpiodRegularBase { GpiodRegularByLabel(std::string label_, int lineNum_, std::string consumer_) : GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_, gpio::Direction::IN, - gpio::LOW, lineNum_), + gpio::Levels::LOW, lineNum_), label(label_) {} std::string label; @@ -127,7 +127,7 @@ class GpiodRegularByLineName : public GpiodRegularBase { GpiodRegularByLineName(std::string lineName_, std::string consumer_) : GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_, gpio::Direction::IN, - gpio::LOW), + gpio::Levels::LOW), lineName(lineName_) {} std::string lineName; diff --git a/hal/src/fsfw_hal/linux/CMakeLists.txt b/hal/src/fsfw_hal/linux/CMakeLists.txt index 0fb2d385..56d4bf48 100644 --- a/hal/src/fsfw_hal/linux/CMakeLists.txt +++ b/hal/src/fsfw_hal/linux/CMakeLists.txt @@ -9,7 +9,9 @@ target_sources(${LIB_FSFW_NAME} PRIVATE ) if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS) +if(FSFW_HAL_LINUX_ADD_LIBGPIOD) add_subdirectory(gpio) +endif() add_subdirectory(spi) add_subdirectory(i2c) add_subdirectory(uart) diff --git a/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp b/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp index a33305b6..3b9a21f7 100644 --- a/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp +++ b/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp @@ -161,11 +161,12 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod consumer = regularGpio.consumer; /* Configure direction and add a description to the GPIO */ switch (direction) { - case (gpio::OUT): { - result = gpiod_line_request_output(lineHandle, consumer.c_str(), regularGpio.initValue); + case (gpio::Direction::OUT): { + result = gpiod_line_request_output(lineHandle, consumer.c_str(), + static_cast(regularGpio.initValue)); break; } - case (gpio::IN): { + case (gpio::Direction::IN): { result = gpiod_line_request_input(lineHandle, consumer.c_str()); break; } @@ -211,7 +212,7 @@ ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) { if (regularGpio == nullptr) { return GPIO_TYPE_FAILURE; } - return driveGpio(gpioId, *regularGpio, gpio::HIGH); + return driveGpio(gpioId, *regularGpio, gpio::Levels::HIGH); } else { auto gpioCallback = dynamic_cast(gpioMapIter->second); if (gpioCallback->callback == nullptr) { @@ -243,7 +244,7 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) { if (regularGpio == nullptr) { return GPIO_TYPE_FAILURE; } - return driveGpio(gpioId, *regularGpio, gpio::LOW); + return driveGpio(gpioId, *regularGpio, gpio::Levels::LOW); } else { auto gpioCallback = dynamic_cast(gpioMapIter->second); if (gpioCallback->callback == nullptr) { @@ -258,11 +259,11 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) { ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio, gpio::Levels logicLevel) { - int result = gpiod_line_set_value(regularGpio.lineHandle, logicLevel); + int result = gpiod_line_set_value(regularGpio.lineHandle, static_cast(logicLevel)); if (result < 0) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId - << " to logic level " << logicLevel << std::endl; + << " to logic level " << static_cast(logicLevel) << std::endl; #else sif::printWarning( "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID %d to " diff --git a/hal/src/fsfw_hal/linux/rpi/GpioRPi.cpp b/hal/src/fsfw_hal/linux/rpi/GpioRPi.cpp index c005e24f..d3c0a577 100644 --- a/hal/src/fsfw_hal/linux/rpi/GpioRPi.cpp +++ b/hal/src/fsfw_hal/linux/rpi/GpioRPi.cpp @@ -7,7 +7,7 @@ ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin, std::string consumer, gpio::Direction direction, - int initValue) { + gpio::Levels initValue) { if (cookie == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/hal/src/fsfw_hal/linux/rpi/GpioRPi.h b/hal/src/fsfw_hal/linux/rpi/GpioRPi.h index 499f984b..8ca7065a 100644 --- a/hal/src/fsfw_hal/linux/rpi/GpioRPi.h +++ b/hal/src/fsfw_hal/linux/rpi/GpioRPi.h @@ -21,7 +21,8 @@ namespace gpio { * @return */ ReturnValue_t createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin, - std::string consumer, gpio::Direction direction, int initValue); + std::string consumer, gpio::Direction direction, + gpio::Levels initValue); } // namespace gpio #endif /* BSP_RPI_GPIO_GPIORPI_H_ */ From 41a82e923cbd78d3e65db4d4c8818ea75a394755 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 7 Mar 2022 16:09:18 +0100 Subject: [PATCH 03/35] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa59651f..26df4486 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes +- GPIO HAL: Renamed entries of enumerations to avoid nameclashes with Windows defines. + `IN` and `OUT` in `Direction` changed to `DIR_IN` and `DIR_OUT`. + `CALLBACK` in `GpioTypes` changed to `TYPE_CALLBACK` - HAL Devicehandlers: Periodic printout is run-time configurable now - `oneShotAction` flag in the `TestTask` class is not static anymore From 32f420c4f0abb9294b6fd178bfd48edb7402de12 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 7 Mar 2022 16:13:04 +0100 Subject: [PATCH 04/35] SPI HAL improvement - Initialize line state --- hal/src/fsfw_hal/linux/spi/SpiComIF.cpp | 8 ++++++++ hal/src/fsfw_hal/linux/spi/SpiComIF.h | 1 + 2 files changed, 9 insertions(+) diff --git a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp index d95232c1..dcf92b5d 100644 --- a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp +++ b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp @@ -401,4 +401,12 @@ void SpiComIF::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) if (retval != 0) { utility::handleIoctlError("SpiComIF::setSpiSpeedAndMode: Setting SPI speed failed"); } + // This updates the SPI clock default polarity. Only setting the mode does not update + // the line state, which can be an issue on mode switches because the clock line will + // switch the state after the chip select is pulled low + clockUpdateTransfer.len = 0; + retval = ioctl(spiFd, SPI_IOC_MESSAGE(1), &clockUpdateTransfer); + if (retval != 0) { + utility::handleIoctlError("SpiComIF::setSpiSpeedAndMode: Updating SPI default clock failed"); + } } diff --git a/hal/src/fsfw_hal/linux/spi/SpiComIF.h b/hal/src/fsfw_hal/linux/spi/SpiComIF.h index 1f825d52..357afa2f 100644 --- a/hal/src/fsfw_hal/linux/spi/SpiComIF.h +++ b/hal/src/fsfw_hal/linux/spi/SpiComIF.h @@ -74,6 +74,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject { MutexIF* spiMutex = nullptr; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; uint32_t timeoutMs = 20; + spi_ioc_transfer clockUpdateTransfer = {}; using SpiDeviceMap = std::unordered_map; using SpiDeviceMapIter = SpiDeviceMap::iterator; From 983fa346b30441e98081992f8abebeb16aa24483 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 7 Mar 2022 16:17:33 +0100 Subject: [PATCH 05/35] update CHANGELOG --- CHANGELOG.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa59651f..717932c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,17 +12,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes -- HAL Devicehandlers: Periodic printout is run-time configurable now -- `oneShotAction` flag in the `TestTask` class is not static anymore +- HAL Linux SPI: Set the Clock Default State when setting new SPI speed + and mode + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/573 +- HAL Devicehandlers: Periodic printout is run-time configurable now. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/561 +- `oneShotAction` flag in the `TestTask` class is not static anymore. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/560 ## Removed - Removed the `HkSwitchHelper`. This module should not be needed anymore, now that the local - datapools have been implemented + datapools have been implemented. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/557 ## Additions - Linux HAL: Add wiretapping option for I2C. Enabled with `FSFW_HAL_I2C_WIRETAPPING` defined to 1 + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/559 # [v4.0.0] From 8b1af232c37fb5a4a2f6d573ed31076025b2f282 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Mon, 7 Mar 2022 18:22:10 +0100 Subject: [PATCH 06/35] Added Tests for CCSDS Time, fixed LPM Test Changed behaviour of Host and Linux Clock --- src/fsfw/osal/host/Clock.cpp | 7 ++-- src/fsfw/osal/linux/Clock.cpp | 3 +- src/fsfw/timemanager/CCSDSTime.cpp | 29 +++++++++++++++++ src/fsfw/timemanager/CCSDSTime.h | 2 ++ .../datapoollocal/LocalPoolManagerTest.cpp | 18 ++++------- .../unit/timemanager/TestCCSDSTime.cpp | 32 +++++++++++++++++++ 6 files changed, 74 insertions(+), 17 deletions(-) diff --git a/src/fsfw/osal/host/Clock.cpp b/src/fsfw/osal/host/Clock.cpp index 62f9d9d5..d0acdfdf 100644 --- a/src/fsfw/osal/host/Clock.cpp +++ b/src/fsfw/osal/host/Clock.cpp @@ -150,17 +150,14 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* time_tm.tm_hour = from->hour; time_tm.tm_min = from->minute; time_tm.tm_sec = from->second; + time_tm.tm_isdst = 0; - time_t seconds = mktime(&time_tm); + time_t seconds = timegm(&time_tm); to->tv_sec = seconds; to->tv_usec = from->usecond; // Fails in 2038.. return HasReturnvaluesIF::RETURN_OK; -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Clock::convertTimeBla: not implemented yet" << std::endl; -#endif - return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) { diff --git a/src/fsfw/osal/linux/Clock.cpp b/src/fsfw/osal/linux/Clock.cpp index 7092e6b2..61eb970f 100644 --- a/src/fsfw/osal/linux/Clock.cpp +++ b/src/fsfw/osal/linux/Clock.cpp @@ -140,8 +140,9 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* fromTm.tm_hour = from->hour; fromTm.tm_min = from->minute; fromTm.tm_sec = from->second; + fromTm.tm_isdst = 0; - to->tv_sec = mktime(&fromTm); + to->tv_sec = timegm(&fromTm); to->tv_usec = from->usecond; return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/timemanager/CCSDSTime.cpp b/src/fsfw/timemanager/CCSDSTime.cpp index 290d58dc..c5132cbb 100644 --- a/src/fsfw/timemanager/CCSDSTime.cpp +++ b/src/fsfw/timemanager/CCSDSTime.cpp @@ -557,6 +557,35 @@ ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from, size_t return RETURN_OK; } +ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const CCSDSTime::CDS_short* from) { + if (to == nullptr or from == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + uint16_t days = (from->dayMSB << 8) + from->dayLSB; + if (days <= DAYS_CCSDS_TO_UNIX_EPOCH) { + return INVALID_TIME_FORMAT; + } + days -= DAYS_CCSDS_TO_UNIX_EPOCH; + to->tv_sec = days * SECONDS_PER_DAY; + uint32_t msDay = + (from->msDay_hh << 24) + (from->msDay_h << 16) + (from->msDay_l << 8) + from->msDay_ll; + to->tv_sec += (msDay / 1000); + to->tv_usec = (msDay % 1000) * 1000; + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to, const CCSDSTime::CDS_short* from) { + if (to == nullptr or from == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + timeval tempTimeval; + ReturnValue_t result = convertFromCDS(&tempTimeval, from); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return CCSDSTime::convertTimevalToTimeOfDay(to, &tempTimeval); +} + ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, uint8_t pField, const uint8_t* from, size_t* foundLength, size_t maxLength) { uint32_t secs = 0; diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index 4a0e1bfc..9de41e09 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -180,6 +180,8 @@ class CCSDSTime : public HasReturnvaluesIF { static ReturnValue_t convertFromCDS(timeval *to, uint8_t const *from, size_t *foundLength, size_t maxLength); + static ReturnValue_t convertFromCDS(timeval *to, const CCSDSTime::CDS_short *from); + static ReturnValue_t convertFromCDS(Clock::TimeOfDay_t *to, const CCSDSTime::CDS_short *from); static ReturnValue_t convertFromCCS(Clock::TimeOfDay_t *to, uint8_t const *from, size_t *foundLength, size_t maxLength); diff --git a/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp b/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp index fb22972e..05436d30 100644 --- a/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp +++ b/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -158,13 +159,10 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { } poolVar->setChanged(true); - /* Store current time, we are going to check the (approximate) time equality later */ CCSDSTime::CDS_short timeCdsNow; timeval now; Clock::getClock_timeval(&now); - CCSDSTime::convertToCcsds(&timeCdsNow, &now); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); /* Check update snapshot was sent. */ @@ -192,14 +190,12 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); CHECK(varCopy.value == 25); - /* Now we check that both times are equal */ - CHECK(cdsShort.pField == timeCdsNow.pField); - CHECK(cdsShort.dayLSB == Catch::Approx(timeCdsNow.dayLSB).margin(1)); - CHECK(cdsShort.dayMSB == Catch::Approx(timeCdsNow.dayMSB).margin(1)); - CHECK(cdsShort.msDay_h == Catch::Approx(timeCdsNow.msDay_h).margin(1)); - CHECK(cdsShort.msDay_hh == Catch::Approx(timeCdsNow.msDay_hh).margin(1)); - CHECK(cdsShort.msDay_l == Catch::Approx(timeCdsNow.msDay_l).margin(1)); - CHECK(cdsShort.msDay_ll == Catch::Approx(timeCdsNow.msDay_ll).margin(5)); + timeval timeFromHK; + auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); + CHECK(result == HasReturnvaluesIF::RETURN_OK); + /// timeval* to, const uint8_t* from, size_t* foundLength,size_t maxLength) + timeval difference = timeFromHK - now; + CHECK(timevalOperations::toDouble(difference) < 1.0); } SECTION("VariableNotificationTest") { diff --git a/tests/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp b/tests/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp index 89713488..271e094e 100644 --- a/tests/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp +++ b/tests/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -89,4 +90,35 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { REQUIRE(timeTo.second == 59); REQUIRE(timeTo.usecond == Catch::Approx(123000)); } + + SECTION("CDS Conversions") { + // Preperation + Clock::TimeOfDay_t time; + time.year = 2020; + time.month = 2; + time.day = 29; + time.hour = 13; + time.minute = 24; + time.second = 45; + time.usecond = 123456; + timeval timeAsTimeval; + auto result = Clock::convertTimeOfDayToTimeval(&time, &timeAsTimeval); + CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(timeAsTimeval.tv_sec == 1582982685); + CHECK(timeAsTimeval.tv_usec == 123456); + + // Conversion to CDS Short + CCSDSTime::CDS_short cdsTime; + result = CCSDSTime::convertToCcsds(&cdsTime, &timeAsTimeval); + CHECK(result == HasReturnvaluesIF::RETURN_OK); + + // Conversion back to timeval + timeval timeReturnAsTimeval; + result = CCSDSTime::convertFromCDS(&timeReturnAsTimeval, &cdsTime); + CHECK(result == HasReturnvaluesIF::RETURN_OK); + // us precision is lost + timeval difference = timeAsTimeval - timeReturnAsTimeval; + CHECK(difference.tv_usec == 456); + CHECK(difference.tv_sec == 0); + } } \ No newline at end of file From a4f97a7ba793f9c1fb277e4f685909d483abf0e0 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Mon, 7 Mar 2022 18:33:24 +0100 Subject: [PATCH 07/35] Fixed another issue of time checks --- .../unit/datapoollocal/LocalPoolManagerTest.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp b/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp index 05436d30..07762595 100644 --- a/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp +++ b/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp @@ -94,10 +94,8 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { poolOwner->dataset.setChanged(true); /* Store current time, we are going to check the (approximate) time equality later */ - CCSDSTime::CDS_short timeCdsNow; timeval now; Clock::getClock_timeval(&now); - CCSDSTime::convertToCcsds(&timeCdsNow, &now); /* Trigger generation of snapshot */ REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); @@ -132,13 +130,11 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { CHECK(newSet.localPoolUint16Vec.value[2] == 42932); /* Now we check that both times are equal */ - CHECK(cdsShort.pField == timeCdsNow.pField); - CHECK(cdsShort.dayLSB == Catch::Approx(timeCdsNow.dayLSB).margin(1)); - CHECK(cdsShort.dayMSB == Catch::Approx(timeCdsNow.dayMSB).margin(1)); - CHECK(cdsShort.msDay_h == Catch::Approx(timeCdsNow.msDay_h).margin(1)); - CHECK(cdsShort.msDay_hh == Catch::Approx(timeCdsNow.msDay_hh).margin(1)); - CHECK(cdsShort.msDay_l == Catch::Approx(timeCdsNow.msDay_l).margin(1)); - CHECK(cdsShort.msDay_ll == Catch::Approx(timeCdsNow.msDay_ll).margin(5)); + timeval timeFromHK; + auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); + CHECK(result == HasReturnvaluesIF::RETURN_OK); + timeval difference = timeFromHK - now; + CHECK(timevalOperations::toDouble(difference) < 1.0); } SECTION("VariableSnapshotTest") { @@ -190,10 +186,10 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); CHECK(varCopy.value == 25); + /* Now we check that both times are equal */ timeval timeFromHK; auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); CHECK(result == HasReturnvaluesIF::RETURN_OK); - /// timeval* to, const uint8_t* from, size_t* foundLength,size_t maxLength) timeval difference = timeFromHK - now; CHECK(timevalOperations::toDouble(difference) < 1.0); } From e5a9cab34eae90df95ca888590bbed4a23a989c3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 08:57:18 +0100 Subject: [PATCH 08/35] fix changelog --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26df4486..e11b2e36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes -- GPIO HAL: Renamed entries of enumerations to avoid nameclashes with Windows defines. - `IN` and `OUT` in `Direction` changed to `DIR_IN` and `DIR_OUT`. - `CALLBACK` in `GpioTypes` changed to `TYPE_CALLBACK` +- GPIO HAL: `Direction` amd `GpioTypes` are enum classes now, which prevents + name clashes with Windows defines - HAL Devicehandlers: Periodic printout is run-time configurable now - `oneShotAction` flag in the `TestTask` class is not static anymore From d6856fc54a519d04667be155e44da4846d96c517 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 09:00:14 +0100 Subject: [PATCH 09/35] another minor changelog update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e11b2e36..54a1bdca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - GPIO HAL: `Direction` amd `GpioTypes` are enum classes now, which prevents name clashes with Windows defines +- New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code - HAL Devicehandlers: Periodic printout is run-time configurable now - `oneShotAction` flag in the `TestTask` class is not static anymore From 89c1878622030cf44f3b7e0c139abca53aa6c6ab Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 09:01:23 +0100 Subject: [PATCH 10/35] add link to PR --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54a1bdca..97a26e74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes - GPIO HAL: `Direction` amd `GpioTypes` are enum classes now, which prevents - name clashes with Windows defines -- New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code + name clashes with Windows defines. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 +- New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 - HAL Devicehandlers: Periodic printout is run-time configurable now - `oneShotAction` flag in the `TestTask` class is not static anymore From 14620fdd72eca6a8a6464a049443dd48cff397fd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 09:02:40 +0100 Subject: [PATCH 11/35] minor correction --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97a26e74..88060922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes -- GPIO HAL: `Direction` amd `GpioTypes` are enum classes now, which prevents +- GPIO HAL: `Direction`, `GpioOperation` and `Levels` are enum classes now, which prevents name clashes with Windows defines. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 - New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code. From ca70c8c61408df79bcc9aea8777a14447e625160 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 10:05:18 +0100 Subject: [PATCH 12/35] function to get fsfw version --- src/fsfw/CMakeLists.txt | 4 ++++ src/fsfw/version.cpp | 8 ++++++++ src/fsfw/version.h | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/fsfw/version.cpp create mode 100644 src/fsfw/version.h diff --git a/src/fsfw/CMakeLists.txt b/src/fsfw/CMakeLists.txt index 12c673ed..efb9f6c7 100644 --- a/src/fsfw/CMakeLists.txt +++ b/src/fsfw/CMakeLists.txt @@ -1,3 +1,7 @@ +target_sources(${LIB_FSFW_NAME} PRIVATE + version.cpp +) + # Core add_subdirectory(action) diff --git a/src/fsfw/version.cpp b/src/fsfw/version.cpp new file mode 100644 index 00000000..1bdd6cc7 --- /dev/null +++ b/src/fsfw/version.cpp @@ -0,0 +1,8 @@ +#include "version.h" +#include "fsfw/FSFWVersion.h" + +void fsfw::getVersion(Version& v) { + v.major = FSFW_VERSION; + v.minor = FSFW_SUBVERSION; + v.revision = FSFW_REVISION; +} diff --git a/src/fsfw/version.h b/src/fsfw/version.h new file mode 100644 index 00000000..04b7e3ce --- /dev/null +++ b/src/fsfw/version.h @@ -0,0 +1,18 @@ +#ifndef FSFW_SRC_FSFW_VERSION_H_ +#define FSFW_SRC_FSFW_VERSION_H_ + +#include + +namespace fsfw { + +struct Version { + uint32_t major = 0; + uint32_t minor = 0; + uint32_t revision = 0; +}; + +void getVersion(Version& version); + +} + +#endif /* FSFW_SRC_FSFW_VERSION_H_ */ From 77e5fba7fdde8daf7d718a6841824c73e0a0b92c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 10:08:53 +0100 Subject: [PATCH 13/35] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa59651f..6c3e4ce5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Additions - Linux HAL: Add wiretapping option for I2C. Enabled with `FSFW_HAL_I2C_WIRETAPPING` defined to 1 +- Dedicated function to get FSFW version inside `fsfw/version.h` # [v4.0.0] From d1e3dc4d49af8b9e5b00bac7f5b6c5ef267b19f3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 09:56:24 +0100 Subject: [PATCH 14/35] define FSFW_DISABLE_PRINTOUT in any case --- src/fsfw/FSFW.h.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fsfw/FSFW.h.in b/src/fsfw/FSFW.h.in index 9cfeab61..953677bd 100644 --- a/src/fsfw/FSFW.h.in +++ b/src/fsfw/FSFW.h.in @@ -30,6 +30,10 @@ #define FSFW_VERBOSE_LEVEL 1 #endif /* FSFW_VERBOSE_LEVEL */ +#ifndef FSFW_DISABLE_PRINTOUT +#define FSFW_DISABLE_PRINTOUT 0 +#endif + #ifndef FSFW_USE_REALTIME_FOR_LINUX #define FSFW_USE_REALTIME_FOR_LINUX 0 #endif /* FSFW_USE_REALTIME_FOR_LINUX */ From 7932afc3150209da93d468226690840bed8f2b68 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 10:13:11 +0100 Subject: [PATCH 15/35] small form change --- src/fsfw/FSFW.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/FSFW.h.in b/src/fsfw/FSFW.h.in index 953677bd..0eeb00eb 100644 --- a/src/fsfw/FSFW.h.in +++ b/src/fsfw/FSFW.h.in @@ -31,7 +31,7 @@ #endif /* FSFW_VERBOSE_LEVEL */ #ifndef FSFW_DISABLE_PRINTOUT -#define FSFW_DISABLE_PRINTOUT 0 +#define FSFW_DISABLE_PRINTOUT 0 #endif #ifndef FSFW_USE_REALTIME_FOR_LINUX From 238baa859737f23f16a005c91547df8625e2ceb1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 11:52:33 +0100 Subject: [PATCH 16/35] call setTimeout --- src/fsfw/timemanager/Countdown.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fsfw/timemanager/Countdown.cpp b/src/fsfw/timemanager/Countdown.cpp index 8ff46f8d..a8ba78cb 100644 --- a/src/fsfw/timemanager/Countdown.cpp +++ b/src/fsfw/timemanager/Countdown.cpp @@ -1,6 +1,8 @@ #include "fsfw/timemanager/Countdown.h" -Countdown::Countdown(uint32_t initialTimeout) : timeout(initialTimeout) {} +Countdown::Countdown(uint32_t initialTimeout) : timeout(initialTimeout) { + setTimeout(initialTimeout); +} Countdown::~Countdown() {} From 445d5dd6f0a1cc67fdb107741d4b3871b38f48cb Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Wed, 9 Mar 2022 18:56:08 +0100 Subject: [PATCH 17/35] Added Checks for CDSShort in unittests --- .../src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp b/tests/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp index 271e094e..2e80487a 100644 --- a/tests/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp +++ b/tests/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp @@ -111,12 +111,20 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { CCSDSTime::CDS_short cdsTime; result = CCSDSTime::convertToCcsds(&cdsTime, &timeAsTimeval); CHECK(result == HasReturnvaluesIF::RETURN_OK); + // Days in CCSDS Epoch 22704 (0x58B0) + CHECK(cdsTime.dayMSB == 0x58); + CHECK(cdsTime.dayLSB == 0xB0); + // MS of day 48285123.456 (floored here) + CHECK(cdsTime.msDay_hh == 0x2); + CHECK(cdsTime.msDay_h == 0xE0); + CHECK(cdsTime.msDay_l == 0xC5); + CHECK(cdsTime.msDay_ll == 0xC3); // Conversion back to timeval timeval timeReturnAsTimeval; result = CCSDSTime::convertFromCDS(&timeReturnAsTimeval, &cdsTime); CHECK(result == HasReturnvaluesIF::RETURN_OK); - // us precision is lost + // micro seconds precision is lost timeval difference = timeAsTimeval - timeReturnAsTimeval; CHECK(difference.tv_usec == 456); CHECK(difference.tv_sec == 0); From 345a799031560947445e404e79ce88c1f21fffb1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Mar 2022 19:05:07 +0100 Subject: [PATCH 18/35] improved version.h --- src/fsfw/FSFWVersion.h.in | 6 +++--- src/fsfw/version.cpp | 13 ++++++++----- src/fsfw/version.h | 25 +++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/fsfw/FSFWVersion.h.in b/src/fsfw/FSFWVersion.h.in index 7935b2f6..19a56214 100644 --- a/src/fsfw/FSFWVersion.h.in +++ b/src/fsfw/FSFWVersion.h.in @@ -2,8 +2,8 @@ #define FSFW_VERSION_H_ // Versioning is kept in project CMakeLists.txt file -#define FSFW_VERSION @FSFW_VERSION@ -#define FSFW_SUBVERSION @FSFW_SUBVERSION@ -#define FSFW_REVISION @FSFW_REVISION@ +#define FSFW_VERSION_MAJOR @FSFW_VERSION@ +#define FSFW_VERSION_MINOR @FSFW_SUBVERSION@ +#define FSFW_VERSION_REVISION @FSFW_REVISION@ #endif /* FSFW_VERSION_H_ */ diff --git a/src/fsfw/version.cpp b/src/fsfw/version.cpp index 1bdd6cc7..e1fc32c9 100644 --- a/src/fsfw/version.cpp +++ b/src/fsfw/version.cpp @@ -1,8 +1,11 @@ #include "version.h" + #include "fsfw/FSFWVersion.h" -void fsfw::getVersion(Version& v) { - v.major = FSFW_VERSION; - v.minor = FSFW_SUBVERSION; - v.revision = FSFW_REVISION; -} +const fsfw::Version fsfw::FSFW_VERSION = {FSFW_VERSION_MAJOR, FSFW_VERSION_MINOR, + FSFW_VERSION_REVISION}; + +fsfw::Version::Version(uint32_t major, uint32_t minor, uint32_t revision) + : major(major), minor(minor), revision(revision) {} + +void fsfw::getVersion(Version& version) {} diff --git a/src/fsfw/version.h b/src/fsfw/version.h index 04b7e3ce..8340fc9d 100644 --- a/src/fsfw/version.h +++ b/src/fsfw/version.h @@ -5,14 +5,35 @@ namespace fsfw { -struct Version { +class Version { + public: + Version(uint32_t major, uint32_t minor, uint32_t revision); uint32_t major = 0; uint32_t minor = 0; uint32_t revision = 0; + + friend bool operator==(const Version& v1, const Version& v2) { + return (v1.major == v2.major and v1.minor == v2.minor and v1.revision == v2.revision); + } + + friend bool operator!=(const Version& v1, const Version& v2) { return not(v1 == v2); } + + friend bool operator<(const Version& v1, const Version& v2) { + return ((v1.major < v2.major) or (v1.major == v2.major and v1.minor < v2.minor) or + (v1.major == v2.major and v1.minor == v2.minor and v1.revision < v2.revision)); + } + + friend bool operator>(const Version& v1, const Version& v2) { return not(v1 < v2); } + + friend bool operator<=(const Version& v1, const Version& v2) { return ((v1 == v2) or (v1 < v2)); } + + friend bool operator>=(const Version& v1, const Version& v2) { return ((v1 == v2) or (v1 > v2)); } }; +extern const fsfw::Version FSFW_VERSION; + void getVersion(Version& version); -} +} // namespace fsfw #endif /* FSFW_SRC_FSFW_VERSION_H_ */ From ca508bfe61ac0f6e33232ca777b6078f972b0e68 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Mar 2022 19:10:05 +0100 Subject: [PATCH 19/35] getter not required anymore --- src/fsfw/version.cpp | 2 -- src/fsfw/version.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/fsfw/version.cpp b/src/fsfw/version.cpp index e1fc32c9..133b9674 100644 --- a/src/fsfw/version.cpp +++ b/src/fsfw/version.cpp @@ -7,5 +7,3 @@ const fsfw::Version fsfw::FSFW_VERSION = {FSFW_VERSION_MAJOR, FSFW_VERSION_MINOR fsfw::Version::Version(uint32_t major, uint32_t minor, uint32_t revision) : major(major), minor(minor), revision(revision) {} - -void fsfw::getVersion(Version& version) {} diff --git a/src/fsfw/version.h b/src/fsfw/version.h index 8340fc9d..47860865 100644 --- a/src/fsfw/version.h +++ b/src/fsfw/version.h @@ -32,8 +32,6 @@ class Version { extern const fsfw::Version FSFW_VERSION; -void getVersion(Version& version); - } // namespace fsfw #endif /* FSFW_SRC_FSFW_VERSION_H_ */ From 7daa9812ff56657726b85c3304afdd852d84d951 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 09:34:29 +0100 Subject: [PATCH 20/35] added tests --- src/fsfw/version.h | 28 ++++++++++++ tests/src/fsfw_tests/unit/CMakeLists.txt | 11 +++-- tests/src/fsfw_tests/unit/version.cpp | 55 ++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 tests/src/fsfw_tests/unit/version.cpp diff --git a/src/fsfw/version.h b/src/fsfw/version.h index 47860865..4ed748d1 100644 --- a/src/fsfw/version.h +++ b/src/fsfw/version.h @@ -1,7 +1,13 @@ #ifndef FSFW_SRC_FSFW_VERSION_H_ #define FSFW_SRC_FSFW_VERSION_H_ +#include "fsfw/FSFW.h" + +#if FSFW_CPP_OSTREAM_ENABLED == 1 +#include +#endif #include +#include namespace fsfw { @@ -28,6 +34,28 @@ class Version { friend bool operator<=(const Version& v1, const Version& v2) { return ((v1 == v2) or (v1 < v2)); } friend bool operator>=(const Version& v1, const Version& v2) { return ((v1 == v2) or (v1 > v2)); } + +#if FSFW_CPP_OSTREAM_ENABLED == 1 + /** + * Print format to given ostream using format "major.minor.revision" + * @param os + * @param v + * @return + */ + friend std::ostream& operator<<(std::ostream& os, const Version& v) { + os << v.major << "." << v.minor << "." << v.revision; + return os; + } +#endif + + /** + * Get version as format "major.minor.revision" + * @param str + * @param maxLen + */ + void getVersion(char* str, size_t maxLen) const { + snprintf(str, maxLen, "%d.%d.%d", major, minor, revision); + } }; extern const fsfw::Version FSFW_VERSION; diff --git a/tests/src/fsfw_tests/unit/CMakeLists.txt b/tests/src/fsfw_tests/unit/CMakeLists.txt index a83e2f7f..a8d31d88 100644 --- a/tests/src/fsfw_tests/unit/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/CMakeLists.txt @@ -2,14 +2,13 @@ target_sources(${FSFW_TEST_TGT} PRIVATE CatchDefinitions.cpp CatchFactory.cpp printChar.cpp + version.cpp ) -# if(FSFW_CUSTOM_UNITTEST_RUNNER) - target_sources(${FSFW_TEST_TGT} PRIVATE - CatchRunner.cpp - CatchSetup.cpp - ) -# endif() +target_sources(${FSFW_TEST_TGT} PRIVATE + CatchRunner.cpp + CatchSetup.cpp +) add_subdirectory(testcfg) add_subdirectory(action) diff --git a/tests/src/fsfw_tests/unit/version.cpp b/tests/src/fsfw_tests/unit/version.cpp new file mode 100644 index 00000000..6fcff215 --- /dev/null +++ b/tests/src/fsfw_tests/unit/version.cpp @@ -0,0 +1,55 @@ + +#include "fsfw/version.h" + +#include + +#include "fsfw/serviceinterface.h" +#include "fsfw_tests/unit/CatchDefinitions.h" + +TEST_CASE("Version API Tests", "[TestVersionAPI]") { + // Check that major version is non-zero + REQUIRE(fsfw::FSFW_VERSION.major > 0); + uint32_t fsfwMajor = fsfw::FSFW_VERSION.major; + REQUIRE(fsfw::Version(255, 0, 0) > fsfw::FSFW_VERSION); + REQUIRE(fsfw::Version(255, 0, 0) >= fsfw::FSFW_VERSION); + REQUIRE(fsfw::Version(0, 0, 0) < fsfw::FSFW_VERSION); + REQUIRE(fsfw::Version(0, 0, 0) <= fsfw::FSFW_VERSION); + fsfw::Version v1 = fsfw::Version(1, 1, 1); + fsfw::Version v2 = fsfw::Version(1, 1, 1); + v1.revision -= 1; + REQUIRE(v1 != v2); + REQUIRE(v1 < v2); + REQUIRE(v1 <= v2); + v1.revision += 1; + v1.minor -= 1; + REQUIRE(v1 != v2); + REQUIRE(v1 < v2); + REQUIRE(v1 <= v2); + v1.minor += 1; + v1.major -= 1; + REQUIRE(v1 != v2); + REQUIRE(v1 < v2); + REQUIRE(v1 <= v2); + v1.major += 1; + REQUIRE(v1 == v2); + v1.major += 1; + REQUIRE(v1 != v2); + REQUIRE(v1 > v2); + REQUIRE(v1 >= v2); + v1.major -= 1; + v1.minor += 1; + REQUIRE(v1 != v2); + REQUIRE(v1 > v2); + REQUIRE(v1 >= v2); + v1.minor -= 1; + v1.revision += 1; + REQUIRE(v1 != v2); + REQUIRE(v1 > v2); + REQUIRE(v1 >= v2); + v1.revision -= 1; + REQUIRE(v1 == v2); + sif::info << "v" << fsfw::FSFW_VERSION << std::endl; + char verString[10] = {}; + fsfw::FSFW_VERSION.getVersion(verString, sizeof(verString)); + sif::info << "v" << verString << std::endl; +} From 949549178a0a6826495c3be96179a1938a29a162 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 09:36:36 +0100 Subject: [PATCH 21/35] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c3e4ce5..e4afb8e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Additions - Linux HAL: Add wiretapping option for I2C. Enabled with `FSFW_HAL_I2C_WIRETAPPING` defined to 1 -- Dedicated function to get FSFW version inside `fsfw/version.h` +- Dedicated Version class and constant `fsfw::FSFW_VERSION` containing version information + inside `fsfw/version.h` # [v4.0.0] From 3779b44813e53cf0e9f4c59f67400e8a72500ee0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 09:37:57 +0100 Subject: [PATCH 22/35] added some more minor tests --- tests/src/fsfw_tests/unit/version.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/src/fsfw_tests/unit/version.cpp b/tests/src/fsfw_tests/unit/version.cpp index 6fcff215..7fffd986 100644 --- a/tests/src/fsfw_tests/unit/version.cpp +++ b/tests/src/fsfw_tests/unit/version.cpp @@ -16,6 +16,9 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") { REQUIRE(fsfw::Version(0, 0, 0) <= fsfw::FSFW_VERSION); fsfw::Version v1 = fsfw::Version(1, 1, 1); fsfw::Version v2 = fsfw::Version(1, 1, 1); + REQUIRE(v1 == v2); + REQUIRE(v1 <= v2); + REQUIRE(v1 >= v2); v1.revision -= 1; REQUIRE(v1 != v2); REQUIRE(v1 < v2); @@ -32,6 +35,8 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") { REQUIRE(v1 <= v2); v1.major += 1; REQUIRE(v1 == v2); + REQUIRE(v1 <= v2); + REQUIRE(v1 >= v2); v1.major += 1; REQUIRE(v1 != v2); REQUIRE(v1 > v2); @@ -48,6 +53,8 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") { REQUIRE(v1 >= v2); v1.revision -= 1; REQUIRE(v1 == v2); + REQUIRE(v1 <= v2); + REQUIRE(v1 >= v2); sif::info << "v" << fsfw::FSFW_VERSION << std::endl; char verString[10] = {}; fsfw::FSFW_VERSION.getVersion(verString, sizeof(verString)); From 6b1a81ee926accdae812db85eae4a0175d96eb29 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 09:40:34 +0100 Subject: [PATCH 23/35] minor tweaks --- tests/src/fsfw_tests/unit/version.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/src/fsfw_tests/unit/version.cpp b/tests/src/fsfw_tests/unit/version.cpp index 7fffd986..d2a1f3ae 100644 --- a/tests/src/fsfw_tests/unit/version.cpp +++ b/tests/src/fsfw_tests/unit/version.cpp @@ -55,8 +55,12 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") { REQUIRE(v1 == v2); REQUIRE(v1 <= v2); REQUIRE(v1 >= v2); +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "v" << fsfw::FSFW_VERSION << std::endl; +#endif char verString[10] = {}; fsfw::FSFW_VERSION.getVersion(verString, sizeof(verString)); - sif::info << "v" << verString << std::endl; +#if FSFW_DISABLE_PRINTOUT == 0 + printf("v%s\n",verString); +#endif } From 14ac852b7e5885fcae2333ce5d5802241a84cb9d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 09:44:06 +0100 Subject: [PATCH 24/35] this tests even a bit more --- tests/src/fsfw_tests/unit/version.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/src/fsfw_tests/unit/version.cpp b/tests/src/fsfw_tests/unit/version.cpp index d2a1f3ae..bca89692 100644 --- a/tests/src/fsfw_tests/unit/version.cpp +++ b/tests/src/fsfw_tests/unit/version.cpp @@ -38,16 +38,18 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") { REQUIRE(v1 <= v2); REQUIRE(v1 >= v2); v1.major += 1; + v1.minor -= 1; REQUIRE(v1 != v2); REQUIRE(v1 > v2); REQUIRE(v1 >= v2); v1.major -= 1; - v1.minor += 1; + v1.minor += 2; + v1.revision -= 1; REQUIRE(v1 != v2); REQUIRE(v1 > v2); REQUIRE(v1 >= v2); v1.minor -= 1; - v1.revision += 1; + v1.revision += 2; REQUIRE(v1 != v2); REQUIRE(v1 > v2); REQUIRE(v1 >= v2); From aa5d1042f054b42ba1eeb75522f6a7658c91b545 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 09:56:23 +0100 Subject: [PATCH 25/35] undef major and minor --- src/fsfw/version.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fsfw/version.cpp b/src/fsfw/version.cpp index 133b9674..aa777c9e 100644 --- a/src/fsfw/version.cpp +++ b/src/fsfw/version.cpp @@ -2,6 +2,9 @@ #include "fsfw/FSFWVersion.h" +#undef major +#undef minor + const fsfw::Version fsfw::FSFW_VERSION = {FSFW_VERSION_MAJOR, FSFW_VERSION_MINOR, FSFW_VERSION_REVISION}; From e684680d605d57be40bd8ff61693009ce5971c5d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 09:58:37 +0100 Subject: [PATCH 26/35] avoid namespace pollution --- src/fsfw/version.cpp | 12 +++++++++++- src/fsfw/version.h | 5 +---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/fsfw/version.cpp b/src/fsfw/version.cpp index aa777c9e..926e465f 100644 --- a/src/fsfw/version.cpp +++ b/src/fsfw/version.cpp @@ -1,12 +1,22 @@ #include "version.h" - #include "fsfw/FSFWVersion.h" +#include + +#ifdef major #undef major +#endif + +#ifdef minor #undef minor +#endif const fsfw::Version fsfw::FSFW_VERSION = {FSFW_VERSION_MAJOR, FSFW_VERSION_MINOR, FSFW_VERSION_REVISION}; fsfw::Version::Version(uint32_t major, uint32_t minor, uint32_t revision) : major(major), minor(minor), revision(revision) {} + +void fsfw::Version::getVersion(char* str, size_t maxLen) const { + snprintf(str, maxLen, "%d.%d.%d", major, minor, revision); +} diff --git a/src/fsfw/version.h b/src/fsfw/version.h index 4ed748d1..598a7aef 100644 --- a/src/fsfw/version.h +++ b/src/fsfw/version.h @@ -7,7 +7,6 @@ #include #endif #include -#include namespace fsfw { @@ -53,9 +52,7 @@ class Version { * @param str * @param maxLen */ - void getVersion(char* str, size_t maxLen) const { - snprintf(str, maxLen, "%d.%d.%d", major, minor, revision); - } + void getVersion(char* str, size_t maxLen) const; }; extern const fsfw::Version FSFW_VERSION; From 0bdcb40609e62c9dd04daa85c48db09edf93beb9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Mar 2022 14:25:01 +0100 Subject: [PATCH 27/35] minor event changes --- src/fsfw/events/Event.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/fsfw/events/Event.h b/src/fsfw/events/Event.h index 20b66679..edc1d838 100644 --- a/src/fsfw/events/Event.h +++ b/src/fsfw/events/Event.h @@ -7,8 +7,19 @@ // could be moved to more suitable location #include -typedef uint16_t EventId_t; -typedef uint8_t EventSeverity_t; +using EventId_t = uint16_t; +using EventSeverity_t = uint8_t ; +using UniqueEventId_t = uint8_t; + +namespace severity { +enum Severity: EventSeverity_t { + INFO = 1, + LOW = 2, + MEDIUM = 3, + HIGH = 4 +}; + +} // namespace severity #define MAKE_EVENT(id, severity) (((severity) << 16) + (SUBSYSTEM_ID * 100) + (id)) @@ -20,18 +31,11 @@ constexpr EventId_t getEventId(Event event) { return (event & 0xFFFF); } constexpr EventSeverity_t getSeverity(Event event) { return ((event >> 16) & 0xFF); } -constexpr Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId, +constexpr Event makeEvent(uint8_t subsystemId, UniqueEventId_t uniqueEventId, EventSeverity_t eventSeverity) { return (eventSeverity << 16) + (subsystemId * 100) + uniqueEventId; } } // namespace event -namespace severity { -static constexpr EventSeverity_t INFO = 1; -static constexpr EventSeverity_t LOW = 2; -static constexpr EventSeverity_t MEDIUM = 3; -static constexpr EventSeverity_t HIGH = 4; -} // namespace severity - #endif /* EVENTOBJECT_EVENT_H_ */ From ce5bcc58974941333f595a9961f4d1ebbefa46ca Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Mar 2022 14:37:41 +0100 Subject: [PATCH 28/35] bugfix --- src/fsfw/version.h | 4 +++- tests/src/fsfw_tests/unit/version.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/fsfw/version.h b/src/fsfw/version.h index 598a7aef..7cddf193 100644 --- a/src/fsfw/version.h +++ b/src/fsfw/version.h @@ -28,7 +28,9 @@ class Version { (v1.major == v2.major and v1.minor == v2.minor and v1.revision < v2.revision)); } - friend bool operator>(const Version& v1, const Version& v2) { return not(v1 < v2); } + friend bool operator>(const Version& v1, const Version& v2) { + return not (v1 < v2) and not (v1 == v2); + } friend bool operator<=(const Version& v1, const Version& v2) { return ((v1 == v2) or (v1 < v2)); } diff --git a/tests/src/fsfw_tests/unit/version.cpp b/tests/src/fsfw_tests/unit/version.cpp index bca89692..92a930dc 100644 --- a/tests/src/fsfw_tests/unit/version.cpp +++ b/tests/src/fsfw_tests/unit/version.cpp @@ -17,10 +17,15 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") { fsfw::Version v1 = fsfw::Version(1, 1, 1); fsfw::Version v2 = fsfw::Version(1, 1, 1); REQUIRE(v1 == v2); + REQUIRE(not (v1 < v2)); + REQUIRE(not (v1 > v2)); REQUIRE(v1 <= v2); REQUIRE(v1 >= v2); v1.revision -= 1; REQUIRE(v1 != v2); + REQUIRE(not (v1 == v2)); + REQUIRE(not (v1 > v2)); + REQUIRE(not (v1 >= v2)); REQUIRE(v1 < v2); REQUIRE(v1 <= v2); v1.revision += 1; @@ -28,35 +33,54 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") { REQUIRE(v1 != v2); REQUIRE(v1 < v2); REQUIRE(v1 <= v2); + REQUIRE(not (v1 == v2)); + REQUIRE(not (v1 > v2)); + REQUIRE(not (v1 >= v2)); v1.minor += 1; v1.major -= 1; REQUIRE(v1 != v2); REQUIRE(v1 < v2); REQUIRE(v1 <= v2); + REQUIRE(not (v1 == v2)); + REQUIRE(not (v1 > v2)); + REQUIRE(not (v1 >= v2)); v1.major += 1; REQUIRE(v1 == v2); REQUIRE(v1 <= v2); REQUIRE(v1 >= v2); + REQUIRE(not (v1 != v2)); + REQUIRE(not (v1 > v2)); + REQUIRE(not (v1 < v2)); v1.major += 1; v1.minor -= 1; REQUIRE(v1 != v2); REQUIRE(v1 > v2); REQUIRE(v1 >= v2); + REQUIRE(not (v1 == v2)); + REQUIRE(not (v1 < v2)); + REQUIRE(not (v1 <= v2)); v1.major -= 1; v1.minor += 2; v1.revision -= 1; REQUIRE(v1 != v2); REQUIRE(v1 > v2); REQUIRE(v1 >= v2); + REQUIRE(not (v1 == v2)); + REQUIRE(not (v1 < v2)); + REQUIRE(not (v1 <= v2)); v1.minor -= 1; v1.revision += 2; REQUIRE(v1 != v2); REQUIRE(v1 > v2); REQUIRE(v1 >= v2); + REQUIRE(not (v1 == v2)); + REQUIRE(not (v1 < v2)); + REQUIRE(not (v1 <= v2)); v1.revision -= 1; REQUIRE(v1 == v2); REQUIRE(v1 <= v2); REQUIRE(v1 >= v2); + REQUIRE(not (v1 != v2)); #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "v" << fsfw::FSFW_VERSION << std::endl; #endif From fca43b3d34917bd11c7ef9a76e7789103ed193d0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Mar 2022 15:08:45 +0100 Subject: [PATCH 29/35] run auto-formatter --- src/fsfw/events/Event.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/fsfw/events/Event.h b/src/fsfw/events/Event.h index edc1d838..ecab0493 100644 --- a/src/fsfw/events/Event.h +++ b/src/fsfw/events/Event.h @@ -8,16 +8,11 @@ #include using EventId_t = uint16_t; -using EventSeverity_t = uint8_t ; +using EventSeverity_t = uint8_t; using UniqueEventId_t = uint8_t; namespace severity { -enum Severity: EventSeverity_t { - INFO = 1, - LOW = 2, - MEDIUM = 3, - HIGH = 4 -}; +enum Severity : EventSeverity_t { INFO = 1, LOW = 2, MEDIUM = 3, HIGH = 4 }; } // namespace severity From 7c64797f035ef4173830a93bb19dada78d7a380c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Mar 2022 17:38:47 +0100 Subject: [PATCH 30/35] Add more baud rates --- hal/src/fsfw_hal/linux/uart/UartComIF.cpp | 44 ++++++++++++++++++++++ hal/src/fsfw_hal/linux/uart/UartCookie.cpp | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp index 0abff60e..3cfa0417 100644 --- a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -269,6 +269,50 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki cfsetispeed(options, B460800); cfsetospeed(options, B460800); break; + case 500000: + cfsetispeed(options, B500000); + cfsetospeed(options, B500000); + break; + case 576000: + cfsetispeed(options, B576000); + cfsetospeed(options, B576000); + break; + case 921600: + cfsetispeed(options, B921600); + cfsetospeed(options, B921600); + break; + case 1000000: + cfsetispeed(options, B1000000); + cfsetospeed(options, B1000000); + break; + case 1152000: + cfsetispeed(options, B1152000); + cfsetospeed(options, B1152000); + break; + case 1500000: + cfsetispeed(options, B1500000); + cfsetospeed(options, B1500000); + break; + case 2000000: + cfsetispeed(options, B2000000); + cfsetospeed(options, B2000000); + break; + case 2500000: + cfsetispeed(options, B2500000); + cfsetospeed(options, B2500000); + break; + case 3000000: + cfsetispeed(options, B3000000); + cfsetospeed(options, B3000000); + break; + case 3500000: + cfsetispeed(options, B3500000); + cfsetospeed(options, B3500000); + break; + case 4000000: + cfsetispeed(options, B4000000); + cfsetospeed(options, B4000000); + break; default: #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::configureBaudrate: Baudrate not supported" << std::endl; diff --git a/hal/src/fsfw_hal/linux/uart/UartCookie.cpp b/hal/src/fsfw_hal/linux/uart/UartCookie.cpp index 99e80a8e..63d90766 100644 --- a/hal/src/fsfw_hal/linux/uart/UartCookie.cpp +++ b/hal/src/fsfw_hal/linux/uart/UartCookie.cpp @@ -1,4 +1,4 @@ -#include "fsfw_hal/linux/uart/UartCookie.h" +#include "UartCookie.h" #include From f441505476a07c74c7859623fd4930f6575e3869 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Mar 2022 17:41:49 +0100 Subject: [PATCH 31/35] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7d3b90b..284ccb6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Dedicated Version class and constant `fsfw::FSFW_VERSION` containing version information inside `fsfw/version.h` PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/559 +- Additional baudrates for Linux UART HAL + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/581 # [v4.0.0] From 3e17011087cfae3f3cbb9028cff35bf1d7a61e55 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Mar 2022 17:42:56 +0100 Subject: [PATCH 32/35] small tweaks for local datapool code --- src/fsfw/datapoollocal/LocalPoolObjectBase.cpp | 11 ++++++----- src/fsfw/datapoollocal/StaticLocalDataSet.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp index c974601c..82aefc18 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp @@ -47,13 +47,14 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, HasLocalDataPoolIF* hkOwner = ObjectManager::instance()->get(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 0x" << std::hex << poolOwner + << std::dec << " 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"); + "LocalPoolVariable: The supplied pool owner 0x%08x did not implement the correct " + "interface HasLocalDataPoolIF\n", + poolOwner); #endif return; } diff --git a/src/fsfw/datapoollocal/StaticLocalDataSet.h b/src/fsfw/datapoollocal/StaticLocalDataSet.h index dd264e58..59047d67 100644 --- a/src/fsfw/datapoollocal/StaticLocalDataSet.h +++ b/src/fsfw/datapoollocal/StaticLocalDataSet.h @@ -46,7 +46,7 @@ class StaticLocalDataSet : public LocalPoolDataSetBase { } private: - std::array poolVarList; + std::array poolVarList = {}; }; #endif /* FSFW_DATAPOOLLOCAL_STATICLOCALDATASET_H_ */ From c60aa68d001270fec67b47c1af9f957d7e5bf372 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 24 Mar 2022 15:44:32 +0100 Subject: [PATCH 33/35] changed hal linux uart baudrate and bits per word to enums --- CHANGELOG.md | 4 +- hal/src/fsfw_hal/linux/uart/UartComIF.cpp | 68 +++++++++++----------- hal/src/fsfw_hal/linux/uart/UartCookie.cpp | 20 ++----- hal/src/fsfw_hal/linux/uart/UartCookie.h | 53 +++++++++++++---- 4 files changed, 83 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 284ccb6e..f3eb6942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 - HAL Devicehandlers: Periodic printout is run-time configurable now - `oneShotAction` flag in the `TestTask` class is not static anymore +- HAL Linux Uart: Baudrate and bits per word are enums now, avoiding misconfigurations + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/585 ## Removed @@ -35,8 +37,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Dedicated Version class and constant `fsfw::FSFW_VERSION` containing version information inside `fsfw/version.h` PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/559 -- Additional baudrates for Linux UART HAL - PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/581 # [v4.0.0] diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp index 3cfa0417..5aa72138 100644 --- a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -148,16 +148,16 @@ void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCook /* Clear size bits */ options->c_cflag &= ~CSIZE; switch (uartCookie->getBitsPerWord()) { - case 5: + case BitsPerWord::BITS_5: options->c_cflag |= CS5; break; - case 6: + case BitsPerWord::BITS_6: options->c_cflag |= CS6; break; - case 7: + case BitsPerWord::BITS_7: options->c_cflag |= CS7; break; - case 8: + case BitsPerWord::BITS_8: options->c_cflag |= CS8; break; default: @@ -193,123 +193,123 @@ void UartComIF::setFixedOptions(struct termios* options) { void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCookie) { switch (uartCookie->getBaudrate()) { - case 50: + case UartBaudRate::RATE_50: cfsetispeed(options, B50); cfsetospeed(options, B50); break; - case 75: + case UartBaudRate::RATE_75: cfsetispeed(options, B75); cfsetospeed(options, B75); break; - case 110: + case UartBaudRate::RATE_110: cfsetispeed(options, B110); cfsetospeed(options, B110); break; - case 134: + case UartBaudRate::RATE_134: cfsetispeed(options, B134); cfsetospeed(options, B134); break; - case 150: + case UartBaudRate::RATE_150: cfsetispeed(options, B150); cfsetospeed(options, B150); break; - case 200: + case UartBaudRate::RATE_200: cfsetispeed(options, B200); cfsetospeed(options, B200); break; - case 300: + case UartBaudRate::RATE_300: cfsetispeed(options, B300); cfsetospeed(options, B300); break; - case 600: + case UartBaudRate::RATE_600: cfsetispeed(options, B600); cfsetospeed(options, B600); break; - case 1200: + case UartBaudRate::RATE_1200: cfsetispeed(options, B1200); cfsetospeed(options, B1200); break; - case 1800: + case UartBaudRate::RATE_1800: cfsetispeed(options, B1800); cfsetospeed(options, B1800); break; - case 2400: + case UartBaudRate::RATE_2400: cfsetispeed(options, B2400); cfsetospeed(options, B2400); break; - case 4800: + case UartBaudRate::RATE_4800: cfsetispeed(options, B4800); cfsetospeed(options, B4800); break; - case 9600: + case UartBaudRate::RATE_9600: cfsetispeed(options, B9600); cfsetospeed(options, B9600); break; - case 19200: + case UartBaudRate::RATE_19200: cfsetispeed(options, B19200); cfsetospeed(options, B19200); break; - case 38400: + case UartBaudRate::RATE_38400: cfsetispeed(options, B38400); cfsetospeed(options, B38400); break; - case 57600: + case UartBaudRate::RATE_57600: cfsetispeed(options, B57600); cfsetospeed(options, B57600); break; - case 115200: + case UartBaudRate::RATE_115200: cfsetispeed(options, B115200); cfsetospeed(options, B115200); break; - case 230400: + case UartBaudRate::RATE_230400: cfsetispeed(options, B230400); cfsetospeed(options, B230400); break; - case 460800: + case UartBaudRate::RATE_460800: cfsetispeed(options, B460800); cfsetospeed(options, B460800); break; - case 500000: + case UartBaudRate::RATE_500000: cfsetispeed(options, B500000); cfsetospeed(options, B500000); break; - case 576000: + case UartBaudRate::RATE_576000: cfsetispeed(options, B576000); cfsetospeed(options, B576000); break; - case 921600: + case UartBaudRate::RATE_921600: cfsetispeed(options, B921600); cfsetospeed(options, B921600); break; - case 1000000: + case UartBaudRate::RATE_1000000: cfsetispeed(options, B1000000); cfsetospeed(options, B1000000); break; - case 1152000: + case UartBaudRate::RATE_1152000: cfsetispeed(options, B1152000); cfsetospeed(options, B1152000); break; - case 1500000: + case UartBaudRate::RATE_1500000: cfsetispeed(options, B1500000); cfsetospeed(options, B1500000); break; - case 2000000: + case UartBaudRate::RATE_2000000: cfsetispeed(options, B2000000); cfsetospeed(options, B2000000); break; - case 2500000: + case UartBaudRate::RATE_2500000: cfsetispeed(options, B2500000); cfsetospeed(options, B2500000); break; - case 3000000: + case UartBaudRate::RATE_3000000: cfsetispeed(options, B3000000); cfsetospeed(options, B3000000); break; - case 3500000: + case UartBaudRate::RATE_3500000: cfsetispeed(options, B3500000); cfsetospeed(options, B3500000); break; - case 4000000: + case UartBaudRate::RATE_4000000: cfsetispeed(options, B4000000); cfsetospeed(options, B4000000); break; diff --git a/hal/src/fsfw_hal/linux/uart/UartCookie.cpp b/hal/src/fsfw_hal/linux/uart/UartCookie.cpp index 63d90766..aa2dd214 100644 --- a/hal/src/fsfw_hal/linux/uart/UartCookie.cpp +++ b/hal/src/fsfw_hal/linux/uart/UartCookie.cpp @@ -3,7 +3,7 @@ #include UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartModes uartMode, - uint32_t baudrate, size_t maxReplyLen) + UartBaudRate baudrate, size_t maxReplyLen) : handlerId(handlerId), deviceFile(deviceFile), uartMode(uartMode), @@ -12,7 +12,7 @@ UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartModes UartCookie::~UartCookie() {} -uint32_t UartCookie::getBaudrate() const { return baudrate; } +UartBaudRate UartCookie::getBaudrate() const { return baudrate; } size_t UartCookie::getMaxReplyLen() const { return maxReplyLen; } @@ -24,23 +24,11 @@ void UartCookie::setParityEven() { parity = Parity::EVEN; } Parity UartCookie::getParity() const { return parity; } -void UartCookie::setBitsPerWord(uint8_t bitsPerWord_) { - switch (bitsPerWord_) { - case 5: - case 6: - case 7: - case 8: - break; - default: -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "UartCookie::setBitsPerWord: Invalid bits per word specified" << std::endl; -#endif - return; - } +void UartCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; } -uint8_t UartCookie::getBitsPerWord() const { return bitsPerWord; } +BitsPerWord UartCookie::getBitsPerWord() const { return bitsPerWord; } StopBits UartCookie::getStopBits() const { return stopBits; } diff --git a/hal/src/fsfw_hal/linux/uart/UartCookie.h b/hal/src/fsfw_hal/linux/uart/UartCookie.h index 884665e5..6840b352 100644 --- a/hal/src/fsfw_hal/linux/uart/UartCookie.h +++ b/hal/src/fsfw_hal/linux/uart/UartCookie.h @@ -12,6 +12,41 @@ enum class StopBits { ONE_STOP_BIT, TWO_STOP_BITS }; enum class UartModes { CANONICAL, NON_CANONICAL }; +enum class BitsPerWord { BITS_5, BITS_6, BITS_7, BITS_8 }; + +enum class UartBaudRate { + RATE_50, + RATE_75, + RATE_110, + RATE_134, + RATE_150, + RATE_200, + RATE_300, + RATE_600, + RATE_1200, + RATE_1800, + RATE_2400, + RATE_4800, + RATE_9600, + RATE_19200, + RATE_38400, + RATE_57600, + RATE_115200, + RATE_230400, + RATE_460800, + RATE_500000, + RATE_576000, + RATE_921600, + RATE_1000000, + RATE_1152000, + RATE_1500000, + RATE_2000000, + RATE_2500000, + RATE_3000000, + RATE_3500000, + RATE_4000000 +}; + /** * @brief Cookie for the UartComIF. There are many options available to configure the UART driver. * The constructor only requests for common options like the baudrate. Other options can @@ -27,25 +62,23 @@ class UartCookie : public CookieIF { * @param uartMode Specify the UART mode. The canonical mode should be used if the * messages are separated by a delimited character like '\n'. See the * termios documentation for more information - * @param baudrate The baudrate to use for input and output. Possible Baudrates are: 50, - * 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, B19200, - * 38400, 57600, 115200, 230400, 460800 + * @param baudrate The baudrate to use for input and output. * @param maxReplyLen The maximum size an object using this cookie expects * @details * Default configuration: No parity * 8 databits (number of bits transfered with one uart frame) * One stop bit */ - UartCookie(object_id_t handlerId, std::string deviceFile, UartModes uartMode, uint32_t baudrate, - size_t maxReplyLen); + UartCookie(object_id_t handlerId, std::string deviceFile, UartModes uartMode, + UartBaudRate baudrate, size_t maxReplyLen); virtual ~UartCookie(); - uint32_t getBaudrate() const; + UartBaudRate getBaudrate() const; size_t getMaxReplyLen() const; std::string getDeviceFile() const; Parity getParity() const; - uint8_t getBitsPerWord() const; + BitsPerWord getBitsPerWord() const; StopBits getStopBits() const; UartModes getUartMode() const; object_id_t getHandlerId() const; @@ -76,7 +109,7 @@ class UartCookie : public CookieIF { /** * Function two set number of bits per UART frame. */ - void setBitsPerWord(uint8_t bitsPerWord_); + void setBitsPerWord(BitsPerWord bitsPerWord_); /** * Function to specify the number of stopbits. @@ -97,10 +130,10 @@ class UartCookie : public CookieIF { std::string deviceFile; const UartModes uartMode; bool flushInput = false; - uint32_t baudrate; + UartBaudRate baudrate; size_t maxReplyLen = 0; Parity parity = Parity::NONE; - uint8_t bitsPerWord = 8; + BitsPerWord bitsPerWord = BitsPerWord::BITS_8; uint8_t readCycles = 1; StopBits stopBits = StopBits::ONE_STOP_BIT; bool replySizeFixed = true; From d9d9a28ef84f01b3915865cd5399e9ebe0e104f2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Mar 2022 21:04:46 +0100 Subject: [PATCH 34/35] delete code which is not required anymore --- hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index 69f6311e..52b6dc07 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -1,9 +1,6 @@ #include "MgmLIS3MDLHandler.h" #include "fsfw/datapool/PoolReadGuard.h" -#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 -#include "fsfw/globalfunctions/PeriodicOperationDivider.h" -#endif #include From 916ed3f56ac676f5a411895d4fadbb8665bb550e Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 28 Mar 2022 13:50:42 +0200 Subject: [PATCH 35/35] added function to add component to a periodic task by pointer --- src/fsfw/osal/freertos/PeriodicTask.cpp | 10 +++++++--- src/fsfw/osal/freertos/PeriodicTask.h | 10 ++++++++++ src/fsfw/osal/host/PeriodicTask.cpp | 10 +++++++--- src/fsfw/osal/host/PeriodicTask.h | 10 ++++++++++ src/fsfw/osal/linux/PeriodicPosixTask.cpp | 10 +++++++--- src/fsfw/osal/linux/PeriodicPosixTask.h | 8 ++++++++ src/fsfw/osal/rtems/PeriodicTask.cpp | 10 +++++++--- src/fsfw/osal/rtems/PeriodicTask.h | 9 +++++++++ src/fsfw/tasks/PeriodicTaskIF.h | 20 ++++++++++++-------- 9 files changed, 77 insertions(+), 20 deletions(-) diff --git a/src/fsfw/osal/freertos/PeriodicTask.cpp b/src/fsfw/osal/freertos/PeriodicTask.cpp index 8dfa0290..d2c46ea8 100644 --- a/src/fsfw/osal/freertos/PeriodicTask.cpp +++ b/src/fsfw/osal/freertos/PeriodicTask.cpp @@ -97,7 +97,11 @@ void PeriodicTask::taskFunctionality() { ReturnValue_t PeriodicTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = ObjectManager::instance()->get(object); - if (newObject == nullptr) { + return addComponent(newObject); +} + +ReturnValue_t PeriodicTask::addComponent(ExecutableObjectIF* object) { + if (object == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" "it implement ExecutableObjectIF" @@ -105,8 +109,8 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object) { #endif return HasReturnvaluesIF::RETURN_FAILED; } - objectList.push_back(newObject); - newObject->setTaskIF(this); + objectList.push_back(object); + object->setTaskIF(this); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/osal/freertos/PeriodicTask.h b/src/fsfw/osal/freertos/PeriodicTask.h index cc395176..fc8e9092 100644 --- a/src/fsfw/osal/freertos/PeriodicTask.h +++ b/src/fsfw/osal/freertos/PeriodicTask.h @@ -63,6 +63,16 @@ class PeriodicTask : public PeriodicTaskIF, public FreeRTOSTaskIF { */ ReturnValue_t addComponent(object_id_t object) override; + /** + * Adds an object to the list of objects to be executed. + * The objects are executed in the order added. + * @param object Id of the object to add. + * @return + * -@c RETURN_OK on success + * -@c RETURN_FAILED if the object could not be added. + */ + ReturnValue_t addComponent(ExecutableObjectIF* object) override; + uint32_t getPeriodMs() const override; ReturnValue_t sleepFor(uint32_t ms) override; diff --git a/src/fsfw/osal/host/PeriodicTask.cpp b/src/fsfw/osal/host/PeriodicTask.cpp index 1de4aedf..cdcfafa6 100644 --- a/src/fsfw/osal/host/PeriodicTask.cpp +++ b/src/fsfw/osal/host/PeriodicTask.cpp @@ -102,11 +102,15 @@ void PeriodicTask::taskFunctionality() { ReturnValue_t PeriodicTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = ObjectManager::instance()->get(object); - if (newObject == nullptr) { + return addComponent(newObject); +} + +ReturnValue_t PeriodicTask::addComponent(ExecutableObjectIF* object) { + if (object == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } - newObject->setTaskIF(this); - objectList.push_back(newObject); + object->setTaskIF(this); + objectList.push_back(object); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/osal/host/PeriodicTask.h b/src/fsfw/osal/host/PeriodicTask.h index 0c41c0f7..6c4d5e8b 100644 --- a/src/fsfw/osal/host/PeriodicTask.h +++ b/src/fsfw/osal/host/PeriodicTask.h @@ -59,6 +59,16 @@ class PeriodicTask : public PeriodicTaskIF { */ ReturnValue_t addComponent(object_id_t object); + /** + * Adds an object to the list of objects to be executed. + * The objects are executed in the order added. + * @param object pointer to the object to add. + * @return + * -@c RETURN_OK on success + * -@c RETURN_FAILED if the object could not be added. + */ + ReturnValue_t addComponent(ExecutableObjectIF* object); + uint32_t getPeriodMs() const; ReturnValue_t sleepFor(uint32_t ms); diff --git a/src/fsfw/osal/linux/PeriodicPosixTask.cpp b/src/fsfw/osal/linux/PeriodicPosixTask.cpp index ca346670..e1937df4 100644 --- a/src/fsfw/osal/linux/PeriodicPosixTask.cpp +++ b/src/fsfw/osal/linux/PeriodicPosixTask.cpp @@ -28,7 +28,11 @@ void* PeriodicPosixTask::taskEntryPoint(void* arg) { ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = ObjectManager::instance()->get(object); - if (newObject == nullptr) { + return addComponent(newObject); +} + +ReturnValue_t PeriodicPosixTask::addComponent(ExecutableObjectIF* object) { + if (object == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" << " it implements ExecutableObjectIF!" << std::endl; @@ -39,8 +43,8 @@ ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) { #endif return HasReturnvaluesIF::RETURN_FAILED; } - objectList.push_back(newObject); - newObject->setTaskIF(this); + objectList.push_back(object); + object->setTaskIF(this); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/osal/linux/PeriodicPosixTask.h b/src/fsfw/osal/linux/PeriodicPosixTask.h index 1c3a52c7..3cd9847a 100644 --- a/src/fsfw/osal/linux/PeriodicPosixTask.h +++ b/src/fsfw/osal/linux/PeriodicPosixTask.h @@ -42,6 +42,14 @@ class PeriodicPosixTask : public PosixThread, public PeriodicTaskIF { */ ReturnValue_t addComponent(object_id_t object) override; + /** + * Adds an object to the list of objects to be executed. + * The objects are executed in the order added. + * @param object pointer to the object to add. + * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. + */ + ReturnValue_t addComponent(ExecutableObjectIF* object) override; + uint32_t getPeriodMs() const override; ReturnValue_t sleepFor(uint32_t ms) override; diff --git a/src/fsfw/osal/rtems/PeriodicTask.cpp b/src/fsfw/osal/rtems/PeriodicTask.cpp index 1785c8cf..ae2ec426 100644 --- a/src/fsfw/osal/rtems/PeriodicTask.cpp +++ b/src/fsfw/osal/rtems/PeriodicTask.cpp @@ -68,11 +68,15 @@ void PeriodicTask::taskFunctionality() { ReturnValue_t PeriodicTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = ObjectManager::instance()->get(object); - if (newObject == nullptr) { + return addComponent(newObject); +} + +ReturnValue_t PeriodicTask::addComponent(ExecutableObjectIF* object) { + if (object == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } - objectList.push_back(newObject); - newObject->setTaskIF(this); + objectList.push_back(object); + object->setTaskIF(this); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/osal/rtems/PeriodicTask.h b/src/fsfw/osal/rtems/PeriodicTask.h index 119329f2..24ce4af1 100644 --- a/src/fsfw/osal/rtems/PeriodicTask.h +++ b/src/fsfw/osal/rtems/PeriodicTask.h @@ -59,6 +59,15 @@ class PeriodicTask : public RTEMSTaskBase, public PeriodicTaskIF { */ ReturnValue_t addComponent(object_id_t object) override; +/** + * Adds an object to the list of objects to be executed. + * The objects are executed in the order added. + * @param object pointer to the object to add. + * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. + */ + ReturnValue_t addComponent(ExecutableObjectIF* object) override; + + uint32_t getPeriodMs() const override; ReturnValue_t sleepFor(uint32_t ms) override; diff --git a/src/fsfw/tasks/PeriodicTaskIF.h b/src/fsfw/tasks/PeriodicTaskIF.h index a8a51229..c78a32de 100644 --- a/src/fsfw/tasks/PeriodicTaskIF.h +++ b/src/fsfw/tasks/PeriodicTaskIF.h @@ -26,21 +26,25 @@ class PeriodicTaskIF { virtual ReturnValue_t startTask() = 0; /** - * Add a component (object) to a periodic task. The pointer to the - * task can be set optionally + * Add a component (object) to a periodic task. * @param object - * Add an object to the task. The most important case is to add an - * executable object with a function which will be called regularly - * (see ExecutableObjectIF) - * @param setTaskIF - * Can be used to specify whether the task object pointer is passed - * to the component. + * Add an object to the task. The object needs to implement ExecutableObjectIF * @return */ virtual ReturnValue_t addComponent(object_id_t object) { return HasReturnvaluesIF::RETURN_FAILED; }; + /** + * Add an object to a periodic task. + * @param object + * Add an object to the task. + * @return + */ + virtual ReturnValue_t addComponent(ExecutableObjectIF* object) { + return HasReturnvaluesIF::RETURN_FAILED; + }; + virtual ReturnValue_t sleepFor(uint32_t ms) = 0; virtual uint32_t getPeriodMs() const = 0;