Previous Next Contents

3. Kernel printer devices

3.1 The lp device

The Linux kernel, assuming you have compiled in or loaded the lp device (the output of cat /proc/devices should include the device lp), provides one or more of /dev/lp0, /dev/lp1, and /dev/lp2. These are NOT assigned dynamically, rather, each corresponds to a specific hardware I/O address. This means that your first printer may be lp0 or lp1 depending on your hardware. Try both ;)

One cannot run the plip and lp drivers at the same time on any given port. You can, however, have one or the other driver loaded at any given time either manually, or by kerneld with v2 (and later 1.3.x) kernels. By carefully setting the interrupts and such, you can supposedly run plip on one port and lp on the other. One person did so by editing the drivers; I eagerly await a success report of someone doing so with only a clever command line.

There is a little utility called tunelp floating about with which you, as root, can tune the Linux lp device's interrupt usage, polling rate, and other options.

When built in to some 1.3.x and v2 kernels, the kernel will accept an lp= option to set interrupts and io addresses:

When the lp driver is built in to the kernel, you may use the
LILO/LOADLIN command line to set the port addresses and interrupts
that the driver will use.

Syntax:      lp=port0[,irq0[,port1[,irq1[,port2[,irq2]]]]]

For example:   lp=0x378,0   or   lp=0x278,5,0x378,7 **

Note that if this feature is used, you must specify *all* the ports
you want considered, there are no defaults.  You can disable a
built-in driver with lp=0.

When loaded as a module in version 2 and late-model 1.3.x kernels, it is possible to specify io addresses and interrupt lines on the insmod command line (or in /etc/conf.modules so as to affect kerneld) using the usual syntax. The parameters are io=port0,port1,port2 and irq=irq0,irq1,irq2. Read ye the man page for insmod for more information on this.

**For those of you who (like me) can never find the standard port numbers when you need them, they are as in the second example above. The other port (lp0) is at 0x3bc. I've no idea what interrupt it usually uses.

3.2 Serial devices

Serial devices are usually called something like /dev/ttyS1 under Linux. The utility stty will allow you to interactively view or set the settings for a serial port; setserial will allow you to control a few extended attributes and configure IRQs and I/O addresses for non-standard ports. Further discussion of serial ports under Linux may be found in the Serial-HOWTO.

When using a slow serial printer with flow control, you may find that some of your print jobs get truncated. This may be due to the serial port, whose default behavior is to purge any untransmitted characters from its buffer 30 seconds after the port device is closed. The buffer can hold up to 4096 characters, and if your printer uses flow control and is slow enough that it can't accept all the data from the buffer within 30 seconds after printing software has closed the serial port, the tail end of the buffer's contents will be lost. If the command cat file > /dev/ttyS2 produces complete printouts for short files but truncated ones for longer files, you may have this condition.

The 30 second interval can be adjusted through the "closing_wait" element of the serial port's data structure using an ioctl() call. Setserial does not deal with this data element but does handle others in the same data structure, and it is a simple matter to modify setserial to deal with closing_wait. Then, in rc.serial, the setserial command for your printing serial port can modified to set the closing_wait at the same time as it sets that port's other parameters.


Previous Next Contents