sunspec / pysunspec2

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

Calling read() on a model gives unexpected results #44

Closed GZPERRA closed 3 years ago

GZPERRA commented 3 years ago

Reading a model (Group object with self.offset=0) results in reading its ID and Length and the next Length-2 points. For example: d.common[0].read() will read all the points of the common model except for DA and Pad. Instead, it could read only the ID and the Length, or ID, Length and the fixed block points.

A simple solution is to change line 85 of client.py:

data = self.model.device.read(self.model.model_addr + self.offset, self.len)

to:

data = self.model.device.read(self.model.model_addr + self.offset, self.len + 2 if self.offset == 0 else 0)