[oe-commits] Paul Eggleton : scripts/contrib/serdevtry: add script to handle transient serial terminals

git at git.openembedded.org git at git.openembedded.org
Thu May 1 15:35:17 UTC 2014


Module: openembedded-core.git
Branch: master-next
Commit: 0537269df779532245eb2954e04fc26b3edfed85
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=0537269df779532245eb2954e04fc26b3edfed85

Author: Paul Eggleton <paul.eggleton at linux.intel.com>
Date:   Wed Apr 30 13:32:02 2014 +0100

scripts/contrib/serdevtry: add script to handle transient serial terminals

When running automated tests (or just generally interacting with)
boards whose serial console devices are on the board itself and thus
disappear when powered down or practically disconnected, such as the
BeagleBone white, some terminal programs (e.g. picocom) will exit when
the device disappears and need to be restarted after the serial device
returns. This script handles this automatically for such terminal
programs.

Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 scripts/contrib/serdevtry | 60 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/scripts/contrib/serdevtry b/scripts/contrib/serdevtry
new file mode 100755
index 0000000..74bd7b7
--- /dev/null
+++ b/scripts/contrib/serdevtry
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+# Copyright (C) 2014 Intel Corporation
+#
+# Released under the MIT license (see COPYING.MIT)
+
+if [ "$1" = "" -o "$1" = "--help" ] ; then
+    echo "Usage: $0 <serial terminal command>"
+    echo
+    echo "Simple script to handle maintaining a terminal for serial devices that"
+    echo "disappear when a device is powered down or reset, such as the USB"
+    echo "serial console on the original BeagleBone (white version)."
+    echo
+    echo "e.g. $0 picocom -b 115200 /dev/ttyUSB0"
+    echo
+    exit
+fi
+
+args="$@"
+DEVICE=""
+while [ "$1" != "" ]; do
+    case "$1" in
+        /dev/*)
+            DEVICE=$1
+            break;;
+    esac
+    shift
+done
+
+if [ "$DEVICE" != "" ] ; then
+    while true; do
+        if [ ! -e $DEVICE ] ; then
+            echo "serdevtry: waiting for $DEVICE to exist..."
+            while [ ! -e $DEVICE ]; do
+                sleep 0.1
+            done
+        fi
+        if [ ! -w $DEVICE ] ; then
+            # Sometimes (presumably because of a race with udev) we get to
+            # the device before its permissions have been set up
+            RETRYNUM=0
+            while [ ! -w $DEVICE ]; do
+                if [ "$RETRYNUM" = "2" ] ; then
+                    echo "Device $DEVICE exists but is not writable!"
+                    exit 1
+                fi
+                RETRYNUM=$((RETRYNUM+1))
+                sleep 0.1
+            done
+        fi
+        $args
+        if [ -e $DEVICE ] ; then
+            break
+        fi
+    done
+else
+    echo "Unable to determine device node from command: $args"
+    exit 1
+fi
+



More information about the Openembedded-commits mailing list