Skip to content

ValueError Invalid literal for int() in _binaryadd for TMC429/TMC262 system #11

@astrophysaxist

Description

@astrophysaxist

Hi,

I discovered a type mismatch when running a controller board using the TMC429 and TMC262. It is a USB device (MCST 3601), but I managed to get the commands working correctly with an edit to TMCL/bus.py.

The specific error was:

>>> motor.rotate_left(1234)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "TMCL/motor.py", line 67, in rotate_left
    reply = self.send(Command.ROL, 0, self.motor_id, velocity)
  File "TMCL/motor.py", line 53, in send
    return self.bus.send(self.module_id, cmd, type, motorbank, value)
  File "TMCL/bus.py", line 51, in send
    checksum = self._binaryadd(address, command, type, motorbank, value)
  File "TMCL/bus.py", line 101, in _binaryadd
    checksum += int(s) % 256
ValueError: invalid literal for int() with base 10: '\x01'

When I changed line 101 in TMCL/bus.py from:

checksum += int(s) % 256

to

checksum += int(s.encode('hex'),16) % 256

Things seemed to operate normally without error. I'm not sure if this is just a newer controller or driver board issue or related to the USB-to-serial conversion happening. Let me know if you'd like me to submit a pull request either way.

Thanks,
Greg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions