-
Notifications
You must be signed in to change notification settings - Fork 0
/
ina231_control.sh
executable file
·87 lines (75 loc) · 1.76 KB
/
ina231_control.sh
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
#!/bin/bash
INA_DIRS[0]=/sys/devices/12c60000.i2c/i2c-4/4-0040
INA_DIRS[1]=/sys/devices/12c60000.i2c/i2c-4/4-0041
INA_DIRS[2]=/sys/devices/12c60000.i2c/i2c-4/4-0044
INA_DIRS[3]=/sys/devices/12c60000.i2c/i2c-4/4-0045
INA_CTS="$(adb shell cat ${INA_DIRS[0]}/available_ct)"
VB=0
VSH=0
AVG=0
print_usage() {
echo "Usage: $0 (-v) [setup (-cg) (-nt) (-nb) (-nogl) (-i) | start | stop | finish (-nr)]"
echo ""
echo "-vb Do not trace binder {binder_transaction, cpu_idle, sched_switch}"
echo "-vsh Do not trace OpenGL {sys_logger:opengl_frame}"
echo "-a Syslogger logging interval, default = 5ms"
echo ""
echo "Available averages:"
echo "1"
echo "4"
echo "16"
echo "64"
echo "128"
echo "256"
echo "512"
echo "1024"
echo ""
echo "Available conversion times:"
echo "140"
echo "204"
echo "332"
echo "588"
echo "1100"
echo "2116"
echo "4156"
echo "8244"
echo ""
}
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-vb)
shift
VB=$1
shift # past argument
;;
-vsh)
shift
VSH=$1
shift # past argument
;;
-a)
shift
AVG=$1
shift
;;
*)
print_usage
exit 1
;;
esac
done
echo "Vbus CT given as ${VB}, Vshunt as ${VSH} with ${AVG} averages"
if [ "$VB" -eq 0 ] || [ "$VSH" -eq 0 ] || [ "$AVG" -eq 0 ]; then
echo "Not all required arguments given"
exit 1
fi
for INA in "${INA_DIRS[@]}"
do
echo "Setting $INA to $VB:$VSH:$AVG"
adb shell "echo $VB > $INA/vbus_ct"
adb shell "echo $VSH > $INA/vsh_ct"
adb shell "echo $AVG > $INA/averages"
done
DELAY=$(adb shell "cat ${INA_DIRS[0]}/delay")
echo "New delay is $DELAY"