andrewm@58: #!/bin/bash andrewm@58: # andrewm@58: # This script runs an already-compiled BeagleRT project on the andrewm@58: # BeagleBone Black. andrewm@58: andrewm@58: BBB_ADDRESS="root@192.168.7.2" andrewm@58: BBB_PATH="~/BeagleRT" andrewm@60: COMMAND_ARGS= andrewm@62: RUN_IN_FOREGROUND=0 andrewm@58: andrewm@58: function usage andrewm@58: { andrewm@58: THIS_SCRIPT=`basename "$0"` andrewm@62: echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-f]" andrewm@58: andrewm@58: echo " andrewm@58: This script runs a previously compiled BeagleRT project on the andrewm@58: BeagleBone Black. The -b option changes the default path, which andrewm@60: is otherwise $BBB_PATH. The -c option passes command-line arguments andrewm@62: to the BeagleRT program; enclose the argument string in quotes. andrewm@62: The -f argument runs the project in the foreground of the current terminal, andrewm@62: within a screen session that can be detached later." andrewm@58: } andrewm@58: andrewm@58: OPTIND=1 andrewm@58: andrewm@62: while getopts "b:c:fh" opt; do andrewm@58: case $opt in andrewm@58: b) BBB_PATH=$OPTARG andrewm@58: ;; andrewm@60: c) COMMAND_ARGS=$OPTARG andrewm@60: ;; andrewm@62: f) RUN_IN_FOREGROUND=1 andrewm@62: ;; andrewm@58: h|\?) usage andrewm@58: exit 1 andrewm@58: esac andrewm@58: done andrewm@58: andrewm@58: shift $((OPTIND-1)) andrewm@58: andrewm@58: echo "Running BeagleRT..." andrewm@62: if [ $RUN_IN_FOREGROUND -eq 0 ] andrewm@62: then andrewm@63: ssh $BBB_ADDRESS "screen -X -S BeagleRT quit ; pkill BeagleRT ; sleep 0.5 ; screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS" andrewm@62: else andrewm@63: ssh -t $BBB_ADDRESS "screen -X -S BeagleRT quit ; pkill BeagleRT ; sleep 0.5 ; screen -S BeagleRT $BBB_PATH/BeagleRT $COMMAND_ARGS" andrewm@62: fi