Estoy corriendo el siguiente fraagmento de codigo de un paquete de ROS llamado canusb
el cual se puede ver a continuacion:
def readline(self):
"""
Overrides io.RawIOBase.readline which cannot handle with '\r' delimiters
"""
ret = ''
while True:
c = self.read(1)
if c == '':
return ret
elif c == '\r':
if ret == 'z' or ret == 'Z':
self.status = 0
return ret + c
elif c == chr(7):
self.status = -1
return c
else:
ret += c
Me esta saltando el siguiente error de la ultima linea:
Traceback (most recent call last):
File "/home/pi/catkin_ws/src/canusb/script/canusb.py", line 191, in <module>
can.init()
File "/home/pi/catkin_ws/src/canusb/script/canusb.py", line 57, in init
line = self.readline()
File "/home/pi/catkin_ws/src/canusb/script/canusb.py", line 51, in readline
ret += c
TypeError: can only concatenate str (not "bytes") to str
¿Como se puede solucionar?
Un saludo y muchas gracias con antelación. Alessandro
c=self.read(1).decode("utf-8")
para convertir bytes a string.