Chapter 6. Additional Information on Printing

Table of Contents

6.1. Manual Configuration of Local Printer Ports
6.2. Manual Configuration of LPRng and lpdfilter
6.3. The LPRng Print Spooler
6.4. Command-Line Tools for LPRng
6.5. The Print Filter of LPRng and lpdfilter
6.6. Working with Ghostscript
6.7. Working with a2ps
6.8. Reformatting PostScript with psutils
6.9. ASCII Text Encoding

Abstract

This chapter provides further in-depth knowledge on printer operation in Linux. Many examples will guide you through the configuration of complex printing scenarios.

6.1. Manual Configuration of Local Printer Ports

6.1.1. Parallel Ports

For the most part, printers are connected to a Linux system through a parallel port. Printers on parallel ports are handled by the parport subsystem of the Linux kernel. The paragraphs below provide more in-depth information on the topic.

The parport subsystem manages parallel ports only through the corresponding architecture-specific kernel modules after these are loaded. Among other things, this allows for several devices, such as a parallel port ZIP drive and a printer, to be linked to one parallel port at the same time. Device files for parallel printers are counted beginning with /dev/lp0. With a SUSE LINUX standard kernel, printing over the parallel port requires that the modules parport, parport_pc, and lp are loaded. This is achieved by kmod (the kernel module loader). Normally, these modules are loaded automatically as soon as some process requests access to the device file.

If the kernel module parport_pc is loaded without any parameters, it tries to autodetect and autoconfigure all available parallel ports. This may not work in some very rare cases and cause a system lock-up. If that happens, configure it manually by explicitly providing the correct parameters for the parport_pc module. This is also the reason why printer autodetection can be disabled for YaST as described in Section 5.3. “Configuring a Printer with YaST”.

6.1.1.1. Manual Configuration of Parallel Ports

The first parallel port (/dev/lp0) is configured with an entry in /etc/modules.conf, as shown in File 6.1. “/etc/modules.conf: First Parallel Port”.

Example 6.1. /etc/modules.conf: First Parallel Port

alias parport_lowlevel parport_pc 
options parport_pc io=0x378irq=none

Under io, enter the IO address of the parallel port. Under irq, keep the default none for polling mode. Otherwise, provide the IRQ number for the parallel port. Polling mode is less problematic than interrupt mode as it helps to avoid interrupt conflicts. However, there are combinations of motherboards and printers that only function well if this is set to interrupt mode. Apart from that, interrupt mode ensures a continuous data flow to the printer even when the system is under very high load.

To make the above configuration work, you may still need to change the parallel port settings made available through your machine's BIOS or firmware:

  • IO address: 378 (hexadecimal)

  • Interrupt: 7 (not relevant for polling mode)

  • Mode: Normal, SPP, or Output-Only (other modes will not always work)

  • DMA: Disabled (should be disabled as long as the mode is set to Normal)

If interrupt 7 is still free, enable in /etc/modules.conf as shown in File 6.2. “/etc/modules.conf: Interrupt Mode for the First Parallel Port”.

Example 6.2. /etc/modules.conf: Interrupt Mode for the First Parallel Port

alias parport_lowlevel parport_pc
options parport_pc io=0x378 irq=7

Before activating the interrupt mode, check the file /proc/interrupts to see which interrupts are already in use. Only the interrupts that are currently in use are displayed. This may change depending on which hardware components are active. The interrupt used for the parallel port must not be occupied by any other device. If you are not sure, use the polling mode.

6.1.1.2. Enabling and Testing a Parallel Port

After configuration, the parallel port is enabled when you reboot the machine. If you do not want to reboot, run the following commands as root to update the module dependency list and to unload all kernel modules related to parallel ports.

depmod -a 2>/dev/null
rmmod lp
rmmod parport_pc
rmmod parport

After this, reload the modules with:

modprobe parport
modprobe parport_pc
modprobe lp

If the printer is capable of direct ASCII text printing, the following command as root should print a single page with the word Hello on it:

echo -en "\rHello\r\f" >/dev/lp0

In the above command, the word Hello is enclosed in two \r ASCII characters to produce carriage returns. The closing ASCII character \f is included to produce a form feed. To test a second or third parallel port in the same way, use /dev/lp1 or /dev/lp2, respectively.

6.1.2. USB Ports

First, make sure the interrupt is enabled for USB in your machine's BIOS. In an Award BIOS, for example, go to the menu PNP AND PCI SETUP and set the entry USB IRQ to Enabled. The wording of these menus and entries may vary depending on the BIOS type and version.

Test whether the USB printer is responding by entering the command (as root):

echo -en "\rHello\r\f" >/dev/usb/lp0

If there is only one USB printer connected to the machine and this printer is able to print ASCII text directly, this should print a single page with the word Hello.

Some USB printers may need a special control sequence before accepting data over a USB line. Further information can be found in the Support Database http://sdb.suse.de/en/sdb/html. Enter the keywords Epson and usb.

In most cases, you should be able to get information about the printer manufacturer and the product name by entering:

cat /proc/bus/usb/devices

If this does not display any information, it will usually be for one of these reasons:

  • The USB system has not detected the device (yet), maybe even because it is disconnected from power, so there is no communication between the system and the printer.

  • The USB system has detected the device, but neither the manufacturer or the product name are known to it. Accordingly, nothing is displayed, but the system can communicate with the printer.

Sometimes it may happen that the USB printer does not respond anymore, for instance, after unplugging it in the middle of a print job. In such a case, the following commands should be sufficient to restart the USB system:

rchotplug stop
rchotplug start

If you are not successful with these commands, terminate all processes that use /dev/usb/lp0. Use lsmod to check which USB modules are loaded (usb-uhci, usb-ohci, or uhci) and how they depend on each other. For instance, the following entry in the output of lsmod shows that the module usbcore is being used by modules printer and usb-uhci:

usbcore ... [printer usb-uhci]

Accordingly, modules printer and usb-uhci need to be unloaded before unloading usbcore. As root, enter the following commands (replace usb-uhci with uhci or usb-ohci depending on your USB system):

fuser -k /dev/usb/lp0
rchotplug stop
rmmod printer
rmmod usb-uhci
umount usbdevfs
rmmod usbcore
modprobe usbcore
mount usbdevfs
modprobe usb-uhci
modprobe printer
rchotplug start

If you have more than one USB printer connected to the system, there is a special issue to consider: All connected devices are autodetected by the USB subsystem with the first USB printer being addressed as device /dev/usb/lp0 and the second one as /dev/usb/lp1. Depending on the model, USB printers can be detected even when they are powerless. Some have the built-in capability to be queried by the system even when powered off. Therefore, to avoid that the system confuses different printers, switch on all printers before booting and try to leave them connected to power all the time.

6.1.3. The IrDA Printer Interface

With IrDA, the system uses an infrared interface to emulate a parallel port. To do so, the Linux drivers provide a simulated parallel port under the device name of /dev/irlpt0. A printer connected through infrared is handled in the same way as any other parallel printer except it is made available to the system under the name of /dev/irlpt0 instead of /dev/lp0.

Test the connection to an IrDA printer by entering the command (as root):

echo -en "\rHello\r\f" >/dev/irlpt0

If the printer is able to print ASCII text directly, this should print a single page with the word Hello on it.

Regardless of the outcome of the above test, the printer should appear in the output of irdadump. If the irdadump command is not available, install the irda. If irdadump does not display the printer, it is not possible to address the printer. If nothing is displayed, most likely the IrDA system service has not been started, as it is not started automatically when the system is booted. Enter the following commands to start and stop the IrDA systems service:

rcirda start
rcirda stop

6.1.4. Serial Ports

The use of the LPRng spooler with a printer connected to the serial port is described in the LPRng-Howto under /usr/share/doc/packages/lprng/LPRng-HOWTO.html (especially under /usr/share/doc/packages/lprng/LPRng-HOWTO.html#SECSERIAL) and in the manual page of printcap. Information is also availabe in the Support Database under the keyword serial.