No logging output from the main c file

Jpadie
Posts: 8
Joined: Tue Feb 13, 2018 6:42 pm

No logging output from the main c file

Postby Jpadie » Sun Apr 22, 2018 4:18 pm

Hi

this is my first time trying to use the esp-idf rather than arduino. I recognise that I'm probably doing something stupid.

I'm trying to build a simple IR sender and using ESP_LOGI to get some serial output for debugging. In an attempt to generate these outputs I use statements such as

Code: Select all

ESP_LOGI(TAG, "[APP] Startup..");
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());
at the top of the file I have the following

Code: Select all

#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
#include "esp_log.h"
static const char *TAG = "IRBLASTER";
and I also set the log levels in app_main

Code: Select all

esp_log_level_set("*", ESP_LOG_VERBOSE);
esp_log_level_set("MQTT_CLIENT", ESP_LOG_VERBOSE);
esp_log_level_set("TRANSPORT_TCP", ESP_LOG_VERBOSE);
esp_log_level_set("OUTBOX", ESP_LOG_VERBOSE);
esp_log_level_set(TAG, ESP_LOG_VERBOSE);
In the menuconfig I've tried setting the default verbosity to verbose

However in the console (make monitor) I get no output at all that I'd expect. i do get output from board though. Examples as follows:

Code: Select all

I (1347) wifi: state: init -> auth (b0)
I (1347) wifi: state: auth -> assoc (0)
I (1357) wifi: state: assoc -> run (10)
I (1367) wifi: connected with ********, channel 8
I (4097) event: sta ip: 192.168.0.39, mask: 255.255.255.0, gw: 192.168.0.254
I (4097) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (4227) MQTT_CLIENT: Sending MQTT CONNECT message, type: 1, id: 0000
I (4357) wifi: pm start, type:0
so the logging appears to be working for the components; just not the main file.

likewise if I send mqtt commands to the board, they appear from the mqtt client, but no logging occurs from the callbacks. my serial connection is to uart0.

Could anyone give me an idea of where I'm going wrong?

thanks in advance.
Justin

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

Re: No logging output from the main c file

Postby kolban » Sun Apr 22, 2018 8:34 pm

Howdy Justin,
Your coding looks right. I do notice that in the sample messages that you showed, they are only at log level Information. I believe that if we even switch on the default logging to Verbose we should see more. This makes me think that maybe something went wrong in the "make menuconfig" to change the level of verbosity during logging.

In make menuconfig go to:

Component Config > Log Output > Default log verbosity (verbose)

Make sure you rebuild ALL your code after making this change.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Jpadie
Posts: 8
Joined: Tue Feb 13, 2018 6:42 pm

Re: No logging output from the main c file

Postby Jpadie » Sun Apr 22, 2018 10:40 pm

Thanks or the reply Nick. You're right that I posted the output before I promoted the logging to verbose via menuconfig. Unfortunately the output from that was poorly formatted on my screen (not honouring LFs) and so ... verbose ... that i thought it didn't help to explain my issues.


I've given up for the time being. I may go back to Arduino IDE although for the original variant of this project I was getting heap corruption with concomitant reboots the whole time. Probably something to do with using esp_log natively in Arduino land.

Although the reason for logging at all is that I couldn't find a way to force a rebuild of the rmt library so that it sent debugging information to the serial console. Thwarted on all sides!

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: No logging output from the main c file

Postby ESP_Angus » Mon Apr 23, 2018 12:45 am

Hi Justin,

I agree with kolban that this all looks like it should work. Are you able to post the full .c file somewhere? (gist.github.com is my favourite, pastebin.com is also an option)?

You should be able to call esp_log macros from Arduino, as well. Heap corruption is probably due to something else, unfortunately.,

Angus

Jpadie
Posts: 8
Joined: Tue Feb 13, 2018 6:42 pm

Re: No logging output from the main c file

Postby Jpadie » Mon Apr 23, 2018 6:37 am

it's possible heap corruption was from something else. I'm not sure what though as on the Arduino I was using stable libraries for pubsub and more or less the out of the box examples for the remote peripheral. But Im always willing to blame myself!

The code I'm using on esp-idf is available as a gist here: https://gist.github.com/jpadie/3e54dd14 ... 66144e1fef

an extract from the verbose debugging is below. As you can see, there are MQTT events that should have resulted in a callback to the event handler that in turn should have resulted in log output. I did think that perhaps the mqtt library was suspect, but I am also not getting the logging from app_main().

In case it is useful, I'm using a esp-wroom-32 board powered from a 5v power supply and an AMS1117 regulator. the only other components on the board are some decoupling caps at the board power pins and a pull up on the enable line, a large electrolytic across the regulator output, two IR LEDs, an NPN transistor and a resistor in series with the gate.

Code: Select all

D (4586) MQTT_CLIENT: pending_id=2411, pending_msg_count = 3
D (4596) OUTBOX: DELETED msgid=26938, msg_type=8, remain size=26
D (4596) MQTT_CLIENT: Subscribe successful
I (4736) wifi: pm start, type:0
D (4746) MQTT_CLIENT: msg_type=9, msg_id=59818
D (4746) MQTT_CLIENT: pending_id=2411, pending_msg_count = 2
D (4746) OUTBOX: DELETED msgid=59818, msg_type=8, remain size=0
D (4756) MQTT_CLIENT: Subscribe successful
D (4926) MQTT_CLIENT: msg_type=9, msg_id=2411
D (4926) MQTT_CLIENT: pending_id=2411, pending_msg_count = 1
D (4926) MQTT_CLIENT: Subscribe successful
D (42046) MQTT_CLIENT: msg_type=3, msg_id=0
I (42046) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
D (42046) MQTT_CLIENT: Get data len= 3, topic len=12
D (47516) MQTT_CLIENT: msg_type=3, msg_id=0
I (47516) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
D (47516) MQTT_CLIENT: Get data len= 3, topic len=12
D (52206) MQTT_CLIENT: msg_type=3, msg_id=0
I (52206) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
D (52206) MQTT_CLIENT: Get data len= 3, topic len=12
D (53116) MQTT_CLIENT: msg_type=3, msg_id=0
I (53116) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
D (53126) MQTT_CLIENT: Get data len= 3, topic len=12

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

Re: No logging output from the main c file

Postby kolban » Mon Apr 23, 2018 11:52 am

Looking at your source app, I believe I saw a

#include <adruino.h>

Try and remove that include and see what happens. I would't try mixing ESP-IDF and Arduino at this point.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Jpadie
Posts: 8
Joined: Tue Feb 13, 2018 6:42 pm

Re: No logging output from the main c file

Postby Jpadie » Mon Apr 23, 2018 12:56 pm

You're right that it's there as a hangover in the codes.h file.

May I ask how that would prevent logging?

Jpadie
Posts: 8
Joined: Tue Feb 13, 2018 6:42 pm

Re: No logging output from the main c file

Postby Jpadie » Mon Apr 23, 2018 5:34 pm

deleting the arduino include exposed two compiler errors in the idf not liking the data type 'byte'. changing those to uint8_t fixed that and now the logging output is there.

This is quite unexpected since the Arduino component was installed and the app compiled fine with the Arduino include in there.

Thank you anyway.

Now I just have to work out why there are such random stray characters in the MQTT payloads. I suspect that the library is not well written (since the mqtt feed works with all the other apps that consume it). I guess I can just use Nick O'Leary's code as it should be compile ok independent of the architecture.

Who is online

Users browsing this forum: ok-home and 99 guests