ao-bringup: Split out easymini test into separate script
authorKeith Packard <keithp@keithp.com>
Sun, 6 Apr 2014 01:16:21 +0000 (18:16 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 6 Apr 2014 01:16:21 +0000 (18:16 -0700)
This lets you run the easy mini testing code without also flashing the device.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-bringup/test-baro
ao-bringup/test-easymini [new file with mode: 0755]
ao-bringup/test-flash
ao-bringup/turnon_easymini

index 45d7ccac4e483fa5923683df05609e3ccb44d71f..2116dce4c750b0d357ebcb31b009f1d51ca6dcd3 100755 (executable)
@@ -36,28 +36,6 @@ void flush_input(file f) {
        }
 }
 
-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 = {};
 
@@ -65,7 +43,11 @@ string[*] baro(file f) {
        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;
diff --git a/ao-bringup/test-easymini b/ao-bringup/test-easymini
new file mode 100755 (executable)
index 0000000..2913938
--- /dev/null
@@ -0,0 +1,63 @@
+#!/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
index c42ddee36aadbca0fb2701b2606f571008460fe7..d79de320d565c258586a6ce5aca117475da782b7 100755 (executable)
@@ -36,28 +36,6 @@ void flush_input(file f) {
        }
 }
 
-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 = {};
 
@@ -65,7 +43,11 @@ string[*] flash(file f) {
        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;
index db2b3248ef35e6127594c1f095e619cc5c2dc7e8..255db0bf742bf09a6d174b269dcf59dd3231dda8 100755 (executable)
@@ -30,67 +30,38 @@ echo "Expectations:"
 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 $?