simplified constant definitions, started examples
[ambros.git] / src / ambros
blobbe64af6a96a71d41652de521164d30a5e7aa712f
1 #!/bin/sh
2 # ambros:
3 # control script for one channel
5 # directory of scripts
6 cd `dirname $0`
7 AMBROSDIR=`pwd`
9 # read global settings
10 . $AMBROSDIR/constants.sh
12 if test "$1" = ""
13 then cat <<EOT
14 usage: $0 <channeldir>
16 AMBROS control script for channel <channeldir>
17 EOT
18 exit 1
21 # (re)generate morse code table
22 cd $AMBROSDIR/morse && ./chargen.sh
23 cd $AMBROSDIR
25 channeldir="$1"
26 if test ! -d "$channeldir" -o ! -x "$channeldir" -o ! -r "$channeldir" -o ! -w "$channeldir"
27 then echo "$channeldir is not read/write/executable directory, aborting!"
28 exit 2
31 cd "$channeldir"
32 echo working in channel $channeldir
33 speed=`configread $CHANNELCONFIG WPM`
34 speed=${speed:-12}
35 echo at speed $speed Words/min
37 # handler for aborting
38 finish () {
39 echo "received abort signal, stopping all subprocesses"
40 # if no PID is set, use 1 (init) as a dummy argument
41 /bin/kill -TERM ${pidassembler:-1} $pidchannelchief
42 echo ending main control loop
43 date +"at %c"
44 AMBROSABORT=1
46 AMBROSABORT=0
48 trap finish INT TERM STOP
50 echo entering main control loop with PID $$ at
51 date +"at %c"
53 while test $AMBROSABORT -eq 0
54 do : # main control loop
56 # poll&process sources with `extractor`
57 # start&control `assembler`
58 # start&control `channelchief`
60 done
62 echo finished.