From 5b933dfe3d922e7f60ee0c3109b602a2b8331188 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 5 May 2020 18:28:50 +0200 Subject: [PATCH 1/4] also added additonal time check for freeRTOS --- osal/FreeRTOS/FixedTimeslotTask.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osal/FreeRTOS/FixedTimeslotTask.cpp b/osal/FreeRTOS/FixedTimeslotTask.cpp index 413d7596..e621d312 100644 --- a/osal/FreeRTOS/FixedTimeslotTask.cpp +++ b/osal/FreeRTOS/FixedTimeslotTask.cpp @@ -57,12 +57,18 @@ ReturnValue_t FixedTimeslotTask::startTask() { ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep) { - if (objectManager->get(componentId) != NULL) { + if (objectManager->get(componentId) != nullptr) { + if(slotTimeMs == 0) { + // TODO: FreeRTOS throws errors for zero values. + // maybe there is a better solution than this. + slotTimeMs = 1; + } pst.addSlot(componentId, slotTimeMs, executionStep, this); return HasReturnvaluesIF::RETURN_OK; } - error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::endl; + error << "Component " << std::hex << componentId << + " not found, not adding it to pst" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } From 736a69795dd3aec0cc9441209c04a2acda770f2d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 5 May 2020 18:32:50 +0200 Subject: [PATCH 2/4] change ported to linux and rtems --- osal/linux/FixedTimeslotTask.cpp | 10 ++++++++-- osal/rtems/PollingTask.cpp | 15 ++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/osal/linux/FixedTimeslotTask.cpp b/osal/linux/FixedTimeslotTask.cpp index 99cbf818..29eb37e7 100644 --- a/osal/linux/FixedTimeslotTask.cpp +++ b/osal/linux/FixedTimeslotTask.cpp @@ -40,8 +40,14 @@ uint32_t FixedTimeslotTask::getPeriodMs() const { ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep) { - pst.addSlot(componentId, slotTimeMs, executionStep, this); - return HasReturnvaluesIF::RETURN_OK; + if (objectManager->get(componentId) != nullptr) { + pst.addSlot(componentId, slotTimeMs, executionStep, this); + return HasReturnvaluesIF::RETURN_OK; + } + + error << "Component " << std::hex << componentId << + " not found, not adding it to pst" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } ReturnValue_t FixedTimeslotTask::checkSequence() const { diff --git a/osal/rtems/PollingTask.cpp b/osal/rtems/PollingTask.cpp index c2dc629b..7409a6b8 100644 --- a/osal/rtems/PollingTask.cpp +++ b/osal/rtems/PollingTask.cpp @@ -66,12 +66,17 @@ ReturnValue_t PollingTask::startTask() { } } -ReturnValue_t PollingTask::addSlot(object_id_t componentId, uint32_t slotTimeMs, - int8_t executionStep) { - pst.addSlot(componentId, slotTimeMs, executionStep, this); - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t Polling::addSlot(object_id_t componentId, + uint32_t slotTimeMs, int8_t executionStep) { + if (objectManager->get(componentId) != nullptr) { + pst.addSlot(componentId, slotTimeMs, executionStep, this); + return HasReturnvaluesIF::RETURN_OK; + } + error << "Component " << std::hex << componentId << + " not found, not adding it to pst" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; +} uint32_t PollingTask::getPeriodMs() const { return pst.getLengthMs(); } From f3dca8044e8c4ee7bdd08a3bcd5034beb4e2d2a5 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 5 May 2020 18:34:04 +0200 Subject: [PATCH 3/4] typo --- osal/rtems/PollingTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osal/rtems/PollingTask.cpp b/osal/rtems/PollingTask.cpp index 7409a6b8..4a70a1ed 100644 --- a/osal/rtems/PollingTask.cpp +++ b/osal/rtems/PollingTask.cpp @@ -66,7 +66,7 @@ ReturnValue_t PollingTask::startTask() { } } -ReturnValue_t Polling::addSlot(object_id_t componentId, +ReturnValue_t PollingTask::addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep) { if (objectManager->get(componentId) != nullptr) { pst.addSlot(componentId, slotTimeMs, executionStep, this); From f1a0bb9dc3ece68f16a42eca68218c807efa1bd7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 5 May 2020 18:36:18 +0200 Subject: [PATCH 4/4] whitespace --- osal/rtems/PollingTask.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/osal/rtems/PollingTask.cpp b/osal/rtems/PollingTask.cpp index 4a70a1ed..03ba0951 100644 --- a/osal/rtems/PollingTask.cpp +++ b/osal/rtems/PollingTask.cpp @@ -77,6 +77,7 @@ ReturnValue_t PollingTask::addSlot(object_id_t componentId, " not found, not adding it to pst" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } + uint32_t PollingTask::getPeriodMs() const { return pst.getLengthMs(); }