@@ -115,7 +115,7 @@ def __init__(self, uart, debug=False):
115
115
self .total_mess_num = None
116
116
self .mess_num = None
117
117
self .debug = debug
118
- self .sentence = None
118
+ self .raw_sentence = None
119
119
120
120
def update (self ):
121
121
"""Check for updated data from the GPS module and process it
@@ -176,7 +176,12 @@ def datetime(self):
176
176
"""Return struct_time object to feed rtc.set_time_source() function"""
177
177
return self .timestamp_utc
178
178
179
- 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 ):
180
185
# Parse any NMEA sentence that is available.
181
186
# pylint: disable=len-as-condition
182
187
# This needs to be refactored when it can be tested.
@@ -201,9 +206,21 @@ def _parse_sentence(self):
201
206
actual ^= ord (sentence [i ])
202
207
if actual != expected :
203
208
return None # Failed to validate checksum.
204
- self .sentence = sentence
205
- # Remove checksum once validated.
206
- sentence = sentence [:- 3 ]
209
+
210
+ # copy the raw sentence
211
+ self .raw_sentence = sentence
212
+
213
+ return sentence
214
+
215
+ def _parse_sentence (self ):
216
+ sentence = self ._read_sentence ()
217
+
218
+ # sentence is a valid NMEA with a valid checksum
219
+ if sentence is None :
220
+ return None
221
+
222
+ # Remove checksum once validated.
223
+ sentence = sentence [:- 3 ]
207
224
# Parse out the type of sentence (first string after $ up to comma)
208
225
# and then grab the rest as data within the sentence.
209
226
delimiter = sentence .find (',' )
0 commit comments