try-except in code samples to fix gps decode error

pull/374/head
Mauricio Buschinelli 3 years ago
parent 04ec0c33be
commit cc4a195047

@ -22,10 +22,14 @@ def print_gps_data(line):
print(f'{lat},{lon} - from {msg.num_sats} satellites')
while True:
try:
line = serial.readline().decode('utf-8')
while len(line) > 0:
print_gps_data(line)
line = serial.readline().decode('utf-8')
except UnicodeDecodeError:
line = serial.readline().decode('utf-8')
time.sleep(1)

@ -9,10 +9,14 @@ def print_gps_data():
print(line.rstrip())
while True:
try:
line = serial.readline().decode('utf-8')
while len(line) > 0:
print_gps_data()
line = serial.readline().decode('utf-8')
except UnicodeDecodeError:
line = serial.readline().decode('utf-8')
time.sleep(1)

Loading…
Cancel
Save