python-tmcl
python-tmcl copied to clipboard
ValueError Invalid literal for int() in _binaryadd for TMC429/TMC262 system
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
Same for me!
@astrophysaxist Since it seems like this project is dead and I need a version of this which is installable via pip asap I made a clone of this project under https://github.com/LukeSkywalker92/pyTMCL. This bug is already fixed. I also added functionality for calling callback functions when the motor has reached the position. Maybe this is also helpful for you. I'm planning to do some more development on this project and will also be happy about other contributions.