diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-05-05 14:44:58 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-05-05 14:44:58 +0100 |
| commit | 472e9dc583e7f61f4d7cfbc4c02a5690230b2c88 (patch) | |
| tree | bca8c08518e5fb2b292c073a18267476e9826aed /tomorrowtheground.py | |
| parent | 0dfef4d8ac8b0aaf56d6d5f643ad6770e3a1ec79 (diff) | |
checking gps
Diffstat (limited to 'tomorrowtheground.py')
| -rwxr-xr-x | tomorrowtheground.py | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/tomorrowtheground.py b/tomorrowtheground.py deleted file mode 100755 index a3d47bc..0000000 --- a/tomorrowtheground.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/python -#UDP listener - -import signal,sys - -def signal_handler(signal, frame): - insock.close() - print "tomorrowtheground: interrupted" - sys.exit(0) - -signal.signal(signal.SIGINT, signal_handler) - -from latLng import * -from layers import * -from xml2obj import * - - -if len(sys.argv)<2: - print "usage: tomorrowtheground configfile [-D] (debug)]" - -debug=False -if len(sys.argv)>2: - if sys.argv[1]=="-D" or sys.argv[1]=="-d": - debug=True - -doc=xml2obj(open(sys.argv[1])) -gpslayers=[] - -#catch invalid xml -try: - for i in doc.gps.index: - #catch invalid xml - try: - g=indexlayer(i.file,i.ll1,i.ll2) - for t in i.trigger: - g.triggers.append(trigger(int(t.id),t.command,t.param)) - gpslayers.append(g) - except: - print "error parsing xml index entry" -except: - print "no index layers found" - -#catch invalid xml -try: - for i in doc.gps.scale: - #catch invalid xml - try: - g=scalelayer(i.file,i.ll1,i.ll2) - g.setcommand(i.command) - gpslayers.append(g) - except: - print "error parsing xml index entry" -except: - print "no scale layers found" - -from gpspoller import * -gpsp="" - -try: - gpsp = GpsPoller(doc.gpsdevice) - gpsp.start() -except: - print "gps device not found" - - -import socket - -GUI_IP="0.0.0.0" -GUI_PORT=5400 -insock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) -insock.bind( (GUI_IP,GUI_PORT) ) -insock.settimeout(0.01) #non blocking -PD_IP="127.0.0.1" -PD_PORT=5401 -outsock = socket.socket( socket.AF_INET,socket.SOCK_DGRAM ) - -pos=latLng() -posChanged=False - -while True: - data="" - try: - data, addr = insock.recvfrom(128) - pos.parse(data) - if (debug): - print "received:",data - posChanged=True - except: - nothing=None - if gpsp!="": - check=gpsp.check() - if check!=False: - pos=latLng(check[0],check[1]) - posChanged=True - if posChanged: - posChanged=False - for layer in gpslayers: - r=layer.checkcoord(pos) #returns a message or None - if r!=None: - if (debug): - print "sending:",str(r[0]),str(r[1]) - #pd needs \n at end of message - outsock.sendto( str(r[0])+' '+str(r[1])+'\n', (PD_IP, PD_PORT) ) -
\ No newline at end of file |
