Skip to content

Instantly share code, notes, and snippets.

@msacchetin
Last active May 16, 2023 09:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msacchetin/84263128cd2b5bc7ddd99c713509dc66 to your computer and use it in GitHub Desktop.
Save msacchetin/84263128cd2b5bc7ddd99c713509dc66 to your computer and use it in GitHub Desktop.
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