Modbus crashing when second UART port in use

decadenza
Posts: 1
Joined: Wed Jun 05, 2024 8:03 am

Modbus crashing when second UART port in use

Postby decadenza » Wed Jun 05, 2024 8:22 am

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?

MicroController
Posts: 1734
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Modbus crashing when second UART port in use

Postby MicroController » Wed Jun 05, 2024 8:52 am

Logging is relatively slow. If you're logging from the process handling the Modbus traffic this may slow processing of this traffic down significantly.

Who is online

Users browsing this forum: Baidu [Spider] and 129 guests