diff options
Diffstat (limited to 'pyDMM/pyDMM.py')
| -rwxr-xr-x | pyDMM/pyDMM.py | 25 |
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)) |
