[Solved] Logging debug output while using the serial port for function

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

[Solved] Logging debug output while using the serial port for function

Postby kolban » Thu Oct 06, 2016 1:16 am

I have an application which is using the serial port for function. What I am finding is that the "log" component (which I have been happily and liberally using) now is stepping over the output of my serial output data from my app. My next quest will be to start looking at the logging functions to see if there are any techniques where the output can be redirected elsewhere. I'm wondering (outloud) if it can't be sent via a TCP/IP connection to some listener that merely logs it. Alternatively, a second serial output would be useful.
Last edited by kolban on Thu Oct 06, 2016 3:40 am, edited 1 time in total.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Logging debug output while using the serial port for function

Postby WiFive » Thu Oct 06, 2016 2:48 am

Well you have 3 UARTs, silent boot, log levels, and can redirect stdout via syscalls so the world is your oyster.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Logging debug output while using the serial port for function

Postby ESP_igrr » Thu Oct 06, 2016 3:01 am

Log component does allow you to set an output function, so redirecting to network should be easy.

https://github.com/espressif/esp-idf/bl ... log.h#L121

The problem right now is that some closed source parts still use ets_printf and printf to log things, instead of using log component. This will be fixed after holidays. If you need a quick workaround, you can run `xtensa-esp32-elf-objcopy --redefine-symbol ets_printf=ets_printf_wrap libxxx.a` for each library in components/esp32/lib. Same for printf, rename it to printf_wrap. Then define empty `ets_printf_wrap` and `printf_wrap` functions in your application. This should remove all unsolicited messages from the closed-source part.

chaotaklon
Posts: 4
Joined: Thu Aug 31, 2017 6:06 am

Re: [Solved] Logging debug output while using the serial port for function

Postby chaotaklon » Mon Sep 04, 2017 9:47 am

The info in this page is helpful.
https://esp-idf.readthedocs.io/en/v1.0/api/log.html

Note that esp_log_set_level("*", ESP_LOG_ERROR); is incorrect.
According to this page: https://github.com/espressif/esp-idf/bl ... /esp_log.h
it should be: esp_log_level_set("*", ESP_LOG_ERROR);

Who is online

Users browsing this forum: No registered users and 157 guests