| # 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 "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 "e.g. $0 picocom -b 115200 /dev/ttyUSB0" |
| if [ "$DEVICE" != "" ] ; then |
| if [ ! -e $DEVICE ] ; then |
| echo "serdevtry: waiting for $DEVICE to exist..." |
| while [ ! -e $DEVICE ]; do |
| if [ ! -w $DEVICE ] ; then |
| # Sometimes (presumably because of a race with udev) we get to |
| # the device before its permissions have been set up |
| while [ ! -w $DEVICE ]; do |
| if [ "$RETRYNUM" = "2" ] ; then |
| echo "Device $DEVICE exists but is not writable!" |
| echo "Unable to determine device node from command: $args" |