This article illustrates how to parse the RTCM 3.x correction data from serial port input of your GPS base station module.
Prerequisites
- Have RTCM 3.x correction data streamed correctly from some serial port of your GPS module
- Have python3 and pip3 installed
- CLI
Getting started
First, you want to know which ports are used by your GPS base module. Run this code (The resource was found here).
Run
python3 NAME_OF_CODE_1.py
import sys
import glob
import serial
def serial_ports():
""" Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms
:returns:
A list of the serial ports available on the system
"""
if sys.platform.startswith('win'):
ports = ['COM%s' % (i + 1) for i in range(256)]
elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
# this excludes your current terminal "/dev/tty"
ports = glob.glob('/dev/tty[A-Za-z]*')
elif sys.platform.startswith('darwin'):
ports = glob.glob('/dev/tty.*')
else:
raise EnvironmentError('Unsupported platform')
result = []
for port in ports:
try:
s = serial.Serial(port)
s.close()
result.append(port)
except (OSError, serial.SerialException):
pass
return result
if __name__ == '__main__':
print(serial_ports())
Then, time to parse the streaming RTCM correction data:
(resource code from here).
Run
python3 NAME_OF_CODE_2.py
Should update the serial port name and the baud rate of your application
from serial import Serial
from pyrtcm import RTCMReader
stream = Serial('/dev/ttyS10', 921600, timeout=3)
rtr = RTCMReader(stream)
for (raw_data, parsed_data) in rtr: print(parsed_data)
part of the results
You can print either raw data or parsed data
References
https://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python
Top comments (1)
Good day. How can one make the "parsed_data" iterable? The idea is to create something like a dataframe from the decoded observations.