Im not sure how to get the GGA message from msg variable, the message var seems to contain all or the parsed messages
import pynmea2
import serial
ser = serial.Serial('/dev/ttyS1', 9600, timeout=5.0)
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
while 1:
try:
line = sio.readline()
msg = pynmea2.parse(line)
print(repr(msg))
except serial.SerialException as e:
print('Device error: {}'.format(e))
break
except pynmea2.ParseError as e:
print('Parse error: {}'.format(e))
continue
This is my current code
_ser = serial.Serial(GPS_PORT, 19200, timeout=1.0)
_gps = io.TextIOWrapper(io.BufferedRWPair(_ser, _ser))
def get_gps_data_v2 ():
while 1:
try:
data = _gps.readline()
prefix = data[0:6]
if prefix == "$GPGGA":
msg = pynmea2.parse(data)
location = {}
location["latitude"] = msg.latitude
location["longitude"] = msg.longitude
location["altitude"] = msg.altitude
return json.dumps(location)
except serial.SerialException as e:
print('Device error: {}'.format(e))
break
except pynmea2.ParseError as e:
print('Parse error: {}'.format(e))
continue
Im not sure how to get the GGA message from
msgvariable, the message var seems to contain all or the parsed messagesThis is my current code