[sane-devel] Timeouts: usb_reset seems necessary to avoid bulk timeouts.

Olaf Meeuwissen olaf@epkowa.co.jp
Tue, 15 Jun 2004 13:31:18 +0900

Hi Tom,

Henning Meier-Geinitz <henning@meier-geinitz.de> writes:

> Hi,
> On Wed, Jun 09, 2004 at 04:48:51PM +0100, Tom Schutzer-Weissmann wrote:
>> I had problems using the Epkowa libraries (libsane-epkowa) and the
>> iscan frontend with my usb scanner in kernel 2.6.
>> The scanner was closed after each operation. Once closed, nothing
>> could be read from it, and I got lots of BULK TIMEOUTs, although
>> there were no errors when the device was reopened.
>> By modifying the code so that usb_reset() was always called before
>> usb_release_interface() and usb_close(), I solved the problem.
> Doesn't usb_reset() cause a renumeration and therefore the device gets
> a new device file? I guess this isn't the default for closing USB
> devices. Maybe the usb_reset just hides a bug in the SANE backend,
> libusb or the kernel.

Henning is right about the re-enumeration.  As far as I understand the
docs, that means that after calling usb_reset(), you may no longer use
the handle you have.  Problem is, it *is* used twice after that call.

If the documentation is serious about this re-enumeration, than your
"fix" is incorrect and has the potential to break support for *all*
SANE supported USB devices.
That it works for you is mere coincidence.

FYI: http://libusb.sourceforge.net/doc/function.usbreset.html

That leads us to a bug in the epson/epkowa backends, quite possibly
caused by undocumented behaviour of this particular scanner.  :-(
Olaf Meeuwissen                            EPSON KOWA Corporation, PF1
FSF Associate Member #1962           sign up at http://member.fsf.org/
GnuPG key: 6BE37D90/AB6B 0D1F 99E7 1BF5 EB97  976A 16C7 F27D 6BE3 7D90
Penguin's lib!       -- I hack, therefore I am --               LPIC-2