Modbus binding limitation / advice

Hi!

Since the serial library in openhab have been recently updated, please try to update your binding first to latest 1.9.0-SNAPSHOT (link). If you are using apt based openhab distribution, make sure you have the latest 1.9.0-SNAPSHOT of org.openhab.io.transport.serial installed.

If that does not work, we can try to tunes the connection parameters to be slower.

I also noticed that you could combine cg2 - cg9 slaves into single slave definition using length parameter?

Best
Sami

Hi,

Thanks for the suggestions. Seem that I need more advice.

I updated modbus binding, that did not help.

Yes, I use apt based, and serial is 1.8.3. Trying to force update of the serial packages, apt says that package is latest version. I did not find serial packages for 1.9.0-SNAPSHOT. I did find binding.serial, but did not io.transport.serial. Without it - does not work.

In order to get it back, I went back to 1.8.3 for packages mentioned. But seem that I have broken something in the process, now I can’t get modbus to work at all :frowning:

While trying to get it back, I tried to lower poll rate and modbus speed, but to no avail.

I have a feeling that problem is not with modbus, it is with serial. I do not know if I told, I have 2 serial interfaces to my system. One is

[    1.945325] usb 1-2: Detected FT232RL
[    1.945741] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0

I use for MySensors gateway, the other is

[    1.947051] pl2303 1-4:1.0: pl2303 converter detected
[    1.947971] usb 1-4: pl2303 converter now attached to ttyUSB1

Whenever I try to activate second serial, I get messages like these (dmesg):

[   33.807749] ttyUSB0: 1 input overrun(s)
[  194.211791] ttyUSB0: 1 input overrun(s)

Sometimes after that I get modbus working, sometimes not. This time I can’t, so switched it off for now :frowning:

Any idea how to proceed will be appreciated!

1.8.3. is almost unusable with serial modbus so I would not spend too much time with it.

Unfortunately I do not know how to install snapshot version with the apt get approach. The main repos include release versions only, not sure if there is separate snapshot repo available.

One way that could work would be to remove the modbus apt packages, and pushing the 1.9.0 SNAPSHOT jar files manually to addons directory. What do you think?

Note that binding.serial is separate from transport so you do not need to touch that.

Best,
Sami

Ok, I tried it once more. I put there 1.9.0 serial and modbus:

:/usr/share/openhab/addons$ ls
org.openhab.binding.http-1.8.3.jar
org.openhab.binding.milight-1.8.3.jar
org.openhab.binding.modbus-1.9.0-SNAPSHOT.jar
org.openhab.binding.ntp-1.8.3.jar
org.openhab.binding.serial-1.9.0-SNAPSHOT.jar
org.openhab.io.openhabcloud_1.9.0.201612192331.jar
org.openhab.io.transport.serial-1.8.3.jar
org.openhab.persistence.exec-1.8.3.jar
org.openhab.persistence.logging-1.8.3.jar
org.openhab.persistence.mapdb-1.8.3.jar
org.openhab.persistence.rrd4j-1.8.3.jar
README

commented out all modbus slaves but one in openhab.cfg:

############################### Modbus Binding ########################################
#
# sets refresh interval to Modbus polling service. 
# Value in milliseconds (optional, defaults to 200)
modbus:poll=200

# host:port (mandatory)
# The data type, can be "coil" "discrete" "holding" "input"
# The slave id (optional, defaults to '1')
# The slave start address (optional, defaults to '0')
# The number of data item to read (optional, defaults to '0' - but set it to something meaningful)

modbus:serial.cg1.connection=/dev/ttyUSB1:9600:8:none:1:rtu
modbus:serial.cg1.type=holding
modbus:serial.cg1.id=1
modbus:serial.cg1.start=0
modbus:serial.cg1.length=8

#.
#modbus:serial.cg2.connection=/dev/ttyUSB1:9600:8:none:1:rtu
#modbus:serial.cg2.type=holding
#modbus:serial.cg2.id=1
#modbus:serial.cg2.start=12288
#modbus:serial.cg2.length=1

#.
#modbus:serial.cg3.connection=/dev/ttyUSB1:9600:8:none:1:rtu
#modbus:serial.cg3.type=holding
#modbus:serial.cg3.id=1
#modbus:serial.cg3.start=12289
#modbus:serial.cg3.length=1

#modbus:serial.cg4.connection=/dev/ttyUSB1:9600:8:none:1:rtu
#modbus:serial.cg4.type=holding
#modbus:serial.cg4.id=1
#modbus:serial.cg4.start=12290
#modbus:serial.cg4.length=1

#.
#modbus:serial.cg5.connection=/dev/ttyUSB1:9600:8:none:1:rtu
#modbus:serial.cg5.type=holding
#modbus:serial.cg5.id=1
#modbus:serial.cg5.start=12291
#modbus:serial.cg5.length=1

#modbus:serial.cg6.connection=/dev/ttyUSB1:9600:8:none:1:rtu
#modbus:serial.cg6.type=holding
#modbus:serial.cg6.id=1
#modbus:serial.cg6.start=12292
#modbus:serial.cg6.length=1

#modbus:serial.cg7.connection=/dev/ttyUSB1:9600:8:none:1:rtu
#modbus:serial.cg7.type=holding
#modbus:serial.cg7.id=1
#modbus:serial.cg7.start=12293
#modbus:serial.cg7.length=1

#.
#modbus:serial.cg8.connection=/dev/ttyUSB1:9600:8:none:1:rtu
#modbus:serial.cg8.type=holding
#modbus:serial.cg8.id=1
#modbus:serial.cg8.start=12294
#modbus:serial.cg8.length=1

#modbus:serial.cg9.connection=/dev/ttyUSB1:9600:8:none:1:rtu
#modbus:serial.cg9.type=holding
#modbus:serial.cg9.id=1
#modbus:serial.cg9.start=12295
#modbus:serial.cg9.length=1

# Value type, required for combined registers (details: http://www.simplymodbus.ca/FAQ.htm#Types)
# Can be "bit", "int8", "uint8", "int16", "uint16", "int32", "uint32", "float32"
# (optional, defaults to 'uint16')
#modbus:serial.cg1.valuetype=uint16
#modbus:serial.cg2.valuetype=uint16
#modbus:serial.cg3.valuetype=bit

(you may notice that I lowered modbus interface speed to 9600 baud) and restarted openhab service. I got this in the openhab.log:

2017-01-16 23:26:59.145 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2017-01-16 23:26:59.193 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
2017-01-16 23:27:00.615 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
2017-01-16 23:27:08.897 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model '___I EDITED THIS OUT___.sitemap'
2017-01-16 23:27:09.050 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'exec.persist'
2017-01-16 23:27:09.065 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'
2017-01-16 23:27:09.073 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'mapdb.persist'
2017-01-16 23:27:09.076 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'logging.persist'
2017-01-16 23:27:09.089 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model '___I EDITED THIS OUT___.items'
2017-01-16 23:27:09.637 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /classicui/openhab.app
2017-01-16 23:27:13.460 [INFO ] [.service.AbstractActiveService] - Modbus Polling Service has been started
2017-01-16 23:27:13.507 [INFO ] [.p.rrd4j.internal.RRD4jService] - Removing invalid defintion component = null heartbeat = 0 min/max = 0.0/0.0 step = 0 0 archives(s) = [] 0 items(s) = []
2017-01-16 23:27:14.057 [INFO ] [o.o.i.o.internal.CloudClient  ] - Connected to the openHAB Cloud service (UUID = ___I EDITED THIS OUT___, local base URL = http://localhost:8080)
2017-01-16 23:27:14.328 [ERROR] [pi.modbus.net.SerialConnection] - open port failed: Unknown Linux Application
2017-01-16 23:27:14.332 [ERROR] [dbusSlaveConnectionFactoryImpl] - connect try 1/3 error: open port failed: Unknown Linux Application. Connection SerialConnection@4bf70952[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@675fc2c3[portName=/dev/ttyUSB1]
2017-01-16 23:27:14.353 [INFO ] [.service.AbstractActiveService] - HTTP Refresh Service has been started
2017-01-16 23:27:14.370 [ERROR] [pi.modbus.net.SerialConnection] - open port failed: Unknown Linux Application
2017-01-16 23:27:14.370 [ERROR] [dbusSlaveConnectionFactoryImpl] - connect try 2/3 error: open port failed: Unknown Linux Application. Connection SerialConnection@4bf70952[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@675fc2c3[portName=/dev/ttyUSB1]
2017-01-16 23:27:14.407 [ERROR] [pi.modbus.net.SerialConnection] - open port failed: Unknown Linux Application
2017-01-16 23:27:14.407 [ERROR] [dbusSlaveConnectionFactoryImpl] - connect try 3/3 error: open port failed: Unknown Linux Application. Connection SerialConnection@4bf70952[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@675fc2c3[portName=/dev/ttyUSB1]
2017-01-16 23:27:14.408 [ERROR] [dbusSlaveConnectionFactoryImpl] - re-connect reached max tries 3, throwing last error: open port failed: Unknown Linux Application. Connection SerialConnection@4bf70952[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@675fc2c3[portName=/dev/ttyUSB1]
2017-01-16 23:27:14.408 [ERROR] [dbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection@4bf70952[portName=/dev/ttyUSB1,port=<null>] for endpoint ModbusSerialSlaveEndpoint@675fc2c3[portName=/dev/ttyUSB1]: open port failed: Unknown Linux Application
2017-01-16 23:27:14.408 [WARN ] [.b.modbus.internal.ModbusSlave] - ModbusSlave (cg1): Error getting a new connection for endpoint ModbusSerialSlaveEndpoint@675fc2c3[portName=/dev/ttyUSB1]. Error was: Unable to validate object
2017-01-16 23:27:14.408 [WARN ] [.b.modbus.internal.ModbusSlave] - ModbusSlave (cg1) not connected -- aborting read request net.wimpi.modbus.msg.ReadMultipleRegistersRequest@1ebbd5c8. Endpoint ModbusSerialSlaveEndpoint@675fc2c3[portName=/dev/ttyUSB1]
2017-01-16 23:27:14.543 [INFO ] [.service.AbstractActiveService] - NTP Refresh Service has been started
2017-01-16 23:27:14.611 [ERROR] [pi.modbus.net.SerialConnection] - open port failed: Unknown Linux Application
2017-01-16 23:27:14.612 [ERROR] [dbusSlaveConnectionFactoryImpl] - connect try 1/3 error: open port failed: Unknown Linux Application. Connection SerialConnection@77316d9b[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@675fc2c3[portName=/dev/ttyUSB1]
2017-01-16 23:27:14.649 [ERROR] [pi.modbus.net.SerialConnection] - open port failed: Unknown Linux Application
2017-01-16 23:27:14.650 [ERROR] [dbusSlaveConnectionFactoryImpl] - connect try 2/3 error: open port failed: Unknown Linux Application. Connection SerialConnection@77316d9b[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@675fc2c3[portName=/dev/ttyUSB1]
2017-01-16 23:27:14.687 [ERROR] [pi.modbus.net.SerialConnection] - open port failed: Unknown Linux Application
2017-01-16 23:27:14.688 [ERROR] [dbusSlaveConnectionFactoryImpl] - connect try 3/3 error: open port failed: Unknown Linux Application. Connection SerialConnection@77316d9b[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@675fc2c3[portName=/dev/ttyUSB1]

I did reboot the system. Noticed that this is again there for the other serial ttyUSB0 (dmesg):

[   28.490609] ttyUSB0: 1 input overrun(s)

openhab.log looked a bit different, but still not working:

2017-01-16 23:36:23.347 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.8.3).
2017-01-16 23:36:24.462 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2017-01-16 23:36:24.533 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
2017-01-16 23:36:26.928 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
2017-01-16 23:36:34.150 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model '___I EDITED THIS OUT___.sitemap'
2017-01-16 23:36:34.442 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'exec.persist'
2017-01-16 23:36:34.478 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'
2017-01-16 23:36:34.495 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'mapdb.persist'
2017-01-16 23:36:34.503 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'logging.persist'
2017-01-16 23:36:34.543 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model '___I EDITED THIS OUT___.items'
2017-01-16 23:36:34.893 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /classicui/openhab.app
2017-01-16 23:36:39.419 [INFO ] [.service.AbstractActiveService] - HTTP Refresh Service has been started
2017-01-16 23:36:39.907 [INFO ] [o.o.i.o.internal.CloudClient  ] - Connected to the openHAB Cloud service (UUID = ___I EDITED THIS OUT___, local base URL = http://localhost:8080)
2017-01-16 23:36:40.354 [INFO ] [.service.AbstractActiveService] - NTP Refresh Service has been started
2017-01-16 23:36:40.380 [INFO ] [.p.rrd4j.internal.RRD4jService] - Removing invalid defintion component = null heartbeat = 0 min/max = 0.0/0.0 step = 0 0 archives(s) = [] 0 items(s) = []
2017-01-16 23:36:40.526 [INFO ] [.service.AbstractActiveService] - Modbus Polling Service has been started
2017-01-16 23:36:42.063 [ERROR] [i.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 00 00 08 44 0c
2017-01-16 23:36:42.064 [ERROR] [i.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2017-01-16 23:36:42.068 [ERROR] [w.m.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@7b4b0956 (unit id 1 & transaction 1). Serial parameters: SerialParameters@91e94b7[portName=/dev/ttyUSB1,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-01-16 23:36:43.604 [ERROR] [i.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 00 00 08 44 0c
2017-01-16 23:36:43.604 [ERROR] [i.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2017-01-16 23:36:43.605 [ERROR] [w.m.io.ModbusSerialTransaction] - execute try 2/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@7b4b0956 (unit id 1 & transaction 1). Serial parameters: SerialParameters@91e94b7[portName=/dev/ttyUSB1,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-01-16 23:36:44.702 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model '___I EDITED THIS OUT___.rules'
2017-01-16 23:36:45.142 [ERROR] [i.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 00 00 08 44 0c
2017-01-16 23:36:45.142 [ERROR] [i.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2017-01-16 23:36:45.143 [ERROR] [w.m.io.ModbusSerialTransaction] - execute try 3/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@7b4b0956 (unit id 1 & transaction 1). Serial parameters: SerialParameters@91e94b7[portName=/dev/ttyUSB1,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-01-16 23:36:45.143 [ERROR] [w.m.io.ModbusSerialTransaction] - execute reached max tries 3, throwing last error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@7b4b0956. Serial parameters: SerialParameters@91e94b7[portName=/dev/ttyUSB1,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-01-16 23:36:45.143 [ERROR] [.b.modbus.internal.ModbusSlave] - ModbusSlave (cg1): Error getting modbus data for request net.wimpi.modbus.msg.ReadMultipleRegistersRequest@7b4b0956. Error: I/O exception - failed to read. Endpoint ModbusSerialSlaveEndpoint@4f1a75c5[portName=/dev/ttyUSB1]. Connection: SerialConnection@3deb9dcd[portName=/dev/ttyUSB1,port=/dev/ttyUSB1]

I tried couple more reboots and openhab service restarts (helped to get it working previously), but no success. Removed modbus binding form addons, reboot, system back to stable.

I’d appreciate if you’d take a look and suggest the next step for me.

Hi,

Sorry to hear that you are having trouble. The error seems to be low level, and I could not find anything from these forums regarding this. The low level serial issues need to be resolved before we can start to work on modbus.

Removed modbus binding form addons, reboot, system back to stable.

Did you revert to modbus 1.8.3? Is there any binding accessing the ttyUSB1 serial line with the “stable” setup?

Regarding

open port failed: Unknown Linux Application

have not seen this before nor could I find anyone with this issue :frowning: I hope you have added openhab user to the correct user groups, see Note 4 in the serial binding wiki

[ 28.490609] ttyUSB0: 1 input overrun(s)

You mentioned previously that

Please note that modbus slave is on ttyUSB1, not ttyUSB0. On ttyUSB0 there is serial interface to Arduino based gateway for communication with MySensors devices.

So I’m thinking that this not related to the modbus binding in any way.

Not too familiar with these things but this discussion indicates that

This happens from reading the receiver buffer to infrequently.

Perhaps you should open up a separate thread on this topic? If you are using serial binding with ttyUSB0, please mention that in the new thread.

Finally, just to be sure, do you have anything else in addition to modbus binding accessing ttyUSB1 at the same time? I noticed that you had that at least serial binding installed.

Best,
Sami

Did you revert to modbus 1.8.3? Is there any binding accessing the ttyUSB1 serial line with the “stable” setup?

Not this time. I removed modbus binding from the system. Although, I gave tried to revert to 1.8.3 binding previously, but that did not help.

I hope you have added openhab user to the correct user groups, see Note 4 in the serial binding wiki

Yes, of course. Any serial interface would not work otherwise. ttyUSB0 is still working fine.

So I’m thinking that this not related to the modbus binding in any way.

I have the same feeling for quite some time.

Not too familiar with these things but this discussion indicates that

I have seen that thread. Overload might be the case. Unfortunately I’m not that good with Linux to figure how to tune it myself. I have thought of moving from serial to TCP/IP for communication with MySensors gateway and modbus device, but that would take quite a bit of redesigning both HW and SW I have made.

Perhaps you should open up a separate thread on this topic?

Yes, I’m going to.

Finally, just to be sure, do you have anything else in addition to modbus binding accessing ttyUSB1 at the same time? I noticed that you had that at least serial binding installed.

No. At least not intentionally configured. I lack the knowledge how to trace if anything else is actually accessing that interface.

Thanks for taking your time on this!

Sorry Tim, I missed your reply in December. No I haven’t looked into managing CG dimming from OpenHab. Seem that I’m not going to in the near future, because currently my OpenHab-CG communication is broken and I’m trying to get back basics. Also, I do not believe the designs match for easy dimming. I commented that somewhere previously on this thread.

Hi Janis, I have the dimming working now. And even via Amazon Echo. I can say dim lounge lights to xx% and Openhab sends the xx% level to the CG controller and dimming function. Now I am working on controlling temperatures via Openhab and Amazon Echo.

Good to hear! What was your solution idea? I can’t think of a good one because my CG dimmers does not accept receiving % by design, just up and down.

I’m back to this topic. After your suggestion I made new topic about serial issues. Those are solved.

But I’m back to the adding modbus slaves problem. As before: whenever I activate cg8 slave (see config earlier in this topic), modbus stops working. Symptom is that cg1 slave is throwing this in openhab.log:

2017-01-24 22:46:13.743 [INFO ] [.service.AbstractActiveService] - Modbus Polling Service has been started
2017-01-24 22:46:15.358 [ERROR] [i.modbus.io.ModbusRTUTransport] - Last request: 01 03 30 06 00 01 6b 0b
2017-01-24 22:46:15.358 [ERROR] [i.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2017-01-24 22:46:15.363 [ERROR] [w.m.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to
 read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@34e572e2 (unit id 1 & transaction 3). Serial para
meters: SerialParameters@15ccf8fe[portName=/dev/ttyCarloGavazzi,baudRate=115200,flowControlIn=none,flowControlOut=n
one,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-01-24 22:46:16.899 [ERROR] [i.modbus.io.ModbusRTUTransport] - Last request: 01 03 30 06 00 01 6b 0b
2017-01-24 22:46:16.899 [ERROR] [i.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2017-01-24 22:46:16.899 [ERROR] [w.m.io.ModbusSerialTransaction] - execute try 2/3 error: I/O exception - failed to
 read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@34e572e2 (unit id 1 & transaction 3). Serial para
meters: SerialParameters@15ccf8fe[portName=/dev/ttyCarloGavazzi,baudRate=115200,flowControlIn=none,flowControlOut=n
one,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-01-24 22:46:18.436 [ERROR] [i.modbus.io.ModbusRTUTransport] - Last request: 01 03 30 06 00 01 6b 0b
2017-01-24 22:46:18.437 [ERROR] [i.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2017-01-24 22:46:18.437 [ERROR] [w.m.io.ModbusSerialTransaction] - execute try 3/3 error: I/O exception - failed to
 read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@34e572e2 (unit id 1 & transaction 3). Serial para
meters: SerialParameters@15ccf8fe[portName=/dev/ttyCarloGavazzi,baudRate=115200,flowControlIn=none,flowControlOut=n
one,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-01-24 22:46:18.437 [ERROR] [w.m.io.ModbusSerialTransaction] - execute reached max tries 3, throwing last error
: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@34e572e2. Serial parameters: SerialParameters@15ccf8fe[portName=/dev/ttyCarloGavazzi,baudRate=115200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2017-01-24 22:46:18.438 [ERROR] [.b.modbus.internal.ModbusSlave] - ModbusSlave (cg8): Error getting modbus data for request net.wimpi.modbus.msg.ReadMultipleRegistersRequest@34e572e2. Error: I/O exception - failed to read. Endpoint ModbusSerialSlaveEndpoint@119409c[portName=/dev/ttyCarloGavazzi]. Connection: SerialConnection@14d86bc9[portName=/dev/ttyCarloGavazzi,port=/dev/ttyCarloGavazzi]

Any ideas?

Remind us what the physical device(s) are? Is it one real device and you have set up several logical OH slaves? How are cg2 to cg7 getting on now?

The physical device ir Carlo Gavazzi Dupline Master Channel Generator I use as smarthome controller. Shortly: majority of the lights and electricity outlets in a house is controlled by that device.

All OH slaves in my config refer to that device: cg1 for polling status of the whole table, cg2-cg7 for writing (8 pcs 16 bit registers).

I have activated cg1, cg2, cg5. Writing to all three is working.

PS Just thinking aloud: isn’t it a config problem? It does not take an actual write to any of cg2-cg9 slaves to get to the problem. Read from cg1 is “broken” immediately after restart after adding extra slave.

Might well be config at one end or other. What is different about cg8.
But Modbus binding will poll (read) values from device on start up, which will show up any read failure such as you seem to get. No write/command is needed.

cg8 is no different according to my knowledge.

CG controller has 128 controllable addresses. I use cg1 for reading 8 16bit registers and cg2-9 for writing 8 16bit registers. Approach for writing is different by controller’s design: it allows to read the whole table, but writing is possible just to single 16bit register at a time. All addresses are equal in CG.

To my understanding, from OH perspective, the only difference I can see between non-problematic behaviour and the problematic one is number of slaves defined in openhab.cfg: 4 slaves versus 5. I have seen posts from the others using CG controllers that they have tens of slaves defined. Not exactly the same model thou, so it still might be CG which can’t handle OH.

Question: does modbus binding actually does something on modbus line on startup? I mean, does binding communicates anything on the line when it reads config from openhab.cfg (before it actually starts reading data/writing)?

Next thing which comes to my mind is that CG modbus addresses I’m using for cg2-9 for writing are actually not ment for reading, just writing. I dicovered that those addresses does not throw error on read by luck. Might be that CG does not “like” a lot of polling from those addresses. Also might be that OH can’t handle CG reply.

I tried two things today.

First, I tried to lower serial speed: 115200, 57600, 38400. No difference.

Second, I tried to comment out/disable cg2 instead of cg8. Still errors from cg8. That indicates that cg8 is different…

I think I found the reason.

I tried to poll each of cg2-9 addresses with modpoll tool directly outside OH.

modbus addresses 12288-12291 return data on read, but 12292-12295 give reply timeout. So, here is the difference. I really need not polling those addressess, just writing.

And my thanks goes to @rossko57 again! Your question about how cg8 might be different made me think in the right direction.

Glad you are getting to the bottom of it. Sounds like the CG slave isn’t fully following the Modbus rules - if you try to read (or write) an invalid register address, a slave should give a rejection response.
Rather than just nothing. Still a failure of course but you would see something more meaningful in your log.

As a general observation, the writeable Modbus coil and holding register types are also expected to be readable. Therefore OH Modbus binding will attempt to read them when it polls.
I’m not sure if that happens if the registers are just in the config, or if you also need to define an item bound to one of that slave.

Now to your specific case; you do not have to define individual slaves to ensure that a block of registers are written only one at a time.
The binding has an option parameter writemultipleregisters If that is false (the default) the binding will use Modbus FC6 write-single for any updates.
Only if it is true will the binding use FC16 for block write, which not all devices support.
So as @ssalonen says, you could/should configure your consecutive registers as a single OH logical slave.

As for write-only registers, I cannot think of a good way around that - googling suggests this is not the only device with write-only registers in the world, but there is no built-in capability in OH. It’s a bonkers concept really. Sure you cannot ‘fix’ the CG device?

You could try configuring the OH item with different read and write bindings as per “Separate coils for reading and writing” in the Wiki. Just use any valid register for the read, you ignore that value as you know the OH item is write-only. I don’t know if is possible to define the out with no in for a true write-only Item.
Reckon you’ll still get polling errors though.

Nice debugging, good to know that EOF can occur because of that as well.

Not with current version , no. The transformation support I have been working on does have this feature (I took the opportunity to introduce more extended configuration syntax), will hopefully release a test version for that during next couple of weeks

Best
Sami