Skip to content

Commit

Permalink
modbus-rtu: esp-idf port, make sure line endings are ignored on UART
Browse files Browse the repository at this point in the history
By default some line ending conversion may be done, so make sure to
disable this on the UART used with libmodbus.
  • Loading branch information
fedepell committed Nov 19, 2024
1 parent a4eb887 commit ef8e7f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/esp-idf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ and would require a heavy change in the library interface.
a standard configuration. Please check the `LWIP_MAX_SOCKETS` configuration
variable.

- Older versions (<=5.3.1) of ESP-IDF contain a buglet in the serial read code that
may cause some packet loss under certain circumstances (when line ending
chars are present), see also: https://github.com/espressif/esp-idf/issues/14155
Please use a newer version of ESP-IDF if you see this behavior.
2 changes: 2 additions & 0 deletions src/modbus-rtu.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ static int _modbus_rtu_connect(modbus_t *ctx)
}

uart_vfs_dev_use_driver(uart_num);
uart_vfs_dev_port_set_rx_line_endings(uart_num, ESP_LINE_ENDINGS_LF);
uart_vfs_dev_port_set_tx_line_endings(uart_num, ESP_LINE_ENDINGS_LF);

return 0;
}
Expand Down

0 comments on commit ef8e7f8

Please sign in to comment.