TCP Modbus not working from 1.6.2 to 1.7.1

Hi,
In OH the pool parameter is not per node. This parameter is for all modbus nodes and you canonly set like this: modbus:poll=
This parameter works correct.
The TCP and Serial Modbus binding really disconnect after several hours and not reconnect. Need restart. I solve it with System CronJob restart (every 3 hours). Not good idea, but solve the problem.

Hi,
I also tried that workaround: disabling and reenabling the network card of the PC where OH is running but it requires more or less 1 minute: a lot of time.
DO you restart the whole PLC and maintain variables values with persistency ?

Thank you !

I restart the OpenHab at all.

Hello,
I do not know if I’m proceeding in the right direction …

The disconnection appears after the log message "“ModbusSlave error getting responce from slave” which can be found in the bindings at: org.openhab.binding.modbus-1.7.1.jar -> org.openhab.binding.modbus.internal -> ModbusSlave.class.

This message is logged after calling a method (do not know if this is the right name) “resetConnection();” which seems to close the connection:

public void resetConnection()
{
if (connection != null) {
connection.close();
}
connection = null;
}
}

Is it maybe possible to try to restart the connection there ?

Maybe someone has aleady worked on this code ?

Thank you !

Hello !

(Just for info , hoping that it could be of interest for someone :slight_smile: )

The Modbus Binding v. 1.7.1 seems to run much better on a Linux maschine (the UDP connection with port 502 looks definetely better)

Hi,
All my tests are on Linux Ubuntu.

Hi, now my sistem is up since 24 hours and deeply tested. My machine has also Ubunto, is connected to the MODBUS via a CAT5 UTP cable. The connection on the UDP port 502 seems to be continuos and stable.
Please tell me if I can profide you furter info.
Ciao

Hello !
I’ve kind of deeply tested modbus tcp binding on different platforms: mainly ubuntu and raspberry.

Here my personal conclusions:

  1. Actually OH sometimes disconnect sending the message “error gettint responce from slave”.
    It happens that after sometimes the system reconnect but it may require sone time (even minutes)
  2. Rebooting the system requires more or less 45 seconds on raspberry PI
  3. The NH (Network health) binding is not reliable as well. Very often openhab lost the connection on modbus port (502) but still OH can communicate with PLC.

Lorenzo

Hi,

I’ve implemented several connection closing fixes in my pull request. I think this might help with the issues like this.

Hi,
I’'m using serial Modbus connection with about 15 nodes. Please provide me somethig for tests. I can give you detailed feedback or remote access for real tests and monitoring.

Hi lgeorgiev, can you explain what you mean by nodes? I though the current serial modbus implementation has issues when there are many slaves defined in openhab.cfg.

Hello @ssalonen. Please excuse me … i’m a rookie . In your pull request i see there are 11 files changed. In order to test your proposal shall i edit manually the binding java files i the .jar binding according to your modifications ? Many thanks

Hi ssalonen,
Nodes mean slaves. One serial port with 15+ connected slaves. Only
different IDS.
Lyubomir

@lorenzo_leonelli : Here’s the jar matching the pull request https://bintray.com/artifact/download/ssalonen/generic/org.openhab.binding.modbus-1.8.0-SNAPSHOT.jar

@lgeorgiev: thanks for the clarification. OK, so that works then since the parameters are the same… good to know

Hi ssalonen,
As I open this discussion, I describe all problems. At the moment not found any solutions. As I’m also programmer but not Java one :smile: I understand the problem. Modbus binding have two major problems:

  1. Not correct pooling loop for devices.
  2. Not correct parsing results from slave devices.
    This binging have problems even if I setup only one slave. It’s looks like working, but same errors happened less often
    I sniff the serial communications from slave and see all pakets are as expected from the standard. The binding reports errors.
    I check the communications with Windows Modbus tool and no any errors detected.
    If you want, I can prepare for you a Modbus test evirement with several slaves and modbus tcp gate for remote tests (on real IP)
    At the moment the Modbus binding is not possible to use. Usable only for demo purposes :smile:

@lgeorgiev: does it show any errors at all if you enable DEBUG level logging?

I would really appreciate if you can test out the experimental version linked above. It contains fixes for serial modbus such that connections should be closed. Definately it does not resolve all issues with the serial modbus but should make it better…

Example test case

  • modbu.cfg with single serial slave, openhab.cfg update enabled (mainconfig:refresh=)
  • wait that communication is up & running and you can get data from modbus
  • change modbus.cfg such that new config is loaded
  • communication should still work

The above test case did not work for me with modbus tcp when the server is restricted to at most one connection at a time

thank you !

Today I update the OH to 1.8 stable . Stituation with devices is the same:

@lgeorgiev Please try out this version and report back how it works out for you. This version fixes several issues with serial devices due to various technical issues in the binding. We have received really good feedback now, especially on non-windows platforms, and I hope it works for you too as well.

The configuration should be compatible with the official version.

If it does not work with the new version, can you please enable debug level logging (logback_debug.xml), and start the openhab using start_debug.sh.

If the new version works for you, I would appreciate that you report your experiences in the pull request and here.