Error in line 146 of ServoSerial.py
Closed this issue · 9 comments
Hi, i tried to run your demo example using Anaconda (Spyder) over MAC, and the following line in ServoSerial.py throw me an error:
File "/Users/christianjimenez/anaconda3/lib/python3.6/site-packages/pyxl320/ServoSerial.py", line 146, in decode
pp = list(map(ord, buff))
TypeError: ord() expected string of length 1, but int found
I changed ord by chr and the code works.
146 pp = list(map(chr, buff))
Thanks for the report. Let me take a look at it this weekend. I typically use python 2 and it looks like you are using python 3, so I need to look into that.
Hi, me again.
The change from ord to chr helps, but not in all the cases, each time that I read the answer from the XL-320 the program cannot identify the first bytes and go direct to the reply routine. I reading in calm the code, but I think it takes time, if you could help me I will appreciate it.
I will take a look
Oops ... I just noticed pypi has version 0.9.3, but my robot has 0.10.0.
I just published the updated code, it might take 5-10 minutes for all of the python mirrors to get the code. Let me know if you have anymore problems ... this is still a work in progress.
Ok, the retries are no more displayed. In my case only work when i change the
pp = list(map(ord, buff)) to pp = list(map(chr, buff))
When I run now the complex.py program, I have a new error
File "/Users/christianjimenez/Documents/OpenCM9.04 and XL-320/Python Code/complexDemo.py", line 57, in run
for p in ret:
TypeError: 'NoneType' object is not iterable
Tomorrow I will trace the error. My setup use a OpenCM9.04, in theory must work because the microcontroller only pass the info from USB to the Motors, with Matlab works, but i have interest in your package, because this will be the base of my system.
can you post the code for complexDemo.py?
Most likely it is a python 2 vs python 3 issue. Python 2 created arrays of things and python 3 does iterators. I am thinking it is that.
Hi Kevin, i fixed the problem, now the programs run.
complex.py runs without modifications.
In your ServoSerial.py i change ord for int as follow:
def decode(buff):
"""
Transforms the raw buffer data read in into a list of bytes
"""
pp = list(map(int, buff))
if 0 == len(pp) == 1:
pp = []
return pp
I didn't have problems with that modification, initially complex.py doesn't run because the SLEEP_TIME and serial.timeout were to low, I increased the timing to 0.05 in both cases and work. I need to review my setup with the OpenCM9.04 but your code works great.