summaryrefslogtreecommitdiff
path: root/pyDMM/pyDMM.py
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2011-12-19 18:20:33 +0000
committerTim Redfern <tim@eclectronics.org>2011-12-19 18:20:33 +0000
commite9a73bbb3c14af340999f70146747787785f4fee (patch)
treea125452f7d641673286542497da051b810427880 /pyDMM/pyDMM.py
initial commit
Diffstat (limited to 'pyDMM/pyDMM.py')
-rwxr-xr-xpyDMM/pyDMM.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/pyDMM/pyDMM.py b/pyDMM/pyDMM.py
new file mode 100755
index 0000000..0b77041
--- /dev/null
+++ b/pyDMM/pyDMM.py
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+
+import time,serial,signal,sys,struct
+
+serIn = serial.Serial(
+ port='/dev/rfcomm0',
+ baudrate=38400
+)
+
+def signal_handler(signal, frame):
+ print "closing",serIn.port
+ serIn.close()
+ sys.exit(0)
+
+signal.signal(signal.SIGINT, signal_handler)
+S=struct.Struct('<HIH')
+while 1:
+ r=bytearray()
+ remaining=8
+ while remaining > 0:
+ if serIn.inWaiting() >0:
+ r.extend(serIn.read())
+ remaining=8-len(r)
+ #time.sleep(1) #doesn't work for some reason
+ print S.unpack_from(buffer(r))