This lets you run the easy mini testing code without also flashing the device.
Signed-off-by: Keith Packard <keithp@keithp.com>
}
}
-string[*] settings(file f) {
- string[...] x = {};
-
- flush_input(f);
- fprintf (f, "c s\nv\n");
- flush(f);
- for (;;) {
- string l = File::fgets(f);
- x[dim(x)] = l;
- if (String::index(l, "software-version") == 0)
- break;
- }
- return x;
-}
-
-string[*] find_setting(string[*] s, string match) {
- for (int i = 0; i < dim(s); i++)
- if (String::index(s[i], match) == 0)
- return String::wordsplit(s[i], " ");
- return (string[*]) {};
-}
-
string[*] baro(file f) {
string[...] x = {};
fprintf (f, "B\n");
flush(f);
for (;;) {
- string l = File::fgets(f);
+ string l = timed_read(f, 1000);
+ if (l == "") {
+ File::fprintf(stderr, "read timedout\n");
+ exit(1);
+ }
x[dim(x)] = l;
if (String::index(l, "Altitude:") == 0)
break;
--- /dev/null
+#!/bin/sh
+
+VERSION=1.0
+PRODUCT=EasyMini
+BASE=`echo $PRODUCT | tr 'A-Z' 'a-z'`
+
+echo "$PRODUCT-v$VERSION Test Program"
+echo "Copyright 2014 by Keith Packard. Released under GPL v2"
+echo
+echo "Expectations:"
+echo "\t$PRODUCT v$VERSION powered from USB"
+echo
+
+ret=1
+ao-list | while read product serial dev; do
+ case "$product" in
+ "$PRODUCT-v$VERSION")
+
+ echo "Testing $product $serial $dev"
+
+ echo "Testing igniters. Both should flash"
+ ./test-igniter "$dev" drogue main
+
+ case $? in
+ 0)
+ ;;
+ *)
+ echo "failed"
+ exit 1
+ esac
+
+ echo "Testing baro sensor"
+ ./test-baro "$dev"
+
+ case $? in
+ 0)
+ ;;
+ *)
+ echo "failed"
+ exit 1
+ esac
+
+ FLASHSIZE=1048576
+
+ echo "Testing flash"
+ ./test-flash "$dev" "$FLASHSIZE"
+
+ case $? in
+ 0)
+ ;;
+ *)
+ echo "failed"
+ exit 1
+ esac
+
+ echo "$PRODUCT-v$VERSION" serial "$serial" is ready to ship
+ ret=0
+ ;;
+ *)
+ echo "Skipping $product $serial $dev"
+ ;;
+ esac
+done
}
}
-string[*] settings(file f) {
- string[...] x = {};
-
- flush_input(f);
- fprintf (f, "c s\nv\n");
- flush(f);
- for (;;) {
- string l = File::fgets(f);
- x[dim(x)] = l;
- if (String::index(l, "software-version") == 0)
- break;
- }
- return x;
-}
-
-string[*] find_setting(string[*] s, string match) {
- for (int i = 0; i < dim(s); i++)
- if (String::index(s[i], match) == 0)
- return String::wordsplit(s[i], " ");
- return (string[*]) {};
-}
-
string[*] flash(file f) {
string[...] x = {};
fprintf (f, "f\nv\n");
flush(f);
for (;;) {
- string l = File::fgets(f);
+ string l = timed_read(f, 1000);
+ if (l == "") {
+ File::fprintf(stderr, "Read timedout\n");
+ exit(1);
+ }
x[dim(x)] = l;
if (String::index(l, "software-version") == 0)
break;
echo "\t$PRODUCT v$VERSION powered from USB"
echo "\t\twith ST-Link-V2 cabled to debug header"
echo
-echo -n "$PRODUCT-$VERSION serial number: "
-read SERIAL
-echo $FLASH_LPC
-
-$FLASH_LPC ../src/$BASE-v$VERSION/flash-loader/$BASE-v$VERSION-altos-flash-*.elf || exit 1
-
-sleep 1
-
-echo $USBLOAD
-
-$USBLOAD --serial=$SERIAL ../src/$BASE-v$VERSION/*.ihx || exit 1
-
-sleep 2
-
-dev=`ao-list | awk '/'"$PRODUCT"'-v'"$VERSION"'/ { print $3; exit(0); }'`
-
-case "$dev" in
-/dev/tty*)
- echo "$PRODUCT found on $dev"
+case $# in
+ 1)
+ SERIAL="$1"
+ echo "$PRODUCT-$VERSION serial number: $SERIAL"
;;
-*)
- echo 'No '"$PRODUCT"'-v'"$VERSION"' found'
- exit 1
+ 0)
+ echo -n "$PRODUCT-$VERSION serial number: "
+ read SERIAL
+ ;;
+ *)
+ echo "Usage: $0 <serial-number>" 1>&2
+ exit 1;
;;
esac
-echo "Testing igniters. Both should flash"
-./test-igniter "$dev" drogue main
+FLASH_FILE=../src/$BASE-v$VERSION/flash-loader/$BASE-v$VERSION-altos-flash-*.elf
-case $? in
-0)
- ;;
-*)
- echo "failed"
- exit 1
-esac
+echo $FLASH_LPC $FLASH_FILE
-echo "Testing baro sensor"
-./test-baro "$dev"
+$FLASH_LPC $FLASH_FILE || exit 1
-case $? in
-0)
- ;;
-*)
- echo "failed"
- exit 1
-esac
+sleep 10
-FLASHSIZE=1048576
+ALTOS_FILE=../src/$BASE-v$VERSION/*.ihx
-echo "Testing flash"
-./test-flash "$dev" "$FLASHSIZE"
+echo $USBLOAD $ALTOS_FILE
-case $? in
-0)
- ;;
-*)
- echo "failed"
- exit 1
-esac
+$USBLOAD --serial=$SERIAL $ALTOS_FILE || exit 1
+
+sleep 2
+
+./test-easymini
-echo "$PRODUCT-v$VERSION" serial "$SERIAL" is ready to ship
-exit 0
+exit $?