Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Piira
#61667 Hi
I have been playing with some ESP:s in the Arduino environment for a while but now I have got into problems with the looking code in the normal Arduino WiFi library's and intended to change to the ESPAsyncTCP library. I would need to get a better understanding of the concepts of contexts, tasks and the relation to callbacks.

I have a number of assumptions (guesses) based on google and tests and I would be happy if somebody would tell me what is wrong.
  • A context is something executing at a specific priority level and that it can be a task or an interrupt that starts the context.
  • An executing task at any priority level can be interrupted by an interrupt but it can not be interrupted by a new task even if the new task has higher priority.
  • "Arduino functions" that includes delay() or yield() can only be called from the loop() context.
  • The callbacks from LWIP is executing in a context started by a task at a higher priority level then the priority levels offered in the ESP API.
  • It is safe to execute for the normal 30-50ms in the LWIP callbacks.
  • The Arduino loop() is executing started from task priority 1 (User priority in ESP API).
  • It is not possible to use task at priority level 0 but priority level 2 can be used.

Then I of cause have some questions ;)
  • Is it safe to use output to Serial from other task priorities then the Arduino loop() task in general?
  • If it isn't generally safe to use Serial is it safe in callbacks from LWIP?
  • Is there some way to find the priority level of a callback and/or if it is coming from an interrupt?
  • Are there any other functions the delay() and yield() that you have to avoid in callbacks?

I would be very happy to get some comments, answers and also other thoughts on this.