From: rick@emma.panam.wimsey.bc.ca (Rick Younie)
Newsgroups: alt.sys.amiga.uucp
Subject: lockserial & Baud Bandit
Date: Sat, 26 Sep 1992 14:30:46 GMT
Distribution: world
Reply-To: rick@emma.panam.wimsey.bc.ca
Bcc:  rick
X-Newsreader: Arn V1.00 beta rel2

I've been running my terminal program, Baud Bandit, as a DCron event, but if
it is still around when uucico starts up, neither can use the serial port.
And since BB detaches when it starts up, there is nothing for lockserial to
hang on to.  I posted to several groups for a work-around and didn't come up
with anything, so I'm assuming I'm not missing something simple here.

I've only been using it for a few hours, but it is so simple, what can go
wrong..  :)

/*
 *  REXX:STICKY       (make sure the script bit is set)
 *
 * $VER:          Rick Younie  26.9.92    rick@emma.panam.wimsey.bc.ca
 *
 * USAGE:     lockserial rexx:sticky
 *
 * SYNOPSIS:  - this script gives uucp:c/lockserial something to hang on
 *              to when you want a term or MIDI program to have exclusive
 *              use of the serial port.
 *          - make it go away with 'rx "address STICKY DIE' or, with Baud
 *            Bandit, have the macro Exit string \m'rx "address STICKY DIE
 *            and it will go away when Baud Bandit exits.
 *          - 'HI' also causes it to exit
 * 
 * LIMITATIONS: - it's not apparent how lockserial parses the command line.
 *            It would be nice to use 'lockserial sticky prog_name' where
 *            prog_name would be any program that detaches from the
 *            launching cli, eg Baud Bandit, Music-X.  As it stands, you
 *            need a separate 'sticky' script for each program.
 *            
 * FILES USED:
 *
 * PROGRAMS USED:
 *
 * TODO:
 *
 */
   signal on HALT
   signal on BREAK_C
   signal Start
HALT:
BREAK_C:
   exit                                /* port goes away when script ends */
Start:

/* constants and assigns */

   fullname = 'Comm:BaudBandit_1.50'   /* name of program that you want.. */
                            /* ..to have exclusive use of the serial port */

/* ---------------------------------------------------------------------- */
Main:
   options results
/*   parse arg fullname */
   tmp = translate(fullname,'  ','/:')   /* parse input into dir and file */
   name = word(tmp,words(tmp))
   dir = left(fullname,length(fullname)-length(name))

   if (openport('STICKY')='0000 0000'x) then do      /* start our port up */
      say 'Couldn''t open port.. aborting'
      exit
   end

   call LaunchPrg                          /* start up the target program */
   do forever
      if WaitCmd() = 'DIE' then exit   /* go away when the DIE message .. */
   end                                         /* .. shows up at the port */
/* ---------------------------------------------------------------------- */

WaitCmd:   
   do forever
      call waitpkt 'STICKY'                    /* only waits for a while */
      pkt = getpkt('STICKY')
      if pkt = '0000 0000'x then iterate
      call reply pkt, 0
      return getarg(pkt)
   end

LaunchPrg:
   call pragma 'D', dir                      /* resets current directory */
   address 'COMMAND' 'Comm:BaudBandit_1.50'
   return


/*
   This port stuff is very powerful.  I don't know how I missed it
   for so long.  By having:

      select
         when WaitCmd() = first command then call
         when WaitCmd() = second command then call
         ..

   you've got a command host that runs in the background, not using many
   cycles, ready to do just about anything.  eg, a spelling checker
   interface.  This probably isn't the place to discuss it though.  There is
   an ARexx mailing list.  To join, send the message:

         to:   LISTSERV@vm.ucs.ualberta.ca
         subj: none

         SUBSCRIBE AREXX-L Your Name
*/

Rick
--
-------------------------------,------------------------------------------
  rick@emma.panam.wimsey.bc.ca |  Reality is just an illusion
  Fido: 1:153/911              |              caused by lack of alcohol.
-------------------------------'------------------------------------------