LBP(4) — NEWS-OS Programmer’s Manual
NAME
lbp − NEWS laser beam printer interface
SYNOPSIS
In case of using NWB-5501 as interface board
lbpx at ap0 sloty addr zzzzzzzz priority 108
( x,y,zzzzzzzz depend on hardware configuration )
/dev/lbp[0-3], /dev/lbp
#include <newsiop/lbp.h>
In case of not using NWB-5501 as interface board
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/5501). 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.
1.1 For the NWP-5501 + NWA-5505 (cassette feeder), select cassette if necessary.
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. If you use NWB-5501, you can also assign the device as /dev/lbp[0-3].
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, NWP-550 or NWP-5501 A4 size: 1770272 bytes (3136 x 4516/8), B4 cassette or NWP-5501 B4 size: 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 one or more sheets of paper on the
manual supply tray, paper is always supplied from the manual supply tray. When you use NWP-5501, if there are one or more sheets of paper on the manual supply tray, paper is always supplied from the manual supply tray.
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);
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).
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. A4. When 05H, there is the B4 size cassette. B4. If you use NWP-550, the code is always 01H. If you use NWP-5501, the code is that of current cassette (built-in cassette or cassette feeder, specified by LBIOCPAPERIN ioctl)
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/5501. 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.
LBIOCHAND
This request switches to manual supply mode when you use NWP-533/537. This request switches to manual supply tray mode when you use NWP-550/5501. For NWP-543, manual supply mode is not available.
ioctl(lbp, LBIOCHAND);
LBIOCCASSETTE
This request switches to cassette supply mode when you use NWP-533/537. This mode is default when you use NWP-533/537.
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.
This request switches to built-in cassette supply mode when you use NWP-5501. This mode is default when you use NWP-5501.
ioctl(lbp, LBIOCCASSETTE);
LBIOCGETTYPE
Get printer type (one of LBP_NWP533, LBP_NWP537, LBP_NWP543, LBP_NWP550). Even if you use NWP-5501, the value of type is LBP_NWP537.
ioctl(lbp, LBIOCGETTYPE, type);
int ∗type;
LBIOCGETTYPE2
Get printer type (bit-assigned). The following bit is available:
LBP_NWP533, LBP_NWP537, LBP_NWP543, LBP_NWP550, LBP_NWP5501.
If you use NWP-5501, both the bit LBP_NWP537 and the bit LBP_NWP5501 are set.
ioctl(lbp, LBIOCGETTYPE2, 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/5501 or NWP-543 and change the cassette, issue this ioctl to change the internal state (cassette size) in device driver.
For NWP-537, the size after open system call is B4 if B4 cartridge is attached. In other case, it is A4.
For NWP-5501, the size after open system call is B4 if B4 cassette is attached in built-in cassette position. In other case, it is A4.
LBIOCGETERROR
Reports error information for the NWP-5501.
This ioctl is available only for NWP-5501. When you use other LBP, this ioctl return the error with -1 and EINVAL is set to the global variable "errno".
ioctl(lbp, LBIOCGETERROR, st);
char st[4];
The following bits are valid:
byte 0 (Misprint information status)
Temporary abnormality has occurred in the
BD signal synchronization.
The VSYNC signal was not received.
byte 1 (Error generating unit status)
Error in manual feed tray.
LBIOCGETCONFIG
Get the status of the paper feed device on NWP-5501.
This ioctl is available only for NWP-5501. When you use other LBP, this ioctl return the error with -1 and EINVAL is set to the global variable "errno".
ioctl(lbp, LBIOCGETCONFIG, st);
char st[8];
The following bits are valid:
byte 0 (Paper feeder configuration status)
Built-in cassette is attached.
Cassette feeder (NWA-5505) is connected.
byte 1 (Paper status)
There is paper in the built-in cassette.
There is paper in the cassette feeder.
byte 1 (Paper feed selection status)
Built-in cassette is selected as feeder device.
Cassette feeder is selected as feeder device.
LBIOCGETPAPERSIZE
Reports the size of paper in paper feed devices connected to NWP-5501.
This ioctl is available only for NWP-5501. When you use other LBP, this ioctl return the error with -1 and EINVAL is set to the global variable "errno".
ioctl(lbp, LBIOCGETPAPERSIZE, size);
char size[4];
Paper size is returned to each of the bytes below. ,br If size is A4, then the value is 1. If size is B4, then the value is 5. The value is 0 if the cassette is not loaded.
byte 0 (Built-in cassette paper size)
byte 2 (Cassette feeder paper size)
LBIOCPAPERIN
Specifies the paper feed device on NWP-5501.
This ioctl is available only for NWP-5501. When you use other LBP, this ioctl return the error with -1 and EINVAL is set to the global variable "errno".
ioctl(lbp, LBIOCPAPERIN, dev);
int ∗dev;
If LBP_FROMBUILTIN is specified into dev, The built-in cassette is assigned as paper feed device whether cassette is loaded or not, whether paper is in it or not.
If LBP_FROMOPT is specified into dev when the cassette feeder is connected, The cassette feeder is assigned as paper feed device whether cassette is loaded or not, whether paper is in it or not.
If LBP_FROMOPT is specified into dev when the cassette feeder is not connected, the built-in cassette is assigned as paper feed device.
After open system call or after lBIOCRESET ioctl, the built-in cassette is assigned as feed device.
Format of the output data
The NEWS’s laser beam printer (NWP-533/537/543/550/5501, NWB-240A/241A/242/243/244 /245/5501) 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/543/5501.
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.
CHANGING THE CASSETTE
B4 laser beam printer (NWP-537/5501) 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".)
FILES
/dev/lbp Laser Beam Printer device file
SEE ALSO
Chapter "Image Board Library" in NEWS-OS Release 4.0 I/O Device Programming Guide,
Chapter "Image Board Library" in NEWS-OS Release 4.0 Programmer’s Guide,
Chapter "LBP Library" in NEWS-OS Release 4.0 Programmer’s Guide.
NEWS-OSRelease 4.2.1R