Skip to content

Instantly share code, notes, and snippets.

@msacchetin

msacchetin/get_gps_data.py

Last active May 11, 2020
Embed
What would you like to do?
Read GPS GPRMC sentence from BeagleBone Blue using GPS Receiver - EM-506
import time
import serial
gps_data = ""
utf_data = ""
ser = serial.Serial('/dev/ttyO2', 4800)
counter = 0
while utf_data.find("GPRMC") == -1:
counter += 1
try:
ser_data = ser.readline()
utf_data = ser_data.decode()
except:
utf_data = ""
time.sleep(0.5)
if counter > 50:
break
ser.close()
if utf_data.find("GPRMC") != -1:
utf_data = utf_data.replace('\r', '')
utf_data = utf_data.replace('\n', '')
gps_data = utf_data
print(gps_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.