

    RSM stands for Renaldo's Serial Manager. It is an ARexx compatible
    multitasking program, designed to control the serial port from another
    program. It came about because we had a project that needed Director2
    for its EXCELLENT sound handling capabilities. Unfortunately, there
    wasn't a serial manager available like the one from CanDo 1.5, so we
    could control an Amiga 500 remotely! Since it would be tacky to use the
    CanDo serial manager, I designed my own! This is an example for you to
    change and embellish!
    RSM is Copyright 1991, Ron M. Battle, and can be re-distributed freely for
    non-commercial applications!

    If you forget the commands and options available, just type 'rsm ?'.


**            Revision History                                         **
**            ----------------------------------------------------     **
**            V1.1  7-25-91  Designed for special app using Dir2       **
**            V1.2  8-24-91  Added cmd line input: -u -t -c            **
**            V1.3  11-3-91  Added -l -b -d  & corrected logic         **
**            V1.4 04-19-92  Changed read and write ports to reflect   **
**                           Unit# so multiple RSMs can be run         **
**                           Used protos and pragmas, 32 bit ints      **
**                           Added prefix string for incoming serial   **
**            V1.41 9-28-92  Added space between prefix and incoming   **
**                           serial string, VERY important for CanDo!  **
**            V1.42 11-18-92 Previous code changes screwed up the      **
**                           adding of any terminator to an output     **
**                           string (CR,etc.), FIXED!! Also did        **
**                           general code clean up                     **
**                                                                     **

  USAGE: run rsm -bBuffer -cCase -lListen -tTalk -uUnit# -dDevice -pPrefix
example: run rsm -b32 -cN -lRSM0 -tdirector0 -u0 -dserial.device  (DEFAULT)

  -b  buffer size 1-255 bytes, actually reads 1-255 bytes out of the
      total serial device buffer which is usually 512 bytes, 1 byte
      serial reads are useful when using Sony laser disc players

  -c  case translation for incoming data from the serial port,
      Upper or Lower or None

  -l  listen port name, Input, where YOU will send ARexx commands

  -t  talk port name, Output, where RSM will SEND incoming serial data

  -u  unit number for serial device, 0-32, if no listen port specified,
      will be appended to RSM, eg: RSM2 RSM32 RSM1

  -d  device name

  -p  prefix ThisString to incoming serial string, 8 chars max\n\


ARexx commands:  (separate arguments with SPACES!)
---------------
    quit      shuts down the serial manager
    flush     flushes out the serial device buffer
    prefix    prefix ThisString  to the incoming serial string (useful for CanDo!)
    send      send ThisString    out the serial port
    seteof    seteof OFF 10      if ON, will set terminator char (ASCII value)
              for serial reads, will also be added as suffix to send strings
              DEFAULT is OFF, for Pioneer LDPs try: setEOF ON 13
       RSM chokes on incoming binary zeros (nulls) UNLESS used as a terminator\n\
    setparams setparams BaudRate 8N1   will set serial port parameters,
              baud=300-19200, 7-8 data bits, parity E O N, 1-2 stop bits
              DEFAULT is 1200 baud, 8 data bits, No parity, 1 stop bit
    status    returns 16bit status comma then number of unread serial chars (4,0)
    test      test ThisString    will send Ready! out the serial port and
              translate ThisString according to how Case was set

    ARexx CLI examples:
      rx 'address RSM0 quit'  rx 'address RSM0 setEOF ON 10'
      rx 'address RSM0 setparams 9600 8N1'
 (remember to put quotes around strings that you DON'T want ARexx to capitalize!)

Example code fragment for Director2:
------------------------------------
Abort 0                               :rem exit on any key press
timer 3,2                             :rem continuous 1/30 sec. interrupt

dim message[32]

execute r,"run YourPath:rsm -b1"      :rem Get Serial Manager running
/RsmLoop:
REXX "FIND",f,"RSM0"                  :rem OR the name of your listen port!
IF f=0 then GOTO RsmLoop
ENDIF
PRINT "Found RSM port!"

baud=1200

REXX "send",r,"RSM0","setparams ";baud;" 8n1"  :rem set up baud rate and params
REXX "send",r,"RSM0","send READY!"             :rem send READY! out serial port

ON KEY   GOTO exit                             :rem ENABLE KEY   EXIT
ON TIMER GOTO ServiceInt                       :rem ENABLE TIMER INTERRUPTS

/Loop:                                      :rem This main loop is NOT BUSY!
PAUSE 32000                                 :rem lets Amiga multi-task,
GOTO Loop                                   :rem while waiting for interrupts

/ServiceInt:                                :rem  interrupt server
    rexx "TEST",SIresult                    :rem  use UNIQUE variables!!
    if SIresult !=0                         :rem  arexx message received
      rexx "RCV",message
      REXX "REPLY",0
      AnyCmd=1
      DO ParseCmd                           :rem  ParseCmd is YOUR routine
      ...
      ...
    endif

    RETURN                                  :rem  from interrupt

/exit:
  REXX "send",r,"RSM0","quit"               :rem  shut down the serial manager
  pause 1                                   :rem  BEFORE ending program!
  END

---------------------------------------------------------------------------------
Ron M. Battle, HyperBorea Studio B,    email: rbattle@hydra.unm.edu  (Internet)


