Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

triMixed register does not allow writeBytes #9

Open
gautamjain opened this issue Apr 20, 2020 · 3 comments
Open

triMixed register does not allow writeBytes #9

gautamjain opened this issue Apr 20, 2020 · 3 comments

Comments

@gautamjain
Copy link
Contributor

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)
@pootle
Copy link
Owner

pootle commented Apr 20, 2020

A triMixed instance should have child triSubxxx fields, use set on the child fields to change the overall value of the total field, and then call writeBytes with value None on the triMixed field to transmit the current value to the chip.

@gautamjain
Copy link
Contributor Author

Thanks. Makes sense.

However, some of the existing triMixed instances do not have any child triSubxxx fields. Should these be fixed?

E.g. GCONF, GSTAT, SWMODE, RAMPSTAT

@pootle
Copy link
Owner

pootle commented Apr 21, 2020

eh? GSTAT uses GSTATflags which is defined in tmc5130regs.py, and similar for the others - when they're read only in particular (and they are all just flag bits) they just use a subclass of intflag so the various flags are named

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants