[sane-devel] Identifying identical scanners dynamically turned on and off

Olaf Meeuwissen olaf.meeuwissen at avasys.jp
Sun Mar 25 23:06:37 UTC 2012


Martin Zackrisson <martin.zackrisson at cmb.gu.se> writes:

> On 03/23/2012 12:37 AM, Olaf Meeuwissen wrote:
>> These days the USB devices stay at the same place below /sys/ even
>> when power cycled. Only when replugging to a *different* USB port
>> will this location change. I'm not sure what happens when you
>> reboot. Assuming that you know which scanner shows up where in
>> /sys/, you can then use the busnum and devnum "files" to construct
>> the device names that the epson2 backend groks. So with $ cat
>> /sys/bus/usb/devices/usb2/2-4/busnum 2 $ cat
>> /sys/bus/usb/devices/usb2/2-4/devnum 3 you'd use
>> epson2:libusb:002:003` for the device name. When power cycling, on
>> the `devnum` will change. Note that there is a libsysfs-dev package
>> which may be useful here. Hope this helps, 
> The path on my machine was similar but didn't have the files you
> specified but your guidance led to this command which gives me the
> proper addresses of all attached scanners:
>
> $ sane-find-scanner -v -v | sed -n -E 's/^found USB.*(libusb.*$)/\1/p'
>
> Thanks for the help,

If that solves your problem then fine but IIRC the sane-find-scanner
output will look like

  libusb:002:003

where the `003` will change every time you power-cycle the device.  If
all your scanners are on a different bus (the `002` part) then you are
okay but if you have two or more on the same bus ...
Let's say you have

  libusb:002:003  --> scanner A
  libusb:002:004  --> scanner B

Now your application starts and power-cycles both devices.  You will
most likely get

  libusb:002:005
  libusb:002:006

but you cannot tell anymore which one is A and which one is B.  You may
be able to work around this if the devices are power-cycled in a well
defined order with sufficiently large delays between devices.

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