dscKeybusInterface icon indicating copy to clipboard operation
dscKeybusInterface copied to clipboard

dsc.loop() in a timer event interrupt

Open cskzoli opened this issue 1 year ago • 3 comments

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

cskzoli avatar Oct 14 '24 14:10 cskzoli

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

Dilbert66 avatar Oct 14 '24 15:10 Dilbert66

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

cskzoli avatar Oct 14 '24 18:10 cskzoli

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.

Dilbert66 avatar Oct 14 '24 20:10 Dilbert66