@@ -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