NP(4)NP(4)NAMEnp - NeXT Laser Printer interface
SYNOPSIS — Kernel Configuration
device np0 at bus? csr 0x0200f000
SYNOPSIS — Programmatic Interface
#include <sys/ioctl.h>
#include <bsd/dev/npio.h>
DESCRIPTION
The NeXT Laser Printer is a 300/400 DPI high-speed, non-impact (low
noise) printer based on electrophotography and laser technology. It is
based on the Canon LBP-SX series laser printer engine. The printer
also can be selected to feed automatically from a paper cartridge or
manually. Print rates can go as high as eight pages per minute.
The device driver allows a NeXT Laser Printer to be attached to
/dev/np0. Upon opening /dev/np0 the printer is powered on and
initialized to 400 DPI and cassette feeding. Only one task can have
the printer open at a time. The printer can only be opened with the
O_WRONLY flag. The O_NDELAY flag will cause the open to return before
the printer has completed the power on and initialize cycle. The
following error codes are returned by open:
ENODEV There is no printer connected to the printer port.
EIO An IO error in initializing the printer.
Please note that with O_NDELAY set, you will not get power on, or
initialization errors reported. All subsequent ioctl and write
operations other than power on/off requests will fail with the EPWROFF
error. The correct way to determine when the open has completed the
power on and initialization is to select for write and exceptional
conditions. If the open fails for some reason, the printer will be
left in the powered off state.
The printer interface supports the FNDELAY file descriptor status flag.
When this flag is set, all operations that would block will instead
return the EWOULDBLOCK error code. The printer interface also supports
the FASYNC file descriptor status flag. When this flag is set, the
write operation will return at once instead of waiting for the page to
complete.
A number of additional ioctl operations are available on the printer
interface. The following definitions are from <sys/npio.h>
/*
* Structures and definitions for NeXT Laser Printer io control commands
*/
/* Paper types */
enum np_papersize { NOCASSETTE, A4, LETTER, B5, LEGAL };
#define NPIOCPOP _IOWR('p', 1, struct npop) /* do a printer op */
/* Structure for NPIOCPOP - printer op command */
struct npop {
short np_op; /* operations defined below */
union {
int npd_power; /* Power */
unsigned char npd_resolution; /* 300/400 DPI */
struct {
int left; /* # of bits to indent on left */
int top; /* # of lines from top of page */
/*
* NOTE: less than a 200 line top margin
* is questionable. Experiment.
*/
int width; /* width in #'s of longwords */
int height; /* height in lines */
} npd_margins;
struct np_stat {
u_int flags;
u_int retrans;
} npd_status;
enum np_papersize npd_size;
boolean_t npd_bool;
} np_Data;
};
#define np_power np_Data.npd_power
#define np_margins np_Data.npd_margins
#define np_resolution np_Data.npd_resolution
#define np_status np_Data.npd_status
#define np_size np_Data.npd_size
#define np_bool np_Data.npd_bool
/* Operations */
#define NPSETPOWER 0 /* turn the printer on/off */
#define NPSETMARGINS 1 /* Set the printer margins */
#define NPSETRESOLUTION 2 /* Set the printer resolution */
#define NPGETSTATUS 3 /* Get the printer status */
#define NPCLEARRETRANS 4 /* Clear the retransmit counter */
#define NPGETPAPERSIZE 5 /* Get the paper size */
#define NPSETMANUALFEED 6 /* Set manual feed based on npop.np_bool */
/* Resolutions */
#define DPI300 0
#define DPI400 1
/* Status bits */
#define NPPAPERDELIVERY 0x0001 /* Paper is being processed in printer */
#define NPDATARETRANS 0x0002 /* Data should be retransmitted due to jam
or poor video signal. Number of pages
is in npop.np_stat.retrans. Clear this
with the NPCLEARRETRANS command. */
#define NPCOLD 0x0004 /* Fixing assembly not yet hot enough */
#define NPNOCARTRIDGE 0x0008 /* No cartridge in printer */
#define NPNOPAPER 0x0010 /* No paper in printer */
#define NPPAPERJAM 0x0020 /* Paper jam */
#define NPDOOROPEN 0x0040 /* Door open */
#define NPNOTONER 0x0080 /* Toner low */
#define NPHARDWAREBAD 0x0100 /* Hardware failure */
#define NPMANUALFEED 0x0200 /* Manual feed selected */
Images consist of a bitmap of the pixels to put on the page. A 1 in
the bitmap will cause a black mark to be placed on the page, and a 0
will leave a pixel white. The page has four margin parameters: left
(the number of pixels to indent on the left hand side); top (the number
of lines to come down from the top of the page); width (the width of
the image in numbers of 32-bit longwords); and height (the number of
lines in the image).
To print a page, you first need to set the image margins for the page
with the NPSETMARGINS printer command. Then you submit the image with
the write command. The image data must be page aligned at the
beginning, and must be quadword (increments of four longwords) aligned
at the end.
ERROR CONDITIONS
The printer can be in one of four states -- off, ready, printing, or
error. The write operation and all NPIOCPOP commands except NPSETOP
will return EPWROFF if the printer is powered off. The write operation
the NPGETPAPERSIZE and the NPSETMANUALFEED commands may block waiting
for the printer to be in the ready state unless the FNDELAY flag has
been set, in which case, they will return EWOULDBLOCK if the printer is
printing and EDEVERR if the printer is in the error state.
More error information about the printer can be retrieved with the
NPGETSTATUS command.
Other error codes that may be returned include:
ENOINIT The margins were not set before write was called.
EDEVERR The printer is in the error state.
ENXIO Unknown NPIOCPOP command.
ENXIO Unknown minor device number on open.
EIO I/O error talking to printer.
EBUSY Printer is already open.
FILES
/dev/np0 printer device
SEE ALSOclose(2), fcntl(2), ioctl(2), open(2), write(2)NeXT Computer, Inc. August 10, 1988 NP(4)