-
Notifications
You must be signed in to change notification settings - Fork 7
/
run_test
executable file
·107 lines (95 loc) · 3.08 KB
/
run_test
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# This test requires a "test8" device, which is an ATmega88.
#
# Connect GND
# Connect VCC and AVCC to +5V
# Connect B1 to D6
# Connect B0 to D7
# Connect B0 via 1Mohm resistor to C0
# Connect C0 via 10µF capacitor to GND
# Connect AREF via a 100nF capacitor to GND
# Connect 1wire to D2
set -e
cfg() {
./cfg world.cfg "$@"
}
V=1
test -z "$V" || echo Setting up
DEV=test8
TYP=$(cfg devices.$DEV.defs.is_onewire)
ID=$(cfg devices.$DEV.onewire_id)
OW=$(cfg codes.onewire.$TYP).$ID
test "$(owread /$OW/config/name)" = "$DEV"
X=""
while : ; do
R="$(owread /uncached/F0.947476A5F130/console)"
if test -z "$R" ; then break; fi;
X="$X$R"
done
if test -n "$X"; then echo "Console: $X"
else test -z "$V" || echo "no console"; fi
#owdir /$OW
#owread /$OW/config/types
owwrite /$OW/pwm.2 1,0
owwrite /$OW/port.1 0
owwrite /$OW/pwm.1 1,0
test -z "$V" || echo PWM and counter monitor
sleep 2
owwrite /$OW/pwm.1 9,11
X=""
C1="$X$(owread /uncached/$OW/count.1)"
sleep 1
X="$X$(owread /uncached/$OW/port.2)"
sleep 1
X="$X$(owread /uncached/$OW/port.2)"
sleep 1
X="$X$(owread /uncached/$OW/port.2)"
sleep 1
X="$X$(owread /uncached/$OW/port.2)"
sleep 1
X="$X$(owread /uncached/$OW/port.2)"
sleep 1
X="$X$(owread /uncached/$OW/port.2)"
test "$X" = "010101"
C2="$(owread /uncached/$OW/count.1)"
test $(( $C2 - $C1 )) = 6
test -z "$V" || echo ADC check
A1=$(owread /uncached/F0.947476a5f130/adc.1|sed -e 's/,.*//')
test $A1 -gt 13700 && test $A1 -lt 14000
A2=$(owread /uncached/F0.947476a5f130/adc.2|sed -e 's/,.*//')
test $A2 -gt 4350 && test $A2 -lt 4500
A3=$(owread /uncached/F0.947476a5f130/adc.3|sed -e 's/,.*//')
test $A3 -gt 20000 && test $A3 -lt 23000
if test $(owread /uncached/$OW/adc.4|sed -e 's/,.*//') -gt 1024 ; then
test -z "$V" || echo Waiting for C to discharge
while : ; do
sleep 1
X=$(owread /uncached/$OW/adc.4|sed -e 's/,.*//')
if test $X -lt 1025 ; then echo " $X."; break; fi;
echo -ne " $X "'\r'
done
echo ""
fi
trap 'owwrite /$OW/pwm.2 1,0' 0 1 2 15
test -z "$V" || echo start PWM
owwrite /$OW/pwm.2 5,2
owwrite /$OW/adc.4 0,15000
sleep 1
X=$(owread /uncached/$OW/adc.4|sed -e 's/,.*//')
if test $X -gt 5300 && test $X -lt 6600 ; then : ; else echo "ADC $X 1"; exit 1; fi
if owread /uncached/$OW/alarm/sources|grep -qs adc ; then echo "ADC ALARM ON?"; exit 1; fi
sleep 1
X=$(owread /uncached/$OW/adc.4|sed -e 's/,.*//')
if test $X -gt 9100 && test $X -lt 10800 ; then : ; else echo "ADC $X 2"; exit 1; fi
sleep 1
X=$(owread /uncached/$OW/adc.4|sed -e 's/,.*//')
if test $X -gt 13600 && test $X -lt 14600 ; then : ; else echo "ADC $X 3"; exit 1; fi
sleep 1
X=$(owread /uncached/$OW/adc.4|sed -e 's/,.*//')
if test $X -gt 16700 && test $X -lt 17750 ; then : ; else echo "ADC $X 4"; exit 1; fi
sleep 1
X=$(owread /uncached/$OW/adc.4|sed -e 's/,.*//')
if test $X -gt 19600 && test $X -lt 20200 ; then : ; else echo "ADC $X 5"; exit 1; fi
if owread /uncached/$OW/alarm/sources|grep -qs adc ; then : ; else echo "ADC ALARM OFF?"; exit 1; fi
if owread /uncached/$OW/alarm/adc|fgrep -qs +4 ; then : ; else echo "ADC ALARM 4?"; exit 1; fi
test -z "$V" || echo TEST DONE OK