Page 1 of 1

Modbus crashing when second UART port in use

Posted: Wed Jun 05, 2024 8:22 am
by decadenza
Hi All,

I am using ESP32 with the following configuration:

Code: Select all

...
#define PIN_MODBUS_RX       3
#define PIN_MODEM_RX        26
#define MODBUS_UART_PORT    UART_NUM_2
#define MODBUS_BAUD_RATE    115200
...
In menuconfig → Component config → ESP System Settings I have defined:

Code: Select all

    Channel for console output (Custom UART)  --->
    UART peripheral to use for console output (0-1) (UART0)  --->
(27) UART TX on GPIO#
(26) UART RX on GPIO#
(115200) UART console baud rate
Everything works fine and I can read logs on pins 27 and 26, while sending commands via Modbus on pin 3 and 26. However, when the traffic increases (high speed commands via Modbus) AND many logs are printed, the Modbus connection starts to slow down, have timeouts and eventually the ESP crashes.

If logs are disabled, everything works fine. Reproduced on several ESP32.

I am compiling with:

Code: Select all

[1/2] espressif/esp-modbus (1.0.15)
[2/2] idf (5.2.1)
Anyone can shed some light on this? Is there a way for me to improve Modbus stability?

Re: Modbus crashing when second UART port in use

Posted: Wed Jun 05, 2024 8:52 am
by MicroController
Logging is relatively slow. If you're logging from the process handling the Modbus traffic this may slow processing of this traffic down significantly.