[sane-devel] Using scanimage's -device option to specify one of two identical scanners

Olaf Meeuwissen olaf.meeuwissen at avasys.jp
Thu Feb 20 23:33:49 UTC 2014


m. allan noah writes:

> Some scanners have a serial number which can be seen by software. Some
> sane backends use that serial as part of the device name. If your
> scanners or the pixma backend don't support this, you will have to
> find another way. Perhaps forcing the device name using udev or
> whatever Linux is using this week.

It just so happens that I've been looking at this about three weeks ago
for a third party backend.  The scanners this backend should support
have varying degrees of serial number support:

 - not at all
 - at the USB level only
 - at the device protocol level only
 - at both USB and device protocol level only

I wanted/needed to be able to support all of the above, even the case
where there is *no* serial number support at all.  With libusb-1.0 this
is possible (at least on a recent enough Linux system) using the

  libusb_get_bus_number()

and

  libusb_get_device_address()

API.  When using libusb-1.0.12 or later you can also use

  libusb_get_port_number()

With a USB device hooked up to my machine, lsusb -t shows:

  /:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/6p, 480M
      |__ Port 5: Dev 26, If 0, Class=Vendor Specific Class, Driver=, 480M

Inserting a USB hub between the two, this changes to:

  /:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/6p, 480M
      |__ Port 5: Dev 27, If 0, Class=Hub, Driver=hub/4p, 480M
          |__ Port 4: Dev 28, If 0, Class=Vendor Specific Class, Driver=, 480M

The device number (Dev) changes every time you reconnect the USB cable
(or power cycle the device) but bus and port numbers don't change (but
they might upon a reboot).

> On Thu, Feb 20, 2014 at 1:47 AM, Joel Penner <joelcpenner at gmail.com> wrote:
>> I have two CanoScan 9000f scanners that I'm using for a time-lapse scanner
>> photography project. How do I tell two instances of scanimage to each use
>> their own 9000f scanner on the same raspberry pi using the -device flag?
>> Using sane-find-scanner to find an ID of connected scanners generates the
>> same ID for both, non-surprisingly.

Hope this helps,
-- 
Olaf Meeuwissen, LPIC-2           FLOSS Engineer -- AVASYS CORPORATION
FSF Associate Member #1962               Help support software freedom
                 http://www.fsf.org/jf?referrer=1962



More information about the sane-devel mailing list