This chapter contains a list of all input/output and XIO calls to the RS-232
"R:" handler of the MIO. Note that IOCB is an input/output channel number that indicates what OPEN device shall receive or provide data. For most XIO
calls, you may use any legal IOCB number as long as it is NOT open to any other device. From Atari BASIC, you may use IOCB numbers 1 through 7 (0 is
reserved for editing "E:" I/O).
Note that IOCB #7 is used for the BASIC LPRINT statement and IOCB #6 is used
for graphics mode functions from BASIC. Also, if using SpartaDOS, IOCB #4 and IOCB #5 are used while doing output and input redirection respectively (via
the DOS PRINT command and batch files).
All the syntaxes use just "R:" for the device name since there is only one
RS-232 port on the MIO. In fact, if you do use a port number (ex. "R2:"), it is simply ignored and treated the same as "R:".
All the function formats are given in their Atari BASIC form. If using
assembly language or some other high level language, refer to the language manual for its equivalent form.
Opening the RS-232 Port
Syntax
OPEN #IOCB,Aux1,0,"R:"
Remarks
This function opens a channel to the RS-232 port in pseudo "non-concurrent" mode. To remain compatible with the 850 and P:R: Connection, the MIO has a
flag indicating whether an XIO 40 (set concurrent mode) has been performed since the last OPEN command. If it has not, then the STATUS command returns
the state of the handshake lines, whereas if in concurrent mode, the STATUS command returns the number of characters in the input and output buffers.
Aux1 contains the I/O direction bits — 4 for input only, 8 for output only,
and 12 for both input and output (which is equivalent to 13 of the 850 interface). Many XIO calls do not require that you open an RS-232 channel
first, however, it is generally a good practice to open the channel first. Care should be taken when setting the state of the handshake lines; if you
set DTR false, the transmitter and receiver are disabled. Therefore, you must re-enable them by setting DTR true before continuing with normal
operation.
When the channel is opened, both the input and output buffers are cleared.
Also, the RTS and DTR handshake lines are set true (to the ready state).
Closing the RS-232 Port
Syntax
CLOSE #IOCB
Remarks
This statement closes the IOCB connected to the RS-232 port. This simply shuts down the IOCB; the
RS-232 port remains untouched except that the system waits until all data in the output buffer has been transmitted.
Input Character or Line From the RS-232 Port
Syntax
GET #IOCB,varb
INPUT #IOCB,varb$
Remarks
These functions input data from the RS-232 port; the GET statement inputs the numeric value of one character into a numeric variable and the INPUT
statement inputs a string of characters into a string variable. On the INPUT statement, if the data is a numerical ASCII string, you may read the data
into a numeric variable. Input strings are terminated by an end-of-line (EOL)
character.
Note that the IOCB must be opened for read or read/write (modes 4 or 12), but
whether in concurrent mode or not has no effect on GET/INPUT statement operation. Refer to your BASIC reference manual for more information on these
statements.
Output Character or Line To the RS-232 Port
Syntax
PUT #IOCB,exp
PRINT #IOCB;exp$
Remarks
These functions output data to the RS-232 port; the PUT statement outputs the numeric value of one character to the port, and the PRINT statement outputs a
string of characters to the port. The syntax of the PRINT statement is the same as a normal PRINT statement except that the "#IOCB;" precedes the
expression.
Note that the IOCB must be opened for write or read/write (mode 8 or 12), but
whether in concurrent mode or not has no effect on GET/INPUT statement operation. Refer to your BASIC reference manual for more information on these
statements.
Reading the Port Status
Syntax
STATUS #IOCB,DUMMY
FLAGS = PEEK(746) : REM Error bits relating to status history
LINESTAT = PEEK(747) : REM Status of handshake lines
or
STATUS #IOCB,DUMMY
FLAGS = PEEK(746) : REM Error bits relating to status history
INCHARS = PEEK(747) : REM Number of chars in input buffer
OUTCHARS = PEEK(749) : REM Number of chars in output buffer
Remarks
These statement sequences are useful for determining many facts about the state of the RS-232 port. The first syntax is
used when in pseudo "block mode I/O" (same as "non-concurrent"), whereas the second is used in concurrent
mode I/O. Notice that the variable DUMMY is simply a CIO status of the success of the STATUS command. If there were an error (DUMMY<>1), then BASIC
would halt and give an error message (unless a TRAP was performed prior to the STATUS).
The block mode STATUS (first syntax) returns a status history of the port (in
FLAGS) and the state of the control lines (in LINESTAT). The meaning of each bit is given in tables 6-1 and 6-2.
The concurrent mode STATUS (second syntax) returns a status history of the
port (in FLAGS) and the number of characters in the input buffer (in INCHARS) and in the output buffer (in OUTCHARS). The meaning of each bit of FLAGS is
given in table 6-1.
Table 6-1. Meaning of Error Bits From Location 746
|
Bit |
|
Dec Equiv |
|
Meaning of Error |
7 |
|
128 |
|
|
Received a data framing error |
6 |
|
64 |
|
|
Received a data byte overrun error |
5 |
|
32 |
|
|
Received a data parity error |
4 |
|
16 |
|
|
Received a buffer overflow error (>255 chars)
|
Table 6-2. Meaning of Status Bits From Location 747
|
Bit* |
|
Dec Equiv
|
|
Meaning When Bit is Set (1)
|
7 |
|
128 |
|
|
DSR is true (ready)
|
5
|
|
32
|
|
|
CTS is true (ready — Always true on MIO)
|
3
|
|
8
|
|
|
CRX is true (ready)
|
0
|
|
1
|
|
|
RCV is at MARK (Always Set on MIO)
|
* Bits 6, 4, and 2 are simply copies of the next highest bit. In the 850 Interface, these bits would indicate a history (i.e. not always ready since
last STATUS).
Forcing Early Transmission of Output Blocks
Syntax
XIO 32,#IOCB,0,0,"R:"
Remarks
This function causes all the buffered data in the computer to be transmitted through the RS-232 port. This is used when the user wants to make sure that
all data is transmitted before performing his next function. (This could also be performed by doing status request until the output data length is zero.)
Controlling Outgoing Lines DTR, RTS, and XMT
Syntax
XIO 34,#IOCB,Aux1,0,"R:"
Remarks
This function allows you to set the state of the output handshaking lines. This function may be perform in both concurrent and "non-current" mode (there
is really no difference except for the way STATUS commands are interpreted). Care should be taken when disabling DTR (setting to false) since transmission
and receiving are halted until DTR is set TRUE. Aux1 is coded as indicated by table 4-3.
Table 6-3. Control Values Added to Aux1 (XIO 34)
|
Function
|
|
Bit
|
|
Dec Equiv
|
|
Meaning When Bit is SET
|
DTR
|
|
7
|
|
128
|
|
|
Set state of DTR (from bit 6)
|
|
|
6
|
|
64
|
|
|
Set DTR Ready (Not ready if bit is CLEAR)
|
RTS
|
|
5
|
|
32
|
|
|
Set state of RTS (from bit 4)
|
|
|
4
|
|
16
|
|
|
Set RTS Ready (Not ready if bit is CLEAR)
|
XMT
|
|
1
|
|
2
|
|
|
Set state of XMT (FROM BIT 0)
|
|
|
0
|
|
1
|
|
|
Set XMT to MARK (SPACE if bit is CLEAR)
|
Setting Baud Rate, Stop Bits, and Ready
Checking
Syntax
XIO 36,#IOCB,Aux1,0,"R:"
Remarks
This function configures the RS-232 port for desired speed and stop bits. Aux1 is the sum of two codes; baud rate and the number of stop bits. The
coding is given by Table 6-4. You must add the value representing the desired
baud rate to the code (0 or 128) for the desired number of stop bits per
word. Note that the word size is always 8 bits plus 1 or 2 stop bits; the MIO
"R:" handler doesnot support smaller word sizes as did the Atari 850
interface.
The "missing" baud rates are available through the ACIA on the MIO but are not supported by the "R:" handler since they are never used.
Table 6-4. Codes to Add to Aux1 (XIO 36)*
|
Add
|
|
Baud Rate
|
|
Add
|
|
Baud Rate
|
0
|
|
|
300
|
|
|
5
|
|
|
110
|
|
8
|
|
|
300
|
|
|
9
|
|
|
600
|
|
10
|
|
|
1200
|
|
|
12
|
|
|
2400
|
|
13
|
|
|
4800
|
|
|
14
|
|
|
9600
|
|
15
|
|
|
19200
|
|
|
|
|
|
|
|
* Default is 1 stop bit. Add 128 for 2 stop bits.
Setting Translation Modes and Parity
Syntax
XIO 38,#IOCB,Aux1,0,"R:"
Remarks
This function configures the parity and level of ASCII/ATASCII translation. The value of Aux1 is derived from Table 6-5.
Table 6-5. Control Values Added to Aux1 (XIO 38)
|
Function
|
|
Add
|
|
Resulting Function Performed
|
PARITY
|
|
0
|
|
|
No parity (8-bit data is untouched) (default)
|
|
|
4
|
|
|
Check/Set odd parity, clear parity bit
|
|
|
8
|
|
|
Check/Set even parity, clear parity bit
|
|
|
12
|
|
|
Send mark parity, clear parity bit
|
|
|
|
|
|
|
TRANS-
|
|
0
|
|
|
Light ATASCII/ASCII translation (default)
|
LATION
|
|
32
|
|
|
No translation
|
|
|
|
|
|
|
LINE
|
|
0
|
|
|
Do not append LF after CR (default)
|
FEEDS
|
|
64
|
|
|
Append LF after CR (translation from
EOL)
|
Setting Concurrent Mode
Syntax
XIO 40,#IOCB,0,0,"R:"
Remarks
This function simulates the "Start concurrent mode I/O" of the P:R: Connection and Atari 850. This is needed because of the dual nature of the
STATUS command. When in concurrent mode, the statement returns the size of the data buffers, whereas, when in "block mode", the statement returns the
state of the handshake lines. This has no effect on the rest of the "R:" handler functioning or on the ACIA. It simply set a flag for the STATUS
function.
|