Mercurial > hg > beaglert
comparison scripts/run_pd_libpd.sh @ 439:e49ae69acbe8 prerelease
Rebuilt run_pd_libpd.sh. Minor fixes, adjusted verbosity
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sat, 18 Jun 2016 04:19:17 +0100 |
parents | 2e01a9d6cb58 |
children | d9a4fc5357e7 |
comparison
equal
deleted
inserted
replaced
438:ad3f61134bb4 | 439:e49ae69acbe8 |
---|---|
12 RUN_IN_FOREGROUND=0 | 12 RUN_IN_FOREGROUND=0 |
13 RUN_WITHOUT_SCREEN=0 | 13 RUN_WITHOUT_SCREEN=0 |
14 | 14 |
15 usage() | 15 usage() |
16 { | 16 { |
17 THIS_SCRIPT=`basename "$0"` | 17 THIS_SCRIPT=`basename "$0"` |
18 echo "Usage: $THIS_SCRIPT [-c command-line-args] [-nfF] <directory-with-source-files>" | 18 echo "Usage: $THIS_SCRIPT [-c 'command-line-args'] [-nfb] <directory-with-source-files>" |
19 echo " | 19 echo " |
20 This script copies a PureData project to the BeagleBone and runs it | 20 This script copies a PureData project to the BeagleBone and runs it |
21 using libpd. The Bela-libpd executable should have first been copied | 21 using libpd. The Bela-libpd executable should have first been copied |
22 to the $BBB_LIBPD_EXECUTABLE_PATH folder on the Beaglebone. | 22 to the $BBB_LIBPD_EXECUTABLE_PATH folder on the Beaglebone. |
23 The source directory should contain a file called _main.pd, which is the | 23 The source directory should contain a file called _main.pd, which is the |
24 patch that will be loaded into Pd. All the content of the folder is | 24 patch that will be loaded into Pd. All the content of the folder is |
25 recursively copied and the folder structure is flattened. | 25 recursively copied and the folder structure is flattened. |
26 If the argument -n is passed, the output will not be run after compiling. | |
27 The -c option passes command-line arguments to the Bela program; | |
28 enclose the argument string in quotes. | |
29 | 26 |
30 The -f argument runs the project in the foreground of the current terminal, | 27 If the argument -n is passed, the output will not be run after copying the files. |
31 within a screen session that can be detached later with ctrl-A ctrl-D. | 28 |
32 The -F argument runs the project in the foreground of the current terminal, | 29 The -c option passes command-line arguments to the Bela program; |
33 without screen, so the output can be piped to another destination." | 30 enclose the argument string in quotes. |
31 | |
32 The -b argument runs the projet in the background, so that no output is displayed | |
33 in the terminal. | |
34 The -f argument runs the project in the foreground of the current terminal, | |
35 without screen, so the output can be piped to another destination." | |
34 } | 36 } |
35 | 37 |
36 OPTIND=1 | 38 OPTIND=1 |
37 | 39 |
38 while getopts "b:c:nfFh" opt; do | 40 while getopts "bc:nfFh" opt; do |
39 case $opt in | 41 case $opt in |
40 c) COMMAND_ARGS=$OPTARG | 42 c) |
41 ;; | 43 COMMAND_ARGS=$OPTARG |
42 f) RUN_IN_FOREGROUND=1 | 44 ;; |
43 ;; | 45 b) |
44 F) RUN_WITHOUT_SCREEN=1 | 46 RUN_IN_FOREGROUND=0 |
45 ;; | 47 ;; |
46 n) RUN_PROJECT=0 | 48 f) |
47 ;; | 49 RUN_WITHOUT_SCREEN=1 |
48 h|\?) usage | 50 ;; |
49 exit 1 | 51 n) |
50 esac | 52 RUN_PROJECT=0 |
53 ;; | |
54 h|\?) | |
55 usage | |
56 exit 1 | |
57 esac | |
51 done | 58 done |
52 | 59 |
53 shift $((OPTIND-1)) | 60 shift $((OPTIND-1)) |
54 | 61 |
55 # Check that we have a directory containing at least one source file | 62 # Check that we have a directory containing at least one source file |
56 # as an argument | 63 # as an argument |
57 | 64 |
58 if [ -z "$1" ] | 65 ADDITIONAL_FOLDER=$1 |
66 | |
67 if [ -z "$ADDITIONAL_FOLDER" ] | |
59 then | 68 then |
60 usage | 69 usage |
61 exit | |
62 fi | |
63 | |
64 FIND_STRING="find $* -maxdepth 10000 -type f " | |
65 | |
66 PROJECT_FILES=$($FIND_STRING) | |
67 | |
68 if [[ -z $PROJECT_FILES ]] | |
69 then | |
70 echo "Please provide a directory containing the _main.pd file and additional abstractions" | |
71 usage | |
72 exit | |
73 fi | |
74 | |
75 # Stop Bela and clean out old source files | |
76 echo "Stopping Bela and removing old source files..." | |
77 ssh -t -t $BBB_ADDRESS "screen -X -S Bela quit &>/dev/null;\ | |
78 pkill Bela ; rm -rf $BBB_LIBPD_PROJECT_PATH/; mkdir -p $BBB_LIBPD_PROJECT_PATH; " | |
79 | |
80 # Copy new source files to the board | |
81 echo "Copying new pd projects to BeagleBone..." | |
82 scp $PROJECT_FILES "$BBB_ADDRESS:$BBB_LIBPD_PROJECT_PATH" | |
83 | |
84 if [ $? -ne 0 ] | |
85 then | |
86 echo "Error while copying files" | |
87 exit | 70 exit |
88 fi | 71 fi |
89 | 72 |
90 # Make new Bela executable and run | 73 #reconstruct the command line options |
91 if [ $RUN_PROJECT -eq 0 ] | 74 OPT= |
92 then | 75 [ $RUN_IN_FOREGROUND -eq 0 ] && OPT="$OPT -b" |
93 echo "Files copied. Run without \"-n\" to run the project" | 76 [ $RUN_WITHOUT_SCREEN -eq 1 ] && OPT="$OPT -f" |
94 else | 77 |
95 echo "Running project..." | 78 ./build_project.sh -p libpd -r $ADDITIONAL_FOLDER $OPT -c "$COMMAND_ARGS" ../examples/basic_libpd/ |
96 | |
97 if [ $RUN_WITHOUT_SCREEN -ne 0 ] | |
98 then | |
99 ssh -t $BBB_ADDRESS "cd $BBB_LIBPD_PROJECT_PATH && $BBB_LIBPD_EXECUTABLE_PATH $COMMAND_ARGS" | |
100 elif [ $RUN_IN_FOREGROUND -eq 0 ] | |
101 then | |
102 ssh $BBB_ADDRESS "cd $BBB_LIBPD_PROJECT_PATH && screen -S Bela -d -m \ | |
103 $BBB_LIBPD_EXECUTABLE_PATH $COMMAND_ARGS" | |
104 else | |
105 ssh -t $BBB_ADDRESS "cd $BBB_LIBPD_PROJECT_PATH && screen -S Bela $BBB_LIBPD_EXECUTABLE_PATH $COMMAND_ARGS" | |
106 fi | |
107 fi |