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

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

Open
astrophysaxist opened this issue Aug 9, 2018 · 2 comments

Comments

@astrophysaxist
Copy link

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

@LukeSkywalker92
Copy link

Same for me!

@LukeSkywalker92
Copy link

@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.

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