sane-scsi(5) | SANE Scanner Access Now Easy | sane-scsi(5) |
sane-scsi - SCSI adapter tips for scanners
This manual page contains various operating-system specific tips and tricks on how to get scanners with a SCSI interface working.
For scanners with a SCSI interface, it may be necessary to edit the appropriate backend configuration file before using SANE for the first time. For most systems, the configuration file should list the name of the generic SCSI device that the scanner is connected to (e.g., under Linux, /dev/sg4 or /dev/sge is such a generic SCSI device). It is customary to create a symlink from /dev/scanner to the generic SCSI device that the scanner is connected to. In this case, the configuration file simply lists the line /dev/scanner. For a detailed description of each backend's configuration file, please refer to the relevant backend manual page (e.g., sane-epson(5) for Epson scanners, sane-hp(5) for HP scanners, etc.).
For some operating systems (e.g. Linux and OS/2), there is an alternate way of specifying scanner devices. This alternate way allows one to identify scanners by the SCSI vendor and model string and/or by the SCSI device address (consisting of bus number, channel number, id, and logical unit number). The syntax for specifying a scanner in this way is:
where VENDOR is the SCSI vendor string, MODEL is the SCSI model string, TYPE is type SCSI device type string, BUS is the SCSI bus number (named "host" in /proc/scsi/scsi), CHANNEL is the SCSI channel number, ID is the SCSI id, and LUN is the logical unit number of the scanner device. The first two fields are strings which must be enclosed in double-quotes if they contain any whitespace. The remaining four fields are non-negative integer numbers. The correct values for these fields can be found by using operating system specific tools, e.g. for Linux by looking at the output of the command cat /proc/scsi/scsi. To simplify configuration, a field's value can be replaced with an asterisk symbol (``*''). An asterisk has the effect that any value is allowed for that particular field. This can have the effect that a single scsi-line matches multiple devices. When this happens, each matching device will be probed by the backend one by one and registered if the backend thinks it is a compatible device. For example, the line
would attach the Mustek SCSI scanner with the following /proc/scsi/scsi entry:
Host: scsi0 Channel: 00 Id: 03 Lun: 00
Vendor: MUSTEK Model: MFS-06000CX Rev: 4.04
Type: Scanner ANSI SCSI revision: 0
Usually it's sufficient to use vendor and model strings only or even only the vendor string. The following example
would have the effect that all SCSI devices in the system with a vendor string of MUSTEK would be probed and recognized by the backend.
If the remainder of a scsi-string consists of asterisks only, the asterisks can be omitted. For example, the following line is equivalent to the one specified previously:
On some platforms (e.g., OpenStep), SANE device names take a special form. This is explained below in the relevant platform-specific section.
When using a SCSI scanner, ensure that the access permission for the generic SCSI device is set appropriately. We recommend to add a group "scanner" to /etc/group which contains all users that should have access to the scanner. The permission of the device should then be set to allow group read and write access. For example, if the scanner is at generic SCSI device /dev/sg0, then the following two commands would set the permission correctly:
When your system uses the device filesystem (devfs), you have to edit /etc/devfs/perms. There you should search the line
and add a new line (eg. for changing permissions of sg4):
Auto-configuration using the "scsi *" lines in the config files only works if the user running the frontend has read/write access to /dev/xpt0. Instead, you can also set a link /dev/scanner to the appropriate /dev/uk device.
First, make sure your kernel has SCSI generic support enabled. In make xconfig, this shows up under ``SCSI support->SCSI generic support''.
To keep scanning times to a minimum, it is strongly recommended to use a large buffer size for the generic SCSI driver. From SG driver version 2.0 on, the maximum buffer size can be changed at program run time, and there is no restriction in size. This driver version is part of the Linux kernels from version 2.2.7 on. If the new SG driver is available some backends (e.g. sane-umax(5), sane-mustek(5), sane-sharp(5)) automatically request larger SCSI buffers. If a backend does not automatically request a larger SCSI buffer, set the environment variable SANE_SG_BUFFERSIZE to the desired buffer size in bytes. It is not recommended to use more than 1 MB, because for large values the probability increases that the SG driver cannot allocate the necessary buffer(s). For ISA cards, even 1 MB might be a too large value. For a detailed discussion of memory issues of the SG driver, see http://www.torque.net/sg.
For Linux kernels before version 2.2.7 the size of the buffer is only 32KB. This works, but for many cheaper scanners this causes scanning to be slower by about a factor of four than when using a size of 127KB. Linux defines the size of this buffer by macro SG_BIG_BUFF in header file /usr/include/scsi/sg.h. Unless a system is seriously short on memory, it is recommended to increase this value to the maximum legal value of 128*1024-512=130560 bytes. After changing this value, it is necessary to recompile both the kernel (or the SCSI generic module) and the SCSI backends. Keep in mind that this is only necessary with older Linux kernels.
A common issue with SCSI scanners is what to do when you booted the system while the scanner was turned off. In such a case, the scanner won't be recognized by the kernel and SANE won't be able to access it. Fortunately, Linux provides a simple mechanism to probe a SCSI device on demand. Suppose you have a scanner connected to SCSI bus 2 and the scanner has a SCSI id of 5. When the system is up and running and the scanner is turned on, you can issue the command:
and the kernel will probe and recognize your scanner (this needs to be done as root). It's also possible to dynamically remove a SCSI device by using the ``remove-single-device'' command. For details, please refer to to the SCSI-2.4-HOWTO.
Scanners are known to work with the following SCSI adapters under Linux. This list isn't complete, usually any SCSI adapter supported by Linux should work.
Under Solaris, OpenStep and NeXTStep, the generic SCSI device name refers to a SCSI bus, not to an individual device. For example, /dev/sg0 refers to the first SCSI bus. To tell SANE which device to use, append the character 'a'+target-id to the special device name. For example, the SCSI device connected to the first SCSI controller and with target-id 0 would be called /dev/sg0a, and the device with target-id 1 on that same bus would be called /dev/sg0b, and so on.
sane(7), sane-find-scanner(1), sane-"backendname"(5), sane-usb(5)
David Mosberger
14 Jul 2008 |