summaryrefslogtreecommitdiff
path: root/wim.py
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-05-08 22:08:01 +0100
committerTim Redfern <tim@eclectronics.org>2012-05-08 22:08:01 +0100
commit8ae7ef3211087357333fd5170b114fb08b8b2ad0 (patch)
treed12d189d35d6c326b1177babe891062ed1df3fb0 /wim.py
parentb7e28404a9962cf220c51e1b83b81b6a2b6a3d87 (diff)
added bluetooth scanner
Diffstat (limited to 'wim.py')
-rwxr-xr-xwim.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/wim.py b/wim.py
index ccc0ac8..e8f6c78 100755
--- a/wim.py
+++ b/wim.py
@@ -5,7 +5,7 @@ import signal,sys
def signal_handler(signal, frame):
insock.close()
- print "tomorrowtheground: interrupted"
+ print "wim: tomorrowtheground: interrupted"
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
@@ -16,7 +16,7 @@ from xml2obj import *
if len(sys.argv)<2:
- print "usage: tomorrowtheground configfile [-D] (debug)]"
+ print "wim: usage: tomorrowtheground configfile [-D] (debug)]"
debug=False
if len(sys.argv)>2:
@@ -37,9 +37,9 @@ try:
g.triggers.append(trigger(int(t.id),t.command,t.param))
gpslayers.append(g)
except:
- print "error parsing xml index entry"
+ print "wim: error parsing xml index entry"
except:
- print "no index layers found"
+ print "wim: no index layers found"
#catch invalid xml
try:
@@ -50,9 +50,9 @@ try:
g.setcommand(i.command)
gpslayers.append(g)
except:
- print "error parsing xml index entry"
+ print "wim: error parsing xml index entry"
except:
- print "no scale layers found"
+ print "wim: no scale layers found"
from gpspoller import *
gpsp=""
@@ -61,7 +61,14 @@ try:
gpsp = GpsPoller(doc.gpsdevice)
gpsp.start()
except:
- print "gps device not found"
+ print "wim: gps device not found"
+
+from btscan import *
+
+scan=scanner("127.0.0.1",5401,False)
+for t in doc.bt.trigger:
+ scan.d.dm.triggers[t.id]=(t.command,t.param)
+scan.start()
import socket
@@ -86,7 +93,7 @@ while True:
data, addr = insock.recvfrom(128)
pos.parse(data)
if debug:
- print "received:",data
+ print "wim: received:",data
posChanged=True
except:
nothing=None
@@ -102,7 +109,7 @@ while True:
check=gpsp.check()
if check!=False:
if debug:
- print "received from gps",check[0],check[1]
+ print "wim: received from gps",check[0],check[1]
pos=latLng(check[0],check[1])
posChanged=True
if posChanged:
@@ -111,7 +118,7 @@ while True:
r=layer.checkcoord(pos) #returns a message or None
if r!=None:
if (debug):
- print "sending:",str(r[0]),str(r[1])
+ print "wim: 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) )