Modbus Master Crashes: assert failed: xMBMasterRTUReceiveFSM mbrtu_m.c:235
Posted: Sat Nov 05, 2022 3:32 pm
I am run after some time of operation into the problem, that my ESP32 restarts with the above mentioned error.
The Modbus master code is pretty much the same as the example which is included in the ESP IDF, i just changed a few minor things.
My application runs a few tasks in parallel if that matters, which is a websocket/webserver, modbus client, modbus server and mqtt.
What could cause this issue and how to trace it back?
(I am a beginner with ESP IDF)
The Modbus master code is pretty much the same as the example which is included in the ESP IDF, i just changed a few minor things.
Code: serial_log.txt Select all
I (1911922) count_task: RAM left 123264; mb_master_hwm: 1508, count_task_hwm: 20, mqtt_ssl_main_hwm: 6276
I (1912262) MASTER_TEST: Characteristic #0 Data_channel_0 (kW) value = 4531.000000 (0x458d9800) read successful. Restarted: 0
I (1912762) MASTER_TEST: Characteristic #0 Data_channel_0 (kW) value = 4531.000000 (0x458d9800) read successful. Restarted: 0
I (1913262) MASTER_TEST: Characteristic #0 Data_channel_0 (kW) value = 4531.000000 (0x458d9800) read successful. Restarted: 0
I (1913762) MASTER_TEST: Characteristic #0 Data_channel_0 (kW) value = 4531.000000 (0x458d9800) read successful. Restarted: 0
I (1914262) MASTER_TEST: Characteristic #0 Data_channel_0 (kW) value = 4531.000000 (0x458d9800) read successful. Restarted: 0
I (1914762) MASTER_TEST: Characteristic #0 Data_channel_0 (kW) value = 4531.000000 (0x458d9800) read successful. Restarted: 0
I (1914922) count_task: RAM left 123640; mb_master_hwm: 1508, count_task_hwm: 20, mqtt_ssl_main_hwm: 6276
I (1915262) MASTER_TEST: Characteristic #0 Data_channel_0 (kW) value = 4531.000000 (0x458d9800) read successful. Restarted: 0
I (1915762) MASTER_TEST: Characteristic #0 Data_channel_0 (kW) value = 4531.000000 (0x458d9800) read successful. Restarted: 0
I (1916262) MASTER_TEST: Characteristic #0 Data_channel_0 (kW) value = 4531.000000 (0x458d9800) read successful. Restarted: 0
I (1916762) MASTER_TEST: Characteristic #0 Data_channel_0 (kW) value = 4531.000000 (0x458d9800) read successful. Restarted: 0
assert failed: xMBMasterRTUReceiveFSM mbrtu_m.c:235 (( eSndState == STATE_M_TX_IDLE ) || ( eSndState == STATE_M_TX_XFWR ))
Backtrace:0x40081c02:0x3ffd00700x40089559:0x3ffd0090 0x400909b5:0x3ffd00b0 0x400e0751:0x3ffd01d0 0x400e1545:0x3ffd0200 0x400e15b4:0x3ffd0230 0x4008cdad:0x3ffd0260
0x40081c02: panic_abort at C:/Users/Michael.Uray/esp/esp-idf/components/esp_system/panic.c:402
0x40089559: esp_system_abort at C:/Users/Michael.Uray/esp/esp-idf/components/esp_system/esp_system.c:128
0x400909b5: __assert_func at C:/Users/Michael.Uray/esp/esp-idf/components/newlib/assert.c:85
0x400e0751: xMBMasterRTUReceiveFSM at C:/Users/Michael.Uray/esp/esp-idf/components/freemodbus/modbus/rtu/mbrtu_m.c:235 (discriminator 2)
0x400e1545: usMBMasterPortSerialRxPoll at C:/Users/Michael.Uray/esp/esp-idf/components/freemodbus/port/portserial_m.c:94
0x400e15b4: vUartTask at C:/Users/Michael.Uray/esp/esp-idf/components/freemodbus/port/portserial_m.c:142
0x4008cdad: vPortTaskWrapper at C:/Users/Michael.Uray/esp/esp-idf/components/freertos/port/xtensa/port.c:131
ELF file SHA256: 375376b08aba9e70
Rebooting...
ets Jul 29 2019 12:21:46
My application runs a few tasks in parallel if that matters, which is a websocket/webserver, modbus client, modbus server and mqtt.
Code: main.c Select all
void app_main()
{
const static char *TAG = "main";
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
// NVS partition was truncated and needs to be erased
// Retry nvs_flash_init
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
}
ESP_ERROR_CHECK(err);
wifi_app_main();
led_setup();
ws_server_start();
xTaskCreate(&nvs_main, "nvs_main", 2000, NULL, 9, NULL);
xTaskCreate(&server_task, "server_task", 2000, NULL, 9, NULL);
xTaskCreate(&server_handle_task, "server_handle_task", 4000, NULL, 6, NULL);
xTaskCreate(&count_task, "count_task", 2000, NULL, 2, NULL);
xTaskCreate(&mb_master_main, "mb_master_main", 3500, NULL, 9, &mb_master_main_th);
xTaskCreate(&mb_slave_main, "mb_slave_main", 3500, NULL, 9, NULL);
xTaskCreate(&mqtt_ssl_main, "mqtt_ssl_main", 1024 * 8, NULL, 9, &mqtt_ssl_main_th);
}
(I am a beginner with ESP IDF)