From c14cfb1436c988eb0a0d26d7c4d83aeccecbc8a3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 5 Apr 2014 18:16:21 -0700 Subject: [PATCH] ao-bringup: Split out easymini test into separate script This lets you run the easy mini testing code without also flashing the device. Signed-off-by: Keith Packard --- ao-bringup/test-baro | 28 +++----------- ao-bringup/test-easymini | 63 ++++++++++++++++++++++++++++++++ ao-bringup/test-flash | 28 +++----------- ao-bringup/turnon_easymini | 75 ++++++++++++-------------------------- 4 files changed, 96 insertions(+), 98 deletions(-) create mode 100755 ao-bringup/test-easymini diff --git a/ao-bringup/test-baro b/ao-bringup/test-baro index 45d7ccac..2116dce4 100755 --- a/ao-bringup/test-baro +++ b/ao-bringup/test-baro @@ -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 index 00000000..29139385 --- /dev/null +++ b/ao-bringup/test-easymini @@ -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 diff --git a/ao-bringup/test-flash b/ao-bringup/test-flash index c42ddee3..d79de320 100755 --- a/ao-bringup/test-flash +++ b/ao-bringup/test-flash @@ -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; diff --git a/ao-bringup/turnon_easymini b/ao-bringup/turnon_easymini index db2b3248..255db0bf 100755 --- a/ao-bringup/turnon_easymini +++ b/ao-bringup/turnon_easymini @@ -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 " 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 $? -- 2.30.2