#!/bin/bash # WPS: I changed the line above to reflect the fact that # This is a 'bash' script, not a 'sh' script. # Under Linux it doesn't matter but on our SUNS this script must be run # with bash not sh. (at least not /bin/sh or /usr/bin/sh) # On the SUNS there is no /bin/bash, so the error is to remind the user # to find/install bash. # Touch the file .debug_scripts in your home directory if you like # to see all the commands echoed. ERROR_OUT_FILE=/dev/null if [ -f ${HOME}/.debug_scripts ] ; then set -x; ERROR_OUT_FILE=/dev/tty fi DEBUGGER=gdb if [ -f ${HOME}/.debugger_name ] ; then DEBUGGER=`cat ${HOME}/.debugger_name | head -n 1` fi # Set the name of the .ini file, using emc.ini as default. Change this to # your .ini file, if you don't use emc.ini. INIFILE=ppmc.ini # Everything past this point is automatic. You need not change anything here # unless you want to customize things that can't be done in the .ini file, # like running additional programs. #------------------------------------------------------------------------------ # change to the directory containing this script # cd $0/.. if [ "$0" != "./generic.run" ] ; then path=$path:/usr/bin prog=`which $0 | grep $0` tail=`echo $prog | sed s#\^.\*/##` dir=`echo $prog | sed s/$tail//` cd $dir fi #USE_INIFILE_PLATS="nonrealtime" IOEXEC_NEEDED=0 if [ `whoami` != root ] ; then if [ -x /sbin/ioexec ] ; then IOEXEC_NEEDED=1 echo Using ioexec. fi fi # override INIFILE, if it's first arg iniarg=0 for arg in $* ; do if [ $iniarg -eq 1 ] ; then INIFILE=$arg iniarg=0 else if [ $arg = "-ini" ] ; then iniarg=1 fi fi done if [ $iniarg -eq 1 ] ; then echo "missing file name after -ini" exit 1 fi # # Determine the current platfrom from uname and set symbolic links to it. # PLATBASE=`uname -s | gawk '{ printf ( "%s",tolower ( $1 ) ) }'` PLAT=`uname -sr | sed "y/ /_/" | sed "y/./_/" | sed s/-rtl.\*\$// | sed "y/-/_/" | gawk '{ printf ( "%s",tolower ( $1 ) ) }'` HOSTNAME=_ OSNAME=_ OSREV=_ if hostname >/dev/null 2>/dev/null ; then HOSTNAME=`hostname` fi if dnsdomainname >/dev/null 2>/dev/null ; then DNSNAME=`dnsdomainname` fi OSNAME=`uname -s` OSREV=`uname -r` HOSTID=$HOSTNAME.$DNSNAME.$OSNAME.$OSREV DATESTRING=`date +%Y%m%d%H%M%S` # rthal is a symbol inserted by the rtai patch # if it is one of the kernel symbols we will use rtai stuff # otherwise look for rtlinux info. if [ $PLATBASE = "linux" ] ; then if /sbin/ksyms -a | grep rthal >/dev/null 2>/dev/null ; then PLAT=linux_rtai; RTPLAT=rtai; else if [ -z "$PURE_SIMULATION" ] ; then if [ ! -f .rtlinux_version.${HOSTID} ] ; then if [ ${PLATBASE} != "linux" ] ; then echo none >.rtlinux_version.${HOSTID} else echo "RT Linux Version?" read rtlinux_version echo $rtlinux_version > .rtlinux_version.${HOSTID} fi fi rtlinux_version=`head -n 1 .rtlinux_version.${HOSTID} | sed "y/ /_/" | sed "y/./_/"` RTPLAT=rtlinux_${rtlinux_version} if [ -z "$RTPLAT" ] ; then echo "Real-time Linux kernel patch not installed."; exit 1; fi if [ ! -d plat/$RTPLAT ] ; then echo "The current real-time platform appears to be $RTPLAT but no directory exists for this platform."; echo "Either install EMC for this platform or create a symbolic link to an existing platform."; exit 1 fi fi fi fi pwd if [ ! -d ./plat/$PLAT ] ; then echo "The current platform appears to be $PLAT but no directory exists for this platform."; echo "Either install EMC for this platform or create a symbolic link to an existing platform."; exit 1 fi cd plat (\rm -f nonrealtime >${ERROR_OUT_FILE}) 2> ${ERROR_OUT_FILE} (ln -s $PLAT nonrealtime >${ERROR_OUT_FILE}) 2> ${ERROR_OUT_FILE} if [ -z "$PURE_SIMULATION" ] ; then (\rm -f realtime >${ERROR_OUT_FILE}) 2> ${ERROR_OUT_FILE} (ln -s $RTPLAT realtime >${ERROR_OUT_FILE}) 2> ${ERROR_OUT_FILE} fi cd .. echo Current platform is $PLAT if [ -z "$PURE_SIMULATION" ] ; then echo Current real-time platform is $RTPLAT fi # Find out where the inivar program is, if it's not in the path. # WPS changed this search algorithm because it would not necessarily find # the correct version of inivar, in fact it picks the one that is first in # the alphabet. if [ -x plat/$PLAT/bin/inivar ] ; then inivar=plat/$PLAT/bin/inivar; else if [ -x /usr/local/nist/emc/plat/$PLAT/bin/inivar ] ; then inivar=/usr/local/nist/emc/plat/$PLAT/bin/inivar; else if [ -x $HOME/emc/plat/$PLAT/bin/inivar ] ; then inivar=$HOME/emc/plat/$PLAT/bin/inivar; else echo "can't locate inivar program-- not in:" plat/$PLAT/bin/inivar /usr/local/nist/emc/plat/$PLAT/bin/inivar $HOME/emc/plat/$PLAT/bin/inivar exit 0; fi fi fi echo inivar = $inivar echo INIFILE = $INIFILE RS274NGC_PARAMFILE=`$inivar -ini $INIFILE -var PARAMETER_FILE -sec RS274NGC` echo RS274NGC_PARAMFILE = $RS274NGC_PARAMFILE # get emcmot information emcmot=`$inivar -ini $INIFILE -var EMCMOT -sec EMCMOT` if [ ! -n "$emcmot" ] ; then echo "Can't find variable EMCMOT in section [EMCMOT] of file $INIFILE."; exit -1; fi if [ -n "$USE_INIFILE_PLATS" ] ; then emcmot_plat=`$inivar -ini $INIFILE -var PLAT -sec EMCMOT`; else case $emcmot in emcmotsim | emcmotsim.tc | genhexsim) emcmot_plat=$PLAT; ;; *) emcmot_plat=$RTPLAT; ;; esac fi sleep 1 # get emcio information emcio=`$inivar -ini $INIFILE -var EMCIO -sec EMCIO` if [ ! -n "$emcio" ] ; then echo "Can't find variable EMCIO in section [EMCIO] of file $INIFILE."; exit -1 fi if [ -n "$USE_INIFILE_PLATS" ] ; then emcio_plat=`$inivar -ini $INIFILE -var PLAT -sec EMCIO`; else emcio_plat=$PLAT; fi # get emctask information emctask=`$inivar -ini $INIFILE -var TASK -sec TASK` if [ ! -n "$emctask" ] ; then echo "Can't find variable TASK in section [TASK] of file $INIFILE."; exit -1 fi if [ -n "$USE_INIFILE_PLATS" ] ; then emctask_plat=`$inivar -ini $INIFILE -var PLAT -sec EMCTASK`; else emctask_plat=$PLAT; fi # get emcserver information emcserver=`$inivar -ini $INIFILE -var EMCSERVER -sec EMCSERVER` if [ -n "$USE_INIFILE_PLATS" ] ; then emcserver_plat=`$inivar -ini $INIFILE -var PLAT -sec EMCSERVER`; else emcserver_plat=$PLAT; fi # get emcstrip information emcstrip=`$inivar -ini $INIFILE -var EMCSTRIP -sec EMCSTRIP` if [ -n "$USE_INIFILE_PLATS" ] ; then emcstrip_plat=`$inivar -ini $INIFILE -var PLAT -sec EMCSTRIP`; else emcstrip_plat=$PLAT; fi emcstrip_options=`$inivar -ini $INIFILE -var OPTIONS -sec EMCSTRIP` # get display information display=`$inivar -ini $INIFILE -var DISPLAY -sec DISPLAY` if [ ! -n "$display" ] ; then echo "Can't find variable DISPLAY in section [DISPLAY] of file $INIFILE."; fi if [ -n "$USE_INIFILE_PLATS" ] ; then display_plat=`$inivar -ini $INIFILE -var PLAT -sec DISPLAY`; else display_plat=$PLAT; fi # Name of lock file to check for that signifies that EMC is up, # to prevent multiple copies of controller lockfile=/tmp/emc.lock # 'started' is flag that's set only if we create lock file, so # if we get ^C we won't delete a previous lock file set started = 0 # Check for lock file if [ -f $lockfile ]; then echo -n "emc is running-- restart it? [y/n] " read input case $input in y|Y) echo cleaning up old emc... ;; *) echo not starting new emc exit 0 ;; esac else echo starting emc... fi # Create the lock file touch $lockfile # Mark that we created it started=1 bccmd=none if [ -x /usr/bin/bc ] ; then bccmd=/usr/bin/bc ; fi if [ -x /bin/bc ] ; then bccmd=/bin/bc ; fi pidofcmd=none if [ -x /usr/bin/pidof ] ; then pidofcmd=/usr/bin/pidof ; fi if [ -x /bin/pidof ] ; then pidofcmd=/bin/pidof ; fi if [ -x /sbin/pidof ] ; then pidofcmd=/sbin/pidof ; fi tasktokill="" killtasktimeout=10 function killtaskwithtimeout () { if [ "${PLATBASE}" = "sunos" ] ; then shorttasktokillname=`echo $tasktokill | awk '{printf("%8.8s",$1);}'` pids=`ps | grep $shorttasktokillname | awk '{printf("%d ",$1);}'` kill -INT $pids else killall -INT $tasktokill 2> ${ERROR_OUT_FILE} if [ $bccmd != "none" -a $pidofcmd != "none" ] ; then time=`date +%s` deadline=`echo $time+ $killtasktimeout | $bccmd` while $pidofcmd $tasktokill > /dev/null ; do if [ `date +%s` -gt $deadline ] ; then echo "Timedout waiting for $tasktokill to die. Upgrading to -KILL" break; fi echo Waiting for $tasktokill to die . . . killall -INT $tasktokill 2> ${ERROR_OUT_FILE} sleep 1 done time=`date +%s` deadline=`echo $time+ $killtasktimeout | $bccmd` while $pidofcmd $tasktokill > /dev/null ; do if [ `date +%s` -gt $deadline ] ; then echo Timedout waiting for $tasktokill to die. break; fi echo Waiting for $tasktokill to die . . . killall -KILL $tasktokill 2> ${ERROR_OUT_FILE} sleep 1 done fi fi } nmlfile=`$inivar -ini $INIFILE -var NML_FILE -sec EMC` ipckeys=`grep SHMEM $nmlfile | gawk '{printf("%x ",$10);}'` # define the cleanup function function cleanup() { # Kill any displays lying around case $display in xemc|yemc|emcpanel|keystick) tasktokill=$display killtaskwithtimeout ;; tkemc) tasktokill=emcsh killtaskwithtimeout ;; *) tasktokill=$display killtaskwithtimeout ;; esac # Kill any emcservers lying around case $emcserver in emcsvr) tasktokill=$emcserver killtaskwithtimeout ;; "") ;; *) tasktokill=$emcserver killtaskwithtimeout ;; esac # Kill any emcstrips lying around case $emcstrip in emcstripchart) tasktokill=$emcstrip killtaskwithtimeout ;; "") ;; *) tasktokill=$emcstrip killtaskwithtimeout ;; esac # Kill any emctasks lying around case $emctask in bridgeporttask|minimilltask) tasktokill=$emctask killtaskwithtimeout ;; *) tasktokill=$emctask killtaskwithtimeout ;; esac # Kill any emcios lying around case $emcio in bridgeportio|minimillio|simio|ppmcio) tasktokill=$emcio killtaskwithtimeout ;; tkio) tasktokill=iosh killtaskwithtimeout ;; *) tasktokill=$emcio killtaskwithtimeout ;; esac # Kill any emcmots lying around case $emcmot in *.o) if /sbin/lsmod | grep $(echo $emcmot | sed s/\\.o//g) >/dev/null 2>/dev/null ; then echo Removing module $(echo $emcmot | sed s/\\.o//g) /sbin/rmmod $(echo $emcmot | sed s/\\.o//g) fi ;; *) tasktokill=$emcmot killtaskwithtimeout ;; esac # remove the lock file, if we create it if [ "$started" = "1" ]; then \rm -f $lockfile fi # Check to see if the inifile was changed. If not delete the unnecessary # backup. if [ -f $INIFILE.$DATESTRING ] ; then if diff $INIFILE $INIFILE.$DATESTRING > /dev/null ; then echo $INIFILE was not changed. \rm $INIFILE.$DATESTRING else echo $INIFILE was changed. diff $INIFILE $INIFILE.$DATESTRING diff $INIFILE $INIFILE.$DATESTRING >$INIFILE.$DATESTRING.diff echo $INIFILE differences saved to $INIFILE.$DATESTRING.diff \rm $INIFILE.$DATESTRING; fi else DATESTRING=`date +%Y%m%d%H%M%S` cp $INIFILE $INIFILE.$DATESTRING fi if [ -n "$RS274NGC_PARAMFILE" ] ; then if [ -f $RS274NGC_PARAMFILE.$DATESTRING ] ; then if diff $RS274NGC_PARAMFILE $RS274NGC_PARAMFILE.$DATESTRING > /dev/null ; then echo $RS274NGC_PARAMFILE was not changed. \rm $RS274NGC_PARAMFILE.$DATESTRING else echo $RS274NGC_PARAMFILE was changed. diff $RS274NGC_PARAMFILE $RS274NGC_PARAMFILE.$DATESTRING diff $RS274NGC_PARAMFILE $RS274NGC_PARAMFILE.$DATESTRING >$RS274NGC_PARAMFILE.$DATESTRING.diff echo $RS274NGC_PARAMFILE differences saved to $RS274NGC_PARAMFILE.$DATESTRING.diff \rm $RS274NGC_PARAMFILE.$DATESTRING; fi else cp $RS274NGC_PARAMFILE $RS274NGC_PARAMFILE.$DATESTRING fi fi # Delete sharedmemory segments and semaphores for key in $ipckeys ; do id=`ipcs -m | grep $key | gawk '{print $2}'` if [ ${#id} -gt 1 ] ; then echo "Removing shared memory " $id if [ "${PLATBASE}" = "sunos" ] ; then ipcrm -m $id else ipcrm shm $id fi fi id=`ipcs -s | grep $key | gawk '{print $2}'` if [ ${#id} -gt 1 ] ; then echo "Removing semaphore" $id if [ "${PLATBASE}" = "sunos" ] ; then ipcrm -s $id else ipcrm sem $id fi fi done if [ -z "$PURE_SIMULATION" ] ; then if [ -x ./remove_realtime_base ] ; then ./remove_realtime_base sleep 1 fi fi } # call cleanup function cleanup # and trap ^C so that it's called if user interrupts script trap 'cleanup ; exit 0' SIGINT # pop up intro graphic img=`$inivar -ini $INIFILE -var INTRO_GRAPHIC -sec DISPLAY` imgtime=`$inivar -ini $INIFILE -var INTRO_TIME -sec DISPLAY` if [ "$imgtime" = "" ] ; then imgtime=5 fi if [ "$img" != "" ] ; then if [ -x plat/$display_plat/bin/popimage ] ; then plat/$display_plat/bin/popimage $img $imgtime & fi fi # install RT-Linux or RTAI modules if [ -z "$PURE_SIMULATION" ] ; then if [ $PLATBASE = "linux" ] ; then ./install_realtime_base; fi fi sleep 1 # run emcmot in background echo -n "starting EMC MOTION PROGRAM -- $emcmot..." case $emcmot in stgmod.o|stg2mod.o|stg8mod.o|stg_v2_8axis.o|newstgmod.o|vtiisamod.o|vtipcimod.o|ppmcmod.o|ppmcmod8.o|univstepmod.o) # STG modules need SHMEM_BASE_ADDRESS and IO_BASE_ADDRESS shmem_base_address=`$inivar -ini $INIFILE -var SHMEM_BASE_ADDRESS -sec EMCMOT` if [ "$shmem_base_address" = "" ]; then echo "can't find SHMEM_BASE_ADDRESS in $INIFILE" cleanup exit 1 fi stg_base_address=`$inivar -ini $INIFILE -var IO_BASE_ADDRESS -sec EMCMOT` if [ "$stg_base_address" = "" ]; then echo "can't find IO_BASE_ADDRESS in $INIFILE" exit 1 fi optargs="" motion_io_address=`$inivar -ini $INIFILE -var MOTION_IO_ADDRESS -sec EMCMOT` if [ "$motion_io_address" != "" ]; then optargs="$optargs MOTION_IO_ADDRESS=$motion_io_address" fi if ! /sbin/insmod -f plat/$emcmot_plat/lib/$emcmot SHMEM_BASE_ADDRESS=$shmem_base_address IO_BASE_ADDRESS=$stg_base_address $optargs; then echo "can't install it" cleanup exit 1 else echo "done" fi ;; steppermod.o|freqmod.o|smdromod.o) # stepper modules need SHMEM_BASE_ADDRESS and IO_BASE_ADDRESS shmem_base_address=`$inivar -ini $INIFILE -var SHMEM_BASE_ADDRESS -sec EMCMOT` if [ "$shmem_base_address" = "" ]; then echo "can't find SHMEM_BASE_ADDRESS in $INIFILE" cleanup exit 1 fi parport_io_address=`$inivar -ini $INIFILE -var IO_BASE_ADDRESS -sec EMCMOT` if [ "$parport_io_address" = "" ]; then echo "can't find IO_BASE_ADDRESS in $INIFILE" cleanup exit 1 fi optargs="" period=`$inivar -ini $INIFILE -var PERIOD -sec EMCMOT` if [ "$period" != "" ]; then period=$(echo $period 1000000000 \* 1 / p c | dc) optargs="$optargs PERIOD=$period" fi steppingtype=`$inivar -ini $INIFILE -var STEPPING_TYPE -sec EMCMOT` if [ "$steppingtype" != "" ]; then optargs="$optargs STEPPING_TYPE=$steppingtype" fi motion_io_address=`$inivar -ini $INIFILE -var MOTION_IO_ADDRESS -sec EMCMOT` if [ "$motion_io_address" != "" ]; then optargs="$optargs MOTION_IO_ADDRESS=$motion_io_address" fi dro_base_address=`$inivar -ini $INIFILE -var DRO_BASE_ADDRESS -sec EMCMOT` if [ "$dro_base_address" != "" ]; then optargs="$optargs DRO_BASE_ADDRESS=$dro_base_address" fi if ! /sbin/insmod -f plat/$emcmot_plat/lib/$emcmot SHMEM_BASE_ADDRESS=$shmem_base_address IO_BASE_ADDRESS=$parport_io_address $optargs; then echo "can't install it" cleanup exit 1 else echo "done" fi ;; minitetra.o) # minitetra module needs SHMEM_BASE_ADDRESS and IO_BASE_ADDRESS shmem_base_address=`$inivar -ini $INIFILE -var SHMEM_BASE_ADDRESS -sec EMCMOT` if [ "$shmem_base_address" = "" ]; then echo "can't find SHMEM_BASE_ADDRESS in $INIFILE" cleanup exit 1 fi parport_io_address=`$inivar -ini $INIFILE -var IO_BASE_ADDRESS -sec EMCMOT` if [ "$parport_io_address" = "" ]; then echo "can't find IO_BASE_ADDRESS in $INIFILE" cleanup exit 1 fi optargs="" period=`$inivar -ini $INIFILE -var PERIOD -sec EMCMOT` if [ "$period" != "" ]; then period=$(echo $period 1000000000 \* 1 / p c | dc) optargs="$optargs PERIOD=$period" fi steppingtype=`$inivar -ini $INIFILE -var STEPPING_TYPE -sec EMCMOT` if [ "$steppingtype" != "" ]; then optargs="$optargs STEPPING_TYPE=$steppingtype" fi motion_io_address=`$inivar -ini $INIFILE -var MOTION_IO_ADDRESS -sec EMCMOT` if [ "$motion_io_address" != "" ]; then optargs="$optargs MOTION_IO_ADDRESS=$motion_io_address" fi if ! /sbin/insmod -f plat/$emcmot_plat/lib/$emcmot SHMEM_BASE_ADDRESS=$shmem_base_address IO_BASE_ADDRESS=$parport_io_address $optargs; then echo "can't install it" cleanup exit 1 else echo "done" fi ;; simmod.o) # Real-time simulation module needs inisim to be run. if ! /sbin/insmod -f plat/$emcmot_plat/lib/$emcmot; then echo "can't install it" cleanup exit 1 else echo Running inisim to send INIFILE simulation parameters to the real-time simulator. plat/$PLAT/bin/inisim -ini $INIFILE echo "done" fi ;; emcmotsim) if [ ! -x plat/$emcmot_plat/bin/$emcmot ] ; then echo "can't run $emcmot program" echo "The file plat/$emcmot_plat/bin/$emcmot does not exist or is not executable." cleanup exit 1 fi if [ -f ${HOME}/.debug_emcmot ] ; then xterm -sb -sl 1000 -e ${DEBUGGER} plat/$emcmot_plat/bin/$emcmot & echo "Press ENTER when the $emcmot is running in the debugger." read foo else plat/$emcmot_plat/bin/$emcmot -ini $INIFILE & fi echo "done" ;; emcmotsim.tc) if [ ! -x plat/$emcmot_plat/bin/$emcmot ] ; then echo "can't run $emcmot program" echo "The file plat/$emcmot_plat/bin/$emcmot does not exist or is not executable." cleanup exit 1 fi if [ -f ${HOME}/.debug_emcmot ] ; then xterm -sb -sl 1000 -e ${DEBUGGER} plat/$emcmot_plat/bin/$emcmot & echo "Press ENTER when the $emcmot is running in the debugger." read foo else plat/$emcmot_plat/bin/$emcmot -ini $INIFILE & fi sleep 20 echo "done" ;; genhexsim) if [ ! -x plat/$emcmot_plat/bin/$emcmot ] ; then echo "can't run $emcmot program" echo "The file plat/$emcmot_plat/bin/$emcmot does not exist or is not executable." cleanup exit 1 fi if [ -f ${HOME}/.debug_emcmot ] ; then xterm -sb -sl 1000 -e ${DEBUGGER} plat/$emcmot_plat/bin/$emcmot & echo "Press ENTER when the $emcmot is running in the debugger." read foo else plat/$emcmot_plat/bin/$emcmot -ini $INIFILE -noforward & fi echo "done" ;; *.o) # Unknown .o assume its a realtime module that # may or may not need SHMEM_BASE_ADDRESS, IO_BASE_ADDRESS, IO_BASE_ADDRESS, PERIOD optargs="" period=`$inivar -ini $INIFILE -var PERIOD -sec EMCMOT` if [ "$period" != "" ]; then period=$(echo $period 1000000000 \* 1 / p c | dc) optargs="$optargs PERIOD=$period" fi shmem_base_address=`$inivar -ini $INIFILE -var SHMEM_BASE_ADDRESS -sec EMCMOT` if [ "$shmem_base_address" != "" ]; then pcount=`/sbin/modinfo -p $emcmot | grep IO_BASE_ADDRESS | wc -l` if [ $pcount -eq 1 ] ; then optargs="$optargs SHMEM_BASE_ADDRESS=$shmem_base_address" fi fi stg_base_address=`$inivar -ini $INIFILE -var IO_BASE_ADDRESS -sec EMCMOT` if [ "$stg_base_address" != "" ]; then pcount=`/sbin/modinfo -p $emcmot | grep IO_BASE_ADDRESS | wc -l` if [ $pcount -eq 1 ] ; then optargs="$optargs IO_BASE_ADDRESS=$stg_base_address" fi fi parport_io_address=`$inivar -ini $INIFILE -var IO_BASE_ADDRESS -sec EMCMOT` if [ "$parport_io_address" != "" ]; then pcount=`/sbin/modinfo -p $emcmot | grep IO_BASE_ADDRESS | wc -l` if [ $pcount -eq 1 ] ; then optargs="$optargs IO_BASE_ADDRESS=$parport_io_address" fi fi motion_io_address=`$inivar -ini $INIFILE -var MOTION_IO_ADDRESS -sec EMCMOT` if [ "$motion_io_address" != "" ]; then pcount=`/sbin/modinfo -p $emcmot | grep MOTION_IO_ADDRESS | wc -l` if [ $pcount -eq 1 ] ; then optargs="$optargs MOTION_IO_ADDRESS=$motion_io_address" fi fi echo /sbin/insmod -f plat/$emcmot_plat/lib/$emcmot $optargs if ! /sbin/insmod -f plat/$emcmot_plat/lib/$emcmot $optargs; then echo "can't install it" cleanup exit 1 else echo "done" fi ;; *) # Unknown but not .o so assume it is a non-realtime executable. if [ ! -x plat/$emcmot_plat/bin/$emcmot ] ; then echo "can't run $emcmot program" echo "The file plat/$emcmot_plat/bin/$emcmot does not exist or is not executable." cleanup exit 1 fi if [ -f ${HOME}/.debug_emcmot ] ; then xterm -sb -sl 1000 -e ${DEBUGGER} plat/$emcmot_plat/bin/$emcmot & echo "Press ENTER when the $emcmot is running in the debugger." read foo else plat/$emcmot_plat/bin/$emcmot -ini $INIFILE & fi echo "done" ;; esac sleep 1 if [ $emcio = simio ] ; then IOEXEC_NEEDED=0; fi # Run emcio in background echo -n "starting EMC IO PROGRAM -- $emcio..." case $emcio in bridgeportio|minimillio|simio|ppmcio) if [ ! -x plat/$emcio_plat/bin/$emcio ] ; then echo "can't run $emcio program" echo "The file plat/$emcio_plat/bin/$emcio does not exist or is not executable." cleanup exit 1 fi if [ $IOEXEC_NEEDED = 1 ] ; then /sbin/ioexec plat/$emcio_plat/bin/$emcio -ini $INIFILE & else if [ -f ${HOME}/.debug_emcio ] ; then xterm -sb -sl 1000 -e ${DEBUGGER} plat/$emcio_plat/bin/$emcio & echo "Press ENTER when the $emcio is running in the debugger." read foo else plat/$emcio_plat/bin/$emcio -ini $INIFILE & fi fi echo "done" ;; tkio) if [ ! -x plat/$emcio_plat/bin/$emcio ] ; then echo "can't run $emcio program" echo "The file plat/$emcio_plat/bin/$emcio does not exist or is not executable." cleanup exit 1 fi if [ $IOEXEC_NEEDED = 1 ] ; then /sbin/ioexec plat/$emcio_plat/bin/$emcio -- -ini $INIFILE & else if [ -f ${HOME}/.debug_emcio ] ; then xterm -sb -sl 1000 -e ${DEBUGGER} plat/$emcio_plat/bin/$emcio & echo "Press ENTER when the $emcio is running in the debugger." read foo else plat/$emcio_plat/bin/$emcio -ini $INIFILE & fi fi echo "done" ;; *) if [ ! -x plat/$emcio_plat/bin/$emcio ] ; then echo "can't run $emcio program" cleanup exit 1 fi if [ $IOEXEC_NEEDED = 1 ] ; then /sbin/ioexec plat/$emcio_plat/bin/$emcio -ini $INIFILE & else if [ -f ${HOME}/.debug_emcio ] ; then xterm -sb -sl 1000 -e ${DEBUGGER} plat/$emcio_plat/bin/$emcio & echo "Press ENTER when the $emcio is running in the debugger." read foo else plat/$emcio_plat/bin/$emcio -ini $INIFILE & fi fi echo "done" ;; esac sleep 1 # Run emctask in background echo -n "starting EMC TASK PROGRAM -- $emctask..." case $emctask in bridgeporttask|minimilltask) if [ ! -x plat/$emctask_plat/bin/$emctask ] ; then echo "can't run $emctask program" echo "The file plat/$emctask_plat/bin/$emctask does not exist or is not executable." cleanup exit 1 fi if [ -f ${HOME}/.debug_emctask ] ; then xterm -sb -sl 1000 -e ${DEBUGGER} plat/$emctask_plat/bin/$emctask & echo "Enter 'y' when the $emctask is running in the debugger." confirm="" while [ "${confirm}" != "y" ] ; do read confirm done else plat/$emctask_plat/bin/$emctask -ini $INIFILE & fi echo "done" ;; *) if [ ! -x plat/$emctask_plat/bin/$emctask ] ; then echo "can't run $emctask program" echo "The file plat/$emctask_plat/bin/$emctask does not exist or is not executable." cleanup exit 1 fi if [ -f ${HOME}/.debug_emctask ] ; then xterm -sb -sl 1000 -e ${DEBUGGER} plat/$emctask_plat/bin/$emctask & echo "Press ENTER when the $emctask is running in the debugger." read foo else plat/$emctask_plat/bin/$emctask -ini $INIFILE & fi echo "done" ;; esac sleep 1 # Run emcserver in background, if necessary case $emcserver in emcsvr) if [ ! -x plat/$emcserver_plat/bin/$emcserver ] ; then echo "can't run $emcserver program" echo "The file plat/$emcserver_plat/bin/$emcserver does not exist or is not executable." cleanup exit 1 fi echo -n "starting EMC SERVER PROGRAM -- $emcserver..." plat/$emcserver_plat/bin/$emcserver -ini $INIFILE & echo "done" ;; "") ;; *) if [ ! -x plat/$emcserver_plat/bin/$emcserver ] ; then echo "can't run $emcserver program" echo "The file plat/$emcserver_plat/bin/$emcserver does not exist or is not executable." cleanup exit 1 fi echo -n "starting $emcserver..." plat/$emcserver_plat/bin/$emcserver -ini $INIFILE & echo "done" ;; esac sleep 1 # Run emcstrip in background, if necessary case $emcstrip in emcstripchart) if [ ! -x plat/$emcstrip_plat/bin/$emcstrip ] ; then echo "can't run $emcstrip program" echo "The file plat/$emcstrip_plat/bin/$emcstrip does not exist or is not executable." fi echo -n "starting $emcstrip $emcstrip_options ..." plat/$emcstrip_plat/bin/$emcstrip $emcstrip_options -- -ini $INIFILE & echo "done" ;; "") ;; *) if [ ! -x plat/$emcstrip_plat/bin/$emcstrip ] ; then echo "can't run $emcstrip program" echo "The file plat/$emcstrip_plat/bin/$emcstrip does not exist or is not executable." fi echo -n "starting $emcstrip..." plat/$emcstrip_plat/bin/$emcstrip $emcstrip_options -- -ini $INIFILE & echo "done" ;; esac sleep 1 if [ -f ~/.debug_scripts ] ; then ps -ael ipcs /sbin/lsmod fi # Run display in foreground echo "running EMC DISPLAY PROGRAM -- $display..." case $display in xemc|yemc|emcpanel|keystick) if [ ! -x plat/$display_plat/bin/$display ] ; then echo "can't run $display program" echo "The file plat/$display_plat/bin/$display does not exist or is not executable." cleanup exit 1 fi plat/$display_plat/bin/$display -ini $INIFILE ;; tkemc) if [ ! -x plat/$display_plat/bin/$display ] ; then echo "can't run $display program" echo "The file plat/$display_plat/bin/$display does not exist or is not executable." cleanup exit 1 fi # need to run tkemc with -- arg to separate remaining args plat/$display_plat/bin/$display -- -ini $INIFILE ;; *) if [ ! -x plat/$display_plat/bin/$display ] ; then echo "can't run $display program" echo "The file plat/$display_plat/bin/$display does not exist or is not executable." cleanup exit 1 fi plat/$display_plat/bin/$display -ini $INIFILE ;; esac sleep 1 if [ -f ~/.debug_scripts -o -f ~/.pause_before_cleanup ] ; then echo 'Press or to continue.' read foo; fi # Now display finished, so let's clean up cleanup exit 0