Thanks for your help, kolban.
There are several tasks in my program. Here is a jpg image describing my task architecture.
- StepperTaskArchitecture.jpg (47.65 KiB) Viewed 9902 times
The abs_stepper_run function is called in the run_steppers task.
When I comment out the abs_stepper_run calls, the code works normally - all the messages are printed, but of course the stepper code is not run.
I suspect I am missing some basic knowledge about tasks / FreeRTOS / low level ESP32 stuff, because it doesn't seem possible to me that the app is behaving the way it is.
Without commenting out the abs_stepper_run calls, I can see that abs_stepper_run is returning. Otherwise the "1st command sent" message would not be printed. Also, I am printing out a message after the stepper_task processes the command it receives from the queue and right before it returns to get another command. So I know the stepper_task is not hanging.
The problem occurs in the next line, the first vTaskDelay call. The code hangs somewhere in here. That is shown in two different ways,
1. the "1st delay done" message is not printed
2. the stepper_task never receives another message from the queue.
How could vTaskDelay not return?
Had the vTaskDelay call not hung, the 2nd abs_stepper_run call would have been executed, another command would be put on the queue to the stepper, stepper_task would receive the command, and it would proceed to control the stepper motor in accordance with that command.
If anyone wants I can provide more details about my architecture.
Here's something else that is interesting. After looking at my architecture, I determined I probably do not want app_main to spawn the run_steppers task. That call should probably be done within app_main. When I do this, my code sort of works. No hangs...not doing what I want but my code is probably still full of bugs. It won't take me long to find what is wrong here. Nevertheless, I am clueless as to why moving the initialization code from a task to the app_main made any difference at all.
As I said earlier, I suspect I am missing some basic knowledge about tasks / FreeRTOS / low level ESP32 stuff. How can I learn this better?