Skip to content

Commit ef8e7f8

Browse files
committed
modbus-rtu: esp-idf port, make sure line endings are ignored on UART
By default some line ending conversion may be done, so make sure to disable this on the UART used with libmodbus.
1 parent a4eb887 commit ef8e7f8

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/esp-idf/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ and would require a heavy change in the library interface.
6464
a standard configuration. Please check the `LWIP_MAX_SOCKETS` configuration
6565
variable.
6666

67+
- Older versions (<=5.3.1) of ESP-IDF contain a buglet in the serial read code that
68+
may cause some packet loss under certain circumstances (when line ending
69+
chars are present), see also: https://github.com/espressif/esp-idf/issues/14155
70+
Please use a newer version of ESP-IDF if you see this behavior.

src/modbus-rtu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ static int _modbus_rtu_connect(modbus_t *ctx)
588588
}
589589

590590
uart_vfs_dev_use_driver(uart_num);
591+
uart_vfs_dev_port_set_rx_line_endings(uart_num, ESP_LINE_ENDINGS_LF);
592+
uart_vfs_dev_port_set_tx_line_endings(uart_num, ESP_LINE_ENDINGS_LF);
591593

592594
return 0;
593595
}

0 commit comments

Comments
 (0)