Modbus binding after migration OH1->OH2

Hi !
I have migrated my system from OH1.8 to OH2.3 and most of the issues I have solve, except Modbus.
So in OH1.8 I have following config:

serial.went_temp.connection=/dev/ttyUSB0:9600:8:even:1:rtu
serial.went_temp.id=10
serial.went_temp.start=16
serial.went_temp.type=input
serial.went_temp.length=6
serial.went_temp.valuetype=int16

and item:

Number Went_Temp_Zewn_M (Wentylacja) {modbus=“went_temp:0”}

On OH1.8 I have no problem with such config. On OH 2.3 I have tested few buddings: 1.12 (installed via PaperUI), 1.9.0 - no luck :roll_eyes:. I got std problem with lack of connections:

> 2018-10-11 21:17:50.955 [ERROR[ t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 0a 03 00 04 00 03 45 71 
> 2018-10-11 21:17:50.958 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 0 bytes: 
> 2018-10-11 21:17:50.961 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@b1071 (unit id 10 & transaction 54). Serial parameters: SerialParameters@7e8781[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

As I understand it should work as it was on OH1 when I use modbus binding <2.0 ?

Today I have tried with new modbus 2.4 and io.modbus 2.4
BTW. Should I used both ?

I have deleted all in modbus.cfg + restarted bindding via Karaf
Based on manual I wrote thing file:

Bridge modbus:serial:went [ port="/dev/ttyUSB0", id= "10", baud=9600, stopBits="1", parity="none", dataBits=8, encoding="rtu" ] { 

    Bridge poller input [ start=16, length=1, refresh=10000, type="input" ] { 
            
            Thing data temp [ readStart="16", readValueType="int16" ] 
     
    } 

}

+item:

Number Went_Temp_Zewn_M "Temp [%.1f °C]" <temperature> (Wentylacja) {channel="modbus:data:went:input:temp:number"}

and got:

2018-10-12 18:00:49.832 [hingStatusInfoChangedEvent] - 'modbus:serial:went' changed from UNINITIALIZED to INITIALIZING

2018-10-12 18:00:49.837 [hingStatusInfoChangedEvent] - 'modbus:serial:went' changed from INITIALIZING to ONLINE

2018-10-12 18:00:49.845 [hingStatusInfoChangedEvent] - 'modbus:poller:went:input' changed from UNINITIALIZED to INITIALIZING

2018-10-12 18:00:49.854 [hingStatusInfoChangedEvent] - 'modbus:poller:went:input' changed from INITIALIZING to ONLINE

2018-10-12 18:00:49.874 [hingStatusInfoChangedEvent] - 'modbus:data:went:input:temp' changed from UNINITIALIZED to INITIALIZING

2018-10-12 18:00:49.881 [hingStatusInfoChangedEvent] - 'modbus:data:went:input:temp' changed from INITIALIZING to ONLINE

==> /var/log/openhab2/openhab.log <==

2018-10-12 18:01:19.856 [ERROR] [et.wimpi.modbus.net.SerialConnection] - open port failed: gnu.io.PortInUseException: Modbus Serial Master

==> /var/log/openhab2/events.log <==

2018-10-12 18:01:19.917 [hingStatusInfoChangedEvent] - 'modbus:data:went:input:temp' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusConnectionException) with read. Request: ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@7ec9ce[slaveId=10,functionCode=READ_INPUT_REGISTERS,start=16,length=1,maxTries=3]. Description: ModbusConnectionException(Error connecting to endpoint=ModbusSerialSlaveEndpoint@414459[portName=/dev/ttyUSB0]). Message: Error connecting to endpoint ModbusSerialSlaveEndpoint@414459[portName=/dev/ttyUSB0]

2018-10-12 18:01:19.921 [hingStatusInfoChangedEvent] - 'modbus:poller:went:input' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.io.transport.modbus.ModbusConnectionException: Error connecting to endpoint ModbusSerialSlaveEndpoint@414459[portName=/dev/ttyUSB0]

and then just got:

2018-10-12 18:03:39.946 [ERROR] [et.wimpi.modbus.net.SerialConnection] - open port failed: gnu.io.PortInUseException: Modbus Serial Master

2018-10-12 18:04:19.969 [ERROR] [et.wimpi.modbus.net.SerialConnection] - open port failed: gnu.io.PortInUseException: Modbus Serial Master

Any tips how to migrate this simple config from OH1 to OH2 ?

That’s the problem.
Maybe you still have old v1 binding using ttyUSB0 , or maybe there are permissions to set

EDIT thinking some more on this (I’m a TCP not serial user) there are changes in the way v2 binding works with serilaIO, a dependancy package. You really need to install this binding properly, not just copy files

You will need to install the serial transport service
In the console:

feature:install openhab-transport-serial

But you will need to do this after each reboot as the binding doesn’t install it because you are using the binding jar file (I think)

Ok. After I wrote my post I have add:

timeBetweenTransactionsMillis=900

Then after restart I have connected with MOdbus device and updated items :slight_smile:
Anyway it was once and then even refresh was set to 2s, items has not been refreshed. From the log I dont see any errors:

15-Oct-2018 12:17:16.349 [DEBUG] [org.openhab.io.transport.modbus                   ] - BundleEvent [unknown:512] - org.openhab.io.transport.modbus
15-Oct-2018 12:17:16.372 [DEBUG] [org.openhab.io.transport.modbus                   ] - ServiceEvent REGISTERED - {org.openhab.io.transport.modbus.ModbusManager}={service.id=119, service.bundleid=273, service.scope=bundle, component.name=org.openhab.io.transport.modbus.internal.ModbusManagerImpl, component.id=18} - org.openhab.io.transport.modbus
15-Oct-2018 12:17:16.380 [DEBUG] [org.openhab.io.transport.modbus                   ] - BundleEvent STARTING - org.openhab.io.transport.modbus
15-Oct-2018 12:17:16.383 [DEBUG] [org.openhab.io.transport.modbus                   ] - BundleEvent STARTED - org.openhab.io.transport.modbus
15-Oct-2018 12:17:16.431 [INFO ] [hab.io.transport.modbus.internal.ModbusManagerImpl] - Modbus manager activated
15-Oct-2018 12:17:16.489 [DEBUG] [org.openhab.binding.modbus                        ] - BundleEvent [unknown:512] - org.openhab.binding.modbus
15-Oct-2018 12:17:16.511 [DEBUG] [org.openhab.binding.modbus                        ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=120, service.bundleid=275, service.scope=bundle, component.name=org.openhab.binding.modbus.internal.ModbusHandlerFactory, component.id=19} - org.openhab.binding.modbus
15-Oct-2018 12:17:16.710 [DEBUG] [org.openhab.binding.modbus                        ] - BundleEvent STARTING - org.openhab.binding.modbus
15-Oct-2018 12:17:16.725 [DEBUG] [org.openhab.binding.modbus                        ] - BundleEvent STARTED - org.openhab.binding.modbus
15-Oct-2018 12:17:16.747 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - Setting manager: org.openhab.io.transport.modbus.internal.ModbusManagerImpl@2dbc7f
15-Oct-2018 12:17:21.032 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - Setting manager: org.openhab.io.transport.modbus.internal.ModbusManagerImpl@2dbc7f
15-Oct-2018 12:18:27.588 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - createHandler Modbus serial
15-Oct-2018 12:18:27.705 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - createHandler Modbus poller
15-Oct-2018 12:18:27.732 [DEBUG] [dbus.internal.handler.ModbusPollerThingHandlerImpl] - Registering polling with ModbusManager
15-Oct-2018 12:18:27.757 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - createHandler Modbus poller
15-Oct-2018 12:18:27.774 [DEBUG] [dbus.internal.handler.ModbusPollerThingHandlerImpl] - Registering polling with ModbusManager
15-Oct-2018 12:18:27.778 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - createHandler data
15-Oct-2018 12:18:27.802 [DEBUG] [hab.io.transport.modbus.internal.ModbusManagerImpl] - Executing scheduled (20000ms) poll task BasicPollTaskImpl@172b58f[request=ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@668128[slaveId=10,functionCode=READ_MULTIPLE_REGISTERS,start=4208,length=3,maxTries=3],endpoint=ModbusSerialSlaveEndpoint@1a2b8f3[portName=/dev/ttyUSB0],callback=org.openhab.binding.modbus.internal.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator@ab484b7d]. Current millis: 1539598707776
15-Oct-2018 12:18:27.804 [DEBUG] [hab.io.transport.modbus.internal.ModbusManagerImpl] - Executing scheduled (20000ms) poll task BasicPollTaskImpl@1cdb63c[request=ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1e16add[slaveId=10,functionCode=READ_INPUT_REGISTERS,start=16,length=3,maxTries=3],endpoint=ModbusSerialSlaveEndpoint@1a2b8f3[portName=/dev/ttyUSB0],callback=org.openhab.binding.modbus.internal.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator@ab4b55ae]. Current millis: 1539598707748
15-Oct-2018 12:18:27.823 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - createHandler data
15-Oct-2018 12:18:27.837 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - createHandler data
15-Oct-2018 12:18:27.851 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - createHandler data
15-Oct-2018 12:18:27.865 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - createHandler data
15-Oct-2018 12:18:27.881 [DEBUG] [enhab.binding.modbus.internal.ModbusHandlerFactory] - createHandler data
15-Oct-2018 12:18:28.188 [DEBUG] [hab.io.transport.modbus.internal.ModbusManagerImpl] - Execution of scheduled (20000ms) poll task BasicPollTaskImpl@1cdb63c[request=ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1e16add[slaveId=10,functionCode=READ_INPUT_REGISTERS,start=16,length=3,maxTries=3],endpoint=ModbusSerialSlaveEndpoint@1a2b8f3[portName=/dev/ttyUSB0],callback=org.openhab.binding.modbus.internal.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator@ab4b55ae] finished at 1539598708187. Was started at millis: 1539598707748 (=duration of 439 millis)
15-Oct-2018 12:18:28.201 [DEBUG] [dbus.internal.handler.ModbusPollerThingHandlerImpl] - Thing modbus:poller:went:Temp received registers RegisterArrayWrappingInputRegister(00 94 00 ca 00 cf) for request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1e16add[slaveId=10,functionCode=READ_INPUT_REGISTERS,start=16,length=3,maxTries=3]
15-Oct-2018 12:18:28.347 [DEBUG] [ing.modbus.internal.handler.ModbusDataThingHandler] - Thing modbus:data:went:Temp:TempZ channels updated: {modbus:data:went:Temp:TempZ:lastReadSuccess=2018-10-15T12:18:28.279+0200}. readValueType=int16, readIndex=Optional[16], readSubIndex(or 0)=0, extractIndex=0 -> numeric value 148 and boolValue=true. Registers RegisterArrayWrappingInputRegister(00 94 00 ca 00 cf) for request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1e16add[slaveId=10,functionCode=READ_INPUT_REGISTERS,start=16,length=3,maxTries=3]
15-Oct-2018 12:18:28.353 [DEBUG] [ing.modbus.internal.handler.ModbusDataThingHandler] - Thing modbus:data:went:Temp:Temp_Nawiew channels updated: {modbus:data:went:Temp:Temp_Nawiew:lastReadSuccess=2018-10-15T12:18:28.350+0200}. readValueType=int16, readIndex=Optional[17], readSubIndex(or 0)=0, extractIndex=1 -> numeric value 202 and boolValue=true. Registers RegisterArrayWrappingInputRegister(00 94 00 ca 00 cf) for request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1e16add[slaveId=10,functionCode=READ_INPUT_REGISTERS,start=16,length=3,maxTries=3]
15-Oct-2018 12:18:28.358 [DEBUG] [ing.modbus.internal.handler.ModbusDataThingHandler] - Thing modbus:data:went:Temp:Temp_Wywiew channels updated: {modbus:data:went:Temp:Temp_Wywiew:lastReadSuccess=2018-10-15T12:18:28.355+0200}. readValueType=int16, readIndex=Optional[18], readSubIndex(or 0)=0, extractIndex=2 -> numeric value 207 and boolValue=true. Registers RegisterArrayWrappingInputRegister(00 94 00 ca 00 cf) for request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1e16add[slaveId=10,functionCode=READ_INPUT_REGISTERS,start=16,length=3,maxTries=3]
15-Oct-2018 12:18:29.284 [DEBUG] [dbus.internal.handler.ModbusPollerThingHandlerImpl] - Thing modbus:poller:went:Mode received registers RegisterArrayWrappingInputRegister(00 00 00 01 00 46) for request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@668128[slaveId=10,functionCode=READ_MULTIPLE_REGISTERS,start=4208,length=3,maxTries=3]
15-Oct-2018 12:18:29.284 [DEBUG] [hab.io.transport.modbus.internal.ModbusManagerImpl] - Execution of scheduled (20000ms) poll task BasicPollTaskImpl@172b58f[request=ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@668128[slaveId=10,functionCode=READ_MULTIPLE_REGISTERS,start=4208,length=3,maxTries=3],endpoint=ModbusSerialSlaveEndpoint@1a2b8f3[portName=/dev/ttyUSB0],callback=org.openhab.binding.modbus.internal.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator@ab484b7d] finished at 1539598709284. Was started at millis: 1539598707776 (=duration of 1508 millis)
15-Oct-2018 12:18:29.291 [DEBUG] [ing.modbus.internal.handler.ModbusDataThingHandler] - Thing modbus:data:went:Mode:ModeW channels updated: {modbus:data:went:Mode:ModeW:lastReadSuccess=2018-10-15T12:18:29.288+0200}. readValueType=uint16, readIndex=Optional[4208], readSubIndex(or 0)=0, extractIndex=0 -> numeric value 0 and boolValue=false. Registers RegisterArrayWrappingInputRegister(00 00 00 01 00 46) for request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@668128[slaveId=10,functionCode=READ_MULTIPLE_REGISTERS,start=4208,length=3,maxTries=3]
15-Oct-2018 12:18:29.314 [DEBUG] [ing.modbus.internal.handler.ModbusDataThingHandler] - Thing modbus:data:went:Mode:Season channels updated: {modbus:data:went:Mode:Season:lastReadSuccess=2018-10-15T12:18:29.294+0200}. readValueType=uint16, readIndex=Optional[4209], readSubIndex(or 0)=0, extractIndex=1 -> numeric value 1 and boolValue=true. Registers RegisterArrayWrappingInputRegister(00 00 00 01 00 46) for request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@668128[slaveId=10,functionCode=READ_MULTIPLE_REGISTERS,start=4208,length=3,maxTries=3]
15-Oct-2018 12:18:29.320 [DEBUG] [ing.modbus.internal.handler.ModbusDataThingHandler] - Thing modbus:data:went:Mode:Flow channels updated: {modbus:data:went:Mode:Flow:lastReadSuccess=2018-10-15T12:18:29.317+0200}. readValueType=uint16, readIndex=Optional[4210], readSubIndex(or 0)=0, extractIndex=2 -> numeric value 70 and boolValue=true. Registers RegisterArrayWrappingInputRegister(00 00 00 01 00 46) for request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@668128[slaveId=10,functionCode=READ_MULTIPLE_REGISTERS,start=4208,length=3,maxTries=3]

From binding point of view I have uninstall 1.12 ver via PaperUI and put 2.4 version in addons folder.
Karaf see those bindings and I can restart them:

openhab> bundle:list -s | grep modb
273 │ Active   │  80 │ 2.4.0.M4               │ org.openhab.io.transport.modbus
275 │ Active   │  80 │ 2.4.0.201810101532     │ org.openhab.binding.modbus

Do I need both of them (before was just modbus) ?

If it is not proper way of adding snapshot version, so how to do this ?

I added, but nothing changed.

One more thing does my config is correct (Apologize, but things are new for me):

Bridge modbus:serial:went [ port="/dev/ttyUSB0", id= "10", baud=9600, stopBits="1", parity="none", dataBits=8, encoding="rtu", timeBetweenTransactionsMillis=900 ] { 
        Bridge poller Temp [ start=16, length=3, refresh=20000, type="input" ] { 
                
                Thing data TempZ [ readStart="16", readValueType="int16" ]
                Thing data Temp_Nawiew [ readStart="17", readValueType="int16" ]
                Thing data Temp_Wywiew [ readStart="18", readValueType="int16" ]

and item:

Number Went_Temp_Zewn_M <temperature> (Wentylacja) {channel=“modbus:serial:data:Temp:TempZ:number”}

While v2 binding was pre-release, you used to be able to install it from the ‘Marketplace’.
Now it is properly released, it is built-in to OH 2.4.0 onwards and can be installed with Habmin.
But that does mean there is no longer a simple way to install it on OH 2.3 or earlier.

The refresh/poll you’ve shown us is for 20s. Maybe check again?

Not sure you’ve shown us the whole thing. Closing curly bracket } is missing, and you log includes info that seems to be about another poller Thing for holding register type.

You named your serial Thing as went

You haven’t used the ‘went’ name here. I think you meant

{channel=“modbus:data:went:Temp:TempZ:number”}

where the channel is modbus:data + serial/TCP Thing name + poller Thing name + data Thing name + type

That’s was my problem.
Thanks for it !
Finally after few hours I even successfully configured my electric meter, with which i gave up a year ago on OH1

It took me so long, since error description are not accurate and usually tells nothing (like read error). First problem which I had after upgrade to 2.4 was lack of io.transport bidding (still I don’t understand why there are two modbus bindings ?? ).
Second problem was receiveTimeoutMillis without that parameter I was able to connect with one modbus slave, but when I add second I got errors. After I add receiveTimeoutMillis and set it to 5s it started coworking.
Then I recognized that system do not react when I change value, so when I want to write something. Item was updated, and the reverted to previous state (read before write … maybe). Finally when I decreased receiveTimeoutMillis to 2.5s it started working well :wink:.

I have noticed strange behavior of Modbus binding. Previously I have used same bus for two slaves: ventilation system I have connected via OH1.8 binding and my power meter via python script. This script was launch few seconds after my ventilation system update all configured items.
Now I have configured it on OH2.4:

Bridge modbus:serial:went [ port="/dev/ttyUSB0", id= “10”, baud=9600, stopBits=“1”, parity=“none”, dataBits=8, encoding=“rtu”, receiveTimeoutMillis=2000, timeBetweenTransactionsMillis=1000 ] {

    Bridge poller Temp [ start=16, length=3, refresh=60000, type="input" ] { 
            
            Thing data TempZ [ readStart="16", readValueType="int16" ]
            Thing data Temp_Nawiew [ readStart="17", readValueType="int16" ]
            Thing data Temp_Wywiew [ readStart="18", readValueType="int16" ]
     }

Bridge modbus:serial:licznik [ port="/dev/ttyUSB0", id= “1”, baud=9600, stopBits=“1”, parity=“even”, dataBits=8, encoding=“rtu”, receiveTimeoutMillis=5000, timeBetweenTransactionsMillis=1000 ] {

    Bridge poller Voltage [ start=14, length=6, refresh=180000, type="holding" ] { 
            
            Thing data Vol_L1 [ readStart="14", readValueType="float32" ]
            Thing data Vol_L2 [ readStart="16", readValueType="float32" ]
            Thing data Vol_L3 [ readStart="18", readValueType="float32" ]
    }

Sometimes it works together, sometimes just one device. Now I got problem with both of them

2018-12-16 15:26:00.931 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 1c 00 08 85 ca
2018-12-16 15:26:00.933 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2018-12-16 15:26:00.935 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@9451e4 (unit id 1 & transaction 1156). Serial parameters: SerialParameters@2b86a8[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=2000]
2018-12-16 15:26:00.937 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@9451e4 (unit id 1 & transaction 1156). Serial parameters: SerialParameters@2b86a8[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=2000]
2018-12-16 15:26:00.938 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1d0aa60[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=28,length=8,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException Error reading response (EOF) [operation ID b031055d-6e2b-45ff-87b6-3aa3ca2f41f2]
2018-12-16 15:26:03.242 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 0a 03 10 80 00 01 80 59
2018-12-16 15:26:03.244 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 0 bytes: 
2018-12-16 15:26:03.248 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException CRC Error in received frame: 0 bytes: . Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@18fbbfd (unit id 10 & transaction 1158). Serial parameters: SerialParameters@1f5b38c[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=5000]
2018-12-16 15:26:03.251 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException CRC Error in received frame: 0 bytes: . Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@18fbbfd (unit id 10 & transaction 1158). Serial parameters: SerialParameters@1f5b38c[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=5000] 

How two slaves over one physical device cooperate each other ?
It looks the problem occur when there is a conflict.
Does anybody know who make them work together ?

Modbus ver is:

223 x Active   x  80 x 2.4.0.201812121631     x org.openhab.binding.modbus
231 x Active   x  80 x 2.4.0.201812121631     x org.openhab.io.transport.modbus

They don’t cooperate, as such. Modbus master - here that’s openHAB - talks to each slave in turn and waits for the conversation to finish (or fail) before talking to the next slave.
The slave ID sorts out which message is which.
openHAB binding manages queuing.

I’m a bit confused by your talk of a script - is this addressing modbus directly? Then it will fail because you cannot have two masters on the same bus.

One master (OH) and two slaves: id 1 and id 10 (0a in hex). It looks that I got error from both devices as log shows: Last request 01 03 … and 0a 03, so both ids are there.

What is strange both devices works and OH got updates, but probably form time to time there are errors in communications and I just want to know why they occured. As I understand OH talking with 2 slaves is nothing extra ordinary ?

No, multiple slaves is exactly what Modbus is intended for.

Hardware can be picky, and from experience bus termination problems can appear to come and go and appear related to what activity happened before.
Be very sure your bus is properly terminated and uses twisted pair wiring.

Bus and hardware are ok. I have used them on OH1.8 more then a year. Now what I have changed is OH1.8 ->OH2.4 and trigger method. Before I have used OH to communicate with one slave and python script with second (launch after first finished).
Now both of them are controlled by OH. I have played a little bit with timers sometimes it helps, but problem return after some time.

Hang on - you’ve got one device configured with even parity and one with no parity on the same wired bus. EVERY transmission will cause the other slave to detect comms errors, and who knows what internal error recovery.
For a bus to work, everyone has to talk the same language.

Try fixing that - change the settings in one or other slave and the Thing settings to match.

Yes, one bus, two diff config for two slaves, one has even parity, second has no parity.
When I change one of them I got error connection to that device.
Anyway it has to be something wrong with transmission control, if master (OH2) can not change transmission parameters per device.
As i wrote before I used script + OH for same devices, same connection, one wires, but “I” controlled time when I ask for device update. It was no errors.
Error were when in same time my script was executed and OH try to connect with second device.

Well, please yourself. The advice was offered - it is never correct to have both even- and no-parity devices on the same bus.

You might get away with in some circumstances. Try adding more time between polls if you must do this, to allow error recovery.

I am close to give up with this Modbus :frowning:

I read a little bit about Modbus protocol and you are right it is not good idea to have diff connection parameters. So I have added second USB/RS485 inwerter and fix config:

One:

Bridge modbus:serial:went [ port="/dev/ttyUSB1", id= "10", baud=9600, stopBits="1", parity="none", dataBits=8, encoding="rtu", receiveTimeoutMillis=2500, timeBetweenTransactionsMillis=1000] { ....

Second:

Bridge modbus:serial:licznik [ port="/dev/ttyUSB0", id= "1", baud=9600, stopBits="1", parity="even", dataBits=8, encoding="rtu", receiveTimeoutMillis=2500, timeBetweenTransactionsMillis=500] {

and same result :roll_eyes::

2019-01-09 11:25:19.731 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/1 error: Modbus serial device /dev/ttyUSB1 doesn't exist!. Connection SerialConnection@14d7e60[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@4b6772[portName=/dev/ttyUSB1]
2019-01-09 11:25:19.734 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 1, throwing last error: Modbus serial device /dev/ttyUSB1 doesn't exist!. Connection SerialConnection@14d7e60[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@4b6772[portName=/dev/ttyUSB1]
2019-01-09 11:25:19.739 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection@14d7e60[portName=/dev/ttyUSB1,port=<null>] for endpoint ModbusSerialSlaveEndpoint@4b6772[portName=/dev/ttyUSB1]: Modbus serial device /dev/ttyUSB1 doesn't exist!
2019-01-09 11:25:19.742 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusSerialSlaveEndpoint@4b6772[portName=/dev/ttyUSB1] -- aborting request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@189edba[slaveId=10,functionCode=READ_MULTIPLE_REGISTERS,start=4224,length=1,maxTries=3] [operation ID 295dc27e-655d-481c-9a74-e1134df796dc]

and same for ttyUSB0.

What’s funny both are working and get updates (maybe with same brakes), but log are a lot of Modbus errors (10MB per day)

I have tried to disconnect first - no issues in log, then connect it and disconnect second, same result no issue, but when I want to use both (with seperate devices) - problem as above.

Any ideas ?

Okay, so it’s not the same error at all.

What you are doing now sounds right, two separate serial buses. Binding should support that.

I don’t know much about serial ports and user permissions, but these are important. This might give a pointer

Thank you for a hint. openhab user was already a member of tty and dialout. Anyway I have mod user by:
sudo usermod -a -G dialout openhab

After that I have standard problem with reading:

2019-01-10 11:52:27.701 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 0e 00 06 a4 0b
2019-01-10 11:52:27.703 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2019-01-10 11:52:27.706 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@100a297 (unit id 1 & transaction 80). Serial parameters: SerialParameters@3e87b1[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=2500]
2019-01-10 11:52:27.709 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@100a297 (unit id 1 & transaction 80). Serial parameters: SerialParameters@3e87b1[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=2500]
2019-01-10 11:52:27.712 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@4e445b[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=14,length=6,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException Error reading response (EOF) [operation ID 5303cafb-9d6e-45f9-8788-b4c7c0118ba4]
2019-01-10 11:52:28.662 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 0a 03 05 00 00 02 c5 bc
2019-01-10 11:52:28.664 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2019-01-10 11:52:28.668 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@d8a762 (unit id 10 & transaction 81). Serial parameters: SerialParameters@171fee8[portName=/dev/ttyUSB1,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=2500]
2019-01-10 11:52:28.671 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@d8a762 (unit id 10 & transaction 81). Serial parameters: SerialParameters@171fee8[portName=/dev/ttyUSB1,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=2500]
2019-01-10 11:52:28.674 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1a9ead0[slaveId=10,functionCode=READ_MULTIPLE_REGISTERS,start=1280,length=2,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException Error reading response (EOF) [operation ID 5a0b5b75-1978-43a2-a2dd-d22900169b92]

EOF = likely no response from slave.

Simplify.
Reduce your modbus setup to one serial thing (slave) , one poller, and take it from there one step at a time.

1 Like