[sane-devel] Proposal: sanei_usb interface for USB scanners
Sun, 5 Aug 2001 22:05:33 +0200
I have just written a quick-and-dirty interface for USB scanners like
sanei_scsi is for SCSI scanners. It's not as generic as the SCSI one,
however. Currently it works only with device files, so e.g. the Linux
USB scanner module is supported. I don't know if it's easy to add
support for libusb; is there documentation for it anywhere? Would it
be possible to add support for the scanners with their own kernel
drivers without too much dirty tricks?
The following functions have been implemented in sanei_usb.c:
The first for functions are simple and just map to the low level open
etc. functions and so some error reporting. They have been lightly
tested with the mustek_usb backend so more testing is necessary.
The last two are a bit more complicated:
sanei_usb_get_vendor_product tries to find out vendor and product ids
for a given device file by asking the USB scanner driver via ioctls
about them (if available). This works only with the latest Linux
versions. This functions allows backends to check if the device file
they use is connected to a scanner they support. If the Linux ioctl is
not available at least it's checked if the file can be opened
(something is listening to the device file). This can also be used in
sane-find-scanner to check all the /dev/usb/scanner files for
connected scanners (see below).
sanei_scsi_find_devices goes the other way round: it returns a device
file for a given vendor and device id. It has the same limitations as
above. With this function it's possible to use "usb 0x1233 0x321" in
the config file (similar to the "scsi" command) to find a device file
for the USB scanner with these ids.
New files: sanei/sanei_usb.c, include/sane/sanei_usb.h
Updated: tools/sane-find-scanner.c (+Makefile)
sane-find-scanner now tries to find USB devices. sanei_config2 has the
extention for the "usb vendor product" line in config files.
The changes can be downloaded from
It's a tar.gz file containing all the updated and new files because I
didn't know how to include files into "cvs diff" that are not yet
added to CVS. Just untar it in the sane-backends directory.
Thanks to Karl Heinz Kremer for the info about the Linux ioctl.