-
Notifications
You must be signed in to change notification settings - Fork 60
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
Conversation
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
@billxinli If you'd like, I can fork your fork and make a PR myself with the changes you made. |
For sure!
…On Sun., Aug. 25, 2019, 1:28 p.m. dherrada, ***@***.***> wrote:
@billxinli <https://github.com/billxinli> If you'd like, I can fork your
fork and make a PR myself with the changes you made.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#32?email_source=notifications&email_token=AAMQX6BFPIRTJHITFMWJTI3QGK6NHA5CNFSM4IGMXBSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5CX3RQ#issuecomment-524647878>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMQX6AFOFSAWYOBYVAEMODQGK6NHANCNFSM4IGMXBSA>
.
|
Moved to #34. Closing |
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.