Hi, Just as background info: The Sunspec modbus spec is a standardized way of doing modbus for energy equipment across many vendors with lots of different features. It also has types like a `string` which is a sequence of modbus registers which are then interpreted as ASCII (used for serial numbers, brand names) and a type for an IPv6 address (and many others).
https://sunspec.org/ https://sunspec.org/wp-content/uploads/2015/06/SunSpec-Information-Models-12041.pdf https://github.com/sunspec/models Long ago I wrote some code to handle modbus for Sunspec (for my Solar panels at home) and my SDM630 (which measures the power usage of my Geothermal Heatpump at home) See: https://github.com/nielsbasjes/energy I recently got a new Heatpump which supports modbus itself and decided to write some code for that thing too and cleanup/refactor/reconsider the code I wrote a few years ago. As part of this reconsidering I'm having a close look at this project. How does the plc4x project look at having these kinds of very specific decoders as part of this project ? Or do you prefer to have them outside this project ? Niels On Mon, Jan 2, 2023 at 1:00 PM Christofer Dutz <[email protected]> wrote: > Hi Niels, > > and welcome to the plc4x community :-) > > In general, we already have a general-purpose mapping layer. However, it’s > not as universal as you would need for that given use-case. > So, if for example you read a register as type “REAL” it will > automatically fetch two registers and interpret the two as 32bit floating > point number. > > However, in your case you currently would need to manually do the > conversion. Unfortunately, I don’t know the “sunspec”, so not 100% sure how > this is encoded. > > Does that help? > > Chris > > > > From: Niels Basjes <[email protected]> > Date: Monday, 2. January 2023 at 12:48 > To: [email protected] <[email protected]> > Subject: Interpreting the modbus registers. > Hi, > > The modbus protocol simply talks about 1 bit coils and 16 bit registers and > are retrieved and written back. > Modbus does not assign any meaning to these bits so real applications need > a translation from these register bits to usable values. > In some cases the meaning of the bits even varies with the content of other > registers; For example the sunspec has a "scaling factor" which indicates > how much 10^X a field must be multiplied to get the real value. > > Is there a generic example on how to implement such a mapping layer cleanly > with plc4j? > > I did have a look at the OPM feature but that retrieves all values one by > one; I want all measurements retrieved at the 'exact' same instant. > > -- > Best regards / Met vriendelijke groeten, > > Niels Basjes > -- Best regards / Met vriendelijke groeten, Niels Basjes
