Page 1 of 1

Unable to open serial port in Python

Posted: Fri Jul 23, 2021 12:54 pm
by MarineLebrec
Hi,
I am able to connect to serial ports using the CoolTerm application without any issues.
When I try to run the #open the serial port# portion of Introduction.py in Python, I am coming across the error:
"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 7507: invalid start byte".
I assume that this is because all commands are written in ASCII and not utf-8. Any idea how I can get around this?

Re: Unable to open serial port in Python

Posted: Fri Jul 23, 2021 6:44 pm
by roger
Try changing this line in the CoolTerm.py module, in the getData function, on line 253 from

Code: Select all

return DATA.decode()
to

Code: Select all

return DATA.decode(encoding='ascii')
This ensures decoding using ASCII when bytes larger than 0x7F are received.