Receive changes

master
Dan 2018-06-13 19:59:02 -06:00
parent ff95dc6aa1
commit 71235a60e2
1 changed files with 10 additions and 2 deletions

View File

@ -3,7 +3,8 @@
import socket
import time
import serial
import pynmea2
import sys, os
#import pynmea2
ser = serial.Serial('/dev/ttyACM0',9600)
@ -16,12 +17,19 @@ sock = socket.socket(socket.AF_INET, # Internet
sock.setblocking(0)
sock.bind((UDP_IP, UDP_PORT))
outfile = open("./results.txt", 'w')
last_gps = ''
while True:
try:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
output_str = "Received Message:" + data + '/' + last_gps
print "received message:", data, '/', last_gps
outfile.write(output_str)
outfile.flush()
os.system('play system-ready.ogg -q -V0')
except socket.error: pass
data = ser.readline()
if (data.startswith("$GNGGA")):
last_gps = pynmea2.parse(data)
last_gps = data
# last_gps = pynmea2.parse(data)