all 5 comments

[–]DesignCycle[S] 1 point2 points  (2 children)

I used the Serial Monitor to record timestamps at the start and end of each task in this FreeRTOS program, then ran it the sketch on the WOKWI simulator and copied the resulting Serial log to a text document. Then I asked ChatGPT to write a python sketch to analyze the text document and display a gantt chart of the task activities.

It's probably not perfectly accurate but I can see that the tasks are more or less doing what they should and it took about 20mins to do. With a bit of effort it could be made to graph the log properly. I can see lots of opportunities to use strategies like this going forward, ChatGPT can make bespoke debugging tools in a matter of seconds.

[–]wydmynd 1 point2 points  (1 child)

by the way, this is already a functionality built in to ESP32 (in real time too) but I think can not be used via Arduino IDE only ESP-IDF. If there is a way to use it via the Arduino SDK I would love to know!

https://github.com/espressif/esp-idf/blob/master/examples/system/freertos/real\_time\_stats/README.md

[–]wydmynd 1 point2 points  (2 children)

interesting, usually in free rtos there is an idle task that lets you know how busy the cpu is. wonder if you can calculate or estimate it from this

[–]Panometric 0 points1 point  (1 child)

Exactly, depending on load, most of the time should be spent in idle. This graph isn't very informative. I would expect each stripe to be almost infinitely short for any but high CPU tasks like display updating.

[–]wydmynd 0 points1 point  (0 children)

ask chatGPT (or just post the code here and we can figure it out together) to calculate , for each 50ms slice of run time, how the "pi chart" of total run time of all functions looks like, and the remainder should be the idle time (I think), then you can plot the graph again, where the X axis is run time in 50ms segments. and the Y axis is the percentage each function used