Skip to content

Commit 70db3f9

Browse files
authored
Merge pull request #17 from jomogalla/checking-input-buffer-before-reading
Update adafruit_gps.py
2 parents 50330e4 + 43d3aed commit 70db3f9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

adafruit_gps.py

+5
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ def _parse_sentence(self):
145145
# Parse any NMEA sentence that is available.
146146
# pylint: disable=len-as-condition
147147
# This needs to be refactored when it can be tested.
148+
149+
# Only continue if we have at least 64 bytes in the input buffer
150+
if self._uart.in_waiting < 64:
151+
return None
152+
148153
sentence = self._uart.readline()
149154
if sentence is None or sentence == b'' or len(sentence) < 1:
150155
return None

0 commit comments

Comments
 (0)