-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
display mqtt raw message data ,present messy code!!!!!!!!! (IDFGH-14089) #19
Comments
#include <stdio.h> #include "freertos/FreeRTOS.h" #define TAG "MQTT" #define MQTT_SUB_TOPIC "/TEST/SUB11" #define PASSWORD "12345678" static SemaphoreHandle_t x_wifi_con_sem;
} void esp_mqtt_event_handler(void* event_handler_arg,
} void app_main(void)
} |
Hi @learnerzcz, can you please try following the example in ESP-IDF, e.g. this one? This does not seem like an issue with IDF Monitor to me. |
@peterdragun ,i use the demo i learned ,it doesn't present the issue ,i think i miss some steps. it result the issue |
The problem is that you are not null-terminating your string buffer, so memcpy(data_buf,event->topic,event->topic_len);
printf("data->topic=%s\n",data_buf); If you fill memcpy(data_buf,event->topic,event->topic_len);
data_buf[event->topic_len] = 0;
printf("data->topic=%s\n",data_buf); (You also need to check that event->topic_len is not larger than the size of your buffer, otherwise you may corrupt other data on the stack.) Alternatively, you can use printf's printf("data->topic=%.*s\n",event->topic_len, event->topic); like it is done in the example: |
@igrr thanks, like you said , i copy the topic to the bufffer,and make the null-terminating ,the display is ok. but the reason that refuse me ,is that log "--- Warning: Failed to decode multiple lines in a row. Try checking the baud rate and XTAL frequency setting in menuconfig" �$;�W��0(d�Dfi: top->/test/topic2434xsUn��]�bj�a G���$\� �$;�W��0(d�Dfi: payload->434xsUn��]�bj�a G���$\� |
Checklist
How often does this bug occurs?
always
Expected behavior
only display the receive message
Actual behavior (suspected bug)
i use mqtt client to subscribe a topic ,and when i receicve the publish message, i will print the message raw data.
Error logs or terminal output
Steps to reproduce the behavior
only flash the firmware
Project release version
idf version v5.2-dirty , espidf monitor ver 1.5.0
System architecture
Intel/AMD 64-bit (modern PC, older Mac)
Operating system
Linux
Operating system version
ubuntu 20.04
Shell
CMD
Additional context
no
The text was updated successfully, but these errors were encountered: