Skip to content

AttributeError: 'str' object has no attribute 'decode' on slscan.py #382

@gustavovelascoh

Description

@gustavovelascoh

Hello, I'm using opencan which relies on python-can. With a simple script I get this error. I'm using python3. I guess is an incompatibility with Py3 because is trying to decode a string and it is not needed.

DEBUG:can:loaded can config: {'interface': 'slcan', 'channel': '/dev/ttyUSB0@115200'}
Traceback (most recent call last):
  File "encoder-test.py", line 19, in <module>
    network.connect(channel='/dev/ttyUSB0@115200', bustype='slcan')
  File "/usr/local/lib/python3.5/dist-packages/canopen/network.py", line 100, in connect
    self.bus = can.interface.Bus(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/can/interface.py", line 120, in __new__
    return cls(channel, *args, **config)
  File "/usr/local/lib/python3.5/dist-packages/can/interfaces/slcan.py", line 81, in __init__
    self.open()
  File "/usr/local/lib/python3.5/dist-packages/can/interfaces/slcan.py", line 93, in open
    self.write('O')
  File "/usr/local/lib/python3.5/dist-packages/can/interfaces/slcan.py", line 89, in write
    self.serialPort.write(string.decode())
AttributeError: 'str' object has no attribute 'decode'

Metadata

Metadata

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions