From 3c7ac60dbe2e2e623f6aea1d746418335a2a6dbe Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 22 Jun 2020 20:39:36 +0200 Subject: [PATCH] added overflow checking --- osal/FreeRTOS/FixedTimeslotTask.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/osal/FreeRTOS/FixedTimeslotTask.cpp b/osal/FreeRTOS/FixedTimeslotTask.cpp index edb7f835..d92474c7 100644 --- a/osal/FreeRTOS/FixedTimeslotTask.cpp +++ b/osal/FreeRTOS/FixedTimeslotTask.cpp @@ -111,8 +111,15 @@ void FixedTimeslotTask::taskFunctionality() { /* If all operations are finished and the difference of the * current time minus the last wake time is larger than the - * expected wait period, a deadline was missed. */ - if(xTaskGetTickCount() - xLastWakeTime >= interval) { + * expected wait period, a deadline was missed. + * We also check whether an overflow has occured first. + * In this special case, we will ignore missed deadlines for now. */ + const TickType_t constTickCount = xTaskGetTickCount(); + if(constTickCount < xLastWakeTime or + constTickCount + interval < xLastWakeTime) { + // don't do anything for now. + } + else if(xTaskGetTickCount() - xLastWakeTime >= interval) { #ifdef DEBUG sif::warning << "FixedTimeslotTask: " << pcTaskGetName(NULL) << " missed deadline!\n" << std::flush;