HP-UX Reference (11i v1 05/09) - 3 Library Functions A-M (vol 6)

b
blmode(3C) blmode(3C)
(TO BE OBSOLETED)
transmission error occurs, all subsequent data is discarded until the transmission is complete. The read
waits until a terminator character is seen, or until a time interval specified by the system has passed that is
longer than necessary for the number of characters specified.
The data-block-terminator character is included in the data returned to the user, and is included in the byte
count. If the number of bytes transferred by the terminal in a block-mode transfer exceeds the number of
bytes requested by the user, the read returns the requested number of bytes and the remaining bytes are
discarded. The user can determine if data was discarded by checking the last character of the returned
data. If the last character is not the terminator character, then more data was received than was
requested and data was discarded.
The [EIO] error can be caused by several events, including errors in transmission, framing, parity, break,
and overrun, or if the internal timer expires. The internal timer starts when the second trigger character
is sent by the computer, and ends when the terminating character is received by the computer. The length
of this timer is determined by the number of bytes requested in the read and the current baud rate, plus an
additional ten seconds.
User Control of Handshaking
If desired, the application program can provide its own handshake mechanism in response to the alert char-
acter by selecting the
OWNTERM mode (see CB_OWNTERM below). With this mode selected, the driver
completes a read request when the alert character is received. No data is discarded before the alert, and
the alert is returned in the data read. The alert character may be escaped with a backslash (
\) character.
The second trigger is sent when the application issues the next read.
blmode Control Calls
First, the standard
open() call to a tty device must be made to obtain a file descriptor for the subsequent
block-mode control calls (an open() is done automatically by the system for
stdin on the terminal).
int bfdes;
bfdes = blopen (int fildes)
A call to blopen() must be made before any block-mode access is allowed on the specified file
descriptor. blopen() initializes the block-mode parameters as described below. The return
value from blopen() is a block-mode file descriptor that must be passed to all subsequent
block-mode control calls.
int blclose (int bfdes)
A call to blclose() must be issued before the standard close() to ensure proper closure
of the device (see close(2)). Otherwise unpredictable results can occur. The argument bfdes is
the file descriptor returned from a previous
blopen() system call.
int blread (int bfdes, char *buf, size_t nbyte)
The blread() routine has the same parameters as the read() sytem call (see read(2)). At
the beginning of a read, the
cb_trig1c character (if defined) is sent to the device. If
CB_BMTRANS is not set, and no cb_alertc character is received, the read data is processed
according to termio(7). If CB_BMTRANS is set, or if a non-escaped cb_alertc character is
received, echo is turned off for the duration of the transfer, and no further special character pro-
cessing is done other than that required for the termination character. The argument bfdes is
the file descriptor returned from a previous
blopen() system call.
int blget (int bfdes, struct blmodeio *arg)
A call to blget() returns the current values of the blmodeio structure (see below). The
argument bfdes is the file descriptor returned from a previous blopen() system call.
int blset (int bfdes, const struct blmodeio *arg)
A call to blset() sets the block-mode values from the structure whose address is arg. The
argument bfdes is the file descriptor returned from a previous blopen() system call.
blmode Structure
The two block-mode control calls, blget() and blset(), use the following structure, defined in
<sys/blmodeio.h>:
#define NBREPLY 64
struct blmodeio {
unsigned long cb_flags; /* Modes */
unsigned char cb_trig1c; /* First trigger */
unsigned char cb_trig2c; /* Second trigger */
Section 344 Hewlett-Packard Company 2 HP-UX 11i Version 1: September 2005