Last active
May 16, 2023 09:28
-
-
Save msacchetin/84263128cd2b5bc7ddd99c713509dc66 to your computer and use it in GitHub Desktop.
Read GPS GPRMC sentence from BeagleBone Blue using GPS Receiver - EM-506
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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