-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprobeMain.py
More file actions
61 lines (43 loc) · 1.19 KB
/
probeMain.py
File metadata and controls
61 lines (43 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#
# probeMain.py
#
# Code to run the DeltaBot probes.
#
from rn4020 import rn4020
from OFile import OFile
from pprint import pprint
import signal
# 3. Turn on broadcast reception
# 4. Log each incoming broadcast
#
# Get the name of this probe for the output file
probe = raw_input("Which probe is this: ")
validProbes = ["A","B","C","D"]
if probe not in validProbes:
print "Bad User! Valid probes are:"
pprint(validProbes)
# Create the output file, but don't crash in to the previous one.
#
# Note that the name of the file CANNOT have a dash in it.
# so "probe-A" is bad! It confuses OFile. Do "probeA" instead.
outFile = OFile("probeData" + probe)
print "Output file is: " + outFile.name
# configure broadcast reception
ble = rn4020("/dev/ttyUSB0")
ble.receivePrepare()
while True:
data = ble.receive()
if data is None: # bad message (wrong magic, size, etc) came in
continue
if not data: # interrupted
break;
eNum = data[0]
mNum = data[1]
st = data[2]
sp = data[3]
rp = data[4]
print str(eNum) + "," + str(mNum)
outFile.write([probe,eNum,mNum,st,sp,rp])
print
print "Closing file and exiting."
outFile.close()