Direct i/o & buffered i/o – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 129

8M. Data Transfers
II. SOFTWARE GUIDES - 8. Driver488/DRV
II-114
Personal488 User’s Manual, Rev. 3.0
Direct I/O & Buffered I/O
Direct I/O is communication through the use of the
and
INPUT
statements, or their equivalent.
Direct I/O is the simplest method of communicating with Driver488/DRV and, through it, with bus
devices. However, direct I/O has a relatively large overhead and so, for large data transfers, buffered
I/O is preferable. In buffered I/O, the program tells Driver488/DRV where in memory to find or put
the data and Driver488/DRV takes care of the actual transfer.
Direct Bus OUTPUT
The
OUTPUT
command sends data to bus devices. For example, the statement
PRINT#1,"OUTPUT 05;SP1;"
sends the characters
SP1;
to device
5
. This is an example of direct I/O as the data is communicated
directly to Driver488/DRV through the
statement. As discussed above, Driver488/DRV
recognizes the
EOL
output terminator as the end of the data and sends the
TERM
output terminator in its
place after sending the data. Binary direct output is also possible. For example, the following
statements send all
256
ASCII characters:
PRINT#1,"OUTPUT 05 #256;";
FOR I=0 TO 255
PRINT#1,CHR$(I);
NEXT I
The first statement tells Driver488/DRV to expect
256
characters to follow that are to be sent to device
5
. Notice the semicolon (
;
)just after the
#256
. This marks the end of the actual
OUTPUT
command
and the start of the data. The semicolon at the end of the line tells BASIC not to send anything else,
such as the normal carriage-return and line-feed combination, after sending the quoted characters. The
next three lines send the
256
ASCII characters from
0
to
255
in order, to Driver488/DRV for transfer
to device
5
. The semicolon at the end of the third line has the same function as the semicolon at the
end of the first line: it prevents BASIC from sending any extra characters. In this example, we are
performing a binary transfer. Driver488/DRV knows how many characters are to be transferred and
neither requires
EOL
output terminators to end the command, nor sends
TERM
output terminators to the
bus device. The data is transferred to the bus device exactly as sent from the program.
Direct Bus ENTER
The
ENTER
command is used to read data from bus devices. For example, the statements:
PRINT#1,"ENTER 16"
INPUT#2,A$
read data from device
16
and store the returned data in the
A$
variable. This is an example of direct
ENTER
input since the data received from the bus is read into the program via the
INPUT
statement that
reads the result directly from Driver488/DRV. As discussed above, Driver488/DRV accepts data from
device
16
until it detects the
TERM
input terminator. It replaces the
TERM
input terminator with the
EOL
output terminator and returns the result to the program. BASIC accepts the data just as it accepts
character data from any file. This allows us to use the varieties of BASIC input statements to control
how the data is received. For example, if the data read form the device is in the form of a valid number
then we can read it as a number:
PRINT#1,"ENTER 16"
INPUT#2,N
Or, if the data consists of several values separated by commas, we can read it as several values:
PRINT#1,"ENTER 16"
INPUT#2,A$,N,B$,I
Or, if we want to read the entire input, even if it includes commas or other special characters, we can
use
LINE INPUT
:
PRINT#1,"ENTER 16"
LINE INPUT#2,L$