NAME | SYNOPSIS | DESCRIPTION | IOCTLS | ERRORS | FILES | SEE ALSO
#include <sys/types.h>
#include <fcntl.h>
#include <sys/ecppio.h>
The ecpp driver provides a bi-directional interface to IEEE 1284 compliant devices. The driver will operate in Centronics mode for non-IEEE 1284 compliant devices. An IEEE 1284 compliant peripheral device must operate at least in Compatibility mode and Nibble mode. The ecpp driver supports Compatibility, Nibble and ECP modes of operation as defined by IEEE 1284. Centronics and Compatibility modes of operation have identical physical characteristics. However, non-IEEE 1284 compliant devices will be logically defined as ECPP_CENTRONICS. IEEE 1284 devices that are in a similar mode will be logically defined as ECPP_COMPAT_MODE. ECPP_COMPAT_MODE operates in conjunction with ECPP_NIBBLE_MODE. The ecpp driver is an exclusive-use device. If the device has already been opened, subsequent opens fail with EBUSY.
Each time the ecpp device is opened, the device is marked as EBUSY and the configuration variables are set to their default values. The write_timeout period is set to 60 seconds. The driver sets the mode variable according to the following algorithm: The driver initially attempts to negotiate the device into ECP mode. If this fails, the driver will attempt to negotiate into Nibble mode. If Nibble mode negotiation fails, the driver will operate in Centronics mode. The application may attempt to negotiate the device into a specific mode or set the write_timeout values through the ECPPIOC_SETPARMS ioctl(2) call. In order for the negotiation to be successful, both the host workstation and the peripheral must support the requested mode.
The preferred mode of operation of an IEEE 1284 device is the bi-directional ECP mode. Nibble mode is a unidirectional backchannel mode. It utilizes a PIO method of transfer and consequently, is inefficient. For devices that primarly receive data from the workstation, such as printers, Nibble operation will have limited impact to system performance. Nibble mode should not be used for devices such as a scanner, that primarily send data to the workstation. Forward transfers under all modes are conducted through a DMA method of transfer.
The default timeout for the ecpp device driver may be changed by adding the following line to the /etc/system file:
set ecpp:ecpp_def_timeout = value
See system(4) for more details.
ecpp is a full duplex STREAMS device driver. While an application is writing to an IEEE 1284 compliant device, another thread may read from it. write(2) will return when all the data has been successfully transferred to the device.
write() returns the number of bytes successfully written to the stream head. If a failure occurs while a Centronics device is transfering data, the content of the status bits will be captured at the time of the error, and can be retrieved by the application program, using the ECPPIOC_GETERR ioctl() call. The captured status information will be overwritten each time an attempted transfer or a ECPPIOC_TESTIO ioctl() occurs.
Intelligent IEEE 1284 compliant devices, such as Postscript printers, return error information through a backchannel. This data may be retrieved with the read(2) call.
If a failure or error condition occurs during a read(2), the number of bytes successfully read is returned (short read). When attempting to read the port that has no data currently available, read() returns 0 if O_NDELAY is set. If O_NONBLOCK is set, read() returns -1 and sets errno to EAGAIN. If O_NDELAY and O_NONBLOCK are clear, read() blocks until data become available.
The following ioctl(2) calls are supported:
Get current transfer parameters. The argument is a pointer to a struct ecpp_transfer_parms. See below for a description of the elements of this structure. If no parameters have been configured since the device was opened, the structure will be set to its default configuration. See Default Operation above.
Set transfer parameters. The argument is a pointer to a struct ecpp_transfer_parms. If a parameter is out of range, EINVAL is returned. If the peripheral or host device can not support the requested mode, EPROTONOSUPPORT is returned. See below for a description of ecpp_transfer_parms and its valid parameters. Transfer Parameters Structure This structure is defined in <sys/ecppio.h>.
struct ecpp_transfer_parms { int write_timeout; int mode; };
The write_timeout field is set to ECPP_W_TIMEOUT_DEFAULT. The write_timeout field specifies how long the driver will wait for the peripheral to respond to a transfer request. The value must be greater than 0 and less than ECPP_MAX_TIMEOUT. Any other values are out of range. The mode field reflects the IEEE 1284 mode that the parallel port is currently configured to. The mode may be set to only one of the following bit values.
#define | ECPP_CENTRONICS | 0x1 |
#define | ECPP_COMPAT_MODE | 0x2 |
#define | ECPP_NIBBLE_MODE | 0x3 |
#define | RESERVED | 0x4 |
#define | ECPP_FAILURE_MODE | 0x5 |
This command may set the mode value to ECPP_CENTRONICS, ECPP_COMPAT_MODE, or ECPP_NIBBLE_MODE. All other values are not valid. If the requested mode is not supported, ECPPIOC_SETPARMS will return EPROTONOSUPPORT. Under this circumstance, ECPPIOC_GETPARMS will return to its orignal mode. If a non-recoverable IEEE 1284 error occurs, the driver will be set to ECPP_FAILURE_MODE. For instance, if the port is not capable of returning to its orignal mode, ECPPIOC_GETPARMS will return ECPP_FAILURE_MODE.
Tests the transfer readiness of ECPP_CENTRONICS or ECPP_COMPAT_MODE devices. If the current mode of the port is ECPP_CENTRONICS or ECPP_COMPAT_MODE, this command determines if write(2) would succeed. If it is not one of these modes, EINVAL is returned. BPPIOC_TESTIO determines if a write(2) would succeed by checking the open flag and status pins. If any of the status pins are set, a transfer would fail. If a transfer would succeed, zero is returned. If a transfer would fail, -1 is returned, and errno is set to EIO, and the state of the status pins is captured. The captured status can be retrieved using the BPPIOC_GETERR ioctl(2) call. Note that the timeout_occurred and bus_error fields will never be set by this ioctl(2). BPPIOC_TESTIO and BPPIOC_GETERR are compatible to the ioctls specified in bpp(7). However, bus_error is not used in this interface.
Get last error status.
The argument is a pointer to a struct bpp_error_status. This structure is described below. This structure indicates the status of all the appropriate status bits at the time of the most recent error condition during a write() call, or the status of the bits at the most recent BPPIOC_TESTIO ioctl() call.
The timeout_occurred value is set when a timeout occurs during write(). bus_error is not used in this interface.
pin_status indicates possible error conditions under ECPP_CENTRONICS or ECPP_COMPAT_MODE. Under these modes, the state of the status pins will indicate the state of the device. For instance, many Centronics printers lower the nErr signal when a paper jam occurs. The behavior of the status pins depends on the device. As defined in the IEEE 1284 Specification, status signals do not represent the error status of ECP devices. Error information is formatted by a printer specific protocol such as PostScript, and is returned through the backchannel. Error Status Structure struct bpp_error_status is defined in the include file <sys/bpp_io.h>. The valid bits for pin_status are presented below. A set bit indicates that the associated pin is asserted. For example, if BPP_ERR_ERR is set, nErr is asserted.
struct bpp_error_status { char timeout_occurred; /* 1=timeout */ char bus_error; /* not used */ uchar_t pin_status; /* * status of pins * which could cause * error. */ }; /* pin_status values */ #define BPP_ERR_ERR 0x01 /* nErr=0 */ #define BPP_SLCT_ERR 0x02 /* Select=1 */ #define BPP_PE_ERR 0x04 /* PE =1 */ #define BPP_BUSY_ERR 0x40 /* Busy = 1 */
The device is opened for write-only access and a read is attempted, or the device is opened for read-only access and a write is attempted.
The device has been opened and another open is attempted. An attempt has been made to unload the driver while one of the units is open.
A ECPPIOC_SETPARMS ioctl() is attempted with an out of range value in the ecpp_transfer_parms structure. A ECPPIOC_SETREGS ioctl() is attempted with an invalid value in the ecpp_regs structure. An ioctl() is attempted with an invalid value in the command argument. An invalid command argument is received from the vd driver during modload(1M), modunload(1M).
The driver encountered a bus error when attempting an access.
A read or write does not complete properly, due to a peripheral error or a transfer timeout.
The driver has received an open request for a unit for which the attach failed. The driver has received a write request for a unit which has an active peripheral error.
NAME | SYNOPSIS | DESCRIPTION | IOCTLS | ERRORS | FILES | SEE ALSO