Closed YannikW closed 1 year ago
Hi Yannik,
First of all - ts.execute()
should not be called anywhere else outside of the main loop()
method. In fact I wanted to even hide it inside TS implementation to spare developers from temptation to use it somewhere else.
With respect to tasks using same callback for different task: https://github.com/arkhipenko/TaskScheduler/blob/master/examples/Scheduler_example08_LTS/Scheduler_example08_LTS.ino
With respect to synchronizing tasks waiting for something https://github.com/arkhipenko/TaskScheduler/tree/master/examples/Scheduler_example04_StatusRequest https://github.com/arkhipenko/TaskScheduler/tree/master/examples/Scheduler_example05_StatusRequest
And putting it all together with different task priorities: https://github.com/arkhipenko/TaskScheduler/tree/master/examples/Scheduler_example20_StatusRequest_LTS_WDT_Timeout_Object
If you need further help with specific code, we will need to discuss some sort of consulting arrangement.
Good luck!
Hi,
first of all thanks for that amazing library, it's really usefull when you need some kind of parallel and asynchronous execution.
Starting point
I'm working an SPS / PLC type software where I have one main task, which handles my main doing in a serial way, and some other tasks to check sensor readings and so on.
In my main task I often call something and then need to wait for an event (serial command or digital input state) to continue.
How I'm doing it now
This works fine and with two functions like above it's no problem, however when adding more and more steps in the main task you will get many function which often have only one or two lines of code. Personal I like to have one callback function per task, I thinks thats easier to understand. Also I would like to reduce the overhead defining all that functions.
Proposal
My proposal / question would be to call the execute() function from inside my task-callback while waiting in the statusrequest to finish.
I did not try if it simply works, because I'm afraid getting unpredictable behaviour when calling execute() inside a running and not finished task.
I have looked into the libraries code, however I do not fully understand everything thats happening there, so I'm asking it here. Is this proposal feasible or is it bad practise (or simply not working at all)?
Thanks!
Best regards Yannik