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

Chapter 3 65
Common Device Control Functions
Reading From Asynchronous Devices
In block mode, the block mode read timer expires. This timer is
active from the time that the second DC1 is sent until the RS
character is received. The timer expires with a VPLUS intrinsic
error if VPLUS block mode is being used. The timer expires with a
file system error (FSERR 27) if any other type of block mode is being
used.
System break is sent from the terminal (and system break is not
disabled). All read data is lost, but the read is reposted when the
user resumes the application.
The subsystem break character is sent from the terminal while
subsystem break is enabled. All read data is returned to the sender.
Subsystem break is not recognized in binary mode.
The DTC encounters a parity error while parity is enabled. Parity is
not recognized in binary mode.
End of File Indicators
If a program is reading from one of the standard input files, certain
conditions will cause an end-of-file to occur and the read will terminate
with a condition code of CCG (>>). On $STDIN an end-of-file occurs if a
colon (:) is encountered in column 1 of the record being read. On
$STDINX the end-of-file occurs only if the first four characters of the
record are :EOF. Once your program encounters an end-of-file condition
on a standard file, any subsequent read requests issued by the program
against the same file will also encounter an end-of-file. For this reason,
your program should check for the end-of-file condition as the first step
in reading input from a device. If one is found, the current file must be
closed, because a read will not succeed.
Using FREAD
Once your program has successfully opened a file on a terminal device,
with read access specified, and a valid file number is obtained as a
result of the file open call, you can use the FREAD intrinsic to read data
from the device. Make sure to issue any calls to affect the way the read
will take place (input mode, data editing mode, etc.) before posting the
read. The syntax of the FREAD call is as follows:
I16 I16V UDS I16V
transfercount
:=FREAD(filenum,buffer,length);
FREAD accesses the devicefile through its file number (filenum) and
the data input from the device is transferred to buffer when one of the
read termination conditions occurs.
The byte count is specified in the length parameter of the FREAD call.
The intrinsic allows you to specify length as either a positive value
representing halfwords or a negative value representing bytes.