[sane-devel] Proposal: sanei_usb interface for USB scanners

Henning Meier-Geinitz henning at meier-geinitz.de
Sun Aug 5 21:05:33 BST 2001


Hi,

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:

sanei_usb_open
sanei_usb_close
sanei_usb_read_bulk
sanei_usb_write_bulk
sanei_usb_get_vendor_product
sanei_usb_find_devices

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)
           sanei/sanei_config2.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
http://www.meier-geinitz.de/sane/download/sanei_usb-2001-08-05.tar.gz

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.

Comments? Additions?

Bye,
  Henning



More information about the sane-devel mailing list