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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions adafruit_gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def __init__(self, uart, debug=False):
self.total_mess_num = None
self.mess_num = None
self.debug = debug
self.sentence = None

def update(self):
"""Check for updated data from the GPS module and process it
Expand Down Expand Up @@ -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.

# Remove checksum once validated.
sentence = sentence[:-3]
# Parse out the type of sentence (first string after $ up to comma)
Expand Down