EasyMotor v3 production script working, sans pressure input test
[fw/altos] / ao-bringup / turnon_easymotor
1 #!/bin/sh
2
3 if [ -x ../ao-tools/ao-flash/ao-flash-lpc ]; then
4         FLASH_LPC=../ao-tools/ao-flash/ao-flash-lpc
5 elif [ -x /usr/bin/ao-flash-lpc ]; then
6         FLASH_LPC=/usr/bin/ao-flash-lpc
7 else
8         echo "Can't find ao-flash-lpc!  Aborting."
9         exit 1
10 fi
11
12 if [ -x ../ao-tools/ao-usbload/ao-usbload ]; then
13         USBLOAD=../ao-tools/ao-usbload/ao-usbload
14 elif [ -x /usr/bin/ao-usbload ]; then
15         USBLOAD=/usr/bin/ao-usbload
16 else
17         echo "Can't find ao-usbload!  Aborting."
18         exit 1
19 fi
20
21 VERSION=3
22 PRODUCT=EasyMotor
23 BASE=`echo $PRODUCT | tr 'A-Z' 'a-z'`
24 echo $FILE
25
26 echo "$PRODUCT v$VERSION Turn-On and Calibration Program"
27 echo "Copyright 2022 by Bdale Garbee.  Released under GPL v3"
28 echo
29 echo "Expectations:"
30 echo "\t$PRODUCT v$VERSION powered from USB"
31 echo "\t\twith ST-Link-V2 cabled to debug header"
32 echo "\t\tand precision 2:1 resistor divider feeding pressure input from 5V out"
33 echo
34
35 case $# in
36     1)
37         SERIAL="$1"
38         echo "$PRODUCT-$VERSION serial number: $SERIAL" 
39         ;;
40     0)
41         echo -n "$PRODUCT-$VERSION serial number: "
42         read SERIAL
43         ;;
44     *)
45         echo "Usage: $0 <serial-number>" 1>&2
46         exit 1;
47         ;;
48 esac
49 otootor
50 #
51 # Use released versions of everything
52 #
53 FLASH_FILE=~/altusmetrumllc/Binaries/loaders/easymotor-v3-altos-flash-*.elf
54 ALTOS_FILE=~/altusmetrumllc/Binaries/easymotor-v3-*.elf
55
56 echo $FLASH_LPC $FLASH_FILE
57
58 $FLASH_LPC $FLASH_FILE || exit 1
59
60 sleep 1
61
62 echo $USBLOAD $ALTOS_FILE
63
64 $USBLOAD --serial=$SERIAL $ALTOS_FILE || exit 1
65
66 sleep 1
67
68 dev=`ao-list | awk '/EasyMotor-v'"$VERSION"'/ { print $3; exit(0); }'`
69
70 case "$dev" in
71 /dev/tty*)
72         echo "EasyMotor found on $dev"
73         ;;
74 *)
75         echo 'No EasyMotor-v'"$VERSION"' found'
76         exit 1
77         ;;
78 esac
79
80 echo 'E 0' > $dev
81
82 failed=1
83 while [ $failed = 1 ]; do
84     ../ao-tools/ao-cal-accel/ao-cal-accel $dev
85     failed=$?
86 done
87
88 echo 'E 1' > $dev
89
90 sleep 1
91
92 ./test-easymotor-v3
93
94 exit $?