Modbus multi-byte registers

I’m about to setup Modbus binding for my Sungrow PV inverter.
It has a couple of registers to be uint16*10, i.e. 10 times 16-bit data in a consecutive line of registers, e.g. for inverter-provided statistics.
Is there any clever way to retrieve these to say a string type item in one go ? To use a transformation to combine multiple registers ?
Or must I configure 10 data things, map these to 10 number type items and combine those via a rule ?
Thanks in advance for any advice how to cope with that more elegantly.

That’s probably the simplest way.
(it makes no difference to the Modbus transfers, it’s just about handling within openHAB)
You could get 4 registers at a time in a uint64, but I would guess that just makes more work in the unpacking/reassembling rule.

We did think about implementing a string-block in the binding decode, but there’s no established standard for e.g. encoding a length attribute in the data stream. Your case would be different again - a fixed block that you know the length of, and would need to configure into the binding. Typical Modbus, everyone does higher functions differently.

How about simply a definable number of bits/bytes ?
That would be independent of any higher layer interpretation but would save an OH user from lots of static config (and think of doing it in OH3 via GUI :()

Could it be mapped to an OH string type ? @ssalonen wdyt ?

Well, it’s all “do-able”, even image data could be shovelled across Modbus. I’m all for binding features for otherwise insoluble problems, but wary of cluttering up with features for some specific device. When, as here, the customizing could be coded in rules.

Approaching it as a device-specific issue, this is probably best dealt with as a “Sungrow” specific binding, which utilizes the Modbus transport. See Sunpec binding.
(You might find your inverter actually supports SunSpec already?)

For a “string” datatype in the generic binding, some basic params alongside count might be useful; register or bytes, big or little endian, ASCII or unicode, etc. I don’t know quite how variable length strings might work, Modbus doesn’t really work that way.

1 Like

Indeed, I agree with @rossko57 here…

String implementation could be indeed be doable, same as raw bytes but over the years this has not been requested many times which makes me think it is less often needed.

I would really like to have device specific bindings, similar to sunspec, upcoming “ISG binding” and others. Makes the configuration so much easier and more user friendly…

1 Like