LBP(4) — NEWS-OS Programmer’s Manual
NAME
lbp − NEWS laser beam printer interface
SYNOPSIS
lb0 at iop addr xxx intr 108 ( xxx depends on machine type )
/dev/lbp
#include <newsiop/lbp.h>
DESCRIPTION
lbp provides the interface to NEWS laser beam printer (NWP-533/537/543/550, NWB-240A/241A/242/243/244/245). Operations will be done through open(2), ioctl(2), write(2) and close(2) system call to /dev/lbp.
("Image Board Library" is available for NWB-242/243. If you would like to use the all functions of NWP-543, use "Image Board Library". "LBP Library" is also available for the printer filter invoked by lpd(8).)
Following list shows a basic control sequence.
1. Open the device.
2. Send frame data to the device.
2.1 Wait for the device to be ready.
2.2 Seek to the top of the device file.
2.3 Send data to the device.
2.4 Start printing.
2.5 Repeat 2.1 to 2.4 until all the frame is sent.
3. Close the device.
3.1 Wait for the device to be ready to be closed.
3.2 Close the device.
To control the device, following header files are needed to be included.
#include <sys/ioctl.h>
#include <newsiop/lbp.h>
Open the Device
How to open the device is described below.
int lbp /∗ LBP file descriptor ∗/
lbp = open("/dev/lbp",O_WRONLY);
If the device file is opened successfully, file descriptor is returned, −1 otherwise. In the case of error, following data is set to the global variable "errno".
EIO
LBP interface board can not be initialized.
Switch of LBP is off.
LBP is not connected.
LBP can not be initialized.
ENXIO
LBP interface board is not connected to NEWS.
EBUSY
/dev/lbp is already opened by other process.
/dev/ir is already opened.
Send data to the device
How to send data to the device is described below.
1. Wait for the device to be ready. (Not necessary on 1st page)
ioctl(lbp, LBIOCSTOP);
Zero is returned by ioctl system call if terminated normally, −1 is returned in the case of some error. If error occurred, you should execute the operation 4 again, after eliminating the cause of the error.
2. Seek to the top of the device file.
lseek(lbp,0,0);
3. Send data to the device file.
Using write system call, the data can be written out to the buffer in the device. Following is the example of sending a A4 size data.
#define FRAME_SIZE (3136 ∗ 4516/8)
#define BSIZE (32 ∗ 1024)
char frame[FRAME_SIZE];
register int len;
register char ∗p;
p = frame;
for (len = FRAME_SIZE; len >= BSIZE; len-=BSIZE) {
write(lbp, p, BSIZE);
p += BSIZE;
}
if (len) {
write(lbp, p, len);
}
The number of the written bytes is returned by write system call if finished normally, −1 is returned if some error occurred. In the case of error, following data is set to the global variable "errno".
EIO
Frame memory in the laser beam printer interface is not accessible.
EFAULT
Specified data in write system call is not accessible.
The length of output data should be less than or equal to the size of the frame buffer. (i.e. A4 cassette or NWP-550: 1770272 bytes (3136 x 4516/8), B4 cassette: 2732800 bytes (3904 x 5600/8)).
4. Start printing
The output data written to the frame buffer is now actually send to the laser beam printer.
ioctl(lbp, LBIOCSTART);
Zero is returned by ioctl system call if finished normally, −1 is returned if some error was detected. If error occurred, you need to execute it after eliminating the cause of the error. When you use NWP-550 with the option cassette feeder, if there are papers on the
manual supply tray, papers are supplied from the manual supply tray.
IOCTL
LBIOCRESET
Initialize the laser beam printer interface.
ioctl(lbp, LBIOCRESET);
LBIOCSTART
Start printing.
ioctl(lbp, LBIOCSTART);
LBIOCSTOP
Wait for the termination of current print job.
ioctl(lbp, LBIOCSTOP);
LBIOCSTATUS
Get the status of the laser beam printer.
ioctl(lbp, LBIOCSTATUS, status);
Structure of the status is as follows;
struct lbp_stat {
unsigned char stat[6];
};
The effective status bytes is first four bytes. MSB (bit 7) of each byte is always Zero and LSB (bit 0) is used for parity bit (odd parity). For their details, see DIAGNOSTICS.
LBIOCHAND
This request switches to manual supply mode when you use NWP-533/537/543. This request switches to manual supply tray mode when you use NWP-550.
ioctl(lbp, LBIOCHAND);
LBIOCCASSETTE
This request switches to cassette supply mode when you use NWP-533/537/543. This mode is default when you use NWP-533/537/543. This request switches to option cassette feeder supply mode when you use
NWP-550. This mode is default when you use NWP-550 with option cassette feeder.
ioctl(lbp, LBIOCCASSETTE);
LBIOCGETTYPE
Get printer type (one of LBP_NWP533, LBP_NWP537, LBP_NWP543, LBP_NWP550).
ioctl(lbp, LBIOCGETTYPE, type);
int ∗type;
LBIOCGETSIZE
Get vertical/horizontal size of the printable region in dot.
ioctl(lbp, LBIOCGETSIZE, size);
Structure is as follows;
struct lbp_size {
int lbp_x;
int lbp_y;
};
If you use NWP-537 or NWP-543 and change the cassette, issue this ioctl to change the internal state (cassette size) in device driver.
Close the device
At the last of the printing job, you should wait for the completion of printing the last page and then the device should be closed.
ioctl(lbp, LBIOCSTOP);
close(lbp);
CHANGING THE CASSETTE
B4 laser beam printer (NWP-537) and A3 laser beam printer (NWP-543) can handle A4 cassette and B4 cassette.
LBP device driver holds the information about paper size. Because the information is set only when the device is open and when the LBIOCGETSIZE ioctl is successfully completed, the application program have to get the information again whether the cassette size is changed or not.
(When using NWP-543 with /dev/lbp interface, all the cassette but B4 size is regard as A4 portrait size. And only the lower cassette can be used with this interface. If you use other size of papers than A4 or B4, or use other paper suply device than lower cassette, use "Image Board Library" or "LBP library".)
Format of the output data
The NEWS’s laser beam printer (NWP-533/537/550, NWB-240A/241A/244/245)
has a resolution of 400 pixel/inch and the maximum printable region of 4516 pixel (vertical) by 3136 pixel (horizontal) with NWP-533/550 and 3904 pixel (vertical) by 5600 pixel (horizontal) with NWP-537.
The raster data are placed from the top to the bottom in the frame data. The byte data are placed from left to right in a raster. In each byte, MSB (bit 7) corresponds to the most left pixel in the image.
DIAGNOSTICS
BYTE 0 (Basic status)
bit 4 ST0_REPRINT_REQ
Reprint request. (a paper jammed or so)
bit 3 ST0_WAIT
The fixer is not heated up enough.
bit 2 ST0_PAUSE
The fixer and the main motor stopped.
bit 1 ST0_CALL
The operator call or the service call occurs.
BYTE 1 (Operator call status)
bit 6 ST1_NO_CARTRIGE
Cartridge is not equipped or not set properly.
bit 4 ST1_NO_PAPER
Out of paper.
bit 3 ST1_JAM
A paper is jamming.
bit 2 ST1_OPEN
The top door of the printer is open.
bit 1 ST1_TEST
Now, test printing.
BYTE 2 (Service call status)
bit 6 ST2_FIXER
Fixer got some trouble.
bit 5 ST2_SCANNER
Printer scanner is out of order.
bit 4 ST2_MOTOR
Motor of the printer scanner does not work.
BYTE 3 (Number of the sheets to be requested to resend)
bit 6 − 1
This byte indicates the number of sheets of paper to be requested to resend. The actual number is got using NREPRINT(x) macro.
BYTE 4 (paper size status)
bit 6 − 1
This byte indicates the size of the attached cassette. The actual code is got using PAPERSIZE(x) macro. When the code is 00H, there is no cassette. When 01H, there is the A4 size cassette. When 05H, there is the B4 size cassette. If you use NWP-550, the code is always 01H.
BYTE 5 (S status)
bit 6 ST5_NO_TONER
The warning of no toner. This status is available only when you use NWP-533/537/543. When you use NWP-550, this bit is not set at all.
BYTE 5 (option cassette feeder status)
bit 5 ST5_OPT_FEEDER
There is the option cassette feeder. This status is available only when you use NWP-550.
FILES
/dev/lbpLaser Beam Printer device file
SEE ALSO
" NEWS-OS Release 4.0 I/O DEVICE PROGRAMMING GUIDE / Laser Beam Printer ", " NEWS-OS Release 4.0 PROGRAMMERS’ GUIDE / Image Board Library ", " NEWS-OS Release 4.0 PROGRAMMERS’ GUIDE / LBP Library "
NEWS-OSRelease 4.1C