Using python 3.7, and pyserial readline on an Adafruit GPS breakout only outputs encoded byte data. How do i decode? It is not utf-8, or ASCII.
Here is a sentence:
b'[}xc5xc5xf5x9dx9dx8dx9fx8dx9dx97xa3x9fx9f>xa7x97x9fx9dx8dxa3x95x8dx8dx99xa7cxa7x9fx91/x9dx9bxa3x91x8dx95x93xa7Qxa7x9bxa7x9fx8dxa7>xa3x8dx95xa7x93x8dxa3x9bxa7exa7xa5x99x97xa36xa7exa7xa7xabx93
b'[}xc5xc5xf5x9dx9dx8dx9fx8dx9dx99xa3x9fx9fx9exa7x97x9fx9dx8dxa3x95x8dx8dx99xa7cxa7x9fx91x97x9dx9bxa3x91x8dx95x93xa7Qxa7x9bxa7x9fx8dxa7x1exa3x8dx95xa7x93x8dxa3x9bxa7exa7xa5x99x97xa3x9bxa7exa7xa7xabx93x8dxe5xebxb7q_qY}F}xa7x99xa7x99x9bxa7x99x9dxa7x9fx9bxa7x9dx9fxe6x9bx8fxa7x9bx9dxa7x9bx99xa7x9bx95xa7x9dx9bxa7Nxa7xa7x9dxa3x93x8fxa7x9fxa3x8dx95xa7x9dxa3x99x9exabx9fx91xe5xebxb7q_[eyxa7x9dx8dx9fx8dx9dx99xa3x9fx9fx9fxa7}xa7x97x9fx9dx8dxa3x95x18x8dx99xa7cxa7x9fx91x97x9dx9bxa3x91x8dx95x93xe6Qxa7x9fxa3x9fx9bxa7x93x9dxa3x99x93xa7x9dx93x9fx8dx9bx97xa7xa7xa7wxabx97x95xe5xebxb7q_xa6Wqxa7x93x9dxa3x99x93xa7Wxa7xa7exa7x9fxa3x9fx9bxa7cxa7x9fxa3x9fx99xa7ixa7wxabx9f{xe5xebx00′
10
b'[}xc5xc5xf5x9dx9dx8dx9fx8dx9dx97xa3x9fx9f>xa7x97x9fx9dx8dxa3x95x8dx8dx99xa7cxa7x9fx91/x9dx9bxa3x91x8dx95x93xa7Qxa7x9bxa7x9fx8dxa7>xa3x8dx95xa7x93x8dxa3x9bxa7exa7xa5x99x97xa36xa7exa7xa7xabx93uxe5xebxb7q_qY}x9c}xa7x99xa7x99x9bxa7x99x9dxa7x9fx9bxa7x9dx9fx0fx9bx8fxa7x9bx9dxa7x9bx99xa7x9bx95xa7x9dx9bxa7Nxa7xa7x9dxa3x93x8fxa7x9fxa3x8dx95xa7x9dxa3x99x1fxabx9fx91xe5xebxb7q_[eyxa7x9dx8dx9fx1ax9dx97xa3x9fx9fx9fxa7}xa7x97x9fx9dx8dxa3x95x1fx8dx99xa7cxa7x9fx91x97x9dx9bxa3x91x8dx95x93NQxa7x9fxa3x9fx9dxa7x93x9dxa3x99x93xa7x9dx93>x8dx9bx97xa7xa7xa7wxabx97x9dxe5xebxb7q_xb3Wqxa7x93x9dxa3x99x93xa7Wxa7xa7exa7x9fFx9fx9dxa7cxa7x9fxa3x9fx9dxa7ixa7wxabx9fxfaxe5xebx00′
The number is loop index I used to keep the output to 10 lines:
The code:
import serial
n = 0
ser = serial.Serial('COM2', 9600, timeout = 0.5)
while n<10:
data = ser.readline()
n= n+1
print(n)
print(data, flush = True)
#Wait = ser.inWaiting()
#print (f'State of waiting = {Wait}')
ser.close()
I am sure that the serial comm is working at 9600 baud. This is a windows 7 computer and the serial adapter works on other PLC communications.
Stuart Stahl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2