]> git.gag.com Git - fw/altos/blob - ao-bringup/turnon_telemetrum_v2.0
Merge branch 'easymotor-v3'
[fw/altos] / ao-bringup / turnon_telemetrum_v2.0
1 #!/bin/sh
2
3 if [ -x /usr/bin/ao-flash-stm ]; then
4         FLASH_STM=/usr/bin/ao-flash-stm
5 else
6         echo "Can't find ao-flash-stm!  Aborting."
7         exit 1
8 fi
9
10 if [ -x /usr/bin/ao-usbload ]; then
11         USBLOAD=/usr/bin/ao-usbload
12 else
13         echo "Can't find ao-usbload!  Aborting."
14         exit 1
15 fi
16
17 VERSION=2.0
18 PRODUCT=TeleMetrum
19
20 echo "$PRODUCT v$VERSION Turn-On and Calibration Program"
21 echo "Copyright 2014 by Bdale Garbee.  Released under GPL v2"
22 echo
23 echo "Expectations:"
24 echo "\t$PRODUCT v$VERSION powered from USB"
25 echo "\t\twith ST-Link-V2 cabled to debug header"
26 echo "\t\twith coax from UHF to frequency counter"
27 echo
28 echo -n "$PRODUCT-$VERSION serial number: "
29
30 case $# in
31     1)
32         SERIAL="$1"
33         echo "$PRODUCT-$VERSION serial number: $SERIAL" 
34         ;;
35     0)
36         echo -n "$PRODUCT-$VERSION serial number: "
37         read SERIAL
38         ;;
39     *)
40         echo "Usage: $0 <serial-number>" 1>&2
41         exit 1;
42         ;;
43 esac
44
45 echo $FLASH_STM
46
47 $FLASH_STM ~/altusmetrumllc/Binaries/loaders/telemetrum-v$VERSION-*.elf || exit 1
48
49 sleep 3
50
51 $USBLOAD --serial=$SERIAL ~/altusmetrumllc/Binaries/telemetrum-v$VERSION-*.elf || exit 1
52
53 sleep 5
54
55 dev=`ao-list | awk '/TeleMetrum-v'"$VERSION"'/ { print $3; exit(0); }'`
56
57 case "$dev" in
58 /dev/tty*)
59         echo "TeleMetrum found on $dev"
60         ;;
61 *)
62         echo 'No TeleMetrum-v'"$VERSION"' found'
63         exit 1
64         ;;
65 esac
66
67 echo 'E 0' > $dev
68
69 SERIAL=$SERIAL ./cal-freq $dev
70
71 failed=1
72 while [ $failed = 1 ]; do
73     ../ao-tools/ao-cal-accel/ao-cal-accel $dev
74     failed=$?
75 done
76
77 echo 'E 1' > $dev
78
79 ./test-telemetrum-v2.0
80
81 exit $?