Skip to content

ValueError: invalid literal for int() with base 10: '+\x0081430' #222

@szantaib

Description

@szantaib

I am running a LEGO Technic XL motor on my Raspberry Build Hat and my script runs the motor for approx five minutes every hour, it turns certain degrees with a certain speed. After a few hours I have the following error:

Traceback (most recent call last):
File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/usr/lib/python3.11/threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.11/dist-packages/buildhat/serinterface.py", line>
newdata.append(int(d))
^^^^^^
ValueError: invalid literal for int() with base 10: ':'
Exception in thread Thread-6 (loop):
Traceback (most recent call last):
File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/usr/lib/python3.11/threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3/dist-packages/buildhat/serinterface.py", line 391, in >
newdata.append(int(d))
^^^^^^
ValueError: invalid literal for int() with base 10: '+\x0081430'

From what I understand, the problem is the motor sometimes sends some invalid (non-integer) data back on the serial port and it crashes the buildhat library, this exception is not handled.

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