Scanning with SANE and Other Tools
A few years ago, Linux users were often confronted by the complex relationship between off-the-shelf video hardware and the XFree86 drivers that made them work. To understand how to configure your new video card, you needed to understand detailed hardware issues, such as which chipset your video card used. While this problem has eased as more video card makers have started to support XFree86 development directly and to provide their own XFree86 drivers, the Linux scanner world still is in that detailed hardware stage.
Scanners can connect to a PC in three basic ways: through a parallel port, through a SCSI bus host adapter or through the newer Universal Serial Bus (USB). It's next to impossible to find off-the-shelf scanners that don't support USB these days, though many also support parallel interfaces as well. SCSI interfaces mostly have been dropped by scanner makers in favor of USB.
USB support in the Linux 2.4 kernel series can be handled either by using the USB kernel scanner driver or by using the libusb library. You can check for the kernel scanner driver by running the following command:
lsmod | grep scanner
If this command returns anything, you have the kernel scanner driver. If it doesn't, you can load the scanner driver with this command:
modprobe scannerThis command also will load the USB core module (called usbcore when you run lsmod) if it's not already loaded. In order for the scanner to work with USB, the right USB HCI module also must be loaded. For USB 1.0 devices, the module to load is usb-uhci. For USB 1.1 it's usb-ohci. For 2.0 devices, even when running at lower speeds, it's usb-ehci. My USB hardware is USB 1.1, so I have to load the OHCI version:
modprobe usb-ohciTo use the libusb library instead, remove the scanner modules using this command (which should be run as the root user):
rmmod scannerAlthough support for the kernel scanner driver is rumored to be going away with the forthcoming 2.6 kernel release, it's still common in the current 2.4 kernels. Therefore, for the rest of this article we assume the use of the kernel scanner driver.
You can launch your scanner software using a script that runs the appropriate modprobe commands, so you can make sure the scanner driver is already loaded. Alternatively, you can use one of the system start-up scripts, such as the /etc/rc.local file commonly used on Red Hat systems, to load the scanner at boot time.
With the scanner driver loaded, next mount the USB filesystem, again as the root user:
Then you can list the devices on the USB bus:
cat /proc/bus/usb/devicesThis command won't produce any output if you don't have the scanner, USB core and HCI drivers (either uhci, ohci or ehci, as described previously) loaded. The devices file is verbose, but what you're looking for are the vendor and product IDs:
P: Vendor=04b8 ProdID=011d Rev= 1.00Hang on to these values—you'll need them later if SANE can't find your scanner. If you want to be certain your scanner will be seen by SANE, reload the scanner driver like so:
rmmod scanner modprobe scanner vendor=0x4b8 product=0x011dWe included the vendor and product IDs this time when we loaded the scanner driver. We also prefixed the IDs with 0x—this is required if you use the modprobe command in this way.
The sane-usb man page gives a more detailed discussion on getting your USB scanner configured. See the Linux USB Project page at www.linux-usb.org for help with general USB configuration and testing.
Now that we have the basic hardware configuration, we want to make sure the SANE software can access it. The version of SANE used for this article is 1.0.8. SANE software comes in two parts: the back-end driver software and the front-end user interfaces. SANE actually only provides the back-end drivers and a few command-line front ends. X-based graphical front ends, such as XSane and QuiteInsane, are separate projects that make use of the SANE back ends.
Most modern Linux distributions now include a version of the SANE back ends. However, many distributions are providing outdated releases. The SANE web site (www.mostang.com/sane) provides links to current binary distributions in RPM or similar formats for Red Hat, Debian, Mandrake and Slackware.
Once you have the SANE back ends installed, you need to configure the back-end drivers. The first trick is to make sure SANE can find a scanner. The SANE software provides a command-line tool, called sane-find-scanner, that can find any SCSI scanner and most USB scanners. Run this command either with your normal user ID or as root; no command-line options are necessary. The output from this command will be some comments and a line that looks something like this (for USB scanners):
sane-find-scanner: found USB scanner (vendor = 0x04b8, product = 0x011d) at device /dev/usb/scanner0
This means SANE can see the scanner using the device /dev/usb/scanner0, which is good; thus, we need to configure only this scanner's back-end drivers. However, if you don't get a line like this—if no scanner can be found—when you run sane-find-scanner as your normal user, you might have to change the permissions of the device file. You can verify this by running the command as the root user. If sane-find-scanner finds the scanner when run as root, the problem is a permissions issue. Assuming you are the only user on your machine, the problem is simple to fix:
chown owner.owner /dev/usb/scanner0 chmod 660 /dev/usb/scanner0In this example, owner is your user ID and group ID. If you need to share this scanner with other users, you can set up a scanner group instead:
chgrp scanner /dev/usb/scanner0 chmod 660 /dev/usb/scanner0These two commands need to be run as root. All users who need access to the scanner must be added to the scanner group. One other note on the device file: you may be tempted to make a symbolic link from /dev/usb/scanner0 to /dev/scanner. Don't. The SCSI back ends use the /dev/scanner device name, and linking it to the USB device will confuse the USB back ends.
Now that SANE can see the scanner, it's time to choose its back-end driver. This is the first tricky part. For most Epson scanners you would use the Epson back end. But for the Epson Perfection 1260—an affordable model commonly stocked by most electronics stores—the back end is actually the Plustek driver. For most scanners you can make educated guesses from the SANE web site supported-hardware list. Barring that, you can try to find the vendor and product IDs and match them to the information on the supported-hardware list on the Linux USB Project web site.
- Server Hardening
- BitTorrent Inc.'s Sync
- The Death of RoboVM
- EnterpriseDB's EDB Postgres Advanced Server and EDB Postgres Enterprise Manager
- The Humble Hacker?
- The US Government and Open-Source Software
- New Container Image Standard Promises More Portable Apps
- Open-Source Project Secretly Funded by CIA
- AdaCore's SPARK Pro
- ACI Worldwide's UP Retail Payments