Package: libsane
Version: 1.0.25-2
Severity: normal
Tags: patch

Dear Maintainer,

I have a Canon Canoscan N650U. It uses the 'plustek' USB sane backend.

When I upgraded my laptop, sane stopped working. sane_find_scanner would find
my Canoscan, but scanimage -L would hang for a long time (maybe 20 seconds) and
then fail, reporting no scanners found. If I ran scanimage -L again, it would
fail immediately. If I unplugged and restored the USB cable, the first scenario
occurred again. (xsane and the GIMP plugin also had the long pause, but would
usually eventually show the device as detected. However, any attempt to access
it caused an I/O error to be reported.)

With SANE_DEBUG_SANEI_USB set, I could see that six bulk writes of 4 or 5 bytes
each would succeed, but the seventh would return "Resource temporarily
unavailable". However, the code did not catch the error, leading to many more
failed writes, and hence the long delay.

After much experimentation, (at first I thought it was the device going to
sleep with autosuspend) I found a hack that would work: a delay before the call
to libusb_bulk_write.

Clearly, that's not a proper solution, but it's a workaround for me. I reduced
the timeout gradually to 50 microseconds, but gave up reducing it at that
point.

A diff of my hack is as follows (against source of sane-backends-1.0.25):

$ diff sanei_usb.c sanei_usb.c.orig
87,88d86
<
<
2416,2419d2413
<   struct timespec sleepytime, sleepyremain;
<
<   sleepytime.tv_nsec = 50000L; /* nanoseconds */
<   sleepytime.tv_sec  = 0;
2450,2451d2443
<         nanosleep(&sleepytime, &sleepyremain);        /* sg */
<
2456c2448
<         if (write_size <= 0)
---
>         if (write_size < 0)



-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.4.0-fuji (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_IE.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages libsane depends on:
ii  acl                2.2.51-8
ii  adduser            3.113+nmu3
ii  libavahi-client3   0.6.31-4
ii  libavahi-common3   0.6.31-4
ii  libc6              2.19-7
ii  libexif12          0.6.21-1
ii  libgphoto2-6       2.5.2-2
ii  libgphoto2-port12  2.5.9-2
ii  libieee1284-3      0.2.11-10
ii  libjpeg62-turbo    1:1.3.1-10
ii  libsane-common     1.0.25-2
ii  libtiff5           4.0.3-5
ii  libusb-1.0-0       2:1.0.20-1
ii  makedev            2.3.1-93
ii  udev               204-10

Versions of packages libsane recommends:
pn  libsane-extras  <none>
ii  sane-utils      1.0.25-2

Versions of packages libsane suggests:
pn  avahi-daemon  <none>
pn  hplip         <none>

-- no debconf information

Reply via email to