sunspec / pysunspec2

SunSpec Python library for interfacing with SunSpec devices.
Apache License 2.0
57 stars 22 forks source link

Modbus client does not comply with the standard limit of registers for read/write requests #38

Closed jmmgenerac closed 3 years ago

jmmgenerac commented 3 years ago

The Modbus specification states that the maximum number of registers returned from a Function 3 ("Read Holding Registers") or Function 4 ("Read Input Registers") is 125. And the number of registers for a Function 16 ("Write Multiple registers") is 123.

The pysunspec2 Modbus client only supports one value for the max register count. By default it is 125. Because there is only one value, this means that there is no way for the client to reach both limits of the standard at the same time.

Could the client be modified to comply with the standard? I think either of the following would be fine:

bobfox commented 3 years ago

We will add REQ_WRITE_COUNT_MAX = 123 and adjust the write functions to use this a the default value.

I am not sure I understand the second bullet item, are you referring to a configuration point in pysunspec2?

jmmgenerac commented 3 years ago

Thanks, @bobfox. That will cover the need perfectly.