Skip to content

Commit 20ce7e7

Browse files
authored
Merge pull request #34 from dherrada/master
Adding raw sentence
2 parents 98b8145 + 237e845 commit 20ce7e7

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

adafruit_gps.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def __init__(self, uart, debug=False):
114114
self.vdop = None
115115
self.total_mess_num = None
116116
self.mess_num = None
117+
self._raw_sentence = None
117118
self.debug = debug
118119

119120
def update(self):
@@ -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 nmea_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+
_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)