-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defined tasks not working depending on files alphabetical order #117
Comments
As usual, need to see the source code to be able to attempt to help. |
Source code: https://github.com/vvinjj/TaskShedulerAbcIssue |
Unfortunately, I do not use Platform.io, but on the surface of things: why not include the external reference to scheduler into aTaks.h file since you need it to create a task in aTask.cpp? |
Perhaps you misunderstood the issue as TaskA is working anyway, but TaskZ is not (but is structurally identical, only file name is different). |
Indeed, it does not work, probably because of the sequence of declarations. I am not using CPP/HPP files for Arduino, so never saw this issue. header.hpp:
aTask.cpp:
zTask.cpp:
main.cpp:
Please let me know if you find a more elegant solution. |
I think in your solution you can remove from header.hpp: extern Scheduler runner; as not needed anymore. |
I am using PlatformIO too and I have the same issue, where frusting @arkhipenko It will usefull to put this information clearly somewhere to prevent people to looking for a bug in their own code Very usefull lib, thanks |
Based on:
TaskScheduler/examples/Scheduler_example16_Multitab/Scheduler_example16_Multitab.ino
It says that Arduino IDE plays some dirty tricks on main sketch file and it rearranges #includes, blindly creates forward definitions. However, developing in PlatformIO I faced the bug that the blank .ino file workaround didn't help and one of my tasks which was defined in file didn't want to execute. After couple of hours on trying to narrow down the issue, found that if I simply rename the file where my task is to make it appear alphabetically earlier than main.cpp, then it fixes the issue.
Example:
ultrasound.cpp & ultrasound.h -> contains Task loopUltrasound which periodically invokes itself;
main.cpp -> defines Scheduler runner; setup() and loop() with runner.execute();
Workaround Fix:
Alternative workaround Fix:
Not sure why it behaves such way, but I hope it helps to narrow down the issue.
The text was updated successfully, but these errors were encountered: