Programm now ignores \n
This commit is contained in:
parent
7ef68564ec
commit
e0cc8ece50
12
render.py
12
render.py
|
@ -3,22 +3,22 @@ import pynmea2
|
||||||
import serial
|
import serial
|
||||||
import io
|
import io
|
||||||
|
|
||||||
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=5.0)
|
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=5.0)
|
||||||
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
|
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
|
||||||
last_time = 00
|
last_time = 00
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
line = sio.readline()
|
line = sio.readline().rstrip('\n') # Remove newline character
|
||||||
msg = pynmea2.parse(line)
|
msg = pynmea2.parse(line)
|
||||||
latitude = msg.latitude
|
latitude = msg.latitude
|
||||||
longitude = msg.longitude
|
longitude = msg.longitude
|
||||||
time = msg.timestamp
|
time = msg.timestamp
|
||||||
except serial.SerialException as e:
|
except serial.SerialException as e:
|
||||||
print('Device error: {}'.format(e))
|
# print('Device error: {}'.format(e))
|
||||||
break
|
break
|
||||||
except pynmea2.ParseError as e:
|
except pynmea2.ParseError as e:
|
||||||
print('Parse error: {}'.format(e))
|
# print('Parse error: {}'.format(e))
|
||||||
continue
|
continue
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
continue
|
continue
|
||||||
|
@ -27,7 +27,7 @@ while 1:
|
||||||
center = (latitude, longitude)
|
center = (latitude, longitude)
|
||||||
m = Map(center=center, zoom=15)
|
m = Map(center=center, zoom=15)
|
||||||
marker = Marker(location=center, draggable=False)
|
marker = Marker(location=center, draggable=False)
|
||||||
m.add_layer(marker);
|
m.add_layer(marker)
|
||||||
display(m)
|
display(m)
|
||||||
last_time = time
|
last_time = time
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue