Asynchronous Serial Communications Programmer's Reference Manual (32022-90052)

66 Chapter3
Common Device Control Functions
Reading From Asynchronous Devices
However, for asynchronous devices, the actual data transfer always
occurs on a byte-by-byte basis. If the number of bytes input reaches the
value specified, the read will terminate on byte count.
For asynchronous terminals, the maximum supported read length is
four kilobytes (4 KB) in standard or transparent editing mode and
128 bytes in binary editing mode.
If
transfercount
is used, the actual number of bytes transferred as a
result of the read will be returned as its value. If you specified NOWAIT
I/O in the FOPEN or HPFOPEN call, however, this value will be 0 and
the actual byte count will be returned in the IOWAIT or IODONTWAIT
call. See Chapter 8, “Intrinsics Reference,” of this manual for more
information on IOWAIT and IODONTWAIT.
The program fragment shown in Figure 3-2 illustrates the use of the
FREAD intrinsic. NOWAIT I/O is not used in this example. A file is
opened as $STDIN with 80 byte ASCII records specified and the file
number is returned in the
fileid_in
variable. A read is then posted
against this file using the FREAD intrinsic to read up to 80 bytes and
store the data as the value of read_buffer. Note that read_buffer is
declared as a string large enough to hold up to the maximum amount of
data that could be transferred in a single FREAD call.