allow to set the satck size for user tasks
This commit is contained in:
parent
cd1fefad52
commit
c837d9b028
|
@ -25,6 +25,9 @@ class GwApi{
|
|||
#ifndef DECLARE_USERTASK
|
||||
#define DECLARE_USERTASK(task)
|
||||
#endif
|
||||
#ifndef DECLARE_USERTASK_PARAM
|
||||
#define DECLARE_USERTASK_PARAM(task,...)
|
||||
#endif
|
||||
#ifndef DECLARE_INITFUNCTION
|
||||
#define DECLARE_INITFUNCTION(task)
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,11 @@ void exampleTask(GwApi *param);
|
|||
void exampleInit(GwApi *param);
|
||||
//make the task known to the core
|
||||
//the task function should not return (unless you delete the task - see example code)
|
||||
DECLARE_USERTASK(exampleTask);
|
||||
DECLARE_USERTASK(exampleTask)
|
||||
//if your task needs more stack then the default 2000 bytes, replace the DECLARE_USERTASK
|
||||
//with: DECLARE_USERTASK_PARAM(exampleTask,2500);
|
||||
//this will give you 2500 bytes of stack
|
||||
|
||||
//let the core call an init function before the
|
||||
//N2K Stuff and the communication is set up
|
||||
//normally you should not need this at all
|
||||
|
|
|
@ -15,11 +15,11 @@ GwUserCode::Capabilities userCapabilities;
|
|||
|
||||
class GwUserTaskDef{
|
||||
public:
|
||||
GwUserTaskDef(TaskFunction_t task,String name){
|
||||
userTasks.push_back(GwUserTask(name,task));
|
||||
GwUserTaskDef(TaskFunction_t task,String name, int stackSize=2000){
|
||||
userTasks.push_back(GwUserTask(name,task,stackSize));
|
||||
}
|
||||
GwUserTaskDef(GwUserTaskFunction task,String name){
|
||||
userTasks.push_back(GwUserTask(name,task));
|
||||
GwUserTaskDef(GwUserTaskFunction task,String name,int stackSize=2000){
|
||||
userTasks.push_back(GwUserTask(name,task,stackSize));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -39,6 +39,7 @@ class GwUserCapability{
|
|||
}
|
||||
};
|
||||
#define DECLARE_USERTASK(task) GwUserTaskDef __##task##__(task,#task);
|
||||
#define DECLARE_USERTASK_PARAM(task,...) GwUserTaskDef __##task##__(task,#task,__VA_ARGS__);
|
||||
#define DECLARE_INITFUNCTION(task) GwInitTask __Init##task##__(task,#task);
|
||||
#define DECLARE_CAPABILITY(name,value) GwUserCapability __CAP##name##__(#name,#value);
|
||||
#include "GwApi.h"
|
||||
|
@ -115,12 +116,12 @@ void userTaskStart(void *p){
|
|||
}
|
||||
void GwUserCode::startAddOnTask(GwApi *api,GwUserTask *task,int sourceId,String name){
|
||||
task->api=new TaskApi(api,sourceId,mainLock);
|
||||
xTaskCreate(userTaskStart,name.c_str(),2000,task,3,NULL);
|
||||
xTaskCreate(userTaskStart,name.c_str(),task->stackSize,task,3,NULL);
|
||||
}
|
||||
void GwUserCode::startUserTasks(int baseId){
|
||||
LOG_DEBUG(GwLog::DEBUG,"starting %d user tasks",userTasks.size());
|
||||
for (auto it=userTasks.begin();it != userTasks.end();it++){
|
||||
LOG_DEBUG(GwLog::LOG,"starting user task %s with id %d",it->name.c_str(),baseId);
|
||||
LOG_DEBUG(GwLog::LOG,"starting user task %s with id %d, stackSize %d",it->name.c_str(), baseId,it->stackSize);
|
||||
startAddOnTask(api,&(*it),baseId,it->name);
|
||||
baseId++;
|
||||
}
|
||||
|
|
|
@ -12,14 +12,17 @@ class GwUserTask{
|
|||
GwUserTaskFunction usertask=NULL;
|
||||
bool isUserTask=false;
|
||||
GwApi *api=NULL;
|
||||
GwUserTask(String name,TaskFunction_t task){
|
||||
int stackSize=2000;
|
||||
GwUserTask(String name,TaskFunction_t task,int stackSize=2000){
|
||||
this->name=name;
|
||||
this->task=task;
|
||||
this->stackSize=stackSize;
|
||||
}
|
||||
GwUserTask(String name, GwUserTaskFunction task){
|
||||
GwUserTask(String name, GwUserTaskFunction task,int stackSize=2000){
|
||||
this->name=name;
|
||||
this->usertask=task;
|
||||
this->isUserTask=true;
|
||||
this->stackSize=stackSize;
|
||||
}
|
||||
};
|
||||
class GwUserCode{
|
||||
|
|
Loading…
Reference in New Issue