1 #!/bin/bash
2 #############################################################
3 # @file run_collector.sh
4 #
5 # @brief TIMAC 2.0 run_collector.sh, used by run_demo.sh to launch collector
6 #
7 # Group: WCS LPC
8 # $Target Devices: Linux: AM335x, Embedded Devices: CC1310, CC1350$
9 #
10 #############################################################
11 # $License: BSD3 2016 $
12 #
13 # Copyright (c) 2015, Texas Instruments Incorporated
14 # All rights reserved.
15 #
16 # Redistribution and use in source and binary forms, with or without
17 # modification, are permitted provided that the following conditions
18 # are met:
19 #
20 # * Redistributions of source code must retain the above copyright
21 # notice, this list of conditions and the following disclaimer.
22 #
23 # * Redistributions in binary form must reproduce the above copyright
24 # notice, this list of conditions and the following disclaimer in the
25 # documentation and/or other materials provided with the distribution.
26 #
27 # * Neither the name of Texas Instruments Incorporated nor the names of
28 # its contributors may be used to endorse or promote products derived
29 # from this software without specific prior written permission.
30 #
31 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
33 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
35 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
36 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
37 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
38 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
40 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
41 # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 #############################################################
43 # $Release Name: TI-15.4Stack Linux x64 SDK$
44 # $Release Date: July 14, 2016 (2.00.00.30)$
45 #############################################################
47 # Because this is a "quick demo" we hard code
48 # the device name in this check. For a production
49 # application, a better check is suggested.
50 #
51 if [ ! -c /dev/ttyACM0 ]
52 then
53 echo ""
54 echo "The Launchpad (/dev/ttyACM0) does not seem to be present"
55 echo ""
56 exit 1
57 fi
59 # This test is simple...
60 arch=`uname -m`
62 if [ "x${arch}x" == 'xx86_64x' ]
63 then
64 exe=host_collector
65 fi
68 if [ "x${arch}x" == 'xarmv7lx' ]
69 then
70 # ---------
71 # This script has no way to determine how you built
72 # the application.
73 # --------
74 # This script assumes that you have built the "collector"
75 # application via the a cross compiler method and not
76 # built natively on the BBB
77 # ---------
78 # If you build natively on the BBB, then the BBB
79 # is actually the HOST... and thus the application is
80 # "host_collector"
81 exe=bbb_collector
82 fi
84 if [ "x${exe}x" == "xx" ]
85 then
86 echo "Cannot find Collector App exe: $exe"
87 exit 1
88 fi
90 if [ ! -x $exe ]
91 then
92 echo "Cannot find EXE $exe"
93 exit 1
94 fi
96 PID=`pidof $exe`
98 if [ "x${PID}x" != "xx" ]
99 then
100 kill -9 ${PID}
101 fi
103 # by default, the application uses the name: "collector.cfg" as the configuration file
104 # or you can pass the name of the configuration file on the command line
105 ./$exe collector.cfg &
106 PID=$!
107 # Wait 3 seconds for it to get started ...
108 sleep 3
109 if ps -p $PID > /dev/null
110 then
111 echo "Collector Running as Process id: ${PID}"
112 exit 0
113 else
114 echo "Error starting collector application"
115 exit 1
116 fi