From 42df77ff32a147a33c0c90ac154377dc414b7b6e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 27 Sep 2021 11:16:27 +0200 Subject: [PATCH 01/16] check for empty PST and return appropriate returnvalue --- src/fsfw/returnvalues/FwClassIds.h | 2 ++ src/fsfw/tasks/FixedSlotSequence.cpp | 6 +++--- src/fsfw/tasks/FixedSlotSequence.h | 4 +++- src/fsfw/tasks/FixedTimeslotTaskIF.h | 5 ++++- src/fsfw/tasks/Typedef.h | 9 ++++++--- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/fsfw/returnvalues/FwClassIds.h b/src/fsfw/returnvalues/FwClassIds.h index af32f9a7..ce093b09 100644 --- a/src/fsfw/returnvalues/FwClassIds.h +++ b/src/fsfw/returnvalues/FwClassIds.h @@ -72,10 +72,12 @@ enum: uint8_t { PUS_SERVICE_3, //PUS3 PUS_SERVICE_9, //PUS9 FILE_SYSTEM, //FILS + LINUX_OSAL, //UXOS HAL_SPI, //HSPI HAL_UART, //HURT HAL_I2C, //HI2C HAL_GPIO, //HGIO + FIXED_SLOT_TASK_IF, //FTIF FW_CLASS_ID_COUNT // [EXPORT] : [END] }; diff --git a/src/fsfw/tasks/FixedSlotSequence.cpp b/src/fsfw/tasks/FixedSlotSequence.cpp index 2e5384b7..5e896af4 100644 --- a/src/fsfw/tasks/FixedSlotSequence.cpp +++ b/src/fsfw/tasks/FixedSlotSequence.cpp @@ -1,4 +1,5 @@ #include "fsfw/tasks/FixedSlotSequence.h" +#include "fsfw/tasks/FixedTimeslotTaskIF.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include @@ -92,10 +93,9 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs, ReturnValue_t FixedSlotSequence::checkSequence() const { if(slotList.empty()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "FixedSlotSequence::checkSequence:" - << " Slot list is empty!" << std::endl; + sif::warning << "FixedSlotSequence::checkSequence: Slot list is empty!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return FixedTimeslotTaskIF::SLOT_LIST_EMPTY; } if(customCheckFunction != nullptr) { diff --git a/src/fsfw/tasks/FixedSlotSequence.h b/src/fsfw/tasks/FixedSlotSequence.h index 077dd10b..7f49ea0c 100644 --- a/src/fsfw/tasks/FixedSlotSequence.h +++ b/src/fsfw/tasks/FixedSlotSequence.h @@ -2,7 +2,7 @@ #define FSFW_TASKS_FIXEDSLOTSEQUENCE_H_ #include "FixedSequenceSlot.h" -#include "../objectmanager/SystemObject.h" +#include "fsfw/objectmanager/SystemObject.h" #include @@ -136,6 +136,7 @@ public: * @details * Checks if timing is ok (must be ascending) and if all handlers were found. * @return + * - SLOT_LIST_EMPTY if the slot list is empty */ ReturnValue_t checkSequence() const; @@ -147,6 +148,7 @@ public: * The general check will be continued for now if the custom check function * fails but a diagnostic debug output will be given. * @param customCheckFunction + * */ void addCustomCheck(ReturnValue_t (*customCheckFunction)(const SlotList &)); diff --git a/src/fsfw/tasks/FixedTimeslotTaskIF.h b/src/fsfw/tasks/FixedTimeslotTaskIF.h index 2fc7e092..605239a4 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskIF.h +++ b/src/fsfw/tasks/FixedTimeslotTaskIF.h @@ -2,7 +2,8 @@ #define FRAMEWORK_TASKS_FIXEDTIMESLOTTASKIF_H_ #include "PeriodicTaskIF.h" -#include "../objectmanager/ObjectManagerIF.h" +#include "fsfw/objectmanager/ObjectManagerIF.h" +#include "fsfw/returnvalues/FwClassIds.h" /** * @brief Following the same principle as the base class IF. @@ -12,6 +13,8 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF { public: virtual ~FixedTimeslotTaskIF() {} + static constexpr ReturnValue_t SLOT_LIST_EMPTY = HasReturnvaluesIF::makeReturnCode( + CLASS_ID::FIXED_SLOT_TASK_IF, 0); /** * Add an object with a slot time and the execution step to the task. * The execution step will be passed to the object (e.g. as an operation diff --git a/src/fsfw/tasks/Typedef.h b/src/fsfw/tasks/Typedef.h index 55f6bda2..f2f9fe65 100644 --- a/src/fsfw/tasks/Typedef.h +++ b/src/fsfw/tasks/Typedef.h @@ -1,5 +1,8 @@ -#ifndef FRAMEWORK_TASKS_TYPEDEF_H_ -#define FRAMEWORK_TASKS_TYPEDEF_H_ +#ifndef FSFW_TASKS_TYPEDEF_H_ +#define FSFW_TASKS_TYPEDEF_H_ + +#include +#include typedef const char* TaskName; typedef uint32_t TaskPriority; @@ -7,4 +10,4 @@ typedef size_t TaskStackSize; typedef double TaskPeriod; typedef void (*TaskDeadlineMissedFunction)(); -#endif /* FRAMEWORK_TASKS_TYPEDEF_H_ */ +#endif /* FSFW_TASKS_TYPEDEF_H_ */ From 8ec35f158c0d445c72f4a5761dd1660c5725e7e0 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Mon, 27 Sep 2021 19:57:42 +0200 Subject: [PATCH 02/16] Removed Timer and updated Countdown --- osal/linux/Timer.cpp | 45 ------------------------- osal/linux/Timer.h | 45 ------------------------- timemanager/Countdown.cpp | 36 ++++++++++++++------ timemanager/Countdown.h | 71 +++++++++++++++++++++++++++++++++------ 4 files changed, 86 insertions(+), 111 deletions(-) delete mode 100644 osal/linux/Timer.cpp delete mode 100644 osal/linux/Timer.h diff --git a/osal/linux/Timer.cpp b/osal/linux/Timer.cpp deleted file mode 100644 index fe0fbebb..00000000 --- a/osal/linux/Timer.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "Timer.h" -#include "../../serviceinterface/ServiceInterfaceStream.h" -#include - - -Timer::Timer() { - sigevent sigEvent; - sigEvent.sigev_notify = SIGEV_NONE; - sigEvent.sigev_signo = 0; - sigEvent.sigev_value.sival_ptr = &timerId; - int status = timer_create(CLOCK_MONOTONIC, &sigEvent, &timerId); - if(status!=0){ -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Timer creation failed with: " << status << - " errno: " << errno << std::endl; -#endif - } -} - -Timer::~Timer() { - timer_delete(timerId); -} - -int Timer::setTimer(uint32_t intervalMs) { - itimerspec timer; - timer.it_value.tv_sec = intervalMs / 1000; - timer.it_value.tv_nsec = (intervalMs * 1000000) % (1000000000); - timer.it_interval.tv_sec = 0; - timer.it_interval.tv_nsec = 0; - return timer_settime(timerId, 0, &timer, NULL); -} - - -int Timer::getTimer(uint32_t* remainingTimeMs){ - itimerspec timer; - timer.it_value.tv_sec = 0; - timer.it_value.tv_nsec = 0; - timer.it_interval.tv_sec = 0; - timer.it_interval.tv_nsec = 0; - int status = timer_gettime(timerId, &timer); - - *remainingTimeMs = timer.it_value.tv_sec * 1000 + timer.it_value.tv_nsec / 1000000; - - return status; -} diff --git a/osal/linux/Timer.h b/osal/linux/Timer.h deleted file mode 100644 index f94bca59..00000000 --- a/osal/linux/Timer.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef FRAMEWORK_OSAL_LINUX_TIMER_H_ -#define FRAMEWORK_OSAL_LINUX_TIMER_H_ - -#include -#include -#include - -/** - * This class is a helper for the creation of a Clock Monotonic timer which does not trigger a signal - */ -class Timer { -public: - /** - * Creates the Timer sets the timerId Member - */ - Timer(); - /** - * Deletes the timer - * - * Careful! According to POSIX documentation: - * The treatment of any pending signal generated by the deleted timer is unspecified. - */ - virtual ~Timer(); - - /** - * Set the timer given in timerId to the given interval - * - * @param intervalMs Interval in ms to be set - * @return 0 on Success 1 else - */ - int setTimer(uint32_t intervalMs); - - /** - * Get the remaining time of the timer - * - * @param remainingTimeMs Pointer to integer value which is used to return the remaining time - * @return 0 on Success 1 else (see timer_getime documentation of posix function) - */ - int getTimer(uint32_t* remainingTimeMs); - -private: - timer_t timerId; -}; - -#endif /* FRAMEWORK_OSAL_LINUX_TIMER_H_ */ diff --git a/timemanager/Countdown.cpp b/timemanager/Countdown.cpp index 20b56189..7aa40e3e 100644 --- a/timemanager/Countdown.cpp +++ b/timemanager/Countdown.cpp @@ -1,4 +1,6 @@ #include "Countdown.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" + Countdown::Countdown(uint32_t initialTimeout): timeout(initialTimeout) { } @@ -6,16 +8,14 @@ Countdown::Countdown(uint32_t initialTimeout): timeout(initialTimeout) { Countdown::~Countdown() { } -ReturnValue_t Countdown::setTimeout(uint32_t miliseconds) { - ReturnValue_t return_value = Clock::getUptime( &startTime ); - timeout = miliseconds; - return return_value; +ReturnValue_t Countdown::setTimeout(uint32_t milliseconds) { + ReturnValue_t returnValue = Clock::getUptime( &startTime ); + timeout = milliseconds; + return returnValue; } bool Countdown::hasTimedOut() const { - uint32_t current_time; - Clock::getUptime( ¤t_time ); - if ( uint32_t(current_time - startTime) >= timeout) { + if ( uint32_t( this->getCurrentTime() - startTime) >= timeout) { return true; } else { return false; @@ -31,7 +31,23 @@ ReturnValue_t Countdown::resetTimer() { } void Countdown::timeOut() { - uint32_t current_time; - Clock::getUptime( ¤t_time ); - startTime= current_time - timeout; + startTime = this->getCurrentTime() - timeout; +} + +uint32_t Countdown::getRemainingMillis() const { + // We fetch the time before the if-statement + // to be sure that the return is in + // range 0 <= number <= timeout + uint32_t currentTime = this->getCurrentTime(); + if (this->hasTimedOut()){ + return 0; + }else{ + return (startTime + timeout) - currentTime; + } +} + +uint32_t Countdown::getCurrentTime() const { + uint32_t current_time; + Clock::getUptime( ¤t_time ); + return current_time; } diff --git a/timemanager/Countdown.h b/timemanager/Countdown.h index f6a41e73..c0afdf75 100644 --- a/timemanager/Countdown.h +++ b/timemanager/Countdown.h @@ -4,28 +4,77 @@ #include "Clock.h" /** - * @brief This file defines the Countdown class. - * @author baetz + * + * Countdown keeps track of a timespan. + * + * Countdown::resetTimer restarts the timer. + * Countdown::setTimeout sets a new countdown duration and resets. + * + * Can be checked with Countdown::hasTimedOut or + * Countdown::isBusy. + * + * Countdown::timeOut will force the timer to time out. + * */ class Countdown { public: - uint32_t timeout; + /** + * Constructor which sets the countdown duration in milliseconds + * + * It does not start the countdown! + * Call resetTimer or setTimeout before usage! + * Otherwise a call to hasTimedOut might return True. + * + * @param initialTimeout Countdown duration in milliseconds + */ Countdown(uint32_t initialTimeout = 0); ~Countdown(); - ReturnValue_t setTimeout(uint32_t miliseconds); - + /** + * Call to set a new countdown duration. + * + * Resets the countdown! + * + * @param milliseconds new countdown duration in milliseconds + * @return Returnvalue from Clock::getUptime + */ + ReturnValue_t setTimeout(uint32_t milliseconds); + /** + * Returns true if the countdown duration has passed. + * + * @return True if the countdown has passed + * False if it is still running + */ bool hasTimedOut() const; - + /** + * Complementary to hasTimedOut. + * + * @return True if the countdown is till running + * False if it is still running + */ bool isBusy() const; - - //!< Use last set timeout value and restart timer. + /** + * Uses last set timeout value and restarts timer. + */ ReturnValue_t resetTimer(); - - //!< Make hasTimedOut() return true + /** + * Returns the remaining milliseconds (0 if timeout) + */ + uint32_t getRemainingMillis() const; + /** + * Makes hasTimedOut() return true + */ void timeOut(); - + /** + * Internal countdown duration in milliseconds + */ + uint32_t timeout; private: + /** + * Last time the timer was started (uptime) + */ uint32_t startTime = 0; + + uint32_t getCurrentTime() const; }; #endif /* FSFW_TIMEMANAGER_COUNTDOWN_H_ */ From 5064d449992a921936211d7e2d8dbac99e4cf6cc Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Mon, 27 Sep 2021 20:45:44 +0200 Subject: [PATCH 03/16] Removed Timer.cpp from CMakeLists --- osal/linux/CMakeLists.txt | 1 - timemanager/Countdown.cpp | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osal/linux/CMakeLists.txt b/osal/linux/CMakeLists.txt index 0fb66b3e..41800764 100644 --- a/osal/linux/CMakeLists.txt +++ b/osal/linux/CMakeLists.txt @@ -13,7 +13,6 @@ target_sources(${LIB_FSFW_NAME} QueueFactory.cpp SemaphoreFactory.cpp TaskFactory.cpp - Timer.cpp tcpipHelpers.cpp unixUtility.cpp ) diff --git a/timemanager/Countdown.cpp b/timemanager/Countdown.cpp index 7aa40e3e..81681beb 100644 --- a/timemanager/Countdown.cpp +++ b/timemanager/Countdown.cpp @@ -47,7 +47,7 @@ uint32_t Countdown::getRemainingMillis() const { } uint32_t Countdown::getCurrentTime() const { - uint32_t current_time; - Clock::getUptime( ¤t_time ); - return current_time; + uint32_t currentTime; + Clock::getUptime( ¤tTime ); + return currentTime; } From 4b62c8aa81abcf5490c6a3045e38d0acc9955f4b Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Mon, 27 Sep 2021 21:53:27 +0200 Subject: [PATCH 04/16] Added tests --- tests/src/fsfw_tests/unit/CMakeLists.txt | 1 + .../unit/timemanager/CMakeLists.txt | 3 +++ .../unit/timemanager/TestCountdown.cpp | 27 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 tests/src/fsfw_tests/unit/timemanager/CMakeLists.txt create mode 100644 tests/src/fsfw_tests/unit/timemanager/TestCountdown.cpp diff --git a/tests/src/fsfw_tests/unit/CMakeLists.txt b/tests/src/fsfw_tests/unit/CMakeLists.txt index 01e4d19c..f30e4b6b 100644 --- a/tests/src/fsfw_tests/unit/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/CMakeLists.txt @@ -18,4 +18,5 @@ add_subdirectory(serialize) add_subdirectory(datapoollocal) add_subdirectory(storagemanager) add_subdirectory(globalfunctions) +add_subdirectory(timemanager) add_subdirectory(tmtcpacket) diff --git a/tests/src/fsfw_tests/unit/timemanager/CMakeLists.txt b/tests/src/fsfw_tests/unit/timemanager/CMakeLists.txt new file mode 100644 index 00000000..2c635711 --- /dev/null +++ b/tests/src/fsfw_tests/unit/timemanager/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${TARGET_NAME} PRIVATE + TestCountdown.cpp +) diff --git a/tests/src/fsfw_tests/unit/timemanager/TestCountdown.cpp b/tests/src/fsfw_tests/unit/timemanager/TestCountdown.cpp new file mode 100644 index 00000000..b1b26679 --- /dev/null +++ b/tests/src/fsfw_tests/unit/timemanager/TestCountdown.cpp @@ -0,0 +1,27 @@ +#include "fsfw_tests/unit/CatchDefinitions.h" +#include +#include + + +TEST_CASE( "Countdown Tests", "[TestCountdown]") { + INFO("Countdown Tests"); + Countdown count(20); + REQUIRE(count.timeout == 20); + REQUIRE(count.setTimeout(100) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(count.timeout == 100); + REQUIRE(count.setTimeout(150) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(count.isBusy()); + REQUIRE(not count.hasTimedOut()); + uint32_t number = count.getRemainingMillis(); + REQUIRE(number > 0); + bool blocked = false; + while(not count.hasTimedOut()){ + blocked = true; + }; + REQUIRE(blocked); + number = count.getRemainingMillis(); + REQUIRE(number==0); + count.resetTimer(); + REQUIRE(not count.hasTimedOut()); + REQUIRE(count.isBusy()); +} From 4f08b2d342d2b025bb477296219d141ad3bfd2d3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 15:42:50 +0200 Subject: [PATCH 05/16] removed include --- hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h | 1 - 1 file changed, 1 deletion(-) diff --git a/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h b/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h index 1ba680cb..6627cbb7 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h +++ b/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h @@ -2,7 +2,6 @@ #define MISSION_DEVICES_MGMRM3100HANDLER_H_ #include "fsfw/FSFW.h" -#include "devices/powerSwitcherList.h" #include "devicedefinitions/MgmRM3100HandlerDefs.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" From 358ee0fbf2220109e2b37446486732114ec710c4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 15:45:45 +0200 Subject: [PATCH 06/16] removed C++14 featue --- .../devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h b/hal/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h index 0ee2c7f6..b6375692 100644 --- a/hal/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h +++ b/hal/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h @@ -49,7 +49,7 @@ static constexpr uint8_t TMRC_DEFAULT_VALUE = TMRC_DEFAULT_37HZ_VALUE; static constexpr uint8_t MEASUREMENT_REG_START = 0x24; static constexpr uint8_t BIST_REGISTER = 0x33; -static constexpr uint8_t DATA_READY_VAL = 0b1000'0000; +static constexpr uint8_t DATA_READY_VAL = 0b10000000; static constexpr uint8_t STATUS_REGISTER = 0x34; static constexpr uint8_t REVID_REGISTER = 0x36; From 42b5f8a79df039a07ad1c0c886be685176a5165c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 11:49:45 +0200 Subject: [PATCH 07/16] small fix for DLE unittest --- tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp b/tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp index a82ac73a..8c2e55ed 100644 --- a/tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp +++ b/tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp @@ -103,7 +103,7 @@ TEST_CASE("DleEncoder" , "[DleEncoder]") { for(size_t faultyDestSize = 0; faultyDestSize < expectedVec.size(); faultyDestSize ++) { result = dleEncoder.encode(vecToEncode.data(), vecToEncode.size(), buffer.data(), faultyDestSize, &encodedLen); - REQUIRE(result == DleEncoder::STREAM_TOO_SHORT); + REQUIRE(result == static_cast(DleEncoder::STREAM_TOO_SHORT)); } }; From 9002c12cf157aec1d84984d0316d6bf94a60ba39 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 11:55:20 +0200 Subject: [PATCH 08/16] update FSFW.h.in --- src/fsfw/FSFW.h.in | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/fsfw/FSFW.h.in b/src/fsfw/FSFW.h.in index f0eb9365..ddc69373 100644 --- a/src/fsfw/FSFW.h.in +++ b/src/fsfw/FSFW.h.in @@ -16,8 +16,21 @@ #cmakedefine FSFW_ADD_MONITORING #cmakedefine FSFW_ADD_SGP4_PROPAGATOR +// Can be used for low-level debugging of the SPI bus +#ifndef FSFW_HAL_SPI_WIRETAPPING +#define FSFW_HAL_SPI_WIRETAPPING 0 +#endif + #ifndef FSFW_HAL_L3GD20_GYRO_DEBUG -#define FSFW_HAL_L3GD20_GYRO_DEBUG 0 +#define FSFW_HAL_L3GD20_GYRO_DEBUG 0 #endif /* FSFW_HAL_L3GD20_GYRO_DEBUG */ +#ifndef FSFW_HAL_RM3100_MGM_DEBUG +#define FSFW_HAL_RM3100_MGM_DEBUG 0 +#endif /* FSFW_HAL_RM3100_MGM_DEBUG */ + +#ifndef FSFW_HAL_LIS3MDL_MGM_DEBUG +#define FSFW_HAL_LIS3MDL_MGM_DEBUG 0 +#endif /* FSFW_HAL_LIS3MDL_MGM_DEBUG */ + #endif /* FSFW_FSFW_H_ */ From faa7e1e24f1f6943111b1445db01b70870d2e717 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 12:00:59 +0200 Subject: [PATCH 09/16] default values for PUS c config --- src/fsfw/FSFW.h.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/fsfw/FSFW.h.in b/src/fsfw/FSFW.h.in index ddc69373..e2591197 100644 --- a/src/fsfw/FSFW.h.in +++ b/src/fsfw/FSFW.h.in @@ -16,6 +16,14 @@ #cmakedefine FSFW_ADD_MONITORING #cmakedefine FSFW_ADD_SGP4_PROPAGATOR +#ifndef FSFW_USE_PUS_C_TELEMETRY +#define FSFW_USE_PUS_C_TELEMETRY 1 +#endif + +#ifndef FSFW_USE_PUS_C_TELECOMMANDS +#define FSFW_USE_PUS_C_TELECOMMANDS 1 +#endif + // Can be used for low-level debugging of the SPI bus #ifndef FSFW_HAL_SPI_WIRETAPPING #define FSFW_HAL_SPI_WIRETAPPING 0 From f388878b99bd30d1faa8429a7f64c300c4cecb23 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 12:05:15 +0200 Subject: [PATCH 10/16] added more defines --- src/fsfw/FSFW.h.in | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/fsfw/FSFW.h.in b/src/fsfw/FSFW.h.in index e2591197..512a25be 100644 --- a/src/fsfw/FSFW.h.in +++ b/src/fsfw/FSFW.h.in @@ -14,19 +14,39 @@ #cmakedefine FSFW_ADD_COORDINATES #cmakedefine FSFW_ADD_PUS #cmakedefine FSFW_ADD_MONITORING -#cmakedefine FSFW_ADD_SGP4_PROPAGATOR +#cmakedefine FSFW_ADD_SGP4_PROPAGATOR0 + +// FSFW core defines + +#ifndef FSFW_CPP_OSTREAM_ENABLED +#define FSFW_CPP_OSTREAM_ENABLED 1 +#endif /* FSFW_CPP_OSTREAM_ENABLED */ + +#ifndef FSFW_VERBOSE_LEVEL +#define FSFW_VERBOSE_LEVEL 1 +#endif /* FSFW_VERBOSE_LEVEL */ + +#ifndef FSFW_USE_REALTIME_FOR_LINUX +#define FSFW_USE_REALTIME_FOR_LINUX 0 +#endif /* FSFW_USE_REALTIME_FOR_LINUX */ + +#ifndef FSFW_NO_C99_IO +#define FSFW_NO_C99_IO 0 +#endif /* FSFW_NO_C99_IO */ #ifndef FSFW_USE_PUS_C_TELEMETRY #define FSFW_USE_PUS_C_TELEMETRY 1 -#endif +#endif /* FSFW_USE_PUS_C_TELEMETRY */ #ifndef FSFW_USE_PUS_C_TELECOMMANDS #define FSFW_USE_PUS_C_TELECOMMANDS 1 #endif +// FSFW HAL defines + // Can be used for low-level debugging of the SPI bus #ifndef FSFW_HAL_SPI_WIRETAPPING -#define FSFW_HAL_SPI_WIRETAPPING 0 +#define FSFW_HAL_SPI_WIRETAPPING 0 #endif #ifndef FSFW_HAL_L3GD20_GYRO_DEBUG From febe3cc4d45ac2a324a0d956e655a988a79abf68 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 12:05:24 +0200 Subject: [PATCH 11/16] define fix --- 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 512a25be..7e52b646 100644 --- a/src/fsfw/FSFW.h.in +++ b/src/fsfw/FSFW.h.in @@ -14,7 +14,7 @@ #cmakedefine FSFW_ADD_COORDINATES #cmakedefine FSFW_ADD_PUS #cmakedefine FSFW_ADD_MONITORING -#cmakedefine FSFW_ADD_SGP4_PROPAGATOR0 +#cmakedefine FSFW_ADD_SGP4_PROPAGATOR // FSFW core defines From b0cbd40e647d1a131e12f1e3ff7ae4ff45443d26 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 30 Sep 2021 11:25:42 +0200 Subject: [PATCH 12/16] possible bugfix for DLE encoder --- src/fsfw/globalfunctions/DleEncoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/globalfunctions/DleEncoder.cpp b/src/fsfw/globalfunctions/DleEncoder.cpp index 47ea5c4e..f4691cc6 100644 --- a/src/fsfw/globalfunctions/DleEncoder.cpp +++ b/src/fsfw/globalfunctions/DleEncoder.cpp @@ -165,7 +165,7 @@ ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_ if (sourceStream[encodedIndex++] != STX_CHAR) { return DECODING_ERROR; } - while ((encodedIndex < sourceStreamLen) + while ((encodedIndex < sourceStreamLen - 1) and (decodedIndex < maxDestStreamlen) and (sourceStream[encodedIndex] != ETX_CHAR) and (sourceStream[encodedIndex] != STX_CHAR)) { From f76f462022e45dbc13b452bb2e2c4e8cea5159f5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 30 Sep 2021 11:27:14 +0200 Subject: [PATCH 13/16] test added --- tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp b/tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp index 8c2e55ed..cffd5308 100644 --- a/tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp +++ b/tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp @@ -218,5 +218,10 @@ TEST_CASE("DleEncoder" , "[DleEncoder]") { REQUIRE(result == static_cast(DleEncoder::DECODING_ERROR)); dleEncoder.setEscapeMode(true); + testArray1EncodedFaulty = TEST_ARRAY_1_ENCODED_ESCAPED; + testArray1EncodedFaulty[5] = 0; + result = dleEncoder.decode(testArray1EncodedFaulty.data(), testArray1EncodedFaulty.size(), + &readLen, buffer.data(), buffer.size(), &encodedLen); + REQUIRE(result == static_cast(DleEncoder::DECODING_ERROR)); } } From afb472996c219c20a94a0df3754430b9df3a546a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 30 Sep 2021 16:49:30 +0200 Subject: [PATCH 14/16] refactoring, code more understandable --- src/fsfw/globalfunctions/DleEncoder.cpp | 48 +++++++++++++------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/fsfw/globalfunctions/DleEncoder.cpp b/src/fsfw/globalfunctions/DleEncoder.cpp index f4691cc6..f77d5472 100644 --- a/src/fsfw/globalfunctions/DleEncoder.cpp +++ b/src/fsfw/globalfunctions/DleEncoder.cpp @@ -165,11 +165,9 @@ ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_ if (sourceStream[encodedIndex++] != STX_CHAR) { return DECODING_ERROR; } - while ((encodedIndex < sourceStreamLen - 1) - and (decodedIndex < maxDestStreamlen) - and (sourceStream[encodedIndex] != ETX_CHAR) - and (sourceStream[encodedIndex] != STX_CHAR)) { - if (sourceStream[encodedIndex] == DLE_CHAR) { + while ((encodedIndex < sourceStreamLen) and (decodedIndex < maxDestStreamlen)) { + switch(sourceStream[encodedIndex]) { + case(DLE_CHAR): { if(encodedIndex + 1 >= sourceStreamLen) { //reached the end of the sourceStream *readLen = sourceStreamLen; @@ -197,29 +195,33 @@ ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_ } } ++encodedIndex; + break; } - else { - destStream[decodedIndex] = sourceStream[encodedIndex]; - } - - ++encodedIndex; - ++decodedIndex; - } - if (sourceStream[encodedIndex] != ETX_CHAR) { - if(decodedIndex == maxDestStreamlen) { - //so far we did not find anything wrong here, so let user try again - *readLen = 0; - return STREAM_TOO_SHORT; - } - else { + case(STX_CHAR): { *readLen = ++encodedIndex; return DECODING_ERROR; } + case(ETX_CHAR): { + *readLen = ++encodedIndex; + *decodedLen = decodedIndex; + return RETURN_OK; + } + default: { + destStream[decodedIndex] = sourceStream[encodedIndex]; + break; + } + } + ++encodedIndex; + ++decodedIndex; } - else { - *readLen = ++encodedIndex; - *decodedLen = decodedIndex; - return RETURN_OK; + + if(decodedIndex == maxDestStreamlen) { + //so far we did not find anything wrong here, so let user try again + *readLen = 0; + return STREAM_TOO_SHORT; + } else { + *readLen = encodedIndex; + return DECODING_ERROR; } } From 2439613f210d416c4d1c734756f76d4951fa2ab1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Oct 2021 14:38:10 +0200 Subject: [PATCH 15/16] preserve STX char --- src/fsfw/globalfunctions/DleEncoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/globalfunctions/DleEncoder.cpp b/src/fsfw/globalfunctions/DleEncoder.cpp index f77d5472..91db5445 100644 --- a/src/fsfw/globalfunctions/DleEncoder.cpp +++ b/src/fsfw/globalfunctions/DleEncoder.cpp @@ -198,7 +198,7 @@ ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_ break; } case(STX_CHAR): { - *readLen = ++encodedIndex; + *readLen = encodedIndex; return DECODING_ERROR; } case(ETX_CHAR): { From 146e1e32827f6bdc705549466025699e8b4f12a3 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 4 Oct 2021 14:47:32 +0200 Subject: [PATCH 16/16] bumped version to 2.0.0 for next release --- src/fsfw/FSFWVersion.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/FSFWVersion.h b/src/fsfw/FSFWVersion.h index f8e89694..c581a85c 100644 --- a/src/fsfw/FSFWVersion.h +++ b/src/fsfw/FSFWVersion.h @@ -3,8 +3,8 @@ const char* const FSFW_VERSION_NAME = "ASTP"; -#define FSFW_VERSION 1 -#define FSFW_SUBVERSION 2 +#define FSFW_VERSION 2 +#define FSFW_SUBVERSION 0 #define FSFW_REVISION 0 #endif /* FSFW_VERSION_H_ */