runDrand.py
上传用户:joranyuan
上传日期:2022-06-23
资源大小:3306k
文件大小:1k
- import os, sys, string, time
- tosRoot = '/home/acwarrie/tinyos-1.x'
- clearMotePath = tosRoot + '/apps/Blink'
- #progPath = tosRoot + '/contrib/zmac/apps/MultiHopThroughput'
- progPath = tosRoot + '/contrib/zmacDrand/apps/TestBedTopology'
- resultPath = '/home/acwarrie/research/TestBedDrand/results'
- loadAllMotes = 'loadlistTB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43'
- allMotes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]
- drandMotes = [ 2, 3, 9, 10, 39, 1, 24, 27, 28, 21, 37, 38, 36, 31, 32, 15,
- 17, 40, 41, 42, 43, 5, 14, 18, 19]
- loadDrandMotes = 'loadlistTB 2 3 9 10 39 1 24 27 28 21 37 38 36 31 32 15 17 40 41 42 43 5 14 ' +
- '18 19'
- expTime = 500
- def clearMotes():
- os.chdir(clearMotePath)
- os.system(loadAllMotes)
- time.sleep(10) #sleep for 10s
- os.system('rm -rf ' + resultPath + '/*')
- for run in range(2):
- clearMotes()
- time.sleep(10)
- os.chdir(progPath)
- os.system(loadDrandMotes)
- time.sleep(10)
- #create run result directory
- runPath = resultPath + '/run' + str(run)
- os.mkdir(runPath)
- for mote in drandMotes:
- pid = os.spawnlp(os.P_NOWAIT, 'telmoteTB', 'telmoteTB', 'h' + str(mote),
- runPath + '/h_' + str(mote))
- time.sleep(expTime)
- os.system('killall -s 9 telnet')
- os.system('kill -s 9 ' + str(pid))