Kernel, Device, and Communications Mode Configuration


The default kernel has support for the parallel and serial ports built into it, as well as basic USB support; so unless you have built a custom kernel and removed support for these ports, you shouldn't have any problems. The easiest way to check for parallel or serial support in the kernel is by checking whether it detected those ports at boot time and emitted kernel messages corresponding to them. These kernel boot messages are available throughout the computer's uptime in the file /var/run/dmesg.boot. Use the grep command to search through this file for any mention of the device corresponding to your printer: ppcN for parallel printers, sioN for serial printers, or ulptN for USB printers.

Note

The N at the end of each device name indicates which device in the chain you're addressing. For example, there are four serial I/O ports in most PC-type computers, and they're numbered (like most things in UNIX) from 0 to 3. Similarly, your (likely only) parallel port controller is ppc0. USB printers, because they can be hot-plugged while the system is running, will echo their device names into the kernel message log at the time you connect them, and you can use the dmesg command to view the current kernel messages if you need to identify the device name for the USB printer you just plugged in. Note that because USB devices provide information about themselves back to the kernel, FreeBSD will usually be able to tell you about the printer's manufacturer and model, whereas parallel and serial printers are usually "black holes" to the systemit just sends data to them without knowing what's on the other end. All it can tell you about is whether it can communicate with the port itself.


The following commands show successful grep commands probing for parallel, serial, and connected USB printers.

# grep ppc /var/run/dmesg.boot ppc0: <Standard parallel printer port> port 0x378-0x37f irq 7 on acpi0 ppc0: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode ppbus0: <Parallel port bus> on ppc0 # grep sio /var/run/dmesg.boot sio1: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 on acpi0 sio1: type 16550A # grep ulpt /var/run/dmesg.boot ulpt0 at uhub0 port 1 configuration 1 interface 0 ulpt0: hp deskjet 3600, rev 2.00/1.00, addr 2, iclass 7/1 ulpt0: using bi-directional mode


Tip

To combine all these commands at once (and to incorporate the ^ character, which indicates the beginning of the line in a regular expression, to avoid false matches), use the following command:

# dmesg | grep '^ppc|^sio|^ulpt'



If FreeBSD responds with nothing, the kernel does not support the port in question. You will need to load a kernel module with the kldload command (sio.ko for serial, ppbus.ko and lpt.ko for parallel, and usb.ko and ulpt.ko for USB)or, for a more permanent solution, add the appropriate device line to the kernel configuration file and rebuild the kernel (see Chapter 18, "Kernel Configuration," for information on how to configure and build the kernel).

Configuring the Parallel Port Mode

If you're using a parallel port printer (the lpt0 device on the ppc0 controller), you'll need to decide what mode you want to run it inpolled mode or interrupt-driven mode. Which mode you'll need depends on your printer, as some printers work better in one mode than the other; interrupt-driven mode is faster, but uses up an interrupt request (IRQ) that your system might have in short supply, and some printers are unstable in interrupt-driven mode. You can use the lptcontrol program to configure the mode of the parallel port. Note that you will need to be root to do this. Also, there must be a printer connected to the parallel port for lptcontrol to work.

The syntax of lptcontrol is lptcontrol -x -d /dev/lpt0, where -x is one of the options detailed in Table 17.1, depending on the mode you want to set.

Table 17.1. The lptcontrol Mode Options

Option

Description

-i

Sets interrupt-driven mode

-p

Sets polled mode

-e

Sets extended mode (whatever extended mode the printer supports)

-s

Sets standard mode (turns off extended mode)


If your printer and your BIOS support ECP, EPP, or other forms of enhanced parallel-port communication, you will want to use -e here.

Also, note that -d (which specifies the port device) is optional. If you do not specify a device, lptcontrol will use the default device, which is /dev/lpt0.

For example, the following command will set the first parallel port to extended mode:

# lptcontol -e -d /dev/lpt0


Maintaining Parallel Port Configuration Across Reboots

If you want these settings to be maintained across reboots, you must add the lptcontrol control command to one of the system startup scripts so that it is run at each system boot. The best way to do so is to create a new file in /usr/local/etc/rc.d that has the command in it. If you create a startup file in /usr/local/etc/rc.d, you will need to set the permissions on the file so that it is executable (for example, chmod 655 filename). See Chapter 14, "System Configuration and Startup Scripts," for more information on these techniques.

Testing Printer Port Communications

After you've determined that your kernel recognizes your printer's port, you should test its connectivity to make sure you can send data to the printer. You can use the lptest program to send a plain-text test page to the printer, or create a PostScript input file to test the printer's capability (if present) to print PostScript data. The printer must be turned on and you must be root for this step.

To test a parallel printer, send the prepackaged output of lptest to the printer device as follows:

# lptest > /dev/lpt0


For a USB printer, use the following:

# lptest > /dev/ulpt0


A test page full of standard ASCII characters should appear on the printer.

If your printer supports PostScript instructions, you can send a simple PostScript file to its device to test that capability. First create the file, as shown in Listing 17.1.

Listing 17.1. A PostScript Printer Test File

%!PS 100 100 moveto 300 300 lineto stroke 310 310 moveto /Helvetica findfont 12 scalefont setfont (Hello world!) show showpage

Save this file, and then send it to the printer using the cat command, using the appropriate device name for your printer:

# cat pstest.ps > /dev/ulpt0





FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net