home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
339.lha
/
SerMod
/
Docs
/
SerMod.doc.pp
/
SerMod.doc
Wrap
Text File
|
1990-02-08
|
10KB
|
265 lines
In this article, we will look at the first module implemented as part of
ROBBS (Rexx Object Building Block System); SerMod, the serial module. Full
source code will not be presented, but will be available on a Transactor disk.
We will look at some of the code that illustrates the principles of the ARexx
interface to this module, and show complete syntax for the commands it will
recognize.
First, let's look at the syntax of the commands that SerMod knows about.
Remember, these commands are the only way that SerMod can be made to do
anything at all. Figure 1 shows a table of commands, a brief description of
their purpose, and the type of arguments they take.
-----------------------------------------------------------------------------
Command Purpose Arguments
-----------------------------------------------------------------------------
RXD Serial receiver enable ON | OFF
TXD Serial trasnmit enable ON | OFF
SEND Send string to serial port STRING
LSEND Send line to serial port (with linefeed) STRING
MATCH Watch for a match from serial data NUMBER STRING
SCAN Enable/disable match checking. ON | OFF
CONNECT Attach receive or transmit to module PORTNAME COMMAND
CTRL Attach to another control port. PORT
COMM Set serial parameters BAUD DUPLEX XON/OFF TRANSLATE
ABORT Stop sending (flush sendstrings) NONE
STATUS Return info about ROBBS NONE
DIE Unload ROBBS NONE
REALLY_DIE Emergency quit if script has terminated NONE
----------------------------------------------------------------------------
Fig. 1
All commands must be in upper case. If you do not quote the command string
within your ARexx program, it will be passed to SerMod in upper case
automatically. The same can be said for any argument required, so if you are
sending data that must be in mixed case, you will need to quote it in the ARexx
program.
----------------------------------------------------------------------------
TXD and RXD take an ON or OFF argument. This is in the form of a string, and
the argument must be in upper case. The purpose of these two commands is to
allow other programs to use the serial port. The other program wishing to open
the serial port must do so in 'shared mode' in order to be successful.
Examples:
RXD ON
RXD OFF
TXD ON
TXD OFF
-----------------------------------------------------------------------------
SEND and LSEND are exactly the same, in that they will both send a string out
the serial port, except that LSEND will automatically append a linefeed to the
string it is sending. LSEND is provided to allow easier use of SEND, since the
only way to SEND an explicit linefeed out the serial port from an ARexx program
is to use hex string notation; '0a'x. Both SEND and LSEND take a string as an
argument. Remember to quote the string if you want it to be sent as you typed
it in, without conversion to upper case.
Examples:
SEND 'This string will have no linefeed'
LSEND ', but this one will.'
Result:
This string will have no linefeed, but this one will.
-------------------------------------------------------------------------
MATCH allows you to set up 10 strings for SerMod to watch for in the incoming
data from the serial port. Each MATCH string may be assigned a number, from 0
through 9, and if any part of the incoming data matches one of the strings, a
message will be sent to the control port, specifying that a match has occured,
and the number of the string that matched. Each string may be up to 100
characters long, and may include embedded linefeeds or carriage returns, making
it possible to set up multi-line match strings.
Examples:
MATCH 0 'login:'
MATCH 1 'Password:'
MATCH 2 'You have email waiting.' || '0a'x || 'Read it now? (Y/N)'
MATCH 1
MATCH C
Result:
Whenever one of the above strings matches with data coming in on the serial
port, SerMod will send a message to the control port (specified by the CTRL
command). If 'login:' arrives, the message would look like this:
MATCH 0
Note that the example for MATCH 2 has an embedded linefeed, and will only
match an incoming string if there is a linefeed in the incoming data, in the
same position as specified in the match string.
Using a number by itself, with no string, will cause that matchstring to be
cleared, meaning that no matches will happen for that string. The MATCH C is
used to clear all match strings, and is provided as a convenience to the
programmer.
----------------------------------------------------------------------------
SCAN is provided because you sometimes want to disable string matching. Good
examples of this are when you are initializing the matchstrings from your
ARexx program. If you were to receive 'MATCH' messages at this time, your
program might not be ready to process them.
Examples:
SCAN ON
SCAN OFF
Results:
ON enables matching, OFF disables matching.
------------------------------------------------------------------------------
CONNECT provides a means to hook the incoming serial port data more directly to
the program it is destined for. While ARexx is fast enough for many operations,
it is not fast enough to process large amounts of data coming in at high
speeds. This command tells SerMod where to send incoming data.
Examples:
CONNECT 'ROBBS_disp' TEXT
Result:
All data received on the serial port will be sent via a message to the port
named 'ROBBS_disp', using the command, 'TEXT'. It is worth noting that the
message will be indistinguishable to the receiver from a message sent from an
ARexx script. This provides a degree of flexibility, allowing any program to be
the actual control program, or for many programs to communicate with one
module.
---------------------------------------------------------------------------
CTRL is similar to CONNECT, but isntead of redirecting the data received from
the serial port, it redirects other messages, such as the 'MATCH' messages.
This lets you use more than one ARexx progam as a control for the ROBBS
modules, or even to use a program written in virually any other language, to be
used as the controlling program. There is only one argument, a string naming
the new CTRL port.
Example:
CTRL 'ROBBS_graphic_control'
Result:
Any messages originating from SerMod (except incoming serial character
messages), will be sent to the port named 'ROBBS_graphic_control'
----------------------------------------------------------------------------
COMM lets you set up the serial port parameters. All arguments are mandatory.
Examples:
COMM 2400 N XE T
COMM 1200 E XD N
Results:
The first example sets the serial port to 2400 baud, no echo (full duplex),
Xon/Off enabled, and Translate ON (7 bits only). The second example sets 1200
baud, echo (half duplex), Xon/Off disabled, and no translation (8 bits
received).
----------------------------------------------------------------------------
ABORT lets you stop sending any string that has been sent via the SEND or LSEND
commands. This is provided for those applications, like BBS's, which can detect
an action on the part of the caller and stop sending the current line.
Example:
ABORT
Result:
The string currently being sent out the serial port is flushed without the
rest being sent.
-----------------------------------------------------------------------------
STATUS is a way for the controlling program to find out what SerMod is doing at
present. You must have previously used the line 'OPTIONS RESULTS' in your ARexx
program, in order for STATUS to return anything, and the result of the STATUS
command will be returned in the special ARexx variable RESULT.
Example:
STATUS
Result:
SerMod replies to the message, filling in the RESULT variable, if OPTIONS
RESULTS is in effect. RESULT will contain something like:
2400 NOECHO XENABLED TRANSLATE TALKON LISTENON SCANOFF ROBBS_disp ROBBS_ctrl
2406A0 240840
In order, these signify:
2400 baud, full duplex, Xon/Off enabled, 7 bit receive, transmit enabled,
receive enabled, not checking for matches, current CONNECT port,
current CTRL port, serial IO port (IOReq) for read, and serial IO port
for write.
------------------------------------------------------------------------------
DIE is a command that will cause SerMod to finish what it is doing, clean up
everything, exit, and unload from memory. Note that it is not necessary to
unload SerMod and reload it for every application that needs to use it. You
must, however, be aware that before an ARexx program stops, it should set
things up so that no messages will be sent to the CTRL port or the CONNECT
port, if the CONNECT port is no longer there.
Example:
DIE
Result:
Sermod cleans up and exits. If there are outstanding messages that have been
sent from SerMod, and have not been replied to, SerMod will print a warning
message on the CLI it was started from, and will not yet exit. If you know that
there can be no replies to the messages, which could easily happen if your
ARexx program is under development, and a bug caused it to exit prematurely,
you can use the REALLY_DIE command to force SerMod to exit.
-------------------------------------------------------------------------------
REALLY_DIE is provided for emergencies. Suppose your ARexx program (or any
other program that receives messages from SerMod) exits prematurely because of
a bug. In this case, SerMod will not send any more messages to the exited
program's port, since the port is checked for existence before a message is
sent. However, the program that exited may have been sent a message that it did
not yet reply to. In this case, SerMod, when told to exit via the DIE command,
will not exit, but will await the reply to its outstanding message. The
REALLY_DIE command should be used at the user's discretion to force SerMod to
free the memory allocated for outstanding messages, and then to exit. If you
should be so careless as to use the DIE and REALLY_DIE commands while there is
a message outstanding, and then the other program or module does reply, the
GURU is likely to be offended enough to come to visit you.
Example:
REALLY_DIE
Result:
Force cleanup and exit of SerMod.
--------------------------------------------------------------------------------