From 51f37e0364c046ebc01bd25332f9f31500fe86dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Raimbault?= Date: Tue, 22 Oct 2024 15:46:34 +0200 Subject: [PATCH] Fix example of modbus_rtu_set_serial_mode (closes #552) --- docs/modbus_rtu_set_rts.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/modbus_rtu_set_rts.md b/docs/modbus_rtu_set_rts.md index 5a33d1c6a..f76e48a83 100644 --- a/docs/modbus_rtu_set_rts.md +++ b/docs/modbus_rtu_set_rts.md @@ -45,8 +45,6 @@ uint16_t tab_reg[10]; ctx = modbus_new_rtu("/dev/ttyS0", 115200, 'N', 8, 1); modbus_set_slave(ctx, 1); -modbus_rtu_set_serial_mode(ctx, MODBUS_RTU_RS485); -modbus_rtu_set_rts(ctx, MODBUS_RTU_RTS_UP); if (modbus_connect(ctx) == -1) { fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno)); @@ -54,6 +52,9 @@ if (modbus_connect(ctx) == -1) { return -1; } +modbus_rtu_set_serial_mode(ctx, MODBUS_RTU_RS485); +modbus_rtu_set_rts(ctx, MODBUS_RTU_RTS_UP); + rc = modbus_read_registers(ctx, 0, 7, tab_reg); if (rc == -1) { fprintf(stderr, "%s\n", modbus_strerror(errno));