| 1234567891011121314151617181920212223242526272829303132 |
- #!/usr/bin/python3
- import serial
- import time
- from pynmeagps import NMEAReader
- gga = None
- rmc = None
- deadline = time.monotonic() + 15
- with serial.Serial('/dev/ttyAMA0', 38400, timeout=1) as stream:
- nmr = NMEAReader(stream)
- while time.monotonic() < deadline and (gga is None or rmc is None):
- raw_data, msg = nmr.read()
- if msg is None:
- continue
- if msg.msgID == "GGA":
- gga = msg
- elif msg.msgID == "RMC":
- rmc = msg
- if gga is None or rmc is None:
- print("Trame GGA ou RMC manquante")
- else:
- print(f"Date : {rmc.date}")
- print(f"Heure_UTC : {rmc.time}")
- print(f"Latitude : {gga.lat} {gga.NS}")
- print(f"Longitude : {gga.lon} {gga.EW}")
- print(f"Altitude : {gga.alt} {gga.altUnit}")
|