stack size is bytes now
This commit is contained in:
parent
3905b72b08
commit
a0f41d3238
@ -5,11 +5,12 @@
|
|||||||
uint32_t FixedTimeslotTask::deadlineMissedCount = 0;
|
uint32_t FixedTimeslotTask::deadlineMissedCount = 0;
|
||||||
const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = configMINIMAL_STACK_SIZE;
|
const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = configMINIMAL_STACK_SIZE;
|
||||||
|
|
||||||
FixedTimeslotTask::FixedTimeslotTask(const char *name, TaskPriority setPriority,
|
FixedTimeslotTask::FixedTimeslotTask(TaskName name, TaskPriority setPriority,
|
||||||
TaskStackSize setStack, TaskPeriod overallPeriod,
|
TaskStackSize setStack, TaskPeriod overallPeriod,
|
||||||
void (*setDeadlineMissedFunc)()) :
|
void (*setDeadlineMissedFunc)()) :
|
||||||
started(false), handle(NULL), pst(overallPeriod * 1000) {
|
started(false), handle(NULL), pst(overallPeriod * 1000) {
|
||||||
xTaskCreate(taskEntryPoint, name, setStack, this, setPriority, &handle);
|
configSTACK_DEPTH_TYPE stackSize = setStack / sizeof(configSTACK_DEPTH_TYPE);
|
||||||
|
xTaskCreate(taskEntryPoint, name, stackSize, this, setPriority, &handle);
|
||||||
// All additional attributes are applied to the object.
|
// All additional attributes are applied to the object.
|
||||||
this->deadlineMissedFunc = setDeadlineMissedFunc;
|
this->deadlineMissedFunc = setDeadlineMissedFunc;
|
||||||
}
|
}
|
||||||
@ -82,7 +83,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.
|
||||||
FixedSlotSequence::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;
|
||||||
@ -155,3 +156,7 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
|
|||||||
vTaskDelay(pdMS_TO_TICKS(ms));
|
vTaskDelay(pdMS_TO_TICKS(ms));
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TaskHandle_t FixedTimeslotTask::getTaskHandle() {
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
#ifndef FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
||||||
#define FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
#define FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
||||||
|
|
||||||
|
#include <framework/osal/FreeRTOS/FreeRTOSTaskIF.h>
|
||||||
#include <framework/devicehandlers/FixedSlotSequence.h>
|
#include <framework/devicehandlers/FixedSlotSequence.h>
|
||||||
#include <framework/tasks/FixedTimeslotTaskIF.h>
|
#include <framework/tasks/FixedTimeslotTaskIF.h>
|
||||||
#include <framework/tasks/Typedef.h>
|
#include <framework/tasks/Typedef.h>
|
||||||
@ -8,7 +9,7 @@
|
|||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
|
|
||||||
class FixedTimeslotTask: public FixedTimeslotTaskIF {
|
class FixedTimeslotTask: public FixedTimeslotTaskIF, public FreeRTOSTaskIF {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,7 +24,7 @@ public:
|
|||||||
* @param setDeadlineMissedFunc Callback if a deadline was missed.
|
* @param setDeadlineMissedFunc Callback if a deadline was missed.
|
||||||
* @return Pointer to the newly created task.
|
* @return Pointer to the newly created task.
|
||||||
*/
|
*/
|
||||||
FixedTimeslotTask(const char *name, TaskPriority setPriority,
|
FixedTimeslotTask(TaskName name, TaskPriority setPriority,
|
||||||
TaskStackSize setStack, TaskPeriod overallPeriod,
|
TaskStackSize setStack, TaskPeriod overallPeriod,
|
||||||
void (*setDeadlineMissedFunc)());
|
void (*setDeadlineMissedFunc)());
|
||||||
|
|
||||||
@ -57,6 +58,8 @@ public:
|
|||||||
|
|
||||||
ReturnValue_t sleepFor(uint32_t ms) override;
|
ReturnValue_t sleepFor(uint32_t ms) override;
|
||||||
|
|
||||||
|
TaskHandle_t getTaskHandle() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool started;
|
bool started;
|
||||||
TaskHandle_t handle;
|
TaskHandle_t handle;
|
||||||
|
13
osal/FreeRTOS/FreeRTOSTaskIF.h
Normal file
13
osal/FreeRTOS/FreeRTOSTaskIF.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef FRAMEWORK_OSAL_FREERTOS_FREERTOSTASKIF_H_
|
||||||
|
#define FRAMEWORK_OSAL_FREERTOS_FREERTOSTASKIF_H_
|
||||||
|
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
|
|
||||||
|
class FreeRTOSTaskIF {
|
||||||
|
public:
|
||||||
|
virtual~ FreeRTOSTaskIF() {}
|
||||||
|
virtual TaskHandle_t getTaskHandle() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FRAMEWORK_OSAL_FREERTOS_FREERTOSTASKIF_H_ */
|
@ -5,12 +5,13 @@
|
|||||||
|
|
||||||
PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
|
PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
|
||||||
TaskStackSize setStack, TaskPeriod setPeriod,
|
TaskStackSize setStack, TaskPeriod setPeriod,
|
||||||
void (*setDeadlineMissedFunc)()) :
|
TaskDeadlineMissedFunction deadlineMissedFunc) :
|
||||||
started(false), handle(NULL), period(setPeriod), deadlineMissedFunc(
|
started(false), handle(NULL), period(setPeriod), deadlineMissedFunc(
|
||||||
setDeadlineMissedFunc)
|
deadlineMissedFunc)
|
||||||
{
|
{
|
||||||
|
configSTACK_DEPTH_TYPE stackSize = setStack / sizeof(configSTACK_DEPTH_TYPE);
|
||||||
BaseType_t status = xTaskCreate(taskEntryPoint, name,
|
BaseType_t status = xTaskCreate(taskEntryPoint, name,
|
||||||
setStack, this, setPriority, &handle);
|
stackSize, this, setPriority, &handle);
|
||||||
if(status != pdPASS){
|
if(status != pdPASS){
|
||||||
sif::debug << "PeriodicTask Insufficient heap memory remaining. "
|
sif::debug << "PeriodicTask Insufficient heap memory remaining. "
|
||||||
"Status: " << status << std::endl;
|
"Status: " << status << std::endl;
|
||||||
@ -81,19 +82,17 @@ void PeriodicTask::taskFunctionality() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PeriodicTask::addComponent(object_id_t object, bool setTaskIF) {
|
ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
|
||||||
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
||||||
object);
|
object);
|
||||||
if (newObject == nullptr) {
|
if (newObject == nullptr) {
|
||||||
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
|
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
|
||||||
"it implements ExecutableObjectIF!" << std::endl;
|
"it implement ExecutableObjectIF" << std::endl;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
objectList.push_back(newObject);
|
objectList.push_back(newObject);
|
||||||
|
newObject->setTaskIF(this);
|
||||||
|
|
||||||
if(setTaskIF) {
|
|
||||||
newObject->setTaskIF(this);
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +123,10 @@ void PeriodicTask::checkMissedDeadline(const TickType_t xLastWakeTime,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TaskHandle_t PeriodicTask::getTaskHandle() {
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
void PeriodicTask::handleMissedDeadline() {
|
void PeriodicTask::handleMissedDeadline() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
sif::warning << "PeriodicTask: " << pcTaskGetName(NULL) <<
|
sif::warning << "PeriodicTask: " << pcTaskGetName(NULL) <<
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#ifndef FRAMEWORK_OSAL_FREERTOS_PERIODICTASK_H_
|
#ifndef FRAMEWORK_OSAL_FREERTOS_PERIODICTASK_H_
|
||||||
#define FRAMEWORK_OSAL_FREERTOS_PERIODICTASK_H_
|
#define FRAMEWORK_OSAL_FREERTOS_PERIODICTASK_H_
|
||||||
|
|
||||||
|
#include <framework/osal/FreeRTOS/FreeRTOSTaskIF.h>
|
||||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||||
#include <framework/tasks/PeriodicTaskIF.h>
|
#include <framework/tasks/PeriodicTaskIF.h>
|
||||||
#include <framework/tasks/Typedef.h>
|
#include <framework/tasks/Typedef.h>
|
||||||
|
|
||||||
|
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ class ExecutableObjectIF;
|
|||||||
* periodic activities of multiple objects.
|
* periodic activities of multiple objects.
|
||||||
* @ingroup task_handling
|
* @ingroup task_handling
|
||||||
*/
|
*/
|
||||||
class PeriodicTask: public PeriodicTaskIF {
|
class PeriodicTask: public PeriodicTaskIF, public FreeRTOSTaskIF {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Keep in Mind that you need to call before this vTaskStartScheduler()!
|
* Keep in Mind that you need to call before this vTaskStartScheduler()!
|
||||||
@ -38,9 +40,9 @@ public:
|
|||||||
* The function pointer to the deadline missed function that shall
|
* The function pointer to the deadline missed function that shall
|
||||||
* be assigned.
|
* be assigned.
|
||||||
*/
|
*/
|
||||||
PeriodicTask(const char *name, TaskPriority setPriority,
|
PeriodicTask(TaskName name, TaskPriority setPriority,
|
||||||
TaskStackSize setStack, TaskPeriod setPeriod,
|
TaskStackSize setStack, TaskPeriod setPeriod,
|
||||||
void (*setDeadlineMissedFunc)());
|
TaskDeadlineMissedFunction deadlineMissedFunc);
|
||||||
/**
|
/**
|
||||||
* @brief Currently, the executed object's lifetime is not coupled with
|
* @brief Currently, the executed object's lifetime is not coupled with
|
||||||
* the task object's lifetime, so the destructor is empty.
|
* the task object's lifetime, so the destructor is empty.
|
||||||
@ -63,12 +65,13 @@ public:
|
|||||||
* -@c RETURN_OK on success
|
* -@c RETURN_OK on success
|
||||||
* -@c RETURN_FAILED if the object could not be added.
|
* -@c RETURN_FAILED if the object could not be added.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t addComponent(object_id_t object,
|
ReturnValue_t addComponent(object_id_t object) override;
|
||||||
bool setTaskIF = true) override;
|
|
||||||
|
|
||||||
uint32_t getPeriodMs() const override;
|
uint32_t getPeriodMs() const override;
|
||||||
|
|
||||||
ReturnValue_t sleepFor(uint32_t ms) override;
|
ReturnValue_t sleepFor(uint32_t ms) override;
|
||||||
|
|
||||||
|
TaskHandle_t getTaskHandle() override;
|
||||||
protected:
|
protected:
|
||||||
bool started;
|
bool started;
|
||||||
TaskHandle_t handle;
|
TaskHandle_t handle;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef FRAMEWORK_TASKS_TYPEDEF_H_
|
#ifndef FRAMEWORK_TASKS_TYPEDEF_H_
|
||||||
#define FRAMEWORK_TASKS_TYPEDEF_H_
|
#define FRAMEWORK_TASKS_TYPEDEF_H_
|
||||||
|
|
||||||
//TODO more generic?
|
|
||||||
typedef const char* TaskName;
|
typedef const char* TaskName;
|
||||||
typedef uint8_t TaskPriority;
|
typedef uint8_t TaskPriority;
|
||||||
typedef size_t TaskStackSize;
|
typedef size_t TaskStackSize;
|
||||||
|
Loading…
Reference in New Issue
Block a user