Modbus binding broken when writing to floating point registers

Been using the modbus binding (1.12.0.SNAPSHOT) for more than a year now with no issues, however I’m just now starting to send data the other way (OH2 writing data to the PLC, instead of just reading it).

I can write values to the PLC just fine if I use uint16 register types. However when the register is floating point, the PLC just gets senseless data (like 4.591846E -39 for example).

modbus config is like so:

# Outdoor Temp PLC
tcp.slave57.connection=192.168.1.18:502:0
tcp.slave57.id=2
tcp.slave57.start=28750
tcp.slave57.length=2
tcp.slave57.type=holding
tcp.slave57.valuetype=float32_swap

Trying to write decimal temperature values like 56.6 for example. They can be read from the PLC no problem, however writing values to the PLC doesn’t. Also, if I change length to just 1, the data the PLC gets is unchanged, making me think it’s not properly sending both registers.

well shit, just saw this in the modbus binding wiki:
“Note: The way Decimal commands are handled currently means that it is probably not useful to try to use Decimal commands with non-16bit valuetypes”

So I guess this is expected behavior. Any chance for a fix? I have a bunch of float values I need to write back to my PLC :slight_smile:

@ssalonen

1 Like

Hi!

Have a look at this link for a suggestion : Write Temperature Setpoint to Modbus as float32

Also, for the record, here is github issue regarding this behavior with the old binding https://github.com/openhab/openhab1-addons/issues/5193

1 Like