From f45a8cc17193fb3176a8410bd8b00e4ca351bad9 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 16 Apr 2020 13:17:26 +0200 Subject: [PATCH] fixed slot sequence safety check added --- devicehandlers/FixedSlotSequence.cpp | 11 ++++++++++- devicehandlers/FixedSlotSequence.h | 4 +++- osal/FreeRTOS/FixedTimeslotTask.cpp | 1 - 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/devicehandlers/FixedSlotSequence.cpp b/devicehandlers/FixedSlotSequence.cpp index 23bb0e78a..f11de94b4 100644 --- a/devicehandlers/FixedSlotSequence.cpp +++ b/devicehandlers/FixedSlotSequence.cpp @@ -1,5 +1,6 @@ #include #include +#include FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) : slotLengthMs(setLengthMs) { @@ -87,7 +88,15 @@ uint32_t FixedSlotSequence::getLengthMs() const { } ReturnValue_t FixedSlotSequence::checkSequence() const { - // Iterate through slotList and check successful creation. + if(slotList.empty()) { + error << "Fixed Slot Sequence: Slot list is empty!" << std::endl; + // does check sequence have to be const? + // if I want to check a class, I need the ability to set + // internal class states. + //isEmpty = true; + std::exit(0); + } + // Iterate through slotList and check successful creation. // Checks if timing is ok (must be ascending) and if all handlers were found. auto slotIt = slotList.begin(); uint32_t count = 0; diff --git a/devicehandlers/FixedSlotSequence.h b/devicehandlers/FixedSlotSequence.h index 813d2fce2..cad7ee875 100644 --- a/devicehandlers/FixedSlotSequence.h +++ b/devicehandlers/FixedSlotSequence.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -23,7 +24,6 @@ using SlotListIter = std::multiset::iterator; class FixedSlotSequence { public: - /** * @brief The constructor of the FixedSlotSequence object. * @@ -127,6 +127,8 @@ protected: SlotList slotList; uint32_t slotLengthMs; + + bool isEmpty = false; }; #endif /* FIXEDSLOTSEQUENCE_H_ */ diff --git a/osal/FreeRTOS/FixedTimeslotTask.cpp b/osal/FreeRTOS/FixedTimeslotTask.cpp index b1c974202..db0247a4a 100644 --- a/osal/FreeRTOS/FixedTimeslotTask.cpp +++ b/osal/FreeRTOS/FixedTimeslotTask.cpp @@ -112,7 +112,6 @@ void FixedTimeslotTask::taskFunctionality() { vTaskDelayUntil(&xLastWakeTime, interval); //TODO deadline missed check } - } }