andrewm@58
|
1 #!/bin/bash
|
andrewm@58
|
2 #
|
giuliomoro@377
|
3 # This script runs an already-compiled Bela project on the
|
andrewm@58
|
4 # BeagleBone Black.
|
andrewm@58
|
5
|
giuliomoro@332
|
6 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
|
giuliomoro@377
|
7 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/"
|
giuliomoro@377
|
8 [ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="Bela"
|
giuliomoro@332
|
9 [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1
|
giuliomoro@332
|
10 [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS=
|
giuliomoro@332
|
11 [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1
|
giuliomoro@332
|
12 [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0
|
giuliomoro@332
|
13 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
|
giuliomoro@332
|
14 [ -z "$BBB_DEFAULT_PROJECT_NAME" ] && BBB_DEFAULT_PROJECT_NAME="scriptUploadedProject"
|
andrewm@58
|
15
|
andrewm@58
|
16 function usage
|
andrewm@58
|
17 {
|
andrewm@58
|
18 THIS_SCRIPT=`basename "$0"`
|
andrewm@89
|
19 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-fF]"
|
andrewm@58
|
20
|
andrewm@58
|
21 echo "
|
giuliomoro@377
|
22 This script runs a previously compiled Bela project on the
|
andrewm@58
|
23 BeagleBone Black. The -b option changes the default path, which
|
giuliomoro@332
|
24 is otherwise $BBB_BELA_HOME. The -c option passes command-line arguments
|
giuliomoro@377
|
25 to the Bela program; enclose the argument string in quotes.
|
andrewm@89
|
26
|
andrewm@62
|
27 The -f argument runs the project in the foreground of the current terminal,
|
andrewm@89
|
28 within a screen session that can be detached later. The -F argument runs
|
andrewm@89
|
29 the project in the foreground of the current terminal, without screen, so
|
andrewm@89
|
30 the output can be piped to another destination."
|
andrewm@58
|
31 }
|
andrewm@58
|
32
|
andrewm@58
|
33 OPTIND=1
|
andrewm@58
|
34
|
andrewm@89
|
35 while getopts "b:c:fFh" opt; do
|
andrewm@58
|
36 case $opt in
|
giuliomoro@332
|
37 b) BBB_BELA_HOME=$OPTARG
|
andrewm@58
|
38 ;;
|
andrewm@60
|
39 c) COMMAND_ARGS=$OPTARG
|
andrewm@60
|
40 ;;
|
andrewm@62
|
41 f) RUN_IN_FOREGROUND=1
|
andrewm@62
|
42 ;;
|
giuliomoro@332
|
43 F) RUN_WITHOUT_SCREEN=1
|
andrewm@89
|
44 ;;
|
andrewm@58
|
45 h|\?) usage
|
andrewm@58
|
46 exit 1
|
andrewm@58
|
47 esac
|
andrewm@58
|
48 done
|
andrewm@58
|
49
|
giuliomoro@360
|
50 shift $((OPTIND-1))
|
giuliomoro@360
|
51
|
giuliomoro@332
|
52 if [ -z "$1" ]
|
giuliomoro@332
|
53 then
|
giuliomoro@332
|
54 BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME
|
giuliomoro@332
|
55 else
|
giuliomoro@332
|
56 BBB_PROJECT_NAME=$1
|
giuliomoro@332
|
57 fi
|
giuliomoro@332
|
58
|
giuliomoro@332
|
59 MAKE_COMMAND="make stop -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS'"
|
giuliomoro@332
|
60 echo "Running $BBB_PROJECT_NAME..."
|
andrewm@89
|
61 if [ $RUN_WITHOUT_SCREEN -ne 0 ]
|
andrewm@89
|
62 then
|
giuliomoro@360
|
63 ssh $BBB_ADDRESS "$MAKE_COMMAND run"
|
andrewm@89
|
64 elif [ $RUN_IN_FOREGROUND -eq 0 ]
|
andrewm@62
|
65 then
|
giuliomoro@332
|
66 ssh $BBB_ADDRESS "$MAKE_COMMAND runscreenfg"
|
andrewm@62
|
67 else
|
giuliomoro@360
|
68 ssh $BBB_ADDRESS "$MAKE_COMMAND runscreen"
|
giuliomoro@332
|
69 fi
|