38 parity=serial.PARITY_NONE,
39 stopbits=serial.STOPBITS_ONE,
40 bytesize=serial.EIGHTBITS,
44print(
"Serial port opened. Waiting for data...")
49 if ser.in_waiting > 0:
53 data = ser.readline().decode().strip()
56 if data.find(
'GGA') > 0:
58 msg = pynmea2.parse(data)
59 print(msg.timestamp,
'Lat:',round(msg.latitude,6),
'Lon:',round(msg.longitude,6),
'Alt:',msg.altitude,
'Sats:',msg.num_sats)
61 except Exception
as e:
65 print(
"No data recieved")
69 print(f
"An error occurred: {e}")
72 print(
"Serial port closed.")