chiark / gitweb /
script to reprogram santa-fe
authorian <ian>
Fri, 1 Sep 2006 17:56:56 +0000 (17:56 +0000)
committerian <ian>
Fri, 1 Sep 2006 17:56:56 +0000 (17:56 +0000)
hostside/reprogram [new file with mode: 0755]
hostside/santafe.cv-s [new file with mode: 0644]

diff --git a/hostside/reprogram b/hostside/reprogram
new file mode 100755 (executable)
index 0000000..0203f85
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+set -e
+
+fail () { echo >&2 "$0: error: $*"; exit 1; }
+
+if [ $# != 2 ]; then cat >&2 <<END; exit 1; fi
+ usage:
+  ./reprogram /dev/ttyS0 LOCO|FILENAME
+  where LOCO means ./LOCO.cv-s
+  and FILENAME must contain a slash
+END
+
+port="$1"; shift
+filename="$1"; shift
+
+case "$filename" in
+*/*)   ;;
+*)     filename="$filename.cv-s";;
+esac
+exec <"$filename"
+
+while read cv value; do
+       case "$cv" in
+       addr)
+               [ x$addr = x ] || fail 'addr twice'
+               addr=$(( $value + 0 ))
+               ;;
+       [0-9]*)
+               cv=$(( $cv + 0 ))
+               value=$(( $value + 0 ))
+               cvlist="$cvlist $cv=$value"
+               ;;
+       '#'*)
+               ;;
+       *)
+               fail 'invalid syntax'
+               ;;
+       esac
+done
+
+echo "Factory reset"
+./factory-reset-svc "$port"
+
+echo "Setting address to $addr"
+./program-cv-svc "$port" 1 $addr
+
+for cvv in $cvlist; do
+       sleep 1
+       cv=${cvv%=*}
+       value=${cvv#*=}
+       echo "Setting CV $cv = $value"
+       ./program-cv "$port" $addr $cv $value
+done
diff --git a/hostside/santafe.cv-s b/hostside/santafe.cv-s
new file mode 100644 (file)
index 0000000..7188743
--- /dev/null
@@ -0,0 +1,8 @@
+addr   2
+33     0
+34     0
+39     1
+40     2
+55     64
+56     64
+57     64