2020-11-17 19:35:37 +01:00
|
|
|
#ifndef FSFW_OSAL_RTEMS_POLLINGTASK_H_
|
|
|
|
#define FSFW_OSAL_RTEMS_POLLINGTASK_H_
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-11-17 19:25:57 +01:00
|
|
|
#include "../../tasks/FixedSlotSequence.h"
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../../tasks/FixedTimeslotTaskIF.h"
|
2018-07-12 16:29:32 +02:00
|
|
|
#include "TaskBase.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
class PollingTask: public TaskBase, public FixedTimeslotTaskIF {
|
|
|
|
public:
|
2016-06-15 23:48:41 +02:00
|
|
|
/**
|
2018-07-12 16:29:32 +02:00
|
|
|
* @brief The standard constructor of the class.
|
|
|
|
*
|
|
|
|
* @details This is the general constructor of the class. In addition to the TaskBase parameters,
|
|
|
|
* the following variables are passed:
|
|
|
|
*
|
|
|
|
* @param (*setDeadlineMissedFunc)() The function pointer to the deadline missed function that shall be assigned.
|
|
|
|
*
|
|
|
|
* @param getPst The object id of the completely initialized polling sequence.
|
|
|
|
*/
|
|
|
|
PollingTask( const char *name, rtems_task_priority setPriority, size_t setStackSize, uint32_t overallPeriod, void (*setDeadlineMissedFunc)());
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
/**
|
2018-07-12 16:29:32 +02:00
|
|
|
* @brief The destructor of the class.
|
2016-06-15 23:48:41 +02:00
|
|
|
*
|
2018-07-12 16:29:32 +02:00
|
|
|
* @details The destructor frees all heap memory that was allocated on thread initialization for the PST and
|
|
|
|
* the device handlers. This is done by calling the PST's destructor.
|
2016-06-15 23:48:41 +02:00
|
|
|
*/
|
2018-07-12 16:29:32 +02:00
|
|
|
virtual ~PollingTask( void );
|
|
|
|
|
|
|
|
ReturnValue_t startTask( void );
|
|
|
|
/**
|
|
|
|
* This static function can be used as #deadlineMissedFunc.
|
|
|
|
* It counts missedDeadlines and prints the number of missed deadlines every 10th time.
|
|
|
|
*/
|
|
|
|
static void missedDeadlineCounter();
|
|
|
|
/**
|
|
|
|
* A helper variable to count missed deadlines.
|
|
|
|
*/
|
|
|
|
static uint32_t deadlineMissedCount;
|
|
|
|
|
|
|
|
ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep);
|
|
|
|
|
|
|
|
uint32_t getPeriodMs() const;
|
|
|
|
|
|
|
|
ReturnValue_t checkSequence() const;
|
|
|
|
|
|
|
|
ReturnValue_t sleepFor(uint32_t ms);
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* @brief id of the associated OS period
|
|
|
|
*/
|
|
|
|
rtems_id periodId;
|
|
|
|
|
|
|
|
FixedSlotSequence pst;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This attribute holds a function pointer that is executed when a deadline was missed.
|
|
|
|
*
|
|
|
|
* @details Another function may be announced to determine the actions to perform when a deadline was missed.
|
|
|
|
* Currently, only one function for missing any deadline is allowed.
|
|
|
|
* If not used, it shall be declared NULL.
|
|
|
|
*/
|
|
|
|
void ( *deadlineMissedFunc )( void );
|
|
|
|
/**
|
|
|
|
* @brief This is the entry point in a new polling thread.
|
|
|
|
*
|
2018-07-12 16:29:32 +02:00
|
|
|
* @details This method, that is the generalOSAL::checkAndRestartPeriod( this->periodId, interval ); entry point in the new thread, is here set to generate
|
2016-06-15 23:48:41 +02:00
|
|
|
* and link the Polling Sequence Table to the thread object and start taskFunctionality()
|
|
|
|
* on success. If operation of the task is ended for some reason,
|
|
|
|
* the destructor is called to free allocated memory.
|
|
|
|
*/
|
2018-07-12 16:29:32 +02:00
|
|
|
static rtems_task taskEntryPoint( rtems_task_argument argument );
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function holds the main functionality of the thread.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @details Holding the main functionality of the task, this method is most important.
|
2018-07-12 16:29:32 +02:00
|
|
|
* It links the functionalities provided by FixedSlotSequence with the OS's System Calls
|
2016-06-15 23:48:41 +02:00
|
|
|
* to keep the timing of the periods.
|
|
|
|
*/
|
|
|
|
void taskFunctionality( void );
|
|
|
|
};
|
|
|
|
|
2020-11-17 19:35:37 +01:00
|
|
|
#endif /* FSFW_OSAL_RTEMS_POLLINGTASK_H_ */
|