'RModbus - RTU Timeout won't reset after the first time out happened
I have two RS485 Modbus RTU Servers. Reading works fine but when I disconnect the second server, RModbus also shows timeout messages for the first server after a second read attempt. After the first timeout, RModbus stops working.
What is wrong?
port = "COM6"
baud = 19200
uid = 1
options = {data_bits: 8, stop_bits: 1, parity: SerialPort::EVEN}
cl = ModBus::RTUClient.new(port, baud, options)
cl.read_retries = 2
cl.debug = true
# Works fine
begin
puts cl.with_slave(1).read_holding_registers(512, 1)
rescue => error
puts error.message
end
# Intended Timeout
begin
puts cl.with_slave(2).read_holding_registers(512, 1)
rescue => error
puts error.message
end
# Should work, however, issues a timeout.
begin
puts cl.with_slave(1).read_holding_registers(512, 1)
rescue => error
puts error.message
end
Solution 1:[1]
In a Modbus RTU network can only exist one master.
Serial communication has no means for avoiding collisions.
It is the single master that must manage the communications following a strict order: request >> wait for a response >> request >> wait for a response...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | from56 |
