Modbus binding doesn't work with multiple slaves in TCP mode

Good time to all!

I’ve encountered the problem with Modbus binding. Couldn’t find a way to configure several slaves in cfg. Whenever I put more than 1 slave, only one of them is working. Regardless of id, data type and so on. But 1 slave is always working fine.
The device I’m connecting to is Shneider-Electric ComBox, which is TCP-gate for multiple modbus-available devices.

I know somewhere from the forum the similar problem was in place with COM connections. And that was fixed in 1.8.1. Unfortunately in TCP mode still doesn’t work.

OpenHab and addons version 1.8.1.

Did anybody treat this problem with TCP-modbus protocol?

Here is my cfg section:

modbus:tcp.combox.connection=192.168.1.50:502
modbus:tcp.combox.type=holding
modbus:tcp.combox.id=201
modbus:tcp.combox.start=68
modbus:tcp.combox.length=50
modbus:tcp.combox.valuetype=int32

modbus:tcp.mppt.connection=192.168.1.50:502
modbus:tcp.mppt.type=holding
modbus:tcp.mppt.id=30
modbus:tcp.mppt.start=76
modbus:tcp.mppt.length=2
modbus:tcp.mppt.valuetype=int32

In this config only “mppt” is working. If I remove this part then “combox” will start working.

Here is debug output of OpenHab:

10:35:18.741 [INFO ] [runtime.busevents :26 ] - AveragePVVoltageRaw state updated to 71580
10:35:18.742 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'AveragePVVoltageRaw’
10:35:18.743 [INFO ] [runtime.busevents :26 ] - AveragePVVoltage state updated to 71.580
10:35:18.748 [DEBUG] [modbus.internal.ModbusTcpSlave:76 ] - ModbusSlave: Error connecting to master: В соединении отказано
10:35:18.748 [INFO ] [.b.modbus.internal.ModbusSlave:267 ] - ModbusSlave not connected

AveragePVVoltageRaw is updating from modbus binding and it works.

Hi, I’m using modbus with a lot of devices, here is an example

modbus:poll=10000

modbus:tcp.temp.connection=192.168.2.96:502
modbus:tcp.temp.id=4
modbus:tcp.temp.start=0
modbus:tcp.temp.length=1
modbus:tcp.temp.type=input

modbus:tcp.lux.connection=192.168.2.96:502
modbus:tcp.lux.id=4
modbus:tcp.lux.start=8
modbus:tcp.lux.length=1
modbus:tcp.lux.type=input

modbus:tcp.wind.connection=192.168.2.96:502
modbus:tcp.wind.id=4
modbus:tcp.wind.start=10
modbus:tcp.wind.length=1
modbus:tcp.wind.type=input

modbus:tcp.rain.connection=192.168.2.96:502
modbus:tcp.rain.id=4
modbus:tcp.rain.start=12
modbus:tcp.rain.length=1
modbus:tcp.rain.type=input

modbus:tcp.pacocucstatus.connection=192.168.2.94:502
modbus:tcp.pacocucstatus.id=60
modbus:tcp.pacocucstatus.start=0
modbus:tcp.pacocucstatus.length=1
modbus:tcp.pacocucstatus.type=holding

modbus:tcp.pacocucmode.connection=192.168.2.94:502
modbus:tcp.pacocucmode.id=60
modbus:tcp.pacocucmode.start=1
modbus:tcp.pacocucmode.length=1
modbus:tcp.pacocucmode.type=holding

modbus:tcp.pacocucset.connection=192.168.2.94:502
modbus:tcp.pacocucset.id=60
modbus:tcp.pacocucset.start=4
modbus:tcp.pacocucset.length=1
modbus:tcp.pacocucset.type=holding

I don’t have any problem using openhab modbus binding 1.8.1. Please check your refresh, try to increase it.
Let me know.

Walter

Hi Walter!

At moment of writing I had poll = 3000. Now I tried poll=30000, poll=200. No difference unfortunately.

It’s very strage… Can @ssalonen help you on this?

What device we have here? Some plcs might reject connections / requests (see openhab issue [here] (https://github.com/openhab/openhab/issues/3537)).

Also, if the device accepts at most one connection at a time, commands will still be problematic with the current implementation. I invite you to test the new experimental version available at this thread

Edit : BTW, can you please paste longer logs on pastebin. It would be also nice to know whether you get errors if you remove the write commands, ie just polling enabled.

Best,
Ssalonen

edit 17.2.2016: fixed thread link

Thank you @ssalonen !
Device is http://solar.schneider-electric.com/product/conext-combox/
I’try your advise and report here.

2016-02-17 16:18:21.589 [INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave error getting responce from slave 2016-02-17 16:18:24.606 [INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave error getting responce from slave 2016-02-17 16:18:29.565 [INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave error getting responce from slave
Getting this if point any other type then “holding”.
And getting this if I comment the type key in cfg:
10:35:18.748 [INFO ] [.b.modbus.internal.ModbusSlave:267 ] - ModbusSlave not connected

I am ready to test new experimental binding, but not that experienced to assemble source to ready-to-use binding. unfortunately I am not a Java-programmer.

@YMedox I think I pasted wrong link to thread previously – sorry for that!

This is the correct link to download the expiremental version: https://community.openhab.org/t/connection-pooling-in-modbus-binding/5246/31?u=ssalonen. It is prebuilt for you, just install as you would normally. Make sure you have only that new version present in the system.

Please follow these steps (modified from linked thread more suitable for TCP testing) to make the debugging easier.

  • have an minimal configuration (for example two slaves that just read data). I suggest creating separate configuration for these tests for your convenience
  • TRACE level logging enabled
  • latest release version of openhab

When you have issues, please

  • paste the logs here (or even better use pastebin.com for long logs to make this thread more readable)
  • the associated openhab.cfg configuration
  • openhab item definitions.
  • modbus device you are using (I believe you already reported this)

I’ve had positive experiences with the experimental version with Modbus TCP but would be nice to hear it from others as well! I really appreciate if you have time to test the new version.

One more thing: Please report your experiences in the other thread, in order to collect all feedback of the new version there.