Modbus rtu over tcp

I have my openhab running on raspberry pi 3. I have installed Modbus Binding but having problem with reading values from salve (id=1).
For communication with slave(thermostat) via tcp I use modbus-rs485-serial-to-ethernet converter.
With test tools, I am able to successfully read all necessary registers, but not able to do that with openhab. Bridge seems to connect succesfully, but on poller i get time out errors. This is my set up:

Bridge modbus:tcp:thermo9 [ host=“192.168.1.17”, port=8899, id=1, timeBetweenTransactionsMillis=100, rtuEncoded=false ]
{
Bridge poller thermobridge9 [ start=0, length=1, refresh=3000, type=“holding” ]
{
Thing data thermodarbas9 [ readStart=“0”, readValueType=“int32”, writeStart=“1”, writeValueType=“int32”, writeType=“holding” ]
}
}

and this is the error i get:
2021-02-22 18:22:57.979 [ERROR] [wimpi.modbus.io.ModbusTCPTransaction] - execute try 1/1 error: I/O exception: SocketTimeoutException Read timed out. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@11356f5 (unit id 1 & transaction 1878). Address: /192.168.1.17:8899

2021-02-22 18:22:57.981 [ERROR] [wimpi.modbus.io.ModbusTCPTransaction] - execute reached max tries 1, throwing last error: I/O exception: SocketTimeoutException Read timed out. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@11356f5 (unit id 1 & transaction 1878). Address: /192.168.1.17:8899

2021-02-22 18:22:57.984 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1da6aad[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=0,length=1,maxTries=3]). Aborting. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID 7c4551e7-b30f-4907-afe9-cde61cb97fd8]

2021-02-22 18:23:04.004 [ERROR] [wimpi.modbus.io.ModbusTCPTransaction] - execute try 1/1 error: I/O exception: SocketTimeoutException Read timed out. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@1821f57 (unit id 1 & transaction 1879). Address: /192.168.1.17:8899

2021-02-22 18:23:04.008 [ERROR] [wimpi.modbus.io.ModbusTCPTransaction] - execute reached max tries 1, throwing last error: I/O exception: SocketTimeoutException Read timed out. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@1821f57 (unit id 1 & transaction 1879). Address: /192.168.1.17:8899

I tried playing with rtuEncoded parameter, setting it to true/false, but with no luck… does not seem to do a thing.

May we see what settings you used to do that?

You cannot really tell, until you try a poll or a write.
The openHAB TCP Thing being online just tells that the TCP/IP pathway is available.

That’s an unusual port for a gateway.

Random settings won’t help. Which does your gateway support on the TCP side? RTU-over-TCP would be unusual.

When you have got polling working, that is not going to work. 32-bit values use at least two standard 16-bit registers.

controller works rtu over tcp (as i understand). it sends 8byte packet… if i capture the traffic from the pc i run test tool. i see that the request pdu looks like this : 01030002000125ca
and response: 01030200017984 ( i attached the test tool request form)

the port i set by myself different than 502…

Okay, none of that includes the settings you need for your TCP Bridge Thing, can we see that part.

connection

i ran tcpdump on raspberry pi and see that openhab is sending Modbus TCp packet (12bytes in this case: 0e1600000006010300000001) and not modbus rtu over tcp. Is it possible to change? i thought that rtuEncoded should do that…

Only in a version that supports it. It’s quite a recent change, I’m not sure when introduced. (unknown config parameters are ignored)

You might change your gateway to regular Modbus-TCP.

i found, that my gateway has an option to work as Modbus tcp. Case closed. Thank you!

1 Like