Skip to content

Commit 8cf5191

Browse files
authored
Merge pull request #8 from billxinli/master
Moving Bill's changes to my repo
2 parents 11382eb + 1d842a0 commit 8cf5191

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

adafruit_gps.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def __init__(self, uart, debug=False):
115115
self.total_mess_num = None
116116
self.mess_num = None
117117
self.debug = debug
118+
self.raw_sentence = None
118119

119120
def update(self):
120121
"""Check for updated data from the GPS module and process it
@@ -175,7 +176,12 @@ def datetime(self):
175176
"""Return struct_time object to feed rtc.set_time_source() function"""
176177
return self.timestamp_utc
177178

178-
def _parse_sentence(self):
179+
@property
180+
def raw_sentence(self):
181+
"""Return raw_sentence which is the raw NMEA sentence read from the GPS"""
182+
return self.raw_sentence
183+
184+
def _read_sentence(self):
179185
# Parse any NMEA sentence that is available.
180186
# pylint: disable=len-as-condition
181187
# This needs to be refactored when it can be tested.
@@ -200,8 +206,23 @@ def _parse_sentence(self):
200206
actual ^= ord(sentence[i])
201207
if actual != expected:
202208
return None # Failed to validate checksum.
203-
# Remove checksum once validated.
204-
sentence = sentence[:-3]
209+
210+
# copy the raw sentence
211+
self.raw_sentence = sentence
212+
213+
return sentence
214+
# At this point we don't have a valid sentence
215+
return None
216+
217+
def _parse_sentence(self):
218+
sentence = self._read_sentence()
219+
220+
# sentence is a valid NMEA with a valid checksum
221+
if sentence is None:
222+
return None
223+
224+
# Remove checksum once validated.
225+
sentence = sentence[:-3]
205226
# Parse out the type of sentence (first string after $ up to comma)
206227
# and then grab the rest as data within the sentence.
207228
delimiter = sentence.find(',')

0 commit comments

Comments
 (0)