initial commit
parent
e188478602
commit
fcffc5ed8f
@ -0,0 +1,38 @@
|
|||||||
|
# https://56k.es/fanta/utilizando-un-modulo-gps-usb-barato-en-gnulinux/
|
||||||
|
# apt install python3-nmea2 python3-serial
|
||||||
|
# NMEA 0183 PROTOCOL: https://www.serialmon.com/protocols/nmea0183.shtml
|
||||||
|
# ('Timestamp', 'timestamp', timestamp),
|
||||||
|
# ('Latitude', 'lat'),
|
||||||
|
# ('Latitude Direction', 'lat_dir'),
|
||||||
|
# ('Longitude', 'lon'),
|
||||||
|
# ('Longitude Direction', 'lon_dir'),
|
||||||
|
# ('GPS Quality Indicator', 'gps_qual', int),
|
||||||
|
# ('Number of Satellites in use', 'num_sats'),
|
||||||
|
# ('Horizontal Dilution of Precision', 'horizontal_dil'),
|
||||||
|
# ('Antenna Alt above sea level (mean)', 'altitude', float),
|
||||||
|
# ('Units of altitude (meters)', 'altitude_units'),
|
||||||
|
# ('Geoidal Separation', 'geo_sep'),
|
||||||
|
# ('Units of Geoidal Separation (meters)', 'geo_sep_units'),
|
||||||
|
# ('Age of Differential GPS Data (secs)', 'age_gps_data'),
|
||||||
|
# ('Differential Reference Station ID', 'ref_station_id'),
|
||||||
|
|
||||||
|
import io
|
||||||
|
import pynmea2
|
||||||
|
import serial
|
||||||
|
|
||||||
|
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=5.0)
|
||||||
|
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
|
||||||
|
|
||||||
|
while 1:
|
||||||
|
try:
|
||||||
|
line = sio.readline()
|
||||||
|
msg = pynmea2.parse(line)
|
||||||
|
if msg.talker == "GP" and msg.sentence_type == "GGA":
|
||||||
|
print("[", msg.timestamp, "] [ Satelites:", msg.num_sats, "] - Lat:", msg.lat, "Lon:", msg.lon, "Alt:", msg.altitude)
|
||||||
|
|
||||||
|
except serial.SerialException as e:
|
||||||
|
print('Device error: {}'.format(e))
|
||||||
|
break
|
||||||
|
except pynmea2.ParseError as e:
|
||||||
|
print('Parse error: {}'.format(e))
|
||||||
|
continue
|
Loading…
Reference in New Issue