andrewm@58: #!/bin/bash andrewm@58: # andrewm@58: # This script runs an already-compiled BeagleRT project on the andrewm@58: # BeagleBone Black. andrewm@58: giuliomoro@332: [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2" giuliomoro@332: [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/BeagleRT/" giuliomoro@332: [ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="BeagleRT" giuliomoro@332: [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1 giuliomoro@332: [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS= giuliomoro@332: [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1 giuliomoro@332: [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0 giuliomoro@332: [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/" giuliomoro@332: [ -z "$BBB_DEFAULT_PROJECT_NAME" ] && BBB_DEFAULT_PROJECT_NAME="scriptUploadedProject" andrewm@58: andrewm@58: function usage andrewm@58: { andrewm@58: THIS_SCRIPT=`basename "$0"` andrewm@89: echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-fF]" 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 giuliomoro@332: is otherwise $BBB_BELA_HOME. The -c option passes command-line arguments andrewm@62: to the BeagleRT program; enclose the argument string in quotes. andrewm@89: andrewm@62: The -f argument runs the project in the foreground of the current terminal, andrewm@89: within a screen session that can be detached later. The -F argument runs andrewm@89: the project in the foreground of the current terminal, without screen, so andrewm@89: the output can be piped to another destination." andrewm@58: } andrewm@58: andrewm@58: OPTIND=1 andrewm@58: andrewm@89: while getopts "b:c:fFh" opt; do andrewm@58: case $opt in giuliomoro@332: b) BBB_BELA_HOME=$OPTARG andrewm@58: ;; andrewm@60: c) COMMAND_ARGS=$OPTARG andrewm@60: ;; andrewm@62: f) RUN_IN_FOREGROUND=1 andrewm@62: ;; giuliomoro@332: F) RUN_WITHOUT_SCREEN=1 andrewm@89: ;; andrewm@58: h|\?) usage andrewm@58: exit 1 andrewm@58: esac andrewm@58: done andrewm@58: giuliomoro@360: shift $((OPTIND-1)) giuliomoro@360: giuliomoro@332: if [ -z "$1" ] giuliomoro@332: then giuliomoro@332: BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME giuliomoro@332: else giuliomoro@332: BBB_PROJECT_NAME=$1 giuliomoro@332: fi giuliomoro@332: giuliomoro@332: MAKE_COMMAND="make stop -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS'" giuliomoro@332: echo "Running $BBB_PROJECT_NAME..." andrewm@89: if [ $RUN_WITHOUT_SCREEN -ne 0 ] andrewm@89: then giuliomoro@360: echo ssh $BBB_ADDRESS "$MAKE_COMMAND run" giuliomoro@360: ssh $BBB_ADDRESS "$MAKE_COMMAND run" andrewm@89: elif [ $RUN_IN_FOREGROUND -eq 0 ] andrewm@62: then giuliomoro@360: echo ssh $BBB_ADDRESS "$MAKE_COMMAND runscreenfg" giuliomoro@332: ssh $BBB_ADDRESS "$MAKE_COMMAND runscreenfg" andrewm@62: else giuliomoro@360: echo ssh $BBB_ADDRESS "$MAKE_COMMAND runscreen" giuliomoro@360: ssh $BBB_ADDRESS "$MAKE_COMMAND runscreen" giuliomoro@332: fi