[sane-devel] USB probing

Henning Meier-Geinitz henning@meier-geinitz.de
Mon, 14 Jan 2002 19:19:06 +0100


Hi,

On Mon, Jan 14, 2002 at 01:00:25PM +0000, Major A wrote:
> Given a device file, how can I determine whether that is a generic
> SCSI or a USB scanner device? It seems that when I try to open a USB
> device file as a SCSI device and probe with INQUIRY, a USB timeout
> will occur. I don't think using a generic SCSI device file with some
> random USB scanner protocol is a good idea either.
> 
> So, is it possible to decide what interface the file stands for, or do
> I have to judge from the filename (example: "usb:/dev/scanner")?

There is no reliable way to detect that automatically. You can use the
automatic detection ("usb vendor product" and "scsi ..."). But this
will only work with Linux. If you have a backend which supports both
USB and SCSI, I would use an prefix as you proposed or an option:

usb:/dev/device

or

/dev/device
option usb

You can also try to analyze the filename, e.g. first character = 'u'.
This will fail with *BSD's /dev/uk* devices (SCSI generic).
An nobody prevents the user from naming his USB device
"/dev/my_own_scanner".

Bye,
  Henning