diff --git a/README.rst b/README.rst index 09cacf7..a1d1aea 100644 --- a/README.rst +++ b/README.rst @@ -41,7 +41,7 @@ Feather boards and many other circuitpython boards will round to two decimal pla >>> float('1234.5678') 1234.57 -This isn't ideal for gps data as this lowers the accuracty from 0.1m to 11m. +This isn't ideal for gps data as this lowers the accuracy from 0.1m to 11m. This can be fixed by using string formatting when the gps data is outputted. diff --git a/adafruit_gps.py b/adafruit_gps.py index a4511d5..57cf008 100644 --- a/adafruit_gps.py +++ b/adafruit_gps.py @@ -99,7 +99,10 @@ def update(self): """ # Grab a sentence and check its data type to call the appropriate # parsing function. - sentence = self._parse_sentence() + try: + sentence = self._parse_sentence() + except UnicodeError: + return None if sentence is None: return False if self.debug: @@ -145,7 +148,10 @@ def _parse_sentence(self): sentence = self._uart.readline() if sentence is None or sentence == b'' or len(sentence) < 1: return None - sentence = str(sentence, 'ascii').strip() + try: + sentence = str(sentence, 'ascii').strip() + except UnicodeError: + return None # Look for a checksum and validate it if present. if len(sentence) > 7 and sentence[-3] == '*': # Get included checksum, then calculate it and compare.