From 194a9eef64785cb2d3abc2d57308053b12cd1ea5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jan 2021 15:11:19 +0100 Subject: [PATCH 01/19] formatting --- unittest/tests/datapoollocal/LocalPoolManagerTest.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/unittest/tests/datapoollocal/LocalPoolManagerTest.cpp b/unittest/tests/datapoollocal/LocalPoolManagerTest.cpp index 81e2fddcb..c8b10442a 100644 --- a/unittest/tests/datapoollocal/LocalPoolManagerTest.cpp +++ b/unittest/tests/datapoollocal/LocalPoolManagerTest.cpp @@ -187,8 +187,7 @@ TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") { CHECK(messageSent.getCommand() == static_cast( HousekeepingMessage::HK_REPORT)); CommandMessageCleaner::clearCommandMessage(&messageSent); - REQUIRE(mqMock->receiveMessage(&messageSent) == - static_cast(MessageQueueIF::EMPTY)); + REQUIRE(mqMock->receiveMessage(&messageSent) == static_cast(MessageQueueIF::EMPTY)); } /* we need to reset the subscription list because the pool owner From a93984869cee6ad9837078c35fdd15543074fd00 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jan 2021 21:38:38 +0100 Subject: [PATCH 02/19] added start and end marker for framework objects --- objectmanager/frameworkObjects.h | 42 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/objectmanager/frameworkObjects.h b/objectmanager/frameworkObjects.h index 8f8e93af7..9810e33b9 100644 --- a/objectmanager/frameworkObjects.h +++ b/objectmanager/frameworkObjects.h @@ -3,28 +3,30 @@ namespace objects { enum framework_objects { - // Default verification reporter. - PUS_SERVICE_1_VERIFICATION = 0x53000001, - PUS_SERVICE_2_DEVICE_ACCESS = 0x53000002, - PUS_SERVICE_3_HOUSEKEEPING = 0x53000003, - PUS_SERVICE_5_EVENT_REPORTING = 0x53000005, - PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008, - PUS_SERVICE_9_TIME_MGMT = 0x53000009, - PUS_SERVICE_17_TEST = 0x53000017, - PUS_SERVICE_200_MODE_MGMT = 0x53000200, + FSFW_OBJECTS_START = 0x53000000, + // Default verification reporter. + PUS_SERVICE_1_VERIFICATION = 0x53000001, + PUS_SERVICE_2_DEVICE_ACCESS = 0x53000002, + PUS_SERVICE_3_HOUSEKEEPING = 0x53000003, + PUS_SERVICE_5_EVENT_REPORTING = 0x53000005, + PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008, + PUS_SERVICE_9_TIME_MGMT = 0x53000009, + PUS_SERVICE_17_TEST = 0x53000017, + PUS_SERVICE_200_MODE_MGMT = 0x53000200, - //Generic IDs for IPC, modes, health, events - HEALTH_TABLE = 0x53010000, -// MODE_STORE = 0x53010100, - EVENT_MANAGER = 0x53030000, - INTERNAL_ERROR_REPORTER = 0x53040000, - IPC_STORE = 0x534f0300, - //IDs for PUS Packet Communication - TC_STORE = 0x534f0100, - TM_STORE = 0x534f0200, - TIME_STAMPER = 0x53500010, + //Generic IDs for IPC, modes, health, events + HEALTH_TABLE = 0x53010000, + // MODE_STORE = 0x53010100, + EVENT_MANAGER = 0x53030000, + INTERNAL_ERROR_REPORTER = 0x53040000, + IPC_STORE = 0x534f0300, + //IDs for PUS Packet Communication + TC_STORE = 0x534f0100, + TM_STORE = 0x534f0200, + TIME_STAMPER = 0x53500010, - NO_OBJECT = 0xFFFFFFFF + FSFW_OBJECTS_END = 0x53ffffff, + NO_OBJECT = 0xFFFFFFFF }; } From d1cd1805347e595ca27c8a0428321d80c4131195 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jan 2021 23:09:08 +0100 Subject: [PATCH 03/19] fixed warning for RTEMS --- osal/rtems/CpuUsage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osal/rtems/CpuUsage.cpp b/osal/rtems/CpuUsage.cpp index 6655c69b6..89c01336a 100644 --- a/osal/rtems/CpuUsage.cpp +++ b/osal/rtems/CpuUsage.cpp @@ -164,7 +164,7 @@ ReturnValue_t CpuUsage::ThreadData::deSerialize(const uint8_t** buffer, if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - if ((*size = *size - MAX_LENGTH_OF_THREAD_NAME) < 0) { + if (*size < MAX_LENGTH_OF_THREAD_NAME) { return STREAM_TOO_SHORT; } memcpy(name, *buffer, MAX_LENGTH_OF_THREAD_NAME); From 47698418fcfaccb0125e7f36a187e93fe8a59294 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jan 2021 23:12:14 +0100 Subject: [PATCH 04/19] some more warning fixes --- osal/rtems/MultiObjectTask.cpp | 6 ------ osal/rtems/TaskBase.cpp | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/osal/rtems/MultiObjectTask.cpp b/osal/rtems/MultiObjectTask.cpp index b111f724c..0cc3c9221 100644 --- a/osal/rtems/MultiObjectTask.cpp +++ b/osal/rtems/MultiObjectTask.cpp @@ -62,12 +62,6 @@ void MultiObjectTask::taskFunctionality() { } rtems_status_code status = TaskBase::restartPeriod(periodTicks,periodId); if (status == RTEMS_TIMEOUT) { - char nameSpace[8] = { 0 }; - char* ptr = rtems_object_get_name(getId(), sizeof(nameSpace), - nameSpace); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "ObjectTask: " << ptr << " Deadline missed." << std::endl; -#endif if (this->deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); } diff --git a/osal/rtems/TaskBase.cpp b/osal/rtems/TaskBase.cpp index 6abfcca8d..7ad94b843 100644 --- a/osal/rtems/TaskBase.cpp +++ b/osal/rtems/TaskBase.cpp @@ -14,7 +14,7 @@ TaskBase::TaskBase(rtems_task_priority set_priority, size_t stack_size, } //The task is created with the operating system's system call. rtems_status_code status = RTEMS_UNSATISFIED; - if (set_priority >= 0 && set_priority <= 99) { + if (set_priority <= 99) { status = rtems_task_create(osalName, (0xFF - 2 * set_priority), stack_size, RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR, From de45e9b8a9c7fae16305e9cec80dbddd07b9dede Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 00:59:34 +0100 Subject: [PATCH 05/19] rtems multi object is now periodicTask --- osal/rtems/CMakeLists.txt | 4 +- osal/rtems/MultiObjectTask.cpp | 86 ------------------- osal/rtems/PeriodicTask.cpp | 80 +++++++++++++++++ .../{MultiObjectTask.h => PeriodicTask.h} | 18 ++-- osal/rtems/PollingTask.cpp | 8 +- osal/rtems/PollingTask.h | 4 +- .../rtems/{TaskBase.cpp => RTEMSTaskBase.cpp} | 20 ++--- osal/rtems/{TaskBase.h => RTEMSTaskBase.h} | 12 +-- osal/rtems/RtemsBasic.cpp | 1 + osal/rtems/RtemsBasic.h | 3 +- osal/rtems/TaskFactory.cpp | 4 +- 11 files changed, 118 insertions(+), 122 deletions(-) delete mode 100644 osal/rtems/MultiObjectTask.cpp create mode 100644 osal/rtems/PeriodicTask.cpp rename osal/rtems/{MultiObjectTask.h => PeriodicTask.h} (90%) rename osal/rtems/{TaskBase.cpp => RTEMSTaskBase.cpp} (75%) rename osal/rtems/{TaskBase.h => RTEMSTaskBase.h} (84%) diff --git a/osal/rtems/CMakeLists.txt b/osal/rtems/CMakeLists.txt index bff031842..ba11a6b5a 100644 --- a/osal/rtems/CMakeLists.txt +++ b/osal/rtems/CMakeLists.txt @@ -5,13 +5,13 @@ target_sources(${LIB_FSFW_NAME} InitTask.cpp InternalErrorCodes.cpp MessageQueue.cpp - MultiObjectTask.cpp + PeriodicTask.cpp Mutex.cpp MutexFactory.cpp PollingTask.cpp QueueFactory.cpp RtemsBasic.cpp - TaskBase.cpp + RTEMSTaskBase.cpp TaskFactory.cpp ) diff --git a/osal/rtems/MultiObjectTask.cpp b/osal/rtems/MultiObjectTask.cpp deleted file mode 100644 index 0cc3c9221..000000000 --- a/osal/rtems/MultiObjectTask.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file MultiObjectTask.cpp - * @brief This file defines the MultiObjectTask class. - * @date 30.01.2014 - * @author baetz - */ - -#include "../../serviceinterface/ServiceInterfaceStream.h" -#include "../../tasks/ExecutableObjectIF.h" -#include "MultiObjectTask.h" - -MultiObjectTask::MultiObjectTask(const char *name, rtems_task_priority setPriority, - size_t setStack, rtems_interval setPeriod, void (*setDeadlineMissedFunc)()) : - TaskBase(setPriority, setStack, name), periodTicks( - RtemsBasic::convertMsToTicks(setPeriod)), periodId(0), deadlineMissedFunc( - setDeadlineMissedFunc) { -} - -MultiObjectTask::~MultiObjectTask(void) { - //Do not delete objects, we were responsible for ptrs only. - rtems_rate_monotonic_delete(periodId); -} -rtems_task MultiObjectTask::taskEntryPoint(rtems_task_argument argument) { - //The argument is re-interpreted as MultiObjectTask. The Task object is global, so it is found from any place. - MultiObjectTask *originalTask(reinterpret_cast(argument)); - originalTask->taskFunctionality(); -} - -ReturnValue_t MultiObjectTask::startTask() { - rtems_status_code status = rtems_task_start(id, MultiObjectTask::taskEntryPoint, - rtems_task_argument((void *) this)); - if (status != RTEMS_SUCCESSFUL) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "ObjectTask::startTask for " << std::hex << this->getId() - << std::dec << " failed." << std::endl; -#endif - } - switch(status){ - case RTEMS_SUCCESSFUL: - //ask started successfully - return HasReturnvaluesIF::RETURN_OK; - default: -/* RTEMS_INVALID_ADDRESS - invalid task entry point - RTEMS_INVALID_ID - invalid task id - RTEMS_INCORRECT_STATE - task not in the dormant state - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task */ - return HasReturnvaluesIF::RETURN_FAILED; - } -} - -ReturnValue_t MultiObjectTask::sleepFor(uint32_t ms) { - return TaskBase::sleepFor(ms); -} - -void MultiObjectTask::taskFunctionality() { - TaskBase::setAndStartPeriod(periodTicks,&periodId); - //The task's "infinite" inner loop is entered. - while (1) { - for (ObjectList::iterator it = objectList.begin(); - it != objectList.end(); ++it) { - (*it)->performOperation(); - } - rtems_status_code status = TaskBase::restartPeriod(periodTicks,periodId); - if (status == RTEMS_TIMEOUT) { - if (this->deadlineMissedFunc != nullptr) { - this->deadlineMissedFunc(); - } - } - } -} - -ReturnValue_t MultiObjectTask::addComponent(object_id_t object) { - ExecutableObjectIF* newObject = objectManager->get( - object); - if (newObject == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - objectList.push_back(newObject); - newObject->setTaskIF(this); - - return HasReturnvaluesIF::RETURN_OK; -} - -uint32_t MultiObjectTask::getPeriodMs() const { - return RtemsBasic::convertTicksToMs(periodTicks); -} diff --git a/osal/rtems/PeriodicTask.cpp b/osal/rtems/PeriodicTask.cpp new file mode 100644 index 000000000..631fa8209 --- /dev/null +++ b/osal/rtems/PeriodicTask.cpp @@ -0,0 +1,80 @@ +#include "PeriodicTask.h" + +#include "../../serviceinterface/ServiceInterface.h" +#include "../../tasks/ExecutableObjectIF.h" + +PeriodicTask::PeriodicTask(const char *name, rtems_task_priority setPriority, + size_t setStack, rtems_interval setPeriod, void (*setDeadlineMissedFunc)()) : + RTEMSTaskBase(setPriority, setStack, name), + periodTicks(RtemsBasic::convertMsToTicks(setPeriod)), + deadlineMissedFunc(setDeadlineMissedFunc) { +} + +PeriodicTask::~PeriodicTask(void) { + /* Do not delete objects, we were responsible for pointers only. */ + rtems_rate_monotonic_delete(periodId); +} + +rtems_task PeriodicTask::taskEntryPoint(rtems_task_argument argument) { + /* The argument is re-interpreted as MultiObjectTask. The Task object is global, + so it is found from any place. */ + PeriodicTask *originalTask(reinterpret_cast(argument)); + return originalTask->taskFunctionality();; +} + +ReturnValue_t PeriodicTask::startTask() { + rtems_status_code status = rtems_task_start(id, PeriodicTask::taskEntryPoint, + rtems_task_argument((void *) this)); + if (status != RTEMS_SUCCESSFUL) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "ObjectTask::startTask for " << std::hex << this->getId() + << std::dec << " failed." << std::endl; +#endif + } + switch(status){ + case RTEMS_SUCCESSFUL: + /* Task started successfully */ + return HasReturnvaluesIF::RETURN_OK; + default: + /* RTEMS_INVALID_ADDRESS - invalid task entry point + RTEMS_INVALID_ID - invalid task id + RTEMS_INCORRECT_STATE - task not in the dormant state + RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task */ + return HasReturnvaluesIF::RETURN_FAILED; + } +} + +ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) { + return RTEMSTaskBase::sleepFor(ms); +} + +void PeriodicTask::taskFunctionality() { + RTEMSTaskBase::setAndStartPeriod(periodTicks,&periodId); + /* The task's "infinite" inner loop is entered. */ + while (1) { + for (const auto& object: objectList) { + object->performOperation(); + } + rtems_status_code status = RTEMSTaskBase::restartPeriod(periodTicks,periodId); + if (status == RTEMS_TIMEOUT) { + if (this->deadlineMissedFunc != nullptr) { + this->deadlineMissedFunc(); + } + } + } +} + +ReturnValue_t PeriodicTask::addComponent(object_id_t object) { + ExecutableObjectIF* newObject = objectManager->get(object); + if (newObject == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + objectList.push_back(newObject); + newObject->setTaskIF(this); + + return HasReturnvaluesIF::RETURN_OK; +} + +uint32_t PeriodicTask::getPeriodMs() const { + return RtemsBasic::convertTicksToMs(periodTicks); +} diff --git a/osal/rtems/MultiObjectTask.h b/osal/rtems/PeriodicTask.h similarity index 90% rename from osal/rtems/MultiObjectTask.h rename to osal/rtems/PeriodicTask.h index 04d122a3d..2ecce457a 100644 --- a/osal/rtems/MultiObjectTask.h +++ b/osal/rtems/PeriodicTask.h @@ -1,10 +1,10 @@ -#ifndef FSFW_OSAL_RTEMS_MULTIOBJECTTASK_H_ -#define FSFW_OSAL_RTEMS_MULTIOBJECTTASK_H_ +#ifndef FSFW_OSAL_RTEMS_PERIODICTASK_H_ +#define FSFW_OSAL_RTEMS_PERIODICTASK_H_ +#include "RTEMSTaskBase.h" #include "../../objectmanager/ObjectManagerIF.h" #include "../../tasks/PeriodicTaskIF.h" -#include "TaskBase.h" #include class ExecutableObjectIF; @@ -18,7 +18,7 @@ class ExecutableObjectIF; * @author baetz * @ingroup task_handling */ -class MultiObjectTask: public TaskBase, public PeriodicTaskIF { +class PeriodicTask: public RTEMSTaskBase, public PeriodicTaskIF { public: /** * @brief Standard constructor of the class. @@ -35,13 +35,13 @@ public: * @param setDeadlineMissedFunc The function pointer to the deadline missed function * that shall be assigned. */ - MultiObjectTask(const char *name, rtems_task_priority setPriority, size_t setStack, rtems_interval setPeriod, - void (*setDeadlineMissedFunc)()); + PeriodicTask(const char *name, rtems_task_priority setPriority, size_t setStack, + rtems_interval setPeriod, void (*setDeadlineMissedFunc)()); /** * @brief Currently, the executed object's lifetime is not coupled with the task object's * lifetime, so the destructor is empty. */ - virtual ~MultiObjectTask(void); + virtual ~PeriodicTask(void); /** * @brief The method to start the task. @@ -76,7 +76,7 @@ protected: /** * @brief id of the associated OS period */ - rtems_id periodId; + rtems_id periodId = 0; /** * @brief The pointer to the deadline-missed function. * @details This pointer stores the function that is executed if the task's deadline is missed. @@ -104,4 +104,4 @@ protected: void taskFunctionality(void); }; -#endif /* FSFW_OSAL_RTEMS_MULTIOBJECTTASK_H_ */ +#endif /* FSFW_OSAL_RTEMS_PERIODICTASK_H_ */ diff --git a/osal/rtems/PollingTask.cpp b/osal/rtems/PollingTask.cpp index 0ebf63e2e..3c9a994ca 100644 --- a/osal/rtems/PollingTask.cpp +++ b/osal/rtems/PollingTask.cpp @@ -20,7 +20,7 @@ uint32_t PollingTask::deadlineMissedCount = 0; PollingTask::PollingTask(const char *name, rtems_task_priority setPriority, size_t setStack, uint32_t setOverallPeriod, void (*setDeadlineMissedFunc)()) : - TaskBase(setPriority, setStack, name), periodId(0), pst( + RTEMSTaskBase(setPriority, setStack, name), periodId(0), pst( setOverallPeriod) { // All additional attributes are applied to the object. this->deadlineMissedFunc = setDeadlineMissedFunc; @@ -104,7 +104,7 @@ void PollingTask::taskFunctionality() { //The start time for the first entry is read. rtems_interval interval = RtemsBasic::convertMsToTicks(it->pollingTimeMs); - TaskBase::setAndStartPeriod(interval,&periodId); + RTEMSTaskBase::setAndStartPeriod(interval,&periodId); //The task's "infinite" inner loop is entered. while (1) { if (pst.slotFollowsImmediately()) { @@ -114,7 +114,7 @@ void PollingTask::taskFunctionality() { interval = RtemsBasic::convertMsToTicks(this->pst.getIntervalToNextSlotMs()); //The period is checked and restarted with the new interval. //If the deadline was missed, the deadlineMissedFunc is called. - rtems_status_code status = TaskBase::restartPeriod(interval,periodId); + rtems_status_code status = RTEMSTaskBase::restartPeriod(interval,periodId); if (status == RTEMS_TIMEOUT) { if (this->deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); @@ -127,5 +127,5 @@ void PollingTask::taskFunctionality() { } ReturnValue_t PollingTask::sleepFor(uint32_t ms){ - return TaskBase::sleepFor(ms); + return RTEMSTaskBase::sleepFor(ms); }; diff --git a/osal/rtems/PollingTask.h b/osal/rtems/PollingTask.h index 42deaf09d..8646220d6 100644 --- a/osal/rtems/PollingTask.h +++ b/osal/rtems/PollingTask.h @@ -1,11 +1,11 @@ #ifndef FSFW_OSAL_RTEMS_POLLINGTASK_H_ #define FSFW_OSAL_RTEMS_POLLINGTASK_H_ +#include #include "../../tasks/FixedSlotSequence.h" #include "../../tasks/FixedTimeslotTaskIF.h" -#include "TaskBase.h" -class PollingTask: public TaskBase, public FixedTimeslotTaskIF { +class PollingTask: public RTEMSTaskBase, public FixedTimeslotTaskIF { public: /** * @brief The standard constructor of the class. diff --git a/osal/rtems/TaskBase.cpp b/osal/rtems/RTEMSTaskBase.cpp similarity index 75% rename from osal/rtems/TaskBase.cpp rename to osal/rtems/RTEMSTaskBase.cpp index 7ad94b843..25d6d4981 100644 --- a/osal/rtems/TaskBase.cpp +++ b/osal/rtems/RTEMSTaskBase.cpp @@ -1,9 +1,9 @@ -#include "../../serviceinterface/ServiceInterfaceStream.h" -#include "TaskBase.h" +#include +#include "../../serviceinterface/ServiceInterface.h" -const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE=RTEMS_MINIMUM_STACK_SIZE; +const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = RTEMS_MINIMUM_STACK_SIZE; -TaskBase::TaskBase(rtems_task_priority set_priority, size_t stack_size, +RTEMSTaskBase::RTEMSTaskBase(rtems_task_priority set_priority, size_t stack_size, const char *name) { rtems_name osalName = 0; for (uint8_t i = 0; i < 4; i++) { @@ -31,21 +31,21 @@ TaskBase::TaskBase(rtems_task_priority set_priority, size_t stack_size, } } -TaskBase::~TaskBase() { +RTEMSTaskBase::~RTEMSTaskBase() { rtems_task_delete(id); } -rtems_id TaskBase::getId() { +rtems_id RTEMSTaskBase::getId() { return this->id; } -ReturnValue_t TaskBase::sleepFor(uint32_t ms) { +ReturnValue_t RTEMSTaskBase::sleepFor(uint32_t ms) { rtems_status_code status = rtems_task_wake_after(RtemsBasic::convertMsToTicks(ms)); return convertReturnCode(status); } -ReturnValue_t TaskBase::convertReturnCode(rtems_status_code inValue) { +ReturnValue_t RTEMSTaskBase::convertReturnCode(rtems_status_code inValue) { switch (inValue) { case RTEMS_SUCCESSFUL: return HasReturnvaluesIF::RETURN_OK; @@ -68,7 +68,7 @@ ReturnValue_t TaskBase::convertReturnCode(rtems_status_code inValue) { } -ReturnValue_t TaskBase::setAndStartPeriod(rtems_interval period, rtems_id *periodId) { +ReturnValue_t RTEMSTaskBase::setAndStartPeriod(rtems_interval period, rtems_id *periodId) { rtems_name periodName = (('P' << 24) + ('e' << 16) + ('r' << 8) + 'd'); rtems_status_code status = rtems_rate_monotonic_create(periodName, periodId); if (status == RTEMS_SUCCESSFUL) { @@ -77,7 +77,7 @@ ReturnValue_t TaskBase::setAndStartPeriod(rtems_interval period, rtems_id *perio return convertReturnCode(status); } -rtems_status_code TaskBase::restartPeriod(rtems_interval period, rtems_id periodId){ +rtems_status_code RTEMSTaskBase::restartPeriod(rtems_interval period, rtems_id periodId){ //This is necessary to avoid a call with period = 0, which does not start the period. rtems_status_code status = rtems_rate_monotonic_period(periodId, period + 1); return status; diff --git a/osal/rtems/TaskBase.h b/osal/rtems/RTEMSTaskBase.h similarity index 84% rename from osal/rtems/TaskBase.h rename to osal/rtems/RTEMSTaskBase.h index 0e186e671..0b8be3e90 100644 --- a/osal/rtems/TaskBase.h +++ b/osal/rtems/RTEMSTaskBase.h @@ -1,5 +1,5 @@ -#ifndef FSFW_OSAL_RTEMS_TASKBASE_H_ -#define FSFW_OSAL_RTEMS_TASKBASE_H_ +#ifndef FSFW_OSAL_RTEMS_RTEMSTASKBASE_H_ +#define FSFW_OSAL_RTEMS_RTEMSTASKBASE_H_ #include "RtemsBasic.h" #include "../../tasks/PeriodicTaskIF.h" @@ -9,7 +9,7 @@ * * @details Task creation base class for rtems. */ -class TaskBase { +class RTEMSTaskBase { protected: /** * @brief The class stores the task id it got assigned from the operating system in this attribute. @@ -26,11 +26,11 @@ public: * @param stack_size The stack size reserved by the operating system for the task. * @param nam The name of the Task, as a null-terminated String. Currently max 4 chars supported (excluding Null-terminator), rest will be truncated */ - TaskBase( rtems_task_priority priority, size_t stack_size, const char *name); + RTEMSTaskBase( rtems_task_priority priority, size_t stack_size, const char *name); /** * @brief In the destructor, the created task is deleted. */ - virtual ~TaskBase(); + virtual ~RTEMSTaskBase(); /** * @brief This method returns the task id of this class. */ @@ -44,4 +44,4 @@ private: }; -#endif /* FSFW_OSAL_RTEMS_TASKBASE_H_ */ +#endif /* FSFW_OSAL_RTEMS_RTEMSTASKBASE_H_ */ diff --git a/osal/rtems/RtemsBasic.cpp b/osal/rtems/RtemsBasic.cpp index 17cb3458b..8ab0ddcd6 100644 --- a/osal/rtems/RtemsBasic.cpp +++ b/osal/rtems/RtemsBasic.cpp @@ -1,5 +1,6 @@ #include "RtemsBasic.h" +// TODO: Can this be removed? //ReturnValue_t RtemsBasic::convertReturnCode(rtems_status_code inValue) { // if (inValue == RTEMS_SUCCESSFUL) { diff --git a/osal/rtems/RtemsBasic.h b/osal/rtems/RtemsBasic.h index d0ca5abab..73f23186e 100644 --- a/osal/rtems/RtemsBasic.h +++ b/osal/rtems/RtemsBasic.h @@ -2,12 +2,13 @@ #define FSFW_OSAL_RTEMS_RTEMSBASIC_H_ #include "../../returnvalues/HasReturnvaluesIF.h" + #include #include #include #include -#include +#include class RtemsBasic { public: diff --git a/osal/rtems/TaskFactory.cpp b/osal/rtems/TaskFactory.cpp index bab48a44e..702ef8947 100644 --- a/osal/rtems/TaskFactory.cpp +++ b/osal/rtems/TaskFactory.cpp @@ -1,5 +1,5 @@ +#include #include "../../tasks/TaskFactory.h" -#include "MultiObjectTask.h" #include "PollingTask.h" #include "InitTask.h" #include "RtemsBasic.h" @@ -18,7 +18,7 @@ TaskFactory* TaskFactory::instance() { PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_,TaskPriority taskPriority_,TaskStackSize stackSize_,TaskPeriod periodInSeconds_,TaskDeadlineMissedFunction deadLineMissedFunction_) { rtems_interval taskPeriod = periodInSeconds_ * Clock::getTicksPerSecond(); - return static_cast(new MultiObjectTask(name_,taskPriority_,stackSize_,taskPeriod,deadLineMissedFunction_)); + return static_cast(new PeriodicTask(name_,taskPriority_,stackSize_,taskPeriod,deadLineMissedFunction_)); } FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(TaskName name_,TaskPriority taskPriority_,TaskStackSize stackSize_,TaskPeriod periodInSeconds_,TaskDeadlineMissedFunction deadLineMissedFunction_) { From 4136420685b28ea164b64eb843d3ff17599bc9d6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 11:42:24 +0100 Subject: [PATCH 06/19] additional common includes --- datapoollocal/StaticLocalDataSet.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/datapoollocal/StaticLocalDataSet.h b/datapoollocal/StaticLocalDataSet.h index 4d1cc6378..08ef6de6a 100644 --- a/datapoollocal/StaticLocalDataSet.h +++ b/datapoollocal/StaticLocalDataSet.h @@ -2,6 +2,9 @@ #define FSFW_DATAPOOLLOCAL_STATICLOCALDATASET_H_ #include "LocalPoolDataSetBase.h" +#include "LocalPoolVariable.h" +#include "LocalPoolVector.h" + #include "../objectmanager/SystemObjectIF.h" #include From 686ae101eeb3a780aa05408e7192596a8e349e23 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 11:51:39 +0100 Subject: [PATCH 07/19] added enum type specification --- objectmanager/frameworkObjects.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/objectmanager/frameworkObjects.h b/objectmanager/frameworkObjects.h index 9810e33b9..a138b07ea 100644 --- a/objectmanager/frameworkObjects.h +++ b/objectmanager/frameworkObjects.h @@ -1,8 +1,10 @@ #ifndef FSFW_OBJECTMANAGER_FRAMEWORKOBJECTS_H_ #define FSFW_OBJECTMANAGER_FRAMEWORKOBJECTS_H_ +#include + namespace objects { -enum framework_objects { +enum framework_objects: object_id_t { FSFW_OBJECTS_START = 0x53000000, // Default verification reporter. PUS_SERVICE_1_VERIFICATION = 0x53000001, From f40cdcf472fa49647fc26e405debf204153a14bb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 13:36:18 +0100 Subject: [PATCH 08/19] DHB adaptiosn and improvements, Srv8 update service 8 does not finish immediately for data replies now --- devicehandlers/DeviceHandlerBase.cpp | 38 +++++++++++++--------------- devicehandlers/DeviceHandlerBase.h | 36 ++++++++++++++++---------- pus/Service8FunctionManagement.cpp | 1 + 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 6092a89f8..ed5c8bda4 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -1202,41 +1202,47 @@ ReturnValue_t DeviceHandlerBase::letChildHandleMessage( return RETURN_FAILED; } -void DeviceHandlerBase::handleDeviceTM(SerializeIF* data, - DeviceCommandId_t replyId, bool neverInDataPool, bool forceDirectTm) { +void DeviceHandlerBase::handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId, + bool forceDirectTm = false) { + if(dataSet == nullptr) { + return; + } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); if (iter == deviceReplyMap.end()) { triggerEvent(DEVICE_UNKNOWN_REPLY, replyId); return; } - DeviceTmReportingWrapper wrapper(getObjectId(), replyId, data); - //replies to a command + + /* Regular replies to a command */ if (iter->second.command != deviceCommandMap.end()) { MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; if (queueId != NO_COMMANDER) { - //This may fail, but we'll ignore the fault. - actionHelper.reportData(queueId, replyId, data); + /* This may fail, but we'll ignore the fault. */ + actionHelper.reportData(queueId, replyId, dataSet); } //This check should make sure we get any TM but don't get anything doubled. if (wiretappingMode == TM && (requestedRawTraffic != queueId)) { + DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet); actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); } + else if (forceDirectTm and (defaultRawReceiver != queueId) and - (defaultRawReceiver != MessageQueueIF::NO_QUEUE)) + (defaultRawReceiver != MessageQueueIF::NO_QUEUE)) { // hiding of sender needed so the service will handle it as // unexpected Data, no matter what state (progress or completed) // it is in - actionHelper.reportData(defaultRawReceiver, replyId, &wrapper, - true); + actionHelper.reportData(defaultRawReceiver, replyId, dataSet, true); } } - //unrequested/aperiodic replies + /* Unrequested or aperiodic replies */ else { + DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet); if (wiretappingMode == TM) { actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); } @@ -1246,17 +1252,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data, // hiding of sender needed so the service will handle it as // unexpected Data, no matter what state (progress or completed) // it is in - actionHelper.reportData(defaultRawReceiver, replyId, &wrapper, - true); - } - } - //Try to cast to GlobDataSet and commit data. - if (not neverInDataPool) { - LocalPoolDataSetBase* dataSet = - dynamic_cast(data); - if (dataSet != nullptr) { - dataSet->setValidity(true, true); - dataSet->commit(); + actionHelper.reportData(defaultRawReceiver, replyId, &wrapper, true); } } } diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 3a993aff0..52ec665fe 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -288,23 +288,29 @@ protected: virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) = 0; /** - * @brief Build a device command packet from data supplied by a - * direct command. - * + * @brief Build a device command packet from data supplied by a direct + * command (PUS Service 8) * @details - * #rawPacket and #rawPacketLen should be set by this method to the packet - * to be sent. The existence of the command in the command map and the - * command size check against 0 are done by the base class. + * This will be called if an functional command via PUS Service 8 is received and is + * the primary interface for functional command instead of #executeAction for users. The + * supplied ActionId_t action ID will be converted to a DeviceCommandId_t command ID after + * an internal check whether the action ID is a key in the device command map. * - * @param deviceCommand the command to build, already checked against - * deviceCommandMap - * @param commandData pointer to the data from the direct command - * @param commandDataLen length of commandData + * #rawPacket and #rawPacketLen should be set by this method to the packet to be sent. + * The existence of the command in the command map and the command size check against 0 are + * done by the base class. + * + * @param deviceCommand The command to build, already checked against deviceCommandMap + * @param commandData Pointer to the data from the direct command + * @param commandDataLen Length of commandData * @return * - @c RETURN_OK to send command after #rawPacket and #rawPacketLen * have been set. - * - Anything else triggers an event with the - * returnvalue as a parameter + * - @c HasActionsIF::EXECUTION_COMPLETE to generate a finish reply immediately. This can + * be used if no reply is expected. Otherwise, the developer can call #actionHelper.finish + * to finish the command handling. + * - Anything else triggers an event with the return code as a parameter as well as a + * step reply failed with the return code */ virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t * commandData, size_t commandDataLen) = 0; @@ -995,8 +1001,10 @@ protected: bool isAwaitingReply(); - void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t commandId, - bool neverInDataPool = false, bool forceDirectTm = false); + void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId, + bool forceDirectTm = false); + void handleDeviceTM(uint8_t* data, size_t dataSize, DeviceCommandId_t replyId, + bool forceDirectTm); virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode); diff --git a/pus/Service8FunctionManagement.cpp b/pus/Service8FunctionManagement.cpp index 49fa6ebe4..e389b0b9e 100644 --- a/pus/Service8FunctionManagement.cpp +++ b/pus/Service8FunctionManagement.cpp @@ -104,6 +104,7 @@ ReturnValue_t Service8FunctionManagement::handleReply( break; } case ActionMessage::DATA_REPLY: { + *isStep = true; result = handleDataReply(reply, objectId, actionId); break; } From 303679381436b1e5f5df41cc594001e99ca0e26d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 14:18:51 +0100 Subject: [PATCH 09/19] fsfw update --- action/ActionHelper.cpp | 2 +- action/ActionHelper.h | 2 +- devicehandlers/DeviceHandlerBase.cpp | 21 ++++++-- devicehandlers/DeviceHandlerBase.h | 78 +++++++++++++++------------- pus/Service8FunctionManagement.cpp | 3 +- 5 files changed, 62 insertions(+), 44 deletions(-) diff --git a/action/ActionHelper.cpp b/action/ActionHelper.cpp index 285579160..705b692bb 100644 --- a/action/ActionHelper.cpp +++ b/action/ActionHelper.cpp @@ -155,7 +155,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, result = queueToUse->sendMessage(reportTo, &reply); } - if (result != HasReturnvaluesIF::RETURN_OK){ + if (result != HasReturnvaluesIF::RETURN_OK) { ipcStore->deleteData(storeAddress); } return result; diff --git a/action/ActionHelper.h b/action/ActionHelper.h index a91722f39..d379e7161 100644 --- a/action/ActionHelper.h +++ b/action/ActionHelper.h @@ -99,7 +99,7 @@ public: */ void setQueueToUse(MessageQueueIF *queue); protected: - //!< Increase of value of this per step + //! Increase of value of this per step static const uint8_t STEP_OFFSET = 1; HasActionsIF* owner;//!< Pointer to the owner //! Queue to be used as response sender, has to be set in ctor or with diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index ed5c8bda4..ed5c1fa75 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -1203,7 +1203,7 @@ ReturnValue_t DeviceHandlerBase::letChildHandleMessage( } void DeviceHandlerBase::handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId, - bool forceDirectTm = false) { + bool forceDirectTm) { if(dataSet == nullptr) { return; } @@ -1224,7 +1224,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t r actionHelper.reportData(queueId, replyId, dataSet); } - //This check should make sure we get any TM but don't get anything doubled. + /* This check should make sure we get any TM but don't get anything doubled. */ if (wiretappingMode == TM && (requestedRawTraffic != queueId)) { DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet); actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); @@ -1246,9 +1246,14 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t r if (wiretappingMode == TM) { actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); } - else if (forceDirectTm and defaultRawReceiver != - MessageQueueIF::NO_QUEUE) + if (forceDirectTm and defaultRawReceiver != MessageQueueIF::NO_QUEUE) { +// sid_t setSid = sid_t(this->getObjectId(), replyId); +// LocalPoolDataSetBase* dataset = getDataSetHandle(setSid); +// if(dataset != nullptr) { +// poolManager.generateHousekeepingPacket(setSid, dataset, true); +// } + // hiding of sender needed so the service will handle it as // unexpected Data, no matter what state (progress or completed) // it is in @@ -1527,3 +1532,11 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, LocalDataPoolManager* DeviceHandlerBase::getHkManagerHandle() { return &poolManager; } + +MessageQueueId_t DeviceHandlerBase::getCommanderId(DeviceCommandId_t replyId) const { + auto commandIter = deviceCommandMap.find(replyId); + if(commandIter == deviceCommandMap.end()) { + return MessageQueueIF::NO_QUEUE; + } + return commandIter->second.sendReplyTo; +} diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 52ec665fe..92dc9201a 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -189,6 +189,38 @@ public: /** Destructor. */ virtual ~DeviceHandlerBase(); + + /** + * Implementation of ExecutableObjectIF function + * Used to setup the reference of the task, that executes this component + * @param task_ Pointer to the taskIF of this task + */ + virtual void setTaskIF(PeriodicTaskIF* task_) override; + virtual MessageQueueId_t getCommandQueue(void) const override; + + /** Explicit interface implementation of getObjectId */ + virtual object_id_t getObjectId() const override; + + /** + * @param parentQueueId + */ + virtual void setParentQueue(MessageQueueId_t parentQueueId); + + /** @brief Implementation required for HasActionIF */ + ReturnValue_t executeAction(ActionId_t actionId, + MessageQueueId_t commandedBy, const uint8_t* data, + size_t size) override; + + Mode_t getTransitionSourceMode() const; + Submode_t getTransitionSourceSubMode() const; + virtual void getMode(Mode_t *mode, Submode_t *submode); + HealthState getHealth(); + ReturnValue_t setHealth(HealthState health); + virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId, + ParameterWrapper *parameterWrapper, + const ParameterWrapper *newValues, uint16_t startAtIndex) override; + + protected: /** * @brief This is used to let the child class handle the transition from @@ -535,37 +567,6 @@ protected: */ virtual void performOperationHook(); -public: - /** Explicit interface implementation of getObjectId */ - virtual object_id_t getObjectId() const override; - - /** - * @param parentQueueId - */ - virtual void setParentQueue(MessageQueueId_t parentQueueId); - - /** @brief Implementation required for HasActionIF */ - ReturnValue_t executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, - size_t size) override; - - Mode_t getTransitionSourceMode() const; - Submode_t getTransitionSourceSubMode() const; - virtual void getMode(Mode_t *mode, Submode_t *submode); - HealthState getHealth(); - ReturnValue_t setHealth(HealthState health); - virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId, - ParameterWrapper *parameterWrapper, - const ParameterWrapper *newValues, uint16_t startAtIndex) override; - /** - * Implementation of ExecutableObjectIF function - * - * Used to setup the reference of the task, that executes this component - * @param task_ Pointer to the taskIF of this task - */ - virtual void setTaskIF(PeriodicTaskIF* task_); - virtual MessageQueueId_t getCommandQueue(void) const; - protected: /** * The Returnvalues id of this class, required by HasReturnvaluesIF @@ -573,16 +574,16 @@ protected: static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE; static const ReturnValue_t INVALID_CHANNEL = MAKE_RETURN_CODE(0xA0); - // Returnvalues for scanForReply() + /* Return codes for scanForReply */ static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(0xB0); //!< This is used to specify for replies from a device which are not replies to requests static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(0xB1); //!< Ignore parts of the received packet static const ReturnValue_t IGNORE_FULL_PACKET = MAKE_RETURN_CODE(0xB2); //!< Ignore full received packet - // Returnvalues for command building + /* Return codes for command building */ static const ReturnValue_t NOTHING_TO_SEND = MAKE_RETURN_CODE(0xC0); //!< Return this if no command sending in required static const ReturnValue_t COMMAND_MAP_ERROR = MAKE_RETURN_CODE(0xC2); - // Returnvalues for getSwitches() + // Return codes for getSwitches */ static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(0xD0); - // Mode handling error Codes + /* Mode handling error Codes */ static const ReturnValue_t CHILD_TIMEOUT = MAKE_RETURN_CODE(0xE0); static const ReturnValue_t SWITCH_FAILED = MAKE_RETURN_CODE(0xE1); @@ -769,6 +770,8 @@ protected: */ virtual void setNormalDatapoolEntriesInvalid(); + MessageQueueId_t getCommanderId(DeviceCommandId_t replyId) const; + /** * Helper function to get pending command. This is useful for devices * like SPI sensors to identify the last sent command. @@ -1003,8 +1006,8 @@ protected: void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false); - void handleDeviceTM(uint8_t* data, size_t dataSize, DeviceCommandId_t replyId, - bool forceDirectTm); +// void handleDeviceTM(uint8_t* data, size_t dataSize, DeviceCommandId_t replyId, +// bool forceDirectTm); virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode); @@ -1070,6 +1073,7 @@ protected: * @param onOff on == @c SWITCH_ON; off != @c SWITCH_ON */ void commandSwitch(ReturnValue_t onOff); + private: /** diff --git a/pus/Service8FunctionManagement.cpp b/pus/Service8FunctionManagement.cpp index e389b0b9e..a2202abc1 100644 --- a/pus/Service8FunctionManagement.cpp +++ b/pus/Service8FunctionManagement.cpp @@ -104,13 +104,14 @@ ReturnValue_t Service8FunctionManagement::handleReply( break; } case ActionMessage::DATA_REPLY: { + /* Multiple data replies are possible, so declare data reply as step */ *isStep = true; result = handleDataReply(reply, objectId, actionId); break; } case ActionMessage::STEP_FAILED: *isStep = true; - /*No break, falls through*/ + /* No break, falls through */ case ActionMessage::COMPLETION_FAILED: result = ActionMessage::getReturnCode(reply); break; From 942ecc89bd92e5e4bbfa61a441cad71bbd7f37fe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 18:03:56 +0100 Subject: [PATCH 10/19] include updates --- monitoring/MonitoringMessageContent.h | 2 +- osal/rtems/PollingTask.cpp | 14 ++++++++++---- timemanager/Stopwatch.cpp | 3 +++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/monitoring/MonitoringMessageContent.h b/monitoring/MonitoringMessageContent.h index d830e3136..0314d7edc 100644 --- a/monitoring/MonitoringMessageContent.h +++ b/monitoring/MonitoringMessageContent.h @@ -10,7 +10,7 @@ #include "../serialize/SerialFixedArrayListAdapter.h" #include "../serialize/SerializeElement.h" #include "../serialize/SerialLinkedListAdapter.h" -#include "../serviceinterface/ServiceInterfaceStream.h" +#include "../serviceinterface/ServiceInterface.h" #include "../timemanager/TimeStamperIF.h" namespace Factory{ diff --git a/osal/rtems/PollingTask.cpp b/osal/rtems/PollingTask.cpp index 3c9a994ca..8cfec942d 100644 --- a/osal/rtems/PollingTask.cpp +++ b/osal/rtems/PollingTask.cpp @@ -1,18 +1,24 @@ +#include "PollingTask.h" +#include "RtemsBasic.h" + #include "../../tasks/FixedSequenceSlot.h" #include "../../objectmanager/SystemObjectIF.h" #include "../../objectmanager/ObjectManagerIF.h" -#include "PollingTask.h" -#include "RtemsBasic.h" #include "../../returnvalues/HasReturnvaluesIF.h" -#include "../../serviceinterface/ServiceInterfaceStream.h" +#include "../../serviceinterface/ServiceInterface.h" + #include #include #include #include #include -#include #include + +#if FSFW_CPP_OSTREAM_ENABLED == 1 #include +#endif + +#include #include uint32_t PollingTask::deadlineMissedCount = 0; diff --git a/timemanager/Stopwatch.cpp b/timemanager/Stopwatch.cpp index 5d67e6c1f..04ccab726 100644 --- a/timemanager/Stopwatch.cpp +++ b/timemanager/Stopwatch.cpp @@ -1,6 +1,9 @@ #include "Stopwatch.h" #include "../serviceinterface/ServiceInterface.h" + +#if FSFW_CPP_OSTREAM_ENABLED == 1 #include +#endif Stopwatch::Stopwatch(bool displayOnDestruction, StopwatchDisplayMode displayMode): displayOnDestruction( From 8a0431c5784145be98b4751331882711f437a04b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 18:12:12 +0100 Subject: [PATCH 11/19] renaming and cleaning up stuff --- ...{PollingTask.cpp => FixedTimeslotTask.cpp} | 41 ++++----- osal/rtems/FixedTimeslotTask.h | 81 ++++++++++++++++++ osal/rtems/MutexFactory.cpp | 5 +- osal/rtems/PollingTask.h | 85 ------------------- osal/rtems/RTEMSTaskBase.cpp | 2 +- osal/rtems/TaskFactory.cpp | 21 +++-- 6 files changed, 120 insertions(+), 115 deletions(-) rename osal/rtems/{PollingTask.cpp => FixedTimeslotTask.cpp} (73%) create mode 100644 osal/rtems/FixedTimeslotTask.h delete mode 100644 osal/rtems/PollingTask.h diff --git a/osal/rtems/PollingTask.cpp b/osal/rtems/FixedTimeslotTask.cpp similarity index 73% rename from osal/rtems/PollingTask.cpp rename to osal/rtems/FixedTimeslotTask.cpp index 8cfec942d..d31011626 100644 --- a/osal/rtems/PollingTask.cpp +++ b/osal/rtems/FixedTimeslotTask.cpp @@ -1,4 +1,4 @@ -#include "PollingTask.h" +#include #include "RtemsBasic.h" #include "../../tasks/FixedSequenceSlot.h" @@ -21,9 +21,9 @@ #include #include -uint32_t PollingTask::deadlineMissedCount = 0; +uint32_t FixedTimeslotTask::deadlineMissedCount = 0; -PollingTask::PollingTask(const char *name, rtems_task_priority setPriority, +FixedTimeslotTask::FixedTimeslotTask(const char *name, rtems_task_priority setPriority, size_t setStack, uint32_t setOverallPeriod, void (*setDeadlineMissedFunc)()) : RTEMSTaskBase(setPriority, setStack, name), periodId(0), pst( @@ -32,33 +32,34 @@ PollingTask::PollingTask(const char *name, rtems_task_priority setPriority, this->deadlineMissedFunc = setDeadlineMissedFunc; } -PollingTask::~PollingTask() { +FixedTimeslotTask::~FixedTimeslotTask() { } -rtems_task PollingTask::taskEntryPoint(rtems_task_argument argument) { +rtems_task FixedTimeslotTask::taskEntryPoint(rtems_task_argument argument) { //The argument is re-interpreted as PollingTask. - PollingTask *originalTask(reinterpret_cast(argument)); + FixedTimeslotTask *originalTask(reinterpret_cast(argument)); //The task's functionality is called. - originalTask->taskFunctionality(); + return originalTask->taskFunctionality(); + /* Should never be reached */ #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Polling task " << originalTask->getId() - << " returned from taskFunctionality." << std::endl; + sif::error << "Polling task " << originalTask->getId() << " returned from taskFunctionality." << + std::endl; #endif } -void PollingTask::missedDeadlineCounter() { - PollingTask::deadlineMissedCount++; - if (PollingTask::deadlineMissedCount % 10 == 0) { +void FixedTimeslotTask::missedDeadlineCounter() { + FixedTimeslotTask::deadlineMissedCount++; + if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PST missed " << PollingTask::deadlineMissedCount + sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount << " deadlines." << std::endl; #endif } } -ReturnValue_t PollingTask::startTask() { - rtems_status_code status = rtems_task_start(id, PollingTask::taskEntryPoint, +ReturnValue_t FixedTimeslotTask::startTask() { + rtems_status_code status = rtems_task_start(id, FixedTimeslotTask::taskEntryPoint, rtems_task_argument((void *) this)); if (status != RTEMS_SUCCESSFUL) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -79,7 +80,7 @@ ReturnValue_t PollingTask::startTask() { } } -ReturnValue_t PollingTask::addSlot(object_id_t componentId, +ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep) { ExecutableObjectIF* object = objectManager->get(componentId); if (object != nullptr) { @@ -94,17 +95,17 @@ ReturnValue_t PollingTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_FAILED; } -uint32_t PollingTask::getPeriodMs() const { +uint32_t FixedTimeslotTask::getPeriodMs() const { return pst.getLengthMs(); } -ReturnValue_t PollingTask::checkSequence() const { +ReturnValue_t FixedTimeslotTask::checkSequence() const { return pst.checkSequence(); } #include -void PollingTask::taskFunctionality() { +void FixedTimeslotTask::taskFunctionality() { // A local iterator for the Polling Sequence Table is created to find the start time for the first entry. FixedSlotSequence::SlotListIter it = pst.current; @@ -132,6 +133,6 @@ void PollingTask::taskFunctionality() { } } -ReturnValue_t PollingTask::sleepFor(uint32_t ms){ +ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms){ return RTEMSTaskBase::sleepFor(ms); }; diff --git a/osal/rtems/FixedTimeslotTask.h b/osal/rtems/FixedTimeslotTask.h new file mode 100644 index 000000000..55f780883 --- /dev/null +++ b/osal/rtems/FixedTimeslotTask.h @@ -0,0 +1,81 @@ +#ifndef FSFW_OSAL_RTEMS_FIXEDTIMESLOTTASK_H_ +#define FSFW_OSAL_RTEMS_FIXEDTIMESLOTTASK_H_ + +#include "RTEMSTaskBase.h" +#include "../../tasks/FixedSlotSequence.h" +#include "../../tasks/FixedTimeslotTaskIF.h" + +class FixedTimeslotTask: public RTEMSTaskBase, public FixedTimeslotTaskIF { +public: + /** + * @brief The standard constructor of the class. + * @details + * This is the general constructor of the class. In addition to the TaskBase parameters, + * the following variables are passed: + * @param setDeadlineMissedFunc The function pointer to the deadline missed function + * that shall be assigned. + * @param getPst The object id of the completely initialized polling sequence. + */ + FixedTimeslotTask( const char *name, rtems_task_priority setPriority, size_t setStackSize, + uint32_t overallPeriod, void (*setDeadlineMissedFunc)()); + + /** + * @brief The destructor of the class. + * @details + * The destructor frees all heap memory that was allocated on thread initialization + * for the PST andthe device handlers. This is done by calling the PST's destructor. + */ + virtual ~FixedTimeslotTask( void ); + + ReturnValue_t startTask( void ); + /** + * This static function can be used as #deadlineMissedFunc. + * It counts missedDeadlines and prints the number of missed deadlines every 10th time. + */ + static void missedDeadlineCounter(); + /** + * A helper variable to count missed deadlines. + */ + static uint32_t deadlineMissedCount; + + ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep); + + uint32_t getPeriodMs() const; + + ReturnValue_t checkSequence() const; + + ReturnValue_t sleepFor(uint32_t ms); +protected: + /** + * @brief id of the associated OS period + */ + rtems_id periodId; + + FixedSlotSequence pst; + + /** + * @brief This attribute holds a function pointer that is executed when a deadline was missed. + * + * @details + * Another function may be announced to determine the actions to perform when a deadline + * was missed. Currently, only one function for missing any deadline is allowed. + * If not used, it shall be declared NULL. + */ + void ( *deadlineMissedFunc )( void ) = nullptr; + /** + * @brief This is the entry point in a new polling thread. + * @details This method is the entry point in the new thread + */ + static rtems_task taskEntryPoint( rtems_task_argument argument ); + + /** + * @brief This function holds the main functionality of the thread. + * @details + * Holding the main functionality of the task, this method is most important. + * It links the functionalities provided by FixedSlotSequence with the OS's system calls to + * keep the timing of the periods. + */ + void taskFunctionality( void ); +}; + +#endif /* FSFW_OSAL_RTEMS_FIXEDTIMESLOTTASK_H_ */ diff --git a/osal/rtems/MutexFactory.cpp b/osal/rtems/MutexFactory.cpp index 24af5fa95..adc599e94 100644 --- a/osal/rtems/MutexFactory.cpp +++ b/osal/rtems/MutexFactory.cpp @@ -1,6 +1,7 @@ -#include "../../ipc/MutexFactory.h" #include "Mutex.h" -#include "RtemsBasic.h" + +#include "../../ipc/MutexFactory.h" + MutexFactory* MutexFactory::factoryInstance = new MutexFactory(); diff --git a/osal/rtems/PollingTask.h b/osal/rtems/PollingTask.h deleted file mode 100644 index 8646220d6..000000000 --- a/osal/rtems/PollingTask.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef FSFW_OSAL_RTEMS_POLLINGTASK_H_ -#define FSFW_OSAL_RTEMS_POLLINGTASK_H_ - -#include -#include "../../tasks/FixedSlotSequence.h" -#include "../../tasks/FixedTimeslotTaskIF.h" - -class PollingTask: public RTEMSTaskBase, public FixedTimeslotTaskIF { - public: - /** - * @brief The standard constructor of the class. - * - * @details This is the general constructor of the class. In addition to the TaskBase parameters, - * the following variables are passed: - * - * @param (*setDeadlineMissedFunc)() The function pointer to the deadline missed function that shall be assigned. - * - * @param getPst The object id of the completely initialized polling sequence. - */ - PollingTask( const char *name, rtems_task_priority setPriority, size_t setStackSize, uint32_t overallPeriod, void (*setDeadlineMissedFunc)()); - - /** - * @brief The destructor of the class. - * - * @details The destructor frees all heap memory that was allocated on thread initialization for the PST and - * the device handlers. This is done by calling the PST's destructor. - */ - virtual ~PollingTask( void ); - - ReturnValue_t startTask( void ); - /** - * This static function can be used as #deadlineMissedFunc. - * It counts missedDeadlines and prints the number of missed deadlines every 10th time. - */ - static void missedDeadlineCounter(); - /** - * A helper variable to count missed deadlines. - */ - static uint32_t deadlineMissedCount; - - ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep); - - uint32_t getPeriodMs() const; - - ReturnValue_t checkSequence() const; - - ReturnValue_t sleepFor(uint32_t ms); -protected: - /** - * @brief id of the associated OS period - */ - rtems_id periodId; - - FixedSlotSequence pst; - - /** - * @brief This attribute holds a function pointer that is executed when a deadline was missed. - * - * @details Another function may be announced to determine the actions to perform when a deadline was missed. - * Currently, only one function for missing any deadline is allowed. - * If not used, it shall be declared NULL. - */ - void ( *deadlineMissedFunc )( void ); - /** - * @brief This is the entry point in a new polling thread. - * - * @details This method, that is the generalOSAL::checkAndRestartPeriod( this->periodId, interval ); entry point in the new thread, is here set to generate - * and link the Polling Sequence Table to the thread object and start taskFunctionality() - * on success. If operation of the task is ended for some reason, - * the destructor is called to free allocated memory. - */ - static rtems_task taskEntryPoint( rtems_task_argument argument ); - - /** - * @brief This function holds the main functionality of the thread. - * - * - * @details Holding the main functionality of the task, this method is most important. - * It links the functionalities provided by FixedSlotSequence with the OS's System Calls - * to keep the timing of the periods. - */ - void taskFunctionality( void ); -}; - -#endif /* FSFW_OSAL_RTEMS_POLLINGTASK_H_ */ diff --git a/osal/rtems/RTEMSTaskBase.cpp b/osal/rtems/RTEMSTaskBase.cpp index 25d6d4981..d0cdc8765 100644 --- a/osal/rtems/RTEMSTaskBase.cpp +++ b/osal/rtems/RTEMSTaskBase.cpp @@ -1,4 +1,4 @@ -#include +#include "RTEMSTaskBase.h" #include "../../serviceinterface/ServiceInterface.h" const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = RTEMS_MINIMUM_STACK_SIZE; diff --git a/osal/rtems/TaskFactory.cpp b/osal/rtems/TaskFactory.cpp index 702ef8947..5dad69fe5 100644 --- a/osal/rtems/TaskFactory.cpp +++ b/osal/rtems/TaskFactory.cpp @@ -1,8 +1,9 @@ -#include -#include "../../tasks/TaskFactory.h" -#include "PollingTask.h" +#include "FixedTimeslotTask.h" +#include "PeriodicTask.h" #include "InitTask.h" #include "RtemsBasic.h" + +#include "../../tasks/TaskFactory.h" #include "../../returnvalues/HasReturnvaluesIF.h" //TODO: Different variant than the lazy loading in QueueFactory. What's better and why? @@ -15,15 +16,21 @@ TaskFactory* TaskFactory::instance() { return TaskFactory::factoryInstance; } -PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_,TaskPriority taskPriority_,TaskStackSize stackSize_,TaskPeriod periodInSeconds_,TaskDeadlineMissedFunction deadLineMissedFunction_) { +PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_, TaskPriority taskPriority_, + TaskStackSize stackSize_,TaskPeriod periodInSeconds_, + TaskDeadlineMissedFunction deadLineMissedFunction_) { rtems_interval taskPeriod = periodInSeconds_ * Clock::getTicksPerSecond(); - return static_cast(new PeriodicTask(name_,taskPriority_,stackSize_,taskPeriod,deadLineMissedFunction_)); + return static_cast(new PeriodicTask(name_, taskPriority_, stackSize_, + taskPeriod,deadLineMissedFunction_)); } -FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(TaskName name_,TaskPriority taskPriority_,TaskStackSize stackSize_,TaskPeriod periodInSeconds_,TaskDeadlineMissedFunction deadLineMissedFunction_) { +FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(TaskName name_, + TaskPriority taskPriority_,TaskStackSize stackSize_,TaskPeriod periodInSeconds_, + TaskDeadlineMissedFunction deadLineMissedFunction_) { rtems_interval taskPeriod = periodInSeconds_ * Clock::getTicksPerSecond(); - return static_cast(new PollingTask(name_,taskPriority_,stackSize_,taskPeriod,deadLineMissedFunction_)); + return static_cast(new FixedTimeslotTask(name_, taskPriority_, + stackSize_, taskPeriod, deadLineMissedFunction_)); } ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) { From 8b5abd1fd5ef2adc26df285facc369a5ec74ffb5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 18:12:48 +0100 Subject: [PATCH 12/19] corrected cmakelists.txt file --- osal/rtems/CMakeLists.txt | 2 +- osal/rtems/FixedTimeslotTask.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osal/rtems/CMakeLists.txt b/osal/rtems/CMakeLists.txt index ba11a6b5a..cd266125f 100644 --- a/osal/rtems/CMakeLists.txt +++ b/osal/rtems/CMakeLists.txt @@ -8,7 +8,7 @@ target_sources(${LIB_FSFW_NAME} PeriodicTask.cpp Mutex.cpp MutexFactory.cpp - PollingTask.cpp + FixedTimeslotTask.cpp QueueFactory.cpp RtemsBasic.cpp RTEMSTaskBase.cpp diff --git a/osal/rtems/FixedTimeslotTask.cpp b/osal/rtems/FixedTimeslotTask.cpp index d31011626..8b9354254 100644 --- a/osal/rtems/FixedTimeslotTask.cpp +++ b/osal/rtems/FixedTimeslotTask.cpp @@ -1,4 +1,4 @@ -#include +#include "FixedTimeslotTask.h" #include "RtemsBasic.h" #include "../../tasks/FixedSequenceSlot.h" From a0e7b45d9427010ae4c631162af9034239f18040 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 18:15:54 +0100 Subject: [PATCH 13/19] printf support --- osal/rtems/Mutex.cpp | 12 +++++++----- osal/rtems/Mutex.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/osal/rtems/Mutex.cpp b/osal/rtems/Mutex.cpp index 7dd512fae..f65c1f55b 100644 --- a/osal/rtems/Mutex.cpp +++ b/osal/rtems/Mutex.cpp @@ -1,18 +1,20 @@ #include "Mutex.h" -#include "../../serviceinterface/ServiceInterfaceStream.h" +#include "../../serviceinterface/ServiceInterface.h" uint8_t Mutex::count = 0; -Mutex::Mutex() : - mutexId(0) { +Mutex::Mutex() { rtems_name mutexName = ('M' << 24) + ('T' << 16) + ('X' << 8) + count++; rtems_status_code status = rtems_semaphore_create(mutexName, 1, RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY, 0, &mutexId); if (status != RTEMS_SUCCESSFUL) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Mutex: creation with name, id " << mutexName << ", " << mutexId - << " failed with " << status << std::endl; + sif::error << "Mutex::Mutex: Creation with name, id " << mutexName << ", " << mutexId << + " failed with " << status << std::endl; +#else + sif::printError("Mutex::Mutex: Creation with name, id %s, %d failed with %d\n", mutexName, + static_cast(mutexId), static_cast(status)); #endif } } diff --git a/osal/rtems/Mutex.h b/osal/rtems/Mutex.h index 4c8613183..c4917e08a 100644 --- a/osal/rtems/Mutex.h +++ b/osal/rtems/Mutex.h @@ -11,7 +11,7 @@ public: ReturnValue_t lockMutex(TimeoutType timeoutType, uint32_t timeoutMs = 0); ReturnValue_t unlockMutex(); private: - rtems_id mutexId; + rtems_id mutexId = 0; static uint8_t count; }; From 73dcb78a65d0367d4a5ddaaf8ceba379d61a3990 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 20:04:16 +0100 Subject: [PATCH 14/19] additional nullptr checks --- objectmanager/ObjectManager.cpp | 4 +++- objectmanager/SystemObject.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/objectmanager/ObjectManager.cpp b/objectmanager/ObjectManager.cpp index 882d2762a..3c2be5321 100644 --- a/objectmanager/ObjectManager.cpp +++ b/objectmanager/ObjectManager.cpp @@ -1,5 +1,5 @@ #include "ObjectManager.h" -#include "../serviceinterface/ServiceInterfaceStream.h" +#include "../serviceinterface/ServiceInterface.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 #include @@ -75,6 +75,8 @@ void ObjectManager::initialize() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::initialize: Passed produceObjects " "functions is nullptr!" << std::endl; +#else + sif::printError("ObjectManager::initialize: Passed produceObjects functions is nullptr!\n"); #endif return; } diff --git a/objectmanager/SystemObject.cpp b/objectmanager/SystemObject.cpp index 64330fbc9..9040002ca 100644 --- a/objectmanager/SystemObject.cpp +++ b/objectmanager/SystemObject.cpp @@ -5,13 +5,17 @@ SystemObject::SystemObject(object_id_t setObjectId, bool doRegister) : objectId(setObjectId), registered(doRegister) { if (registered) { - objectManager->insert(objectId, this); + if(objectManager != nullptr) { + objectManager->insert(objectId, this); + } } } SystemObject::~SystemObject() { if (registered) { - objectManager->remove(objectId); + if(objectManager != nullptr) { + objectManager->remove(objectId); + } } } From 2fce82db10f277d6a3f357fc1fef24da92ee0e32 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 22:51:50 +0100 Subject: [PATCH 15/19] bugfix for clock --- osal/rtems/Clock.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osal/rtems/Clock.cpp b/osal/rtems/Clock.cpp index 8bd7ac37e..9f4634cca 100644 --- a/osal/rtems/Clock.cpp +++ b/osal/rtems/Clock.cpp @@ -104,9 +104,13 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) { } ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { - // TIsn't this a bug? Are RTEMS ticks always microseconds? + /* For all but the last field, the struct will be filled with the correct values */ rtems_time_of_day* timeRtems = reinterpret_cast(time); rtems_status_code status = rtems_clock_get_tod(timeRtems); + /* The last field now contains the RTEMS ticks of the seconds from 0 + to rtems_clock_get_ticks_per_second() minus one. We calculate the microseconds accordingly */ + timeRtems->ticks = static_cast(timeRtems->ticks) / + rtems_clock_get_ticks_per_second() * 1e6; switch (status) { case RTEMS_SUCCESSFUL: return HasReturnvaluesIF::RETURN_OK; From 3b7bebeb6f25c8d87b9448619db8b3fcb72a9bce Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 23:49:50 +0100 Subject: [PATCH 16/19] added init after task creation --- osal/rtems/PeriodicTask.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osal/rtems/PeriodicTask.cpp b/osal/rtems/PeriodicTask.cpp index 631fa8209..067983cb6 100644 --- a/osal/rtems/PeriodicTask.cpp +++ b/osal/rtems/PeriodicTask.cpp @@ -50,6 +50,9 @@ ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) { void PeriodicTask::taskFunctionality() { RTEMSTaskBase::setAndStartPeriod(periodTicks,&periodId); + for (const auto& object: objectList) { + object->initializeAfterTaskCreation(); + } /* The task's "infinite" inner loop is entered. */ while (1) { for (const auto& object: objectList) { From f85ab2b300d7f605d000223b274db41912d75367 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 23:52:09 +0100 Subject: [PATCH 17/19] emitting warning now --- datapoollocal/LocalDataPoolManager.cpp | 4 ++-- datapoollocal/LocalDataPoolManager.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 16a4aec28..2c5c4e0ea 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -890,7 +890,7 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, << std::dec << std::setfill(' ') << std::endl; #else sif::printWarning("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n", - owner->getObjectId(), errorPrint); + functionName, owner->getObjectId(), errorPrint); #endif } else if(outputType == sif::OutputTypes::OUT_ERROR) { @@ -901,7 +901,7 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, << std::dec << std::setfill(' ') << std::endl; #else sif::printError("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n", - owner->getObjectId(), errorPrint); + functionName, owner->getObjectId(), errorPrint); #endif } } diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index d13dfbc30..05c6adfd6 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -399,14 +399,14 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, PoolEntry **poolEntry) { auto poolIter = localPoolMap.find(localPoolId); if (poolIter == localPoolMap.end()) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "fetchPoolEntry", + printWarningOrError(sif::OutputTypes::OUT_WARNING, "fetchPoolEntry", localpool::POOL_ENTRY_NOT_FOUND); return localpool::POOL_ENTRY_NOT_FOUND; } *poolEntry = dynamic_cast< PoolEntry* >(poolIter->second); if(*poolEntry == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "fetchPoolEntry", + printWarningOrError(sif::OutputTypes::OUT_WARNING, "fetchPoolEntry", localpool::POOL_ENTRY_TYPE_CONFLICT); return localpool::POOL_ENTRY_TYPE_CONFLICT; } From 5b0758638b6a81cd984036e910adaa4b39879961 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 28 Jan 2021 00:00:26 +0100 Subject: [PATCH 18/19] added missing function is fixed timeslot task --- osal/rtems/FixedTimeslotTask.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/osal/rtems/FixedTimeslotTask.cpp b/osal/rtems/FixedTimeslotTask.cpp index 8b9354254..ce8eadcfc 100644 --- a/osal/rtems/FixedTimeslotTask.cpp +++ b/osal/rtems/FixedTimeslotTask.cpp @@ -8,6 +8,7 @@ #include "../../serviceinterface/ServiceInterface.h" #include +#include #include #include #include @@ -103,20 +104,23 @@ ReturnValue_t FixedTimeslotTask::checkSequence() const { return pst.checkSequence(); } -#include - void FixedTimeslotTask::taskFunctionality() { - // A local iterator for the Polling Sequence Table is created to find the start time for the first entry. + /* A local iterator for the Polling Sequence Table is created to find the start time for + the first entry. */ FixedSlotSequence::SlotListIter it = pst.current; - //The start time for the first entry is read. + /* Initialize the PST with the correct calling task */ + pst.intializeSequenceAfterTaskCreation(); + + /* The start time for the first entry is read. */ rtems_interval interval = RtemsBasic::convertMsToTicks(it->pollingTimeMs); RTEMSTaskBase::setAndStartPeriod(interval,&periodId); //The task's "infinite" inner loop is entered. while (1) { if (pst.slotFollowsImmediately()) { //Do nothing - } else { + } + else { //The interval for the next polling slot is selected. interval = RtemsBasic::convertMsToTicks(this->pst.getIntervalToNextSlotMs()); //The period is checked and restarted with the new interval. From dcb569a7c853cf7273a5504fab7f99479a155290 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 28 Jan 2021 00:15:13 +0100 Subject: [PATCH 19/19] indentation --- osal/rtems/FixedTimeslotTask.cpp | 142 +++++++++++++++---------------- osal/rtems/FixedTimeslotTask.h | 116 ++++++++++++------------- 2 files changed, 128 insertions(+), 130 deletions(-) diff --git a/osal/rtems/FixedTimeslotTask.cpp b/osal/rtems/FixedTimeslotTask.cpp index ce8eadcfc..3a3be6b32 100644 --- a/osal/rtems/FixedTimeslotTask.cpp +++ b/osal/rtems/FixedTimeslotTask.cpp @@ -25,118 +25,116 @@ uint32_t FixedTimeslotTask::deadlineMissedCount = 0; FixedTimeslotTask::FixedTimeslotTask(const char *name, rtems_task_priority setPriority, - size_t setStack, uint32_t setOverallPeriod, - void (*setDeadlineMissedFunc)()) : - RTEMSTaskBase(setPriority, setStack, name), periodId(0), pst( - setOverallPeriod) { - // All additional attributes are applied to the object. - this->deadlineMissedFunc = setDeadlineMissedFunc; + size_t setStack, uint32_t setOverallPeriod, void (*setDeadlineMissedFunc)(void)): + RTEMSTaskBase(setPriority, setStack, name), periodId(0), pst(setOverallPeriod) { + // All additional attributes are applied to the object. + this->deadlineMissedFunc = setDeadlineMissedFunc; } FixedTimeslotTask::~FixedTimeslotTask() { } rtems_task FixedTimeslotTask::taskEntryPoint(rtems_task_argument argument) { - - //The argument is re-interpreted as PollingTask. - FixedTimeslotTask *originalTask(reinterpret_cast(argument)); - //The task's functionality is called. - return originalTask->taskFunctionality(); - /* Should never be reached */ + /* The argument is re-interpreted as a FixedTimeslotTask */ + FixedTimeslotTask *originalTask(reinterpret_cast(argument)); + /* The task's functionality is called. */ + return originalTask->taskFunctionality(); + /* Should never be reached */ #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Polling task " << originalTask->getId() << " returned from taskFunctionality." << - std::endl; + sif::error << "Polling task " << originalTask->getId() << " returned from taskFunctionality." << + std::endl; #endif } void FixedTimeslotTask::missedDeadlineCounter() { - FixedTimeslotTask::deadlineMissedCount++; - if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) { + FixedTimeslotTask::deadlineMissedCount++; + if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount - << " deadlines." << std::endl; + sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount + << " deadlines." << std::endl; #endif - } + } } ReturnValue_t FixedTimeslotTask::startTask() { - rtems_status_code status = rtems_task_start(id, FixedTimeslotTask::taskEntryPoint, - rtems_task_argument((void *) this)); - if (status != RTEMS_SUCCESSFUL) { + rtems_status_code status = rtems_task_start(id, FixedTimeslotTask::taskEntryPoint, + rtems_task_argument((void *) this)); + if (status != RTEMS_SUCCESSFUL) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PollingTask::startTask for " << std::hex << this->getId() - << std::dec << " failed." << std::endl; + sif::error << "PollingTask::startTask for " << std::hex << this->getId() + << std::dec << " failed." << std::endl; #endif - } - switch(status){ - case RTEMS_SUCCESSFUL: - //ask started successfully - return HasReturnvaluesIF::RETURN_OK; - default: -/* RTEMS_INVALID_ADDRESS - invalid task entry point + } + switch(status){ + case RTEMS_SUCCESSFUL: + //ask started successfully + return HasReturnvaluesIF::RETURN_OK; + default: + /* + RTEMS_INVALID_ADDRESS - invalid task entry point RTEMS_INVALID_ID - invalid task id RTEMS_INCORRECT_STATE - task not in the dormant state RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task */ - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; + } } ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, - uint32_t slotTimeMs, int8_t executionStep) { - ExecutableObjectIF* object = objectManager->get(componentId); - if (object != nullptr) { - pst.addSlot(componentId, slotTimeMs, executionStep, object, this); - return HasReturnvaluesIF::RETURN_OK; - } + uint32_t slotTimeMs, int8_t executionStep) { + ExecutableObjectIF* object = objectManager->get(componentId); + if (object != nullptr) { + pst.addSlot(componentId, slotTimeMs, executionStep, object, this); + return HasReturnvaluesIF::RETURN_OK; + } #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Component " << std::hex << componentId << - " not found, not adding it to pst" << std::endl; + sif::error << "Component " << std::hex << componentId << + " not found, not adding it to pst" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_FAILED; } uint32_t FixedTimeslotTask::getPeriodMs() const { - return pst.getLengthMs(); + return pst.getLengthMs(); } ReturnValue_t FixedTimeslotTask::checkSequence() const { - return pst.checkSequence(); + return pst.checkSequence(); } void FixedTimeslotTask::taskFunctionality() { - /* A local iterator for the Polling Sequence Table is created to find the start time for + /* A local iterator for the Polling Sequence Table is created to find the start time for the first entry. */ - FixedSlotSequence::SlotListIter it = pst.current; + FixedSlotSequence::SlotListIter it = pst.current; - /* Initialize the PST with the correct calling task */ - pst.intializeSequenceAfterTaskCreation(); + /* Initialize the PST with the correct calling task */ + pst.intializeSequenceAfterTaskCreation(); - /* The start time for the first entry is read. */ - rtems_interval interval = RtemsBasic::convertMsToTicks(it->pollingTimeMs); - RTEMSTaskBase::setAndStartPeriod(interval,&periodId); - //The task's "infinite" inner loop is entered. - while (1) { - if (pst.slotFollowsImmediately()) { - //Do nothing - } - else { - //The interval for the next polling slot is selected. - interval = RtemsBasic::convertMsToTicks(this->pst.getIntervalToNextSlotMs()); - //The period is checked and restarted with the new interval. - //If the deadline was missed, the deadlineMissedFunc is called. - rtems_status_code status = RTEMSTaskBase::restartPeriod(interval,periodId); - if (status == RTEMS_TIMEOUT) { - if (this->deadlineMissedFunc != nullptr) { - this->deadlineMissedFunc(); - } - } - } - //The device handler for this slot is executed and the next one is chosen. - this->pst.executeAndAdvance(); - } + /* The start time for the first entry is read. */ + rtems_interval interval = RtemsBasic::convertMsToTicks(it->pollingTimeMs); + RTEMSTaskBase::setAndStartPeriod(interval,&periodId); + //The task's "infinite" inner loop is entered. + while (1) { + if (pst.slotFollowsImmediately()) { + /* Do nothing */ + } + else { + /* The interval for the next polling slot is selected. */ + interval = RtemsBasic::convertMsToTicks(this->pst.getIntervalToNextSlotMs()); + /* The period is checked and restarted with the new interval. + If the deadline was missed, the deadlineMissedFunc is called. */ + rtems_status_code status = RTEMSTaskBase::restartPeriod(interval,periodId); + if (status == RTEMS_TIMEOUT) { + if (this->deadlineMissedFunc != nullptr) { + this->deadlineMissedFunc(); + } + } + } + /* The device handler for this slot is executed and the next one is chosen. */ + this->pst.executeAndAdvance(); + } } ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms){ - return RTEMSTaskBase::sleepFor(ms); + return RTEMSTaskBase::sleepFor(ms); }; diff --git a/osal/rtems/FixedTimeslotTask.h b/osal/rtems/FixedTimeslotTask.h index 55f780883..0d78c4748 100644 --- a/osal/rtems/FixedTimeslotTask.h +++ b/osal/rtems/FixedTimeslotTask.h @@ -8,74 +8,74 @@ class FixedTimeslotTask: public RTEMSTaskBase, public FixedTimeslotTaskIF { public: /** - * @brief The standard constructor of the class. - * @details - * This is the general constructor of the class. In addition to the TaskBase parameters, - * the following variables are passed: - * @param setDeadlineMissedFunc The function pointer to the deadline missed function - * that shall be assigned. - * @param getPst The object id of the completely initialized polling sequence. - */ - FixedTimeslotTask( const char *name, rtems_task_priority setPriority, size_t setStackSize, - uint32_t overallPeriod, void (*setDeadlineMissedFunc)()); + * @brief The standard constructor of the class. + * @details + * This is the general constructor of the class. In addition to the TaskBase parameters, + * the following variables are passed: + * @param setDeadlineMissedFunc The function pointer to the deadline missed function + * that shall be assigned. + * @param getPst The object id of the completely initialized polling sequence. + */ + FixedTimeslotTask( const char *name, rtems_task_priority setPriority, size_t setStackSize, + uint32_t overallPeriod, void (*setDeadlineMissedFunc)()); - /** - * @brief The destructor of the class. - * @details - * The destructor frees all heap memory that was allocated on thread initialization - * for the PST andthe device handlers. This is done by calling the PST's destructor. - */ - virtual ~FixedTimeslotTask( void ); + /** + * @brief The destructor of the class. + * @details + * The destructor frees all heap memory that was allocated on thread initialization + * for the PST andthe device handlers. This is done by calling the PST's destructor. + */ + virtual ~FixedTimeslotTask( void ); - ReturnValue_t startTask( void ); - /** - * This static function can be used as #deadlineMissedFunc. - * It counts missedDeadlines and prints the number of missed deadlines every 10th time. - */ - static void missedDeadlineCounter(); - /** - * A helper variable to count missed deadlines. - */ - static uint32_t deadlineMissedCount; + ReturnValue_t startTask( void ); + /** + * This static function can be used as #deadlineMissedFunc. + * It counts missedDeadlines and prints the number of missed deadlines every 10th time. + */ + static void missedDeadlineCounter(); + /** + * A helper variable to count missed deadlines. + */ + static uint32_t deadlineMissedCount; - ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep); + ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep); - uint32_t getPeriodMs() const; + uint32_t getPeriodMs() const; - ReturnValue_t checkSequence() const; + ReturnValue_t checkSequence() const; - ReturnValue_t sleepFor(uint32_t ms); + ReturnValue_t sleepFor(uint32_t ms); protected: - /** - * @brief id of the associated OS period - */ - rtems_id periodId; + /** + * @brief id of the associated OS period + */ + rtems_id periodId; - FixedSlotSequence pst; + FixedSlotSequence pst; - /** - * @brief This attribute holds a function pointer that is executed when a deadline was missed. - * - * @details - * Another function may be announced to determine the actions to perform when a deadline - * was missed. Currently, only one function for missing any deadline is allowed. - * If not used, it shall be declared NULL. - */ - void ( *deadlineMissedFunc )( void ) = nullptr; - /** - * @brief This is the entry point in a new polling thread. - * @details This method is the entry point in the new thread - */ - static rtems_task taskEntryPoint( rtems_task_argument argument ); + /** + * @brief This attribute holds a function pointer that is executed when a deadline was missed. + * + * @details + * Another function may be announced to determine the actions to perform when a deadline + * was missed. Currently, only one function for missing any deadline is allowed. + * If not used, it shall be declared NULL. + */ + void ( *deadlineMissedFunc )( void ) = nullptr; + /** + * @brief This is the entry point in a new polling thread. + * @details This method is the entry point in the new thread + */ + static rtems_task taskEntryPoint( rtems_task_argument argument ); - /** - * @brief This function holds the main functionality of the thread. - * @details - * Holding the main functionality of the task, this method is most important. - * It links the functionalities provided by FixedSlotSequence with the OS's system calls to - * keep the timing of the periods. - */ - void taskFunctionality( void ); + /** + * @brief This function holds the main functionality of the thread. + * @details + * Holding the main functionality of the task, this method is most important. + * It links the functionalities provided by FixedSlotSequence with the OS's system calls to + * keep the timing of the periods. + */ + void taskFunctionality( void ); }; #endif /* FSFW_OSAL_RTEMS_FIXEDTIMESLOTTASK_H_ */