I was wondering if I could get some guidance (or directed to some documentation on the subject) with regards to what socket operations are safe to do in a-sync timer callback.
Right now I am trying the following:
If I try and do step 3 asynchronously, within the timer handler, it fails.
The steps involve include:
By failing I mean that the code gets stuck and doesn't complete. No faults or other errors are seen in the debug output. Additionally, adding a debug print to the main loop shows that the main loop is not continuing either.
My current solution is to handle this synchronously by raising a flag at the end of step 2, then executing step 3 in the main loop if said flag is raised.
However, I am curious about what is going on here. I imagine that there are other callbacks (possibly using the same timer interface) which are being delayed or blocked by my timer callback. Where can I find more on detailed information on this?
K_TIMER, right? Those will execute in interrupt context, so I would not recommend calling functions directly from the k_timer_handler, as some functions (like taking a semaphore) will generate a fault condition if called from interrupt context, but instead use a work queue (https://docs.zephyrproject.org/1.9.0/kernel/threads/workqueues.html)
This would be similar in behavior as your current workaround (setting a flag).