Modbus RTU openHAB binding Error

Trying to integrate openHAB with Toshiba Air conditioner with Modbus Binding. However not sure what goes wrong ?

Toshiba air conditioner Modbus Interface manual.

openHAB 1.8.x configuration

Switch MySwitch "My Modbus Switch" (ALL) {modbus="onoffcmdstat:0"}

modbus:serial.onoffcmdstat.connection=COM4:19200:8:even:1:rtu:1000
modbus:serial.onoffcmdstat.id=1
modbus:serial.onoffcmdstat.type=discrete
modbus:serial.onoffcmdstat.start=0
modbus:serial.onoffcmdstat.length=1
modbus:serial.onoffcmdstat.valuetype=bit

Error LOG FILE: https://pastebin.com/2YqJSa34

Troubleshoot with some Modbus tool - Simply Modbus, Radzio, etc. Consider COM port, RS485 termination, A/B wires swapped, baud rate etc.

Thanks rossko57. I already check and confirmed there is no physical connection issue as same setup is working with Node-red. So, I need help specific to openHab configuration. Any wrog did you find in logs?

Hi

Logs refer to “stat” which should be input registers. It does not match the configuration you pasted with discrete inputs and with name onoffcmdstat.

Check if you are suffering from this openhab2 issue : https://github.com/openhab/openhab1-addons/issues/5084 (check the link at end). Openhab2 caches configuration which might lead to these kind of ssues . Especially note this trick to clear up the cache

Sami

Edit : Are you using openhab2 or openhab1? The above only applies to openhab2.

Dear Ssalonen,

Item specification need “Discrete input”. I am using openHAB 1.8 with modbus 1.9 version. check if you can review Manual and describe correct configuration.

Address table and function reference

2017-05-05 16:02:15.958 [ERROR] [i.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2017-05-05 16:02:15.967 [ERROR] [w.m.io.ModbusSerialTransaction] - execute try 2/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@617422f4 (unit id 1 & transaction 1). Serial parameters: SerialParameters@b52a7a9[portName=COM4,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-05-05 16:02:19.013 [ERROR] [i.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 00 00 01 31 ca


16:01:10.945 [ERROR] [i.modbus.io.ModbusRTUTransport:172 ] - failed to read: Error reading response (EOF)
16:01:10.953 [ERROR] [w.m.io.ModbusSerialTransaction:199 ] - execute try 2/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputDiscretesRequest@1c27f854 (unit id 1 & transaction 38). Serial parameters: SerialParameters@4bc283b2[portName=COM4,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
16:01:13.999 [ERROR] [i.modbus.io.ModbusRTUTransport:171 ] - Last request: 01 02 00 00 00 08 79 cc

Could you please output full modbus configuration? It seems that there is something else defined as well (input registers).

Please follow the troubleshooting tips in order to enable easier debugging

Best
Sami

This is unnecessary , a discrete register type is by definition a single bit.
It shouldn’t matter, but might interfere as your Switch Item expects ON/OFF states, and 'bit’might circumvent the bindings internal transformation.
Just remove this line.

Thanks Rossko57,

I able to read value after removing “modbus:serial.onoffcmdstat.valuetype=bit”. read successfully. However, Still many error in configuration might be.

For reference

ITEM configuration

Switch MySwitch "My Modbus Switch" (ALL) {modbus="onoffcmdstat:0"}
Number Temp "Room Temperature [%.1f °C]" (ALL) {modbus="stat:0"}
Number SetTemp "Set Temperature [%.1f °C]" (ALL) {modbus="stat:1"}

Sitemap configuration

sitemap demo label="HOME" 
{
		Frame label="Home"  {
		Switch item=MySwitch
		Text item=Temp
		Text item=SetTemp
		}
					
}

openHAB_defualt.cfg

modbus:poll=9000
#Room Temperarature AC-1##
modbus:serial.stat.connection=COM4:19200:8:even:1:rtu:35:9000:none:none
modbus:serial.stat.id=1 
modbus:serial.stat.type=input
modbus:serial.stat.start=0
modbus:serial.stat.length=4
######modbus:serial.stat.valuetype=int16
#Air Condtioner Stat AC-1###
modbus:serial.onoffcmdstat.connection=COM4:19200:8:even:1:rtu:9000
modbus:serial.onoffcmdstat.id=1 
modbus:serial.onoffcmdstat.type=discrete
modbus:serial.onoffcmdstat.start=0
modbus:serial.onoffcmdstat.length=8
###########modbus:serial.onoffcmdstat.valuetype=bit

Logs file

Temperature reading using Radzio Modbus master without any error
Room Temperature = 270 i.e 27C
Set Point = 290 i.e 29C
Communication parameter

Hi

Thanks for he extended information

Please make sure you have same connection parameters with all “slaves” pointing to same com port

Now they are different (none:none and 35 in the other slave) and you get

2017-05-08 18:42:19.629 [WARN ] [.modbus.internal.ModbusBinding] - Slave onoffcmdstat (endpoint ModbusSerialSlaveEndpoint@706f882f[portName=COM4]) has different retry/connection delay (EndpointPoolConfiguration) etc. settings. Replacing EndpointPoolConfiguration@25d135b6[passivateBorrowMinMillis=35,interConnectDelayMillis=0,connectMaxTries=3,reconnectAfterMillis=-1,connectTimeoutMillis=0] with EndpointPoolConfiguration@2973efd3[passivateBorrowMinMillis=9000,interConnectDelayMillis=0,connectMaxTries=3,reconnectAfterMillis=-1,connectTimeoutMillis=0]

Best
Sami

Dear Sami,

Thanks for pointing. Corrected as below.

Modbus function-1
modbus:serial.onoffcmdstat.connection=COM4:19200:8:even:1:rtu:9000
Modbus function-2
modbus:serial.stat.connection=COM4:19200:8:even:1:rtu:9000

However if you can analyse below has even single function . successful reading and some are fails.
Full Logs file for Single Modbus reading

2017-05-08 16:51:28.652 [DEBUG] [i.modbus.io.ModbusRTUTransport] - Sent: 01 02 00 00 00 08 79 cc
2017-05-08 16:51:28.797 [TRACE] [i.modbus.io.ModbusRTUTransport] - Managed to read at least one byte
2017-05-08 16:51:28.827 [DEBUG] [i.modbus.io.ModbusRTUTransport] - Response: 01 02 01 08 a0 4e
2017-05-08 16:51:28.838 [INFO ] [w.m.io.ModbusSerialTransaction] - execute eventually succeeded with 1 re-tries. Request: net.wimpi.modbus.msg.ReadInputDiscretesRequest@18b9182e. Serial parameters: SerialParameters@40d29d35[portName=COM4,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-05-08 16:51:28.844 [TRACE] [dbusSlaveConnectionFactoryImpl] - Validating endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4] connection SerialConnection@22e77406[portName=COM4,port=//./COM4] -> true
2017-05-08 16:51:28.849 [TRACE] [dbusSlaveConnectionFactoryImpl] - Passivating connection SerialConnection@22e77406[portName=COM4,port=//./COM4] for endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4]…
2017-05-08 16:51:28.855 [TRACE] [dbusSlaveConnectionFactoryImpl] - (passivate) Connection SerialConnection@22e77406[portName=COM4,port=//./COM4] (endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4]) age (6251ms) is below the reconnectAfterMillis (-1ms) limit. Keep the connection open.
2017-05-08 16:51:28.864 [TRACE] [dbusSlaveConnectionFactoryImpl] - …Passivated connection SerialConnection@22e77406[portName=COM4,port=//./COM4] for endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4]
2017-05-08 16:51:28.867 [TRACE] [.b.modbus.internal.ModbusSlave] - ModbusSlave (onoffcmdstat): returned connection for endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4]
2017-05-08 16:51:28.869 [TRACE] [et.wimpi.modbus.util.BitVector] - Get bit #0
2017-05-08 16:51:31.855 [TRACE] [dbusSlaveConnectionFactoryImpl] - Waited 1983ms (passivateBorrowMinMillis 3000ms) before giving returning connection SerialConnection@22e77406[portName=COM4,port=//./COM4] for endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4], to ensure delay between transactions.
2017-05-08 16:51:31.861 [TRACE] [dbusSlaveConnectionFactoryImpl] - Validating endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4] connection SerialConnection@22e77406[portName=COM4,port=//./COM4] -> true
2017-05-08 16:51:31.866 [TRACE] [.b.modbus.internal.ModbusSlave] - ModbusSlave (onoffcmdstat): borrowing connection (got SerialConnection@22e77406[portName=COM4,port=//./COM4]) for endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4] took 1995 ms
2017-05-08 16:51:31.872 [DEBUG] [i.modbus.io.ModbusRTUTransport] - Sent: 01 02 00 00 00 08 79 cc
2017-05-08 16:51:32.017 [TRACE] [i.modbus.io.ModbusRTUTransport] - Managed to read at least one byte
2017-05-08 16:51:32.046 [DEBUG] [i.modbus.io.ModbusRTUTransport] - Response: 01 02 01 08 a0 4e
2017-05-08 16:51:32.057 [TRACE] [dbusSlaveConnectionFactoryImpl] - Validating endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4] connection SerialConnection@22e77406[portName=COM4,port=//./COM4] -> true
2017-05-08 16:51:32.061 [TRACE] [dbusSlaveConnectionFactoryImpl] - Passivating connection SerialConnection@22e77406[portName=COM4,port=//./COM4] for endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4]…
2017-05-08 16:51:32.070 [TRACE] [dbusSlaveConnectionFactoryImpl] - (passivate) Connection SerialConnection@22e77406[portName=COM4,port=//./COM4] (endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4]) age (9467ms) is below the reconnectAfterMillis (-1ms) limit. Keep the connection open.
2017-05-08 16:51:32.075 [TRACE] [dbusSlaveConnectionFactoryImpl] - …Passivated connection SerialConnection@22e77406[portName=COM4,port=//./COM4] for endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4]
2017-05-08 16:51:32.078 [TRACE] [.b.modbus.internal.ModbusSlave] - ModbusSlave (onoffcmdstat): returned connection for endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4]
2017-05-08 16:51:32.080 [TRACE] [et.wimpi.modbus.util.BitVector] - Get bit #0
2017-05-08 16:51:35.070 [TRACE] [dbusSlaveConnectionFactoryImpl] - Waited 1988ms (passivateBorrowMinMillis 3000ms) before giving returning connection SerialConnection@22e77406[portName=COM4,port=//./COM4] for endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4], to ensure delay between transactions.
2017-05-08 16:51:35.071 [TRACE] [dbusSlaveConnectionFactoryImpl] - Validating endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4] connection SerialConnection@22e77406[portName=COM4,port=//./COM4] -> true
2017-05-08 16:51:35.093 [TRACE] [.b.modbus.internal.ModbusSlave] - ModbusSlave (onoffcmdstat): borrowing connection (got SerialConnection@22e77406[portName=COM4,port=//./COM4]) for endpoint ModbusSerialSlaveEndpoint@4f79f9f2[portName=COM4] took 2011 ms
2017-05-08 16:51:35.095 [DEBUG] [i.modbus.io.ModbusRTUTransport] - Sent: 01 02 00 00 00 08 79 cc
2017-05-08 16:51:38.111 [TRACE] [i.modbus.io.ModbusRTUTransport] - Managed to read at least one byte
2017-05-08 16:51:38.112 [ERROR] [i.modbus.io.ModbusRTUTransport] - Last request: 01 02 00 00 00 08 79 cc
2017-05-08 16:51:38.113 [ERROR] [i.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2017-05-08 16:51:38.122 [ERROR] [w.m.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputDiscretesRequest@31fdefeb (unit id 1 & transaction 7). Serial parameters: SerialParameters@40d29d35[portName=COM4,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-05-08 16:51:41.124 [DEBUG] [i.modbus.io.ModbusRTUTransport] - Sent: 01 02 00 00 00 08 79 cc
2017-05-08 16:51:44.133 [TRACE] [i.modbus.io.ModbusRTUTransport] - Managed to read at least one byte
2017-05-08 16:51:44.136 [ERROR] [i.modbus.io.ModbusRTUTransport] - Last request: 01 02 00 00 00 08 79 cc
2017-05-08 16:51:44.141 [ERROR] [i.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)

Regards

Hitesh Patel

Hi

Thanks for the fast reply

You can try to make the binding slower :

  • increase interConnectDelayMillis to 500, see wiki for details
  • increase receiveTimeoutMillis to 3000

Best
Sami

Dear Sami,

Thanks. As per your recommendation, new lines are in openHAB_default.cfg. Please confirm my understanding are correct ?

modbus:poll=9000
#Room Temperarature AC-1#
modbus:serial.stat.connection=COM4:19200:8:even:1:rtu:9000
modbus:serial.stat.interTransactionDelayMillis=500
modbus:serial.stat.increase receiveTimeoutMillis=3000
modbus:serial.stat.id=1
modbus:serial.stat.type=input
modbus:serial.stat.start=0
modbus:serial.stat.length=4

#Air Condtioner Stat AC-1#
modbus:serial.onoffcmdstat.connection=COM4:19200:8:even:1:rtu:9000
modbus:serial.onoffcmdstat.interTransactionDelayMillis=500
modbus:serial.onoffcmdstat.increase receiveTimeoutMillis=3000
modbus:serial.onoffcmdstat.id=1
modbus:serial.onoffcmdstat.type=discrete
modbus:serial.onoffcmdstat.start=0
modbus:serial.onoffcmdstat.length=8

No that is not what i meant. Can you please consult the docs for the exact syntax?

The parameters go to the connection string

Best
Sami

Noted: It should as per below. I will check and confirm back.

modbus:poll=9000
#Room Temperarature AC-1#
modbus:serial.stat.connection=COM4:19200:8:even:1:rtu:500:3000
modbus:serial.stat.id=1
modbus:serial.stat.type=input
modbus:serial.stat.start=0
modbus:serial.stat.length=4

#Air Condtioner Stat AC-1#
modbus:serial.onoffcmdstat.connection=COM4:19200:8:even:1:rtu:500:3000
modbus:serial.onoffcmdstat.id=1
modbus:serial.onoffcmdstat.type=discrete
modbus:serial.onoffcmdstat.start=0
modbus:serial.onoffcmdstat.length=8

1 Like

As per your suggestion, I had re-configure configuration, However my configuration is still faulty.
I am trying to read after many attempt it able to read after than it is again fail to read.
Note: I am using single function.

.Items

Switch ACONOFFSTAT "AC" (ALL) {modbus="onoffcmdstat:0"}

sitemaps
sitemap demo label=“HOME”
{
Frame label=“Home” {
Switch item=ACONOFFSTAT
}
}

Openhab.cfg

Air Conditioner Stat AC-1

modbus:serial.onoffcmdstat.connection=COM4:19200:8:even:1:rtu:500:3000:none:none
modbus:serial.onoffcmdstat.id=1
modbus:serial.onoffcmdstat.type=discrete
modbus:serial.onoffcmdstat.start=0
modbus:serial.onoffcmdstat.length=2

Full Logs files
https://pastebin.com/1cgtSt3M

Communication Reconfirmation



Thanks for this. This test confirms that the errors remain even with slow/seldom queries.

If I understand correctly, the read works successfully with “Modbus poll” application?

Best,
Sami

Dear Sami,

Yes, I am able to read data using Radzio Modbus & Modbus Poll modbus master simulator.
their communication’s configuration parameter also i had posted in forum.

Regards

Hitesh Patel

Thanks

This might be a bit far fetched but still worth a try. You have flow control defined in the windows software. Should you define it in the binding as well?

Could you try with different flow control settings? I am sorry but not too familiar what the alternatives actually mean in practice and what would correspond to the windows application…

Best
Sami

Maybe it is not that far fetched. hitesh.patel didn’t mention what kind of RS485 converter is used. Nowadays one would use something like an ftdi chip (ft232 or similiar) + RS485 transceiver. The transmit enable signal for the RS485 transceiver is automatically generated by the ftdi chip and there is no need to take care of that in software. BUT some rather simple RS232 to RS485 converters just use the RTS line of the RS232 interface as a transmit enable signal for the RS485 transceiver. In that case you need to enable that in the software you are using - just like it’s done in the screenshot…

I don’t have any datasheet to share but i am using USB to Rs485 converter same as above.

I haven’t done any flow control in both software. It is default software’s configuration. If it necessary to configure, I will configure it and respond back.

How ever my understating of configuration require is as follows

modbus:serial.onoffcmdstat.connection=COM4:19200:8:even:1:rtu:500:3000:rts/cts in:rts/cts out

please confirm opernHAB configuration.