@@ -114,6 +114,7 @@ def __init__(self, uart, debug=False):
114
114
self .vdop = None
115
115
self .total_mess_num = None
116
116
self .mess_num = None
117
+ self ._raw_sentence = None
117
118
self .debug = debug
118
119
119
120
def update (self ):
@@ -175,7 +176,12 @@ def datetime(self):
175
176
"""Return struct_time object to feed rtc.set_time_source() function"""
176
177
return self .timestamp_utc
177
178
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 ):
179
185
# Parse any NMEA sentence that is available.
180
186
# pylint: disable=len-as-condition
181
187
# This needs to be refactored when it can be tested.
@@ -200,8 +206,23 @@ def _parse_sentence(self):
200
206
actual ^= ord (sentence [i ])
201
207
if actual != expected :
202
208
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 ]
205
226
# Parse out the type of sentence (first string after $ up to comma)
206
227
# and then grab the rest as data within the sentence.
207
228
delimiter = sentence .find (',' )
0 commit comments