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

Oliver Neukum Oliver.Neukum@lrz.uni-muenchen.de
Mon, 6 Aug 2001 00:07:46 +0200

Am Sonntag,  5. August 2001 22:05 schrieben Sie:
> 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

The architecture you use will work with nothing else.
But it should work on BSD's generic USB devices.

> 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?

Which would be ? There are three scanner drivers in the Linux kernel, the 
generic, microtek and hp5300. The latter two use SCSI over USB.

Generally speaking scanners which cannot use the generic driver cannot be 
used in a way that would map to only bulk read/write.

> 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_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.

This is dangerous. In fact it's a race. The id might be invalid by the time 
the device is actually opened. You should return an fd.

		Oliver Neukum