Open phu251099 opened 3 months ago
What about using?
ctx = modbus_new_rtu("/dev/ttyS3", 115200, 'N', 8, 1);
modbus_set_slave(ctx, 1);
modbus_read_registers(ctx, 0, 2, tab_reg);
...
modbus_set_slave(ctx, 2);
modbus_read_registers(ctx, 0, 2, tab_reg);
...
modbus_set_slave(ctx, 3);
modbus_read_registers(ctx, 0, 2, tab_reg);
...
Currently I am facing the following problem:
I have 3 slaves with 3 IDs 1, 2, 3 connected to 1 modbus rtu COM port.
I don't know how to read and write data to 3 devices.
When using the following functions, communication with only 1 address is possible: ctx = modbus_new_rtu("/dev/ttyS3", 115200, 'N', 8, 1); modbus_set_slave(ctx, 1); modbus_read_registers(ctx, 0, 2, tab_reg);