-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iterate through a Talker Sentence #85
Comments
Hi, Here is one way to do this today: msg = pynmea2.parse("$GPGGA,184353.07,1929.045,S,02410.506,E,1,04,2.6,100.00,M,-33.9,M,,0000*6D")
fields = {k: getattr(msg, k) for k in msg.name_to_idx}
print(fields) Output: {'timestamp': datetime.time(18, 43, 53, 70000), 'lat': '1929.045', 'lat_dir': 'S', 'lon': '02410.506', 'lon_dir': 'E', 'gps_qual': 1, 'num_sats': '04', 'horizontal_dil': '2.6', 'altitude': 100.0, 'altitude_units': 'M', 'geo_sep': '-33.9', 'geo_sep_units': 'M', 'age_gps_data': '', 'ref_station_id': '0000'} Note that not all NMEA messages map cleanly to key-value pairs, and some types will have extra data that will not appear in I will leave this ticket open for myself to create a better public facing API for this usage. |
Thanks! Might suggest just adding it to the example code. |
There are fields like |
I'm trying to figure out the best way to parse through the fields in a talker.
type(pynmea2.parse("$GPGSV,..."))
produces<class 'pynmea2.types.talker.GSV'>
A bit of exploring didn't seem to come up with a good solution, without having to follow how the test code is setup where you have to know before you do.
I was trying to target something like the following.
However I get the following response.
I also tried a variant with
but got
suggestions welcome!
The text was updated successfully, but these errors were encountered: