Created
October 30, 2023 01:48
-
-
Save mr-sour/d08cbc98521c8ae04f9c4ada2d12dce7 to your computer and use it in GitHub Desktop.
UBLOX agps betaflight cli
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 requests | |
import serial | |
#Edit me!! | |
token = "TOKEN" #Token getted from u-blox | |
comPort = "/dev/tty.usbmodem" #GPS Com port | |
print ("Connecting to u-blox") | |
r = requests.get("http://online-live1.services.u-blox.com/GetOnlineData.ashx?token=" + token + ";gnss=gps;datatype=eph,alm,aux,pos;filteronpos;format=aid", stream=True) | |
print ("Downloading A-GPS data") | |
ser = serial.Serial(comPort, 9600) | |
print("Waiting to GPS be free") | |
drainer = True | |
while drainer: | |
drainer = ser.inWaiting() | |
ser.read(drainer) | |
print("Writing AGPS data") | |
#print(r.content) | |
ser.write(r.content) | |
print ("Done") | |
buffer = True | |
message = "" | |
try: | |
while buffer: | |
buffer = ser.read() | |
if buffer.decode() == "$": | |
if message.startswith("$GPGGA"): | |
print (message.strip()) | |
message = "" | |
message = message + buffer.decode() | |
except KeyboardInterrupt: | |
ser.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment