Red Hat Linux 7 Unleashed

Red Hat Linux 7 Unleashed

By William Ball

How Do I Print?

One of the first things you should do before setting up your printer for Linux (especially if it is a parallel-port printer), is to make sure the printer works. First, check to see that your printer is plugged in, turned on, and attached to your computer's parallel port. Pass-through parallel port cables shouldn't pose a problem, but don't expect to be able to use your printer while you're using your CD-ROM, QuickCam, SCSI adapter, tape drive, or SyQuest drive if attached to a pass-through cable.

For starters, try this simple code:


   # ls >/dev/lp0

Chances are your printer will activate and its print head will move, but when you look at the printout, you might see a staircase effect, with each word on a separate line, moving across the page. Don't worry—this is normal and tells you that you can at least access your printer. Later in this chapter, you'll find out how to fine-tune your printing.

New Parallel-Port Drivers

Red Hat Linux uses version 2.2.16 of the Linux kernel. Unlike previous 2.0 versions of the kernel, recent 2.2.X and newer kernels use a different approach to parallel-port initialization, recognition, and configuration. In legacy kernels, parallel-port support was aimed specifically at providing printer support and was "hard-wired" into the kernel. This approach did not cover the needs of the myriad of parallel-port devices on the market. The newer approach, which uses several parallel-port kernel modules, abstracts communication with your computer's hardware to better support a much wider range of devices and provide new features, such as using multiple devices.

As distributed, Red Hat Linux contains a default parallel-port kernel module configuration in /etc/modules.conf. This line enables the low-level parallel-port parport kernel modules to attempt to autodetect any attached printers or devices:

alias parport_lowlevel parport_pc

You can view the output of these modules with the dmesg command following an attempt to print. Look for output similar to this:

parport0: PC-style at 0x3bc [SPP,PS2]
parport_probe: succeeded
parport0: Printer, Hewlett-Packard HP DeskJet 340
lp0: using parport0 (polling).

This shows that the computer's parallel port was detected, along with an attached printer (HP 340). The attached printer will use /dev/lp0 as the printer device. You can also use the lsmod command to verify that the printer drivers have been loaded following a print job, like this:


   # lsmod
Module                  Size  Used by
parport_probe           3428   0  (autoclean)
parport_pc              7464   1  (autoclean)
lp                      5416   0  (autoclean)
parport                 7320   1  (autoclean) [parport_probe parport_pc lp]
...

The parport modules are automatically loaded whenever the lp.o kernel module is used. If your parallel port hardware is detected, you can examine the contents of the hardware file under the printer port's device number (such as /dev/lp0) like this:


   # cat /proc/parport/0/hardware
base:   0x3bc
irq:    none
dma:    none
modes:  SPP,PS2

You can also use the parport_pc kernel module to specify your system's parallel I/O port address and IRQ. Use the insmod command to first load the parport.o module like this:


   # insmod parport

Next, use the parport_pc module, along with its io and irq options like this:


   # insmod parport_pc io=0x378 irq=7

This will tell the Linux kernel that your computer has a parallel port using the specified address and IRQ. This can be important, especially if you need to custom configure the port for a printer or other device.

You can also try the tunelp command, which sets various parameters to "tune" your printer port or lets you know if your printer device is using interrupts or polling for printing. Try using the command with its -s or status option like this:


   # tunelp /dev/lp0 -s

You might see this output:

/dev/lp0 status is 223, on-line

If tunelp reports "No such device or address", if you do not find an lp character device, and if you cannot load the parport modules, see Chapter 27, "Configuring and Building Kernels," to learn how to build kernel modules for your system.

For details about the new parport drivers, read the file parport.txt under the /usr/share/doc/kernel-doc-2.2.16 directory.

Share ThisShare This

Informit Network