Skip to content

Commit

Permalink
Fix example of modbus_rtu_set_serial_mode (closes #552)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane committed Oct 22, 2024
1 parent 452dc8b commit 51f37e0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/modbus_rtu_set_rts.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ 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));
modbus_free(ctx);
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));
Expand Down

0 comments on commit 51f37e0

Please sign in to comment.