We have an application using the ESP32 S2 in production and are unable to log an issue we have that the ESP32 S2 does not reconnect occasionally. As in production use we require to access the logs remotely.
The system has a SD card and logs could be written on it. However, this would require that the log file will be properly closed after writing. What are the options by avoiding to change the IDF core?
Any hint appreciated, thanks
obstacles and best practise to redirect error loggig to a SD card file?
-
- Posts: 1710
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: obstacles and best practise to redirect error loggig to a SD card file?
You could redirect IDF's logging to a custom function (via esp_log_set_vprintf(...)), and that function can do whatever is necessary to dump the log message to wherever.
You can of course call your own log-file writing function directly at only those specific points where you want it, instead of pushing all ESP_LOGx log messages through.
Using FatFs, I found that it is actually not necessary (or beneficial) to close a file just to get it into a consistent persistent state: FatFs's f_sync(...) will do that without actually closing the file, so that you do not have to costly re-open it everytime to continue writing. However, flushing to SD may still be too "expensive" (possibly tens of milliseconds!) to do for every log event.
You can of course call your own log-file writing function directly at only those specific points where you want it, instead of pushing all ESP_LOGx log messages through.
Using FatFs, I found that it is actually not necessary (or beneficial) to close a file just to get it into a consistent persistent state: FatFs's f_sync(...) will do that without actually closing the file, so that you do not have to costly re-open it everytime to continue writing. However, flushing to SD may still be too "expensive" (possibly tens of milliseconds!) to do for every log event.
Re: obstacles and best practise to redirect error loggig to a SD card file?
Thanks @MicroController looks very strait forward. Great hint
Who is online
Users browsing this forum: Baidu [Spider], Bing [Bot] and 84 guests