Modbus binding development

Hi all,

I’ve been using OpenHAB for a while now to integrate with my PLC. I’ve however had some trouble along the way, I used to use the OpenHAB modbus binding to write a register in the NOVRAM memory of my PLC. This memory can be read/written by the PLC and by modbus making it very versatile for several applications. I however noticed that in a 5% case of the modbus writes the regsiter wasn’t written in the PLC. First I suspected a problem/bug in the OpenHAB modbus binding but when i tried the same with a .net modbus I experienced the same problem.

As a result I implemented an ACK register in my PLC which comes high for a certain amount of time after a correlated register has been written. I now use some custom code to convert MQTT commands coming from OpenHAB to Modbus. the custom code simply writes a PLC register using modbus, checks the ACK register correlated to the write register to verify if the write came through and if not retries.

This all works beautiful, With this implementation I’ve experienced no more hick ups in my home automation system. The downside however is that I’m now using an extra console application and this is something I’d like to work away.

I’m therefore looking into the modbus binding implementation so I can add some extra functionality to fit my specific needs. With this ofcourse comes a set of questions I’d like some help on.

  • I believe this is where the latest modbus code is hosted: https://github.com/openhab/openhab1-addons/tree/master/bundles/binding/org.openhab.binding.modbus?
  • Is it sufficient to simply take a copy of the my current modbus binding directory, adjust the pom.xml in de modbus addon directory with a new name and add that new name in the global pom.xml?
  • I’m currently going through the code, does anyone has a suggestion to where I’d need to look to implement the following logic/user story: when a modbus write occurs it should be possible to define an ack register in the item, when verified the binding performs a read on that register, if it’s high then do nothing. if it’s low then perform the write again. This behavior should continue until the retry count is reached, this retry count is of course specified in the modbus config file.

I know this might sound a bit crazy but this would really improve my current home automation considerable.

Remarks/questions/advise: SHOOT! :slight_smile: