annotate scripts/run_project.sh @ 60:ad6b2767beaf newapi

Command-line argument support for BeagleRT program in scripts, plus a simple script for halting the BBB
author andrewm
date Wed, 15 Jul 2015 18:53:10 +0100
parents 3ffafa57302c
children afc593f7469e
rev   line source
andrewm@58 1 #!/bin/bash
andrewm@58 2 #
andrewm@58 3 # This script runs an already-compiled BeagleRT project on the
andrewm@58 4 # BeagleBone Black.
andrewm@58 5
andrewm@58 6 BBB_ADDRESS="root@192.168.7.2"
andrewm@58 7 BBB_PATH="~/BeagleRT"
andrewm@60 8 COMMAND_ARGS=
andrewm@58 9
andrewm@58 10 function usage
andrewm@58 11 {
andrewm@58 12 THIS_SCRIPT=`basename "$0"`
andrewm@60 13 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args]"
andrewm@58 14
andrewm@58 15 echo "
andrewm@58 16 This script runs a previously compiled BeagleRT project on the
andrewm@58 17 BeagleBone Black. The -b option changes the default path, which
andrewm@60 18 is otherwise $BBB_PATH. The -c option passes command-line arguments
andrewm@60 19 to the BeagleRT program; enclose the argument string in quotes."
andrewm@58 20 }
andrewm@58 21
andrewm@58 22 OPTIND=1
andrewm@58 23
andrewm@60 24 while getopts "b:c:h" opt; do
andrewm@58 25 case $opt in
andrewm@58 26 b) BBB_PATH=$OPTARG
andrewm@58 27 ;;
andrewm@60 28 c) COMMAND_ARGS=$OPTARG
andrewm@60 29 ;;
andrewm@58 30 h|\?) usage
andrewm@58 31 exit 1
andrewm@58 32 esac
andrewm@58 33 done
andrewm@58 34
andrewm@58 35 shift $((OPTIND-1))
andrewm@58 36
andrewm@58 37 echo "Running BeagleRT..."
andrewm@60 38 ssh $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null ; sleep 0.5 ; screen -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS"