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

Chapter 3 73
Common Device Control Functions
Writing to Asynchronous Devices
Writing to Asynchronous Devices
The most common ways to write information to an asynchronous
devicefile are provided by the FWRITE and PRINT intrinsics. FWRITE
is the most versatile of these and can be used to write information to
any device. PRINT is more limited in its usage, but does not require the
use of a file number.
Using FWRITE
FWRITE transfers a record of data to a file on any device. You must
first open a file on the device with write access specified and obtain a
valid file number. The file number is then used by the FWRITE call to
access the file. The syntax of FWRITE is as follows:
I16V UDS I16V U16V
FWRITE(filenum,buffer,length,controlcode);
The filenum parameter passes the file number of the file to which data
will be written. The record to be written is passed in the buffer
parameter, with the length of the data specified in the length
parameter. A positive or negative value is used to indicate whether
length is halfwords or bytes. You should be aware, however, that for
asynchronous devices, physical data transfer will always occur on a
byte-by-byte basis. Specifying halfwords will result in an even number
of bytes being output.
If length is 0, no data transfer will occur. You might use FWRITE with
length specified as 0 to set line spacing (carriage control) at the device
before any data is output.
Carriage control is passed through the controlcode parameter. The
carriage control specification can be 0, 1, or one of the values designated
as controlcode values for MPE/iX. Table 8-1, “Intrinsics and Device
Control,” on page 152 lists many of the carriage control directive values
most commonly used with asynchronous devices. For a complete list of
carriage control directive codes that can be used with the FWRITE
intrinsic you should see the MPE/iX Intrinsics Reference Manual.
If controlcode is 0, the full record of data will be transferred to the
devicefile, up to a maximum of 132 characters per printed line, and
single spacing will be applied.
If controlcode is 1, the first character of the data will be interpreted
as space control and will be suppressed when the data is printed. Any of
the values supported as carriage control directives can be used as the
first character when this method is used.
The carriage control directive values can also be applied directly
through the controlcode parameter. Simply use one of these values
instead of a 0 or 1.