Skip to content
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

dsc.loop() in a timer event interrupt #357

Open
cskzoli opened this issue Oct 14, 2024 · 3 comments
Open

dsc.loop() in a timer event interrupt #357

cskzoli opened this issue Oct 14, 2024 · 3 comments

Comments

@cskzoli
Copy link

cskzoli commented Oct 14, 2024

Hi,

Asking advice on following:
In my main loop I have some blocking procedures (can be several seconds) and would like to put dsc.loop() out from the main loop (to maintain its functionality).
My idea is to run dsc.loop() with a timer interrupt (eg. every 100ms).

What is the recommended interval for dsc.loop() to run?
Developing on PlatformIO/esp32 if that matter.

Thanks

@Dilbert66
Copy link
Contributor

Just run it as a task on the second core.
https://techtutorialsx.com/2017/05/09/esp32-running-code-on-a-specific-core/

@cskzoli
Copy link
Author

cskzoli commented Oct 14, 2024

Hi Dilbert66
Good idea, but not sure that dsc.loop() function is designed in a thread safe operation (eg. dsc.loop put something into the dsc buffer, while main loop also accessing the same buffer...)
Thx

@Dilbert66
Copy link
Contributor

Dilbert66 commented Oct 14, 2024

Might be an issue but since you are only reading the buffer with the main loop and not writing to it, it might be fine. Yes, you are also resetting some flags so that could be a cause of issue.

Alternatively, you could put your blocking process in it's own task instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants