AP(4) —
NAME
ap − asynchronous data mode protocol line discipline
SYNOPSIS
pseudo-device ap
DESCRIPTION
The ap line discipline is used to communicate with the IBM 3812 Pageprinter through a serial adapter in asynchronous data mode. The ap line discipline detects and recovers from line errors, establishes an expedited command path to the printer logically independent from the data path, and returns printer status information to the user. The normal system calls open(2), close(2), write(2), read(2), and ioctl(2) are used. There can be only one program at a time using ap on a given serial port. The program may consist of more than one process.
To use the ap line discipline, open the serial port, use ioctl to set the appropriate speed (typically 19.2 kilobaud) with no parity (set both EVENP and ODDP), and issue the TIOCSETD ioctl with the argument APLDISC. After ap has control, the only ioctl commands that are valid are APRDCMD, APTEST, APTESTRD, APWRTCMD, TIOCGETD, TIOCSETD, TIOCGETP, TIOCEXCL, and TIOCNXCL.
Data is written to ap using write. Expedited commands are written using ioctl. Only one write operation can be done at a time, whether by write or by ioctl. Data is read using read. Expedited commands are read using ioctl. If there is pending data or an expedited command to be read, a write may write only part of the data. The number of bytes actually written will be returned. If the read or write returns a -1, and errno is set to EIO, then either the line is down, or there is data or an expedited command to be read from the 3812. Ioctl is used to determine the condition that terminated the write or caused the EIO.
The ioctl calls that apply to ap have the form:
#include <machineio/apio.h>
#include <sys/tty.h>
ioctl(fildes,code,arg)
struct apioinfo ∗arg;
where:
struct apioinfo {
int apstatus;/∗ status code ∗/
char apcmd;/∗ expedited command ∗/
};
The ioctl codes are:
APRDCMD
Read an expedited command from the 3812. This command will block waiting for an expedited command. It will return an EIO if the connection is down, or if there is data to be read from the 3812.
APTEST
Return the status of ap. It will not read an expedited command. If an expedited command is available to be read, the status field in arg is set to APGOTCMD.
APTESTRD
Return the status of ap and return expedited commands. If an expedited command is available to be read, it is read into arg. If there is nothing to read, and no status to report, the status field in arg is set to APNOINFO.
APWRTCMD
Send an expedited command to the 3812. Arg points to the expedited command.
The status codes are:
APDOWN
The 3812 has lost synchronization. The file descriptor for the serial port must be closed and the ap line discipline restarted.
APGOTDATA
Data has been received from the 3812 and is available to be read from ap.
APGOTCMD
An expedited command byte has been received from the 3812. It is stored in arg if the ioctl was APRDCMD or APTESTRD.
APNOINFO
There is no data nor expedited command to be read, and the line is not down. It is returned only for APTEST and APTESTRD.
APSYNCING
Synchronization with the 3812 is in process but is not complete.
NOTE
Expedited commands are described in the IBM 3812 Pageprinter Programming Reference, S544-3268.
SEE ALSO
tty(4)
IBM 3812 Pageprinter Programming Reference, S544-3268
ERRORS
[EIO]A read, write, or ioctl encountered a condition that prevented its execution. Issue the APTEST or APTESTRD ioctl to determine the condition.
[ENOMEM]
This condition is encountered when the TIOCSETD ioctl is executed to switch to APLDISC, and the line discipline can not acquire the necessary buffer space.
Incomplete write
A write that returns a non-negative count less than the count requested indicates an outstanding condition that should be checked with the APTEST or APTESTRD ioctl. The returned count indicates the number of bytes successfully written. After clearing the condition, adjust the parameters and continue the write.
PRPQs 5799-WZQ/5799-PFF: IBM/4.3 — 07 Feb 1986