tripipy icon indicating copy to clipboard operation
tripipy copied to clipboard

triMixed register does not allow writeBytes

Open gautamjain opened this issue 4 years ago • 3 comments

If you try to write to a triMixed field, a ValueError is thrown. For example:

self.writeInt('GCONF', 0)

causes:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/py_ws/tripipy/trinamicDriver.py", line 203, in writeInt
    creg.writeBytes(ba, value=regValue)
  File "/root/py_ws/tripipy/trinamicDriver.py", line 603, in writeBytes
    raise ValueError('register %s cannot accept new value in writeBytes' % self.name)
ValueError: register GCONF cannot accept new value in writeBytes

Can you help me understand why write_bytes() shouldn't accept a new value? It seems like this error will always be thrown:

class triMixed(triRegister):
...

    def writeBytes(self, ba, value=None):
        """
        fills the given 5 byte buffer with the bytes to write to the chip.
        """
        if not value is None:
            raise ValueError('register %s cannot accept new value in writeBytes' % self.name)
        self.packBytes(ba, self.curval)

gautamjain avatar Apr 20 '20 06:04 gautamjain