Skip to content

feat(raw): Adding raw sentence #32

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

Closed
wants to merge 3 commits into from
Closed

Conversation

billxinli
Copy link
Contributor

I am unsure if this is within the scope of contributing to the module.

I purchased the Adafruit ultimate GPS feather, the Adafruit M4 express board, and finally the OLED board, with the hopes that I can log both the raw NMEA sentence to the SD card, at the same time display the current data with the OLED.

However, I realized that this module never exposed the raw sentence post parsing. I've added the functionality for the raw NMEA sentence to be fetched.

adafruit_gps.py Outdated
@@ -200,6 +201,7 @@ def _parse_sentence(self):
actual ^= ord(sentence[i])
if actual != expected:
return None # Failed to validate checksum.
self.sentence = sentence
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea! we'd want a new private variable that gets set, and isn't changed (below, the checksum is removed) and then a property getter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ladyada thanks for the comment. I split out _parse_sentence into _read_sentence which will set the property raw_sentence. I've also added a new property getter that returns the raw_sentence string.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you made the requested changes. I'll be testing the examples, and will merge the PR assuming they pass

Copy link
Collaborator

@evaherrada evaherrada Aug 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so for some reason, when self.raw_sentence is defined as None in __init__, it says:
AttributeError: 'GPS' object has no attribute 'raw_sentence'
The same thing happens with all example files except the datalogging files, which don't use the gps module.

When I comment out self.raw_sentence = None, that fixes it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so I think that you can't have both a variable defined in __init__ as None and a property getter. @ladyada Would it be ok if the variable got removed from __init__? I've tested with the example files, and that seems to be the only way to get it to run.

Copy link
Member

@ladyada ladyada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep thats right, you'll need to change around the variable usage, since you cannot assign a function to None :) make sure the data the property emits is initialized to None tho :)

@@ -175,7 +176,12 @@ def datetime(self):
"""Return struct_time object to feed rtc.set_time_source() function"""
return self.timestamp_utc

def _parse_sentence(self):
@property
def raw_sentence(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to nmea_sentence

@@ -115,6 +115,7 @@ def __init__(self, uart, debug=False):
self.total_mess_num = None
self.mess_num = None
self.debug = debug
self.raw_sentence = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call this _raw_sentence (private)

@evaherrada
Copy link
Collaborator

@billxinli If you'd like, I can fork your fork and make a PR myself with the changes you made.

@billxinli
Copy link
Contributor Author

billxinli commented Aug 25, 2019 via email

@evaherrada evaherrada mentioned this pull request Aug 27, 2019
@evaherrada
Copy link
Collaborator

Moved to #34. Closing

@evaherrada evaherrada closed this Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants