# HG changeset patch # User andrewm # Date 1436982790 -3600 # Node ID ad6b2767beafe879dd4510f78ffbecf7c6dc264c # Parent 5bdf6efbd0eddb7884008d28c40c323a1f94507a Command-line argument support for BeagleRT program in scripts, plus a simple script for halting the BBB diff -r 5bdf6efbd0ed -r ad6b2767beaf scripts/build_project.sh --- a/scripts/build_project.sh Wed Jul 15 17:50:09 2015 +0100 +++ b/scripts/build_project.sh Wed Jul 15 18:53:10 2015 +0100 @@ -7,11 +7,12 @@ BBB_ADDRESS="root@192.168.7.2" BBB_PATH="~/BeagleRT" RUN_PROJECT=1 +COMMAND_ARGS= function usage { THIS_SCRIPT=`basename "$0"` - echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-n] " + echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n] " echo " This script copies a directory of source files to the BeagleBone, compiles and runs it. The BeagleRT core files should have first been copied over @@ -20,15 +21,18 @@ The source directory should contain at least one .c, .cpp or .S file. If the argument -n is passed, the output will not be run after compiling. The argument -b will change the local path on the BeagleBone where the - BeagleRT files are found." + BeagleRT files are found. The -c option passes command-line arguments to + the BeagleRT program; enclose the argument string in quotes." } OPTIND=1 -while getopts "b:nh" opt; do +while getopts "b:c:nh" opt; do case $opt in b) BBB_PATH=$OPTARG ;; + c) COMMAND_ARGS=$OPTARG + ;; n) RUN_PROJECT=0 ;; h|\?) usage @@ -73,5 +77,5 @@ ssh $BBB_ADDRESS "make all -C $BBB_PATH" else echo "Building and running project..." - ssh $BBB_ADDRESS "make all -C $BBB_PATH ; screen -d -m $BBB_PATH/BeagleRT" + ssh $BBB_ADDRESS "make all -C $BBB_PATH ; screen -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS" fi \ No newline at end of file diff -r 5bdf6efbd0ed -r ad6b2767beaf scripts/halt_board.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/halt_board.sh Wed Jul 15 18:53:10 2015 +0100 @@ -0,0 +1,8 @@ +#!/bin/bash +# +# This script halts the BeagleBone Black. + +BBB_ADDRESS="root@192.168.7.2" + +echo "Shutting down the BeagleBone Black..." +ssh $BBB_ADDRESS "halt" \ No newline at end of file diff -r 5bdf6efbd0ed -r ad6b2767beaf scripts/run_project.sh --- a/scripts/run_project.sh Wed Jul 15 17:50:09 2015 +0100 +++ b/scripts/run_project.sh Wed Jul 15 18:53:10 2015 +0100 @@ -5,24 +5,28 @@ BBB_ADDRESS="root@192.168.7.2" BBB_PATH="~/BeagleRT" +COMMAND_ARGS= function usage { THIS_SCRIPT=`basename "$0"` - echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone]" + echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args]" echo " This script runs a previously compiled BeagleRT project on the BeagleBone Black. The -b option changes the default path, which - is otherwise $BBB_PATH." + is otherwise $BBB_PATH. The -c option passes command-line arguments + to the BeagleRT program; enclose the argument string in quotes." } OPTIND=1 -while getopts "b:h" opt; do +while getopts "b:c:h" opt; do case $opt in b) BBB_PATH=$OPTARG ;; + c) COMMAND_ARGS=$OPTARG + ;; h|\?) usage exit 1 esac @@ -31,4 +35,4 @@ shift $((OPTIND-1)) echo "Running BeagleRT..." -ssh $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null ; sleep 0.5 ; screen -d -m $BBB_PATH/BeagleRT" \ No newline at end of file +ssh $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null ; sleep 0.5 ; screen -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS" \ No newline at end of file diff -r 5bdf6efbd0ed -r ad6b2767beaf scripts/set_startup.sh --- a/scripts/set_startup.sh Wed Jul 15 17:50:09 2015 +0100 +++ b/scripts/set_startup.sh Wed Jul 15 18:53:10 2015 +0100 @@ -6,6 +6,7 @@ BBB_ADDRESS="root@192.168.7.2" BBB_PATH="/root/BeagleRT" ENABLE_STARTUP=1 +COMMAND_ARGS= # This path is hard-coded in the BeagleRT image at present. BBB_STARTUP_SCRIPT="/root/BeagleRT_startup.sh" @@ -13,21 +14,24 @@ function usage { THIS_SCRIPT=`basename "$0"` - echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-n]" + echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n]" echo " This script enables (by default) or disables running the BeagleRT project at startup. The -n option disables auto-startup, otherwise auto-startup is enabled. The -b option changes the default path, which - is otherwise $BBB_PATH." + is otherwise $BBB_PATH. The -c option passes command-line arguments to + the BeagleRT program; enclose the argument string in quotes." } OPTIND=1 -while getopts "b:nh" opt; do +while getopts "b:c:nh" opt; do case $opt in b) BBB_PATH=$OPTARG ;; + c) COMMAND_ARGS=$OPTARG + ;; n) ENABLE_STARTUP=0 ;; h|\?) usage @@ -55,6 +59,6 @@ # This file is autogenerated by BeagleRT. Do not edit! echo Running BeagleRT... -screen -S BeagleRT -d -m $BBB_PATH/BeagleRT\" > $BBB_STARTUP_SCRIPT" +screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS\" > $BBB_STARTUP_SCRIPT" fi \ No newline at end of file