Closed fightforlife closed 3 years ago
So you are basically asking to debug your code for you?
I would suspect that your problem is undefined word Module in Module.cpp, no?
Where is Module defined?
Sorry, #define Module is included the Main.h in my original code. This is an error in my code abstraction. I edited my example above. Other functions in Module.cpp are working just fine.
Since there is no compiler error/warning or any debug output I am currently stuck. Maybe there is a way of enabling debug output and seeing what is really hapenning in the Scheduler?
Need to see the entire code.
What you describe is basic Task scheduler functionality that has been proven to work in 100's of projects. The issue is somewhere else.
Closing this for lack of activity
Since I ran into this, I figured I should leave a note.
I think the problem relates to when the global-scoped objects are initialized.
I don't believe there's a guarantee that Scheduler mainRunner
is fully-constructed before the Task CC1101_loopTask
in Module.cpp is constructed. So the order ends up being (I think):
CC1101_loopTask
calls addTask()
, which sets up iFirst
et al.Scheduler mainRunner
constructs, which calls init()
and nulls out iFirst
.iScheduler
and linked list pointers are all suspect, so calling addTask()
or deleteTask()
probably ends in a crash.My solution was to avoid hooking up the Scheduler in the Task constructor, and addTask()
at some point during runtime.
That is quite possible. I also suspect there is a way to figure out how platform sequences the global objects and avoid this scenario. I do not use platform.io very often, so apologies - never ran into a situation like this. Happy to look at the code if you have a working example of this behavior.
Hello together, I have a problem getting multiple files in platformio to work. I tried to follow https://github.com/arkhipenko/TaskScheduler/tree/master/examples/Scheduler_example16_Multitab. But something ist still wrong.
Example of my code.
ConnectionTask
in Main.cpp is successfully run every 1000msCC1101_loopTask
in Module.cpp is never started. it seems like it is not added to the external SchedulermainRunner
Main.h
Main.cpp
Module.h
Module.cpp
ts.cpp