File: test.py

package info (click to toggle)
tinyos 2.1.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 47,476 kB
  • ctags: 36,607
  • sloc: ansic: 63,646; cpp: 14,974; java: 10,358; python: 5,215; makefile: 1,724; sh: 902; asm: 597; xml: 392; perl: 74; awk: 46
file content (44 lines) | stat: -rw-r--r-- 1,266 bytes parent folder | download
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
# This script is a simple TOSSIM test of dissemination.
# It builds a 15x15 grid of nodes and has nodes start
# disseminating two values (based on the TinyOS app).
# It prints out when nodes receive new values, including
# the dissemination key and sequence number. You should
# be able to see how the implementation can resolve
# multiple concurrent changes within the network as
# well as more than one value being updated at a time.

import TOSSIM
import sys

t = TOSSIM.Tossim([])
m = t.mac();
r = t.radio();
t.init()

#t.addChannel("LedsC", sys.stdout);
#t.addChannel("AM", sys.stdout);
#t.addChannel("TestDisseminationC", sys.stdout);
t.addChannel("Dissemination", sys.stdout)
t.addChannel("TestDisseminationC", sys.stdout)
#t.addChannel("Gain", sys.stdout);
#t.addChannel("TossimPacketModelC", sys.stdout);

print (dir(TOSSIM.Tossim))

f = open("topo.txt", "r")
lines = f.readlines()
for line in lines:
  s = line.split()
  if (len(s) > 0):
    if (s[0] == "gain"):
      r.add(int(s[1]), int(s[2]), float(s[3]))

for i in range(0, 225):
  m = t.getNode(i);
  for j in range (0, 100):
    m.addNoiseTraceReading(-105)
  m.createNoiseModel()
  m.bootAtTime((t.ticksPerSecond() / 50) * i + 43);
 
while (t.time() / t.ticksPerSecond() < 600):
  t.runNextEvent()