Open-Agriculture / AgIsoStack-plus-plus

AgIsoStack++ is the completely free open-source C++ ISOBUS library for everyone
https://agisostack.com/
MIT License
187 stars 41 forks source link

Add ESP32 + PlatformIO Tutorial and Example #326

Closed ad3154 closed 12 months ago

ad3154 commented 1 year ago

What's new

I would like some feedback on this new tutorial before merging it, ideally, so you can find a draft of it here

Any and all comments would be welcome.

Closes #263

AndreaInverardi commented 1 year ago

Built "esp32_platformio_object_pool" example, as in the tutorial. Deployed on some ESP32 module. I can see some CAN frames been sent at boot. If I check serial port of ESP32 module it says every 5 seconds:

"E (391530) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:"

Tried also connected to some tractor's virtual terminal. It do not detect it.

ad3154 commented 1 year ago

Built "esp32_platformio_object_pool" example, as in the tutorial. Deployed on some ESP32 module. I can see some CAN frames been sent at boot. If I check serial port of ESP32 module it says every 5 seconds:

"E (391530) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:"

Tried also connected to some tractor's virtual terminal. It do not detect it.

Thanks for this feedback - I will see what I can do. I can sometimes repeat this same symptom, and have seen some successes with replacing some calls to std::this_thread::sleep_for with calls directly to FreeRTOS on ESP32 with vTaskDelay for example. We might have some success #defineing around these when ESP_PLATFORM is defined... or maybe we can use CMake and some clever abstraction to optionally compile in different kind of thread delays (this might be the cleanest solution...).

GwnDaan commented 1 year ago

Hi @AndreaInverardi @ad3154, sorry for the delay, the fix for your issues should already be in the stack: https://github.com/Open-Agriculture/AgIsoStack-plus-plus/pull/91/commits/29fe04ff5d1c9e66880c9d2fc496c0972c0b5744

Basically the default FreeRTOS tick is 10ms (100Hz), but the stack tries to update internally with 4ms by default. Hence the watchdog gets triggered as the thread is never allowed to switch.

There are 2 solutions:

I prefer the latter to minimize platform specific issues, but both should work fine I think.

EDIT: Actually it might be really useful to document this, and/or put it in the FAQ

ad3154 commented 1 year ago

Added updates to the ESP32 instructions to run menuconfig and adjust both the tick rate and some default stack sizes. When testing on my end this seemed to resolve all instances of runtime crashes I was seeing.

Check out the new section Set up your ESP32’s OS and PThread options in the draft.

sonarcloud[bot] commented 12 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication