5 # control-mote.sh - script for executing the control commands
9 # /sbin/control-mote.sh TTY CMD
13 # The script makes an use of a bootloader for a particular platform
14 # to issue one of the available commands (STOP/START/RESET).
20 # The first argument is a USB device name used by the bootloader
21 # to execute the command.
25 # The second one is the command itself to be executed.
27 # ENVIRONMENT VARIABLES
28 # ---------------------
31 # It contains a name of the platform. The featured platforms
32 # are TMoteSky and MicaZ.
36 # /sbin/control-mote.sh /dev/ttyUSB0 reset
40 # Copyright (c) 2008 Rostislav Spinar <rostislav.spinar@cit.ie>
42 #######################################################################
44 #######################################################################
46 #Get parameters from command line
50 #Have it as a env. variable
53 #Check the parameters first
54 #Suppose to have 2 args
55 if [ "$#" -ne 2 ]; then
56 echo "Incorrect number of arguments!"
60 if [[ ! -n "$TTY" && ! -c "$TTY" ]]; then
61 echo "Port has to be defined and point to a valid character device! Port=$TTY!"
65 #Run command(reset, stop & start)
67 "reset" |
"stop" |
"start")
69 echo "$PLATFORM : command $CMD"
71 if [ "$CMD" = "start" ]; then
77 #echo "tos-bsl --telosb -c $TTY --$CMD"
78 #echo "cppbsl -D -b -c $TTY --$CMD"
79 #tos-bsl --telosb -c "$TTY" --"$CMD"
80 cppbsl
-D -b -c "$TTY" --"$CMD" > /dev
/null
2>&1
84 #echo "uisp -dprog=mib510 -dserial=$TTY -dpart=ATmega128 --$CMD"
85 uisp
-dprog=mib510
-dserial=$TTY -dpart=ATmega128
--"$CMD" > /dev
/null
2>&1
89 echo "Unknown platform $PLATFORM!"
95 echo "Unknown command $CMD!"