summaryrefslogtreecommitdiff
path: root/mac/pbproc/test/maximus/py/host_test_pbproc.py
blob: 2d55c183eef63998d2e754b8d54f6ed966d83e69 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/python
import sys;
sys.path.append ('../../../../maximus/python')
sys.path.append ('../../../../maximus/python/obj')

trace = { }
for i in ('phy', 'ca', 'pbproc'):
    o = '--%s-trace' % i
    if o in sys.argv:
        trace[i] = True
        sys.argv.remove (o)

bp_tck = 25000000 / 50
before_bp_tck = bp_tck * 3 / 4

from interface import *
from test_pbproc import *

maximus = Maximus ()
maximus.init (sys.argv + ['-e', 'obj/test_pbproc.elf'])

sta1 = maximus.create_sta ()
sta1.set_name ('sta1')
sta2 = maximus.create_sta ()
sta2.set_name ('sta2')

t1 = TestPBProc (maximus, sta1)
t2 = TestPBProc (maximus, sta2)

sta1.debug ()
sta2.debug ()

t1.set_config (tei = 1, snid = 1)
t2.set_config (tei = 2, snid = 1)

beacon_period = dict (glid = 0xff, coex = 2)

t1.add_beacon_period (start_date = 0, **beacon_period)
t1.add_beacon_period (start_date = bp_tck, **beacon_period)
t1.add_beacon_period (start_date = 2 * bp_tck, **beacon_period)
t2.add_beacon_period (start_date = 0, **beacon_period)
t2.add_beacon_period (start_date = bp_tck, **beacon_period)
t2.add_beacon_period (start_date = 2 * bp_tck, **beacon_period)

t1.seg = t2.seg = 0
t1.add_seg (mme = False, lid = 0, tei = 2, seg_nb = 16, gen = 0); t1.seg += 16
t1.add_seg (mme = True, lid = 0, tei = 2, seg_nb = 4, gen = 0); t1.seg += 4
t1.add_seg (mme = False, lid = 1, tei = 2, seg_nb = 4, gen = 0); t1.seg += 4
t2.add_seg (mme = False, lid = 0, tei = 1, seg_nb = 16, gen = 0); t2.seg += 16

t1.rx_seg_refill (seg_nb = 25)
t2.rx_seg_refill (seg_nb = 25)
t1.activate ()
t2.activate ()

stop = 0

def get_seg_cb (r, seg_nb):
    assert (r.seg_nb == seg_nb)
    global stop
    stop += 1
t1.get_seg_async (lambda r: get_seg_cb (r, t2.seg), seg_nb = t2.seg)
t2.get_seg_async (lambda r: get_seg_cb (r, t1.seg), seg_nb = t1.seg)

bp = 0
while stop != 2:
    bp += 1
    maximus.wait (before_bp_tck)
    t1.prepare_beacon (lid = 0xfd)
    maximus.wait (bp_tck - before_bp_tck)
    if bp == 1:
        t2.set_tonemap (RX, tei = 1, tmi = 5, bits = 10)
        t1.set_tonemap (TX, tei = 2, tmi = 5, bits = 10)
        t1.set_tonemap (RX, tei = 2, tmi = 6, bits = 6)
        t2.set_tonemap (TX, tei = 1, tmi = 6, bits = 6)
    t1.add_beacon_period (start_date = (bp + 2) * bp_tck, **beacon_period)
    t2.add_beacon_period (start_date = (bp + 2) * bp_tck, **beacon_period)

t1.activate (False)
t2.activate (False)

print 'trace sta1:'; sys.stdout.flush ()
t1.trace_dump (**trace)
print '\ntrace sta2:'; sys.stdout.flush ()
t2.trace_dump (**trace)