doc fix
This commit is contained in:
parent
dadc867d9e
commit
6a7f47e06d
@ -82,7 +82,7 @@ ReturnValue_t FixedTimeslotTask::checkSequence() const {
|
|||||||
void FixedTimeslotTask::taskFunctionality() {
|
void FixedTimeslotTask::taskFunctionality() {
|
||||||
// A local iterator for the Polling Sequence Table is created to find the
|
// A local iterator for the Polling Sequence Table is created to find the
|
||||||
// start time for the first entry.
|
// start time for the first entry.
|
||||||
SlotListIter slotListIter = pst.current;
|
auto slotListIter = pst.current;
|
||||||
|
|
||||||
//The start time for the first entry is read.
|
//The start time for the first entry is read.
|
||||||
uint32_t intervalMs = slotListIter->pollingTimeMs;
|
uint32_t intervalMs = slotListIter->pollingTimeMs;
|
||||||
@ -90,9 +90,9 @@ void FixedTimeslotTask::taskFunctionality() {
|
|||||||
|
|
||||||
TickType_t xLastWakeTime;
|
TickType_t xLastWakeTime;
|
||||||
/* The xLastWakeTime variable needs to be initialized with the current tick
|
/* The xLastWakeTime variable needs to be initialized with the current tick
|
||||||
count. Note that this is the only time the variable is written to explicitly.
|
count. Note that this is the only time the variable is written to
|
||||||
After this assignment, xLastWakeTime is updated automatically internally within
|
explicitly. After this assignment, xLastWakeTime is updated automatically
|
||||||
vTaskDelayUntil(). */
|
internally within vTaskDelayUntil(). */
|
||||||
xLastWakeTime = xTaskGetTickCount();
|
xLastWakeTime = xTaskGetTickCount();
|
||||||
|
|
||||||
// wait for first entry's start time
|
// wait for first entry's start time
|
||||||
@ -109,10 +109,40 @@ void FixedTimeslotTask::taskFunctionality() {
|
|||||||
intervalMs = this->pst.getIntervalToPreviousSlotMs();
|
intervalMs = this->pst.getIntervalToPreviousSlotMs();
|
||||||
interval = pdMS_TO_TICKS(intervalMs);
|
interval = pdMS_TO_TICKS(intervalMs);
|
||||||
|
|
||||||
/* If all operations are finished and the difference of the
|
checkMissedDeadline(xLastWakeTime, interval);
|
||||||
* current time minus the last wake time is larger than the
|
|
||||||
* expected wait period, a deadline was missed. */
|
// Wait for the interval. This exits immediately if a deadline was
|
||||||
if(xTaskGetTickCount() - xLastWakeTime >= interval) {
|
// missed while also updating the last wake time.
|
||||||
|
vTaskDelayUntil(&xLastWakeTime, interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FixedTimeslotTask::checkMissedDeadline(const TickType_t xLastWakeTime,
|
||||||
|
const TickType_t interval) {
|
||||||
|
/* Check whether deadline was missed while also taking overflows
|
||||||
|
* into account. Drawing this on paper with a timeline helps to understand
|
||||||
|
* it. */
|
||||||
|
TickType_t currentTickCount = xTaskGetTickCount();
|
||||||
|
TickType_t timeToWake = xLastWakeTime + interval;
|
||||||
|
// Tick count has overflown
|
||||||
|
if(currentTickCount < xLastWakeTime) {
|
||||||
|
// Time to wake has overflown as well. If the tick count
|
||||||
|
// is larger than the time to wake, a deadline was missed.
|
||||||
|
if(timeToWake < xLastWakeTime and
|
||||||
|
currentTickCount > timeToWake) {
|
||||||
|
handleMissedDeadline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No tick count overflow. If the timeToWake has not overflown
|
||||||
|
// and the current tick count is larger than the time to wake,
|
||||||
|
// a deadline was missed.
|
||||||
|
else if(timeToWake > xLastWakeTime and currentTickCount > timeToWake) {
|
||||||
|
handleMissedDeadline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FixedTimeslotTask::handleMissedDeadline() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
sif::warning << "FixedTimeslotTask: " << pcTaskGetName(NULL) <<
|
sif::warning << "FixedTimeslotTask: " << pcTaskGetName(NULL) <<
|
||||||
" missed deadline!\n" << std::flush;
|
" missed deadline!\n" << std::flush;
|
||||||
@ -120,12 +150,6 @@ void FixedTimeslotTask::taskFunctionality() {
|
|||||||
if(deadlineMissedFunc != nullptr) {
|
if(deadlineMissedFunc != nullptr) {
|
||||||
this->deadlineMissedFunc();
|
this->deadlineMissedFunc();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Wait for the interval. This exits immediately if a deadline was
|
|
||||||
// missed while also updating the last wake time.
|
|
||||||
vTaskDelayUntil(&xLastWakeTime, interval);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
|
ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
|
||||||
|
@ -12,7 +12,7 @@ class FixedTimeslotTask: public FixedTimeslotTaskIF {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keep in Mind that you need to call before this vTaskStartScheduler()!
|
* Keep in Mind that you need to call before vTaskStartScheduler()!
|
||||||
* A lot of task parameters are set in "FreeRTOSConfig.h".
|
* A lot of task parameters are set in "FreeRTOSConfig.h".
|
||||||
* @param name Name of the task, lenght limited by configMAX_TASK_NAME_LEN
|
* @param name Name of the task, lenght limited by configMAX_TASK_NAME_LEN
|
||||||
* @param setPriority Number of priorities specified by
|
* @param setPriority Number of priorities specified by
|
||||||
@ -89,6 +89,10 @@ protected:
|
|||||||
* OS's System Calls to keep the timing of the periods.
|
* OS's System Calls to keep the timing of the periods.
|
||||||
*/
|
*/
|
||||||
void taskFunctionality(void);
|
void taskFunctionality(void);
|
||||||
|
|
||||||
|
void checkMissedDeadline(const TickType_t xLastWakeTime,
|
||||||
|
const TickType_t interval);
|
||||||
|
void handleMissedDeadline();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* POLLINGTASK_H_ */
|
#endif /* POLLINGTASK_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user