added deadline check

This commit is contained in:
Robin Müller 2020-05-16 13:09:50 +02:00
parent 20900227f8
commit 7d57988979
2 changed files with 19 additions and 5 deletions

View File

@ -1,6 +1,7 @@
#include "PeriodicTask.h"
#include <framework/serviceinterface/ServiceInterfaceStream.h> #include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/tasks/ExecutableObjectIF.h> #include <framework/tasks/ExecutableObjectIF.h>
#include "PeriodicTask.h"
PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority, PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
TaskStackSize setStack, TaskPeriod setPeriod, TaskStackSize setStack, TaskPeriod setPeriod,
@ -31,7 +32,7 @@ void PeriodicTask::taskEntryPoint(void* argument) {
// if it is not set and we get here, the scheduler was started before #startTask() was called and we need to suspend // if it is not set and we get here, the scheduler was started before #startTask() was called and we need to suspend
// if it is set, the scheduler was not running before #startTask() was called and we can continue // if it is set, the scheduler was not running before #startTask() was called and we can continue
if (!originalTask->started) { if (not originalTask->started) {
vTaskSuspend(NULL); vTaskSuspend(NULL);
} }
@ -70,8 +71,19 @@ void PeriodicTask::taskFunctionality() {
it != objectList.end(); ++it) { it != objectList.end(); ++it) {
(*it)->performOperation(); (*it)->performOperation();
} }
//TODO deadline missed check
/* If all operations are finished and the difference of the
* current time minus the last wake time is larger than the
* wait period, a deadline was missed. */
if(xTaskGetTickCount() - xLastWakeTime >= xPeriod) {
sif::warning << "PeriodicTask: " << pcTaskGetName(NULL) <<
" missed deadline!\n" << std::flush;
if(deadlineMissedFunc != nullptr) {
this->deadlineMissedFunc();
}
}
vTaskDelayUntil(&xLastWakeTime, xPeriod); vTaskDelayUntil(&xLastWakeTime, xPeriod);
} }
} }

View File

@ -5,8 +5,10 @@
#include <framework/tasks/PeriodicTaskIF.h> #include <framework/tasks/PeriodicTaskIF.h>
#include <framework/tasks/Typedef.h> #include <framework/tasks/Typedef.h>
#include <FreeRTOS.h> extern "C" {
#include "task.h" #include <freertos/FreeRTOS.h>
#include <freertos/task.h>
}
#include <vector> #include <vector>