[sane-devel] USB scanner paper

Karl F. Larsen k5di@zianet.com
Sun, 17 Nov 2002 16:04:20 -0700 (MST)


	Hi Gang, this is expected to work with the Linux systems 
defined. If you see errors please note them to me.


		Recipe for Setting Up a Scanner using USB
				Karl Larsen
			     November 17, 2002

	If the scanner you have has a USB cable that plugs into the
computer, and if your computer has a plug for it to plug into, this paper
will tell you how to make certain that the software called Sane on your
Linux operating system can find and use your scanner.

	First your Linux. It should have at least a 2.4.8 kernel and among
other things should have the scanner module compiled and ready for use. 

	Next your Sane. You should have a recent version of this software.
To find out what you have, run this simple test. In an Xterm window type
scanimage --version. This will print out the backend version and it needs
to be 1.0.7 or higher to work well with a USB scanner. If your version is
older you need to install the latest version from

	In terms of the Red Hat Linux, version 7.3 or higher will fully
support running a USB scanner. An earlier version might require both a
kernel and Sane upgrade.

	Plug your scanner into the computer and turn it on. Notice the Name
of your scanner and it's model number. Now in an Xterm window at the command
line do this:

		cat /proc/bus/usb/devices <Enter>

This lists all the data about your USB ports. Here is a copy of my
computer's setup:

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 0.00
S:  Product=USB UHCI Root Hub
S:  SerialNumber=6400
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=  0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=255ms
T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=ff(vend.) Sub=00 Prot=ff MxPS= 8 #Cfgs=  1
P:  Vendor=04b8 ProdID=010f Rev= 1.00
S:  Manufacturer=EPSON
S:  Product=EPSON Scanner 010F
C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=  2mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=ff Driver=(none)
E:  Ad=81(I) Atr=03(Int.) MxPS=   1 Ivl=16ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

	I have an Epson model Perfection 1250 scanner and you can see that
this printout is correct for an Epson. Notice at the second P: is listed a
number called Vender=04b8 which means Epson. ProdID=010f which means
model Perfection 1250 are the 2 numbers we need to set up Sane so it can
find the scanner.

	The numbers need to be changed to exact Hex numbers so instead of
04b8 it is written 0x04b8 and 010f is written 0x010f. We will use these
numbers with the scanner module to set up a working scanner. It's assumed
you have scanner as a module on your Linux. 

	To load the module with the scanner numbers in place we use modprobe
and we must be in an xterm window as root. To do this type su - and when it
asks for your password type that in. You will see the prompt turn to # and
you will be in the /root directory. Now type in the following:

	modprobe vendor=0x04b8 product=0x010f

but instead of my numbers put in your scanners numbers. It should take a
second to do it's job and then stop without any error messages. If you get
an error message you didn't type it in right.

	Now to see if Sane can find the scanner. For this we use the tool
that comes with Sane called "sane-find-scanner". In an xterm window type in:

		sane-find-scanner

	My Linux came back with this:  	

# Note that sane-find-scanner will find any scanner that is connected
# to a SCSI bus and some scanners that are connected to the Universal
# Serial Bus (USB) depending on your OS. It will even find scanners
# that are not supported at all by SANE. It won't find a scanner that
# is connected to a parallel or proprietary port.

sane-find-scanner: found USB scanner (vendor = 0x04b8, product = 0x010f) at
device /dev/usb/scanner0

Notice the last 2 lines that begin "sane-find-scanner:". It says Sane has
found our scanner because it gives the proper vendor and product numbers for
my scanner. 

	At this point your scanner will probably not work yet but your sure
that Sane can find your scanner. Your more than 1/2 toward a working
scanner in Linux.

	To use the scanner you will want to load the module scanner each
time you turn on your Linux. There are several ways to do this but the most
straight forward way is to load scanner from the file /etc/rc.d/rc.local.
This file on my computer looks like this:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

# This turns on the scanner module with the Epson scanner

insmod scanner >/dev/null

It's the insmod scanner that loads the module. Now we want to load the
vendor and product numbers. This is done in the file /etc/modules.conf. Mine
looks like this:

alias parport_lowlevel parport_pc
alias eth0 8139too
alias sound-slot-0 es1371
post-install sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -L >/dev/null
2>&1 || :
pre-remove sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -S >/dev/null
2>&1 || :
alias usb-controller usb-uhci
options scanner vendor=0x4b8 product=0x010f

Notice the last line which is what I added. To make that line active as root
you need to use a tool that reads the file and does what it says to do. This
tool is called "depmod" and you use it this way:

		#depmod -a

It will take several seconds and then just stop.

	Testing the setup is easy and takes little time. Remove the scanner
module from the kernel with rmmod scanner. Then run sane-find-scanner and
see it can't find it. Then use modprobe scanner to re-load it and again run
sane-find-scanner and observe it again finds it.

	At this point your ready to approach which back end to use with your
scanner. 


-- 
                      
               - Karl Larsen k5di Las Cruces,NM Az ScQRPions -