Root/prod/Common

Source at commit 86ea428afcef59fd87407fe10ccd84c7294873a5 created 9 years 4 months ago.
By Werner Almesberger, prod/doc/analysis.html: emphasize that 1 MHz clock is normal without firmware
1#!/bin/sh
2
3DIV1=------------------------------------------------------------------------
4DIV2=========================================================================
5
6
7usage()
8{
9    echo "usage: $0 ref_dev test_dev" 1>&2
10    exit 1
11}
12
13
14[ "$2" -a -z "$3" ] || usage
15REF=$1
16# DUT = Device Under Test
17DUT=$2
18LOG=_log
19>$LOG
20
21if [ ${REF#net:} = $REF ]; then
22    REF_EXEC=
23else
24    REF_EXEC="ssh `echo $REF | sed 's/^net://;s/,.*$//'`"
25fi
26
27if [ ${DUT#net:} = $DUT ]; then
28    LOCAL_EXEC=
29    LOCAL_DUT=$DUT
30else
31    LOCAL_EXEC="ssh `echo $DUT | sed 's/^net://;s/,.*$//'`"
32    LOCAL_DUT=`atrf-id -d $DUT -s -s`
33fi
34
35
36##### Test setup ############################################################
37
38
39step()
40{
41    echo -n " .... $1"
42    step=$1
43    cmd=
44    >_out
45    echo $DIV2 >>$LOG
46}
47
48
49##### Test result ###########################################################
50
51
52finish()
53{
54    echo "$cmd" >>$LOG
55    echo | sed "c$DIV1" >>$LOG
56    cat _out >>$LOG
57    sed "1i$DIV1" >>$LOG
58}
59
60
61pass()
62{
63    echo '\r\033[42;30m PASS \033[0m '
64    echo "$step: PASS" >>$LOG
65    finish </dev/null
66}
67
68
69fail()
70{
71    echo '\r\033[41;37m FAIL \033[0m '
72    echo "$step: FAIL" >>$LOG
73    finish
74#
75# to do: allow looping back
76#
77    exit 1
78}
79
80
81todo()
82{
83    echo '\r\033[43;30m TODO \033[0m '
84    echo "$step: TODO" >>$LOG
85    finish </dev/null
86}
87
88
89##### Test execution ##########################################################
90
91
92cmd()
93{
94    cmd=$1
95}
96
97
98##### Evaluation ############################################################
99
100
101_doit()
102{
103    eval "$cmd" >_out 2>&1 || { echo "exit code $?" | fail; exit 1; }
104}
105
106
107doit()
108{
109    _doit
110    pass
111}
112
113
114expect()
115{
116    _doit
117    fgrep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
118    pass
119}
120
121
122expect_re()
123{
124    _doit
125    grep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
126    pass
127}
128
129
130##### Tests #################################################################
131
132
133begin()
134{
135    if [ "$1" ]; then
136        PROFILE=$1
137        if [ ! -r $PROFILE ]; then
138            echo "$PROFILE not found" 1>&2
139            exit 1
140        fi
141    fi
142    if [ "$2" ]; then
143        CLKREF=$2
144        if ! $LOCAL_EXEC "[ -r $CLKREF ]"; then
145            echo "$CLKREF not found" 1>&2
146            exit 1
147        fi
148    fi
149}
150
151
152identify()
153{
154    step "Identification"
155    cmd "atrf-id -d $DUT"
156    expect "AT86RF231, part 0x03 version 2 manufacturer xxxx001f (Atmel)"
157}
158
159
160spectrum()
161{
162    step "Spectrum"
163# todo:
164# - trim values (maybe)
165# - decide on power
166# - decide on offset
167    cmd "atrf-path -g -T +0.5 -P $PROFILE $REF $DUT 10"
168    expect PASS
169}
170
171
172transmit()
173{
174    step "Receive"
175# todo:
176# - trim values (maybe)
177# - channel
178# - tolerate imperfection (e.g., 99/100|100/100)
179    cmd "atrf-xmit -p 0 $REF $DUT 100"
180    expect 100/100
181
182    step "Send"
183    cmd "atrf-xmit -p 15 $DUT $REF 100"
184    expect 100/100
185}
186

Archive Download this file



interactive