view program @ 5:1a405bda2ffe

rewrite gpib using state machine instead of procedural code, add proper timeout, command queueing, several new commands, improve hardcopy utility
author Frank Kingswood <frank@kingswood-consulting.co.uk>
date Sat, 29 Mar 2014 23:23:58 +0000
parents 6dfcd8e5b8df
children acbd0ddd002b
line wrap: on
line source
1 #!/bin/sh
2 set -e
4 if [ $# -ne 3 ] || [ "$1" = "--help" ] ; then
5 echo "Called from Makefile to program USB-GPIB"
6 exit 1
7 fi
9 for DEV in /dev/ttyUSB0* ; do
10 true
11 done
13 MODE=
14 if lsusb -d 16c0:047a >/dev/null ; then
15 echo "Autodetecting USB-GPIB"
17 exec 3<>$DEV
19 (
20 sleep 1
21 kill -ALRM $$
22 ) &
23 trap "true" ALRM
24 while read X ; do echo $X ; done
25 sleep 1
27 echo "++ver" >&3
28 read V <&3
29 case "$V" in
30 *USB-GPIB-32U4*)
31 echo "Found USB-GPIB"
32 ;;
33 *)
34 exit 2
35 ;;
36 esac
38 # call the boot loader
39 case "$V" in
40 *Teensy*)
41 echo "++DEBUG 0x7e00" >&3
42 MODE=Teensy
43 ;;
44 *)
45 echo "++DEBUG 0x7800" >&3
46 MODE=AVR109
47 ;;
48 esac
50 exec 3>&-
51 sleep 0.5
53 elif lsusb -d 2341:8036 >/dev/null ; then
54 MODE=AVR109
56 elif lsusb -d 16c0:0478 >/dev/null ; then
57 MODE=Teensy
59 else
60 echo "No device found"
61 exit 1
62 fi
64 echo "$MODE boot loader"
66 if [ "$1" != "--program" ] ; then
67 exit 1
68 fi
70 sleep 0.5
71 set -x
73 case "$MODE" in
74 Teensy)
75 teensy_loader_cli -mmcu="$2" -w -v "$3"
76 ;;
77 AVR109)
78 avrdude -c avr109 -P $DEV -p "$2" -q -U flash:w:"$3"
79 ;;
80 esac