Created
February 15, 2022 21:15
-
-
Save maxim75/bc712d4f003c8abee63bb8e75d48dce9 to your computer and use it in GitHub Desktop.
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 pynmea2 | |
nmea_data = open("data/gps_data_20220215-070028.nmea", "rb") | |
for message_bytes in nmea_data.readlines()[:10]: # read first 10 messages from file | |
try: | |
message = message_bytes.decode("utf-8").replace("\n", "").replace("\r", "") | |
parsed_message = pynmea2.parse(message) | |
except: | |
# skip invalid messages | |
continue | |
print(f"message: {message}") | |
for field in parsed_message.fields: | |
value = getattr(parsed_message, field[1]) | |
print(f"{field[0]:40} {field[1]:20} {value}") | |
print("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment