[SOLVED] OpenHab2 ModBus binding connection problem

  • Platform information:

    • Hardware: Intel i7-4790K
    • OS: Windows 8.1 Pro - 64bit
    • Java Runtime Environment: jdk1.8.0_181
    • openHAB version: 2.3.0
  • Issue of the topic: I am trying to configure ModBus serial binding for openhub, but it fail to connect to the COM port. I tried connecting to Arduino ModBus slave as well as to mod_RSsim through Null-modem emulator (com0com).

I have clean OpenHab instalation with ModBus binding installed using paper UI (binding-modbus1 - 1.12.0).

I have changed the modbus.cfg file and added to the end of the dovcument:

serial.slave1.connection=COM4
serial.slave1.type=coil
serial.slave1.lenght=1

I have created home.items file and added switch item:

Switch  MB_LED 	 	"LED" 			(All){modbus="slave1:0"}

I have created home.sitemap and added frame:

sitemap demo label="My home automation" {
	Frame {
			Switch item= MB_LED	
	}	
}

When I start OpenHab no connection happening and there is log file report below:

2018-07-27 17:20:30.104 [INFO ] [er.internal.HomeBuilderDashboardTile] - Started Home Builder at /homebuilder
2018-07-27 17:20:31.932 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.0.127:8090
2018-07-27 17:20:31.933 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.0.127:8443
2018-07-27 17:20:33.289 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.items'
2018-07-27 17:20:33.785 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-07-27 17:20:33.949 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.sitemap'
2018-07-27 17:20:34.428 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-07-27 17:20:34.459 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-07-27 17:20:34.471 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-07-27 17:20:34.492 [INFO ] [sysfs.internal.SysfsUsbSerialScanner] - Cannot perform scans with this configuration: sysfsTtyDevicesDirectory: /sys/class/tty, devDirectory: /dev
2018-07-27 17:20:34.495 [INFO ] [sysfs.internal.SysfsUsbSerialScanner] - Cannot perform scans with this configuration: sysfsTtyDevicesDirectory: /sys/class/tty, devDirectory: /dev
2018-07-27 17:20:34.497 [INFO ] [sfs.internal.PollingUsbSerialScanner] - Do not start background scanning, as the configured USB-Serial scanner cannot perform scans on this system
2018-07-27 17:20:34.498 [INFO ] [sfs.internal.PollingUsbSerialScanner] - Do not start background scanning, as the configured USB-Serial scanner cannot perform scans on this system
2018-07-27 17:20:34.537 [INFO ] [b.core.service.AbstractActiveService] - Modbus Polling Service has been started
2018-07-27 17:20:36.331 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: readResponse I/O exception - failed to read: readResponse: I/O exception - Serial port timeout.. Request: net.wimpi.modbus.msg.ReadCoilsRequest@aa5eb18 (unit id 1 & transaction 1). Serial parameters: SerialParameters@5fc22def[portName=COM4,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=ascii,echo=false,receiveTimeoutMillis=1500]
2018-07-27 17:20:37.868 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 2/3 error: readResponse I/O exception - failed to read: readResponse: I/O exception - Serial port timeout.. Request: net.wimpi.modbus.msg.ReadCoilsRequest@aa5eb18 (unit id 1 & transaction 2). Serial parameters: SerialParameters@5fc22def[portName=COM4,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=ascii,echo=false,receiveTimeoutMillis=1500]
2018-07-27 17:20:39.405 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 3/3 error: readResponse I/O exception - failed to read: readResponse: I/O exception - Serial port timeout.. Request: net.wimpi.modbus.msg.ReadCoilsRequest@aa5eb18 (unit id 1 & transaction 3). Serial parameters: SerialParameters@5fc22def[portName=COM4,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=ascii,echo=false,receiveTimeoutMillis=1500]
2018-07-27 17:20:39.405 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 3, throwing last error: readResponse I/O exception - failed to read: readResponse: I/O exception - Serial port timeout.. Request: net.wimpi.modbus.msg.ReadCoilsRequest@aa5eb18 (unit id 1 & transaction 3). Serial parameters: SerialParameters@5fc22def[portName=COM4,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=ascii,echo=false,receiveTimeoutMillis=1500]
2018-07-27 17:20:39.405 [ERROR] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (slave1): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@aa5eb18. Error: readResponse I/O exception - failed to read: readResponse: I/O exception - Serial port timeout.. Endpoint ModbusSerialSlaveEndpoint@25e4957f[portName=COM4]. Connection: SerialConnection@5053abb1[portName=COM4,port=//./COM4]
2018-07-27 17:20:41.120 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: readResponse I/O exception - failed to read: readResponse: I/O exception - Serial port timeout.. Request: net.wimpi.modbus.msg.ReadCoilsRequest@50d0c779 (unit id 1 & transaction 4). Serial parameters: SerialParameters@5fc22def[portName=COM4,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=ascii,echo=false,receiveTimeoutMillis=1500]
2018-07-27 17:20:42.657 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 2/3 error: readResponse I/O exception - failed to read: readResponse: I/O exception - Serial port timeout.. Request: net.wimpi.modbus.msg.ReadCoilsRequest@50d0c779 (unit id 1 & transaction 5). Serial parameters: SerialParameters@5fc22def[portName=COM4,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=ascii,echo=false,receiveTimeoutMillis=1500]
2018-07-27 17:20:44.194 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 3/3 error: readResponse I/O exception - failed to read: readResponse: I/O exception - Serial port timeout.. Request: net.wimpi.modbus.msg.ReadCoilsRequest@50d0c779 (unit id 1 & transaction 6). Serial parameters: SerialParameters@5fc22def[portName=COM4,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=ascii,echo=false,receiveTimeoutMillis=1500]
2018-07-27 17:20:44.194 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 3, throwing last error: readResponse I/O exception - failed to read: readResponse: I/O exception - Serial port timeout.. Request: net.wimpi.modbus.msg.ReadCoilsRequest@50d0c779 (unit id 1 & transaction 6). Serial parameters: SerialParameters@5fc22def[portName=COM4,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=ascii,echo=false,receiveTimeoutMillis=1500]
2018-07-27 17:20:44.194 [ERROR] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (slave1): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@50d0c779. Error: readResponse I/O exception - failed to read: readResponse: I/O exception - Serial port timeout.. Endpoint ModbusSerialSlaveEndpoint@25e4957f[portName=COM4]. Connection: SerialConnection@1e333c05[portName=COM4,port=//./COM4]

com0com is set to virtual port pair COM4-COM5.
mod_RSsim is connected to COM5; baud rate 9600; parity:none; data bits 8; stop bits 1; RTS control - disable.

What am I doing wrong?
Thank you!

Solved it myself at the end. There are some problems with older version of ModBus (which I used in previous example 1.12.0). It does not work well.
I have found that there is new version of ModBus, but it is not listed in paper UI by default.
To download new version of ModBus you should follow this instruction - https://community.openhab.org/t/modbus-openhab2-binding-available-for-alpha-testing/27657

  1. Download Eclipse IoT Marketplace add-on using paper UI, it is in the MISC tab.
  2. Do not forget to restart openhab after install.
  3. Install ModBus transport binding add-on using paper UI.
  4. Do not forget to restart openhab after install.
  5. Install ModBus binding add-on using paper UI.
  6. Do not forget to restart openhab after install.
  7. Now you can set up your modbus master device in paper UI by adding things.

It worked for me, but took too much time to understand all this information, because first of all I did not know about Eclipse Marketplace. Wish good luck to everyone!