I have a pair of Sparkfun RTK2 receivers (GPS-15136) in moving base and rover configuration, and the base is streaming the UBX-NAV-RELPOSNED message into the Pi’s UART at 4Hz. I have the message structure from page 158 of Ublox’s F9P Interface Description (see attached). As a beginner, my plan is to convert the binary message to ascii, then parse, to access the (relPosHeading) live data that I need.
After trying the following on the Pi terminal:
stty -F /dev/ttyAMA0 raw 115200 cs8 clocal -cstopb
cat /dev/ttyAMA0
I saw rubbish like: �b<@^S`j�b<@XS[=�b<@RSV�b<@LSQ�b<@FSL��b<@@SG��b<@:�S… but at least it was something.
Eventually after running the following:
import serial
port = “/dev/ttyAMA0”
ser = serial.Serial(port,baudrate = 115200, timeout =0.5)
while True:
data = ser.readline()
print(data)
I got something more readable on the terminal (probably because the 115200 baud rate is the same as the receiver); a sample of the output is as follows: b’\xb5b\x01<@\x00\x01\x00\x00\x00\x02/X\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00…
Most of the data in this format is zero probably because when I copied the message the GPS receiver was inside and the signal was too weak. Is this binary that can be converted to ascii?
I have tried using int() and binascii b2a to convert the above to text without success. Could you please help me convert this data to text which I can parse.