-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeaconMain.py
More file actions
39 lines (25 loc) · 828 Bytes
/
beaconMain.py
File metadata and controls
39 lines (25 loc) · 828 Bytes
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
from rn4020 import rn4020
import time
from OFile import OFile
msgCount = 10
#device = rn4020('COM3')
device = rn4020('/dev/ttyUSB0')
eNum = raw_input("Enter the experiment number: ")
print eNum
outFile = OFile("beacon")
print "Output file is: " + outFile.name
msSpacing = 500
for power in [0,1,2,3,4,5,6,7]:
powerString = str(power)
device.setPower(powerString)
startTime = 0
targetTime = time.clock()*1000 + msSpacing
for msg in range(0, msgCount):
while time.clock()*1000 < targetTime:
pass
targetTime = time.clock()*1000 + msSpacing
device.broadcast(eNum, msg, startTime, power)
startTime += msSpacing
# e m st p
outFile.write([eNum, msg, startTime, power])
#(E#, M#, Sender-Time, Sender-Power)