[sane-devel] Timeouts: usb_reset seems necessary to avoid bulk
timeouts.
Tom Schutzer-Weissmann
misc@tomweissmann.org
Fri, 11 Jun 2004 14:21:16 +0100
On Fri, 11 Jun 2004 13:50:39 +0900
Olaf Meeuwissen <olaf@epkowa.co.jp> wrote:
[...]
> Problem confirmed for the GT-9700 (aka Perfection 2450) with both the
> epson and epkowa backends. Note that these same backends work fine
> with the GT-8200 (aka Perfection 1650) under identical conditions.
>
> Just starting a SANE frontend (tried with xsane and iscan) with the
> GT-9700 already takes "ages" and it just refuses to preview.
Aha. That's not at all what I expected - many apologies to any slighted libusb developer!
Like I said, you can get it to work by calling usb_reset() whenever the scanner device is closed. My hacked code for sanei_usb_close() (in sanei/sanei_usb.c) is below.
I hope you don't need it :)
> Looks like Karl and/or I have some digging to do ;-(
Maybe. It would be very interesting to know what's wrong. Is it perhaps that the scanner needs to be send a message before it is closed.
Many thanks,
Tom
-----------------------------------------------------------
-----------------------------------------------------------
void
sanei_usb_close (SANE_Int dn)
{
DBG (5, "sanei_usb_close: closing device %d\n", dn);
if (dn >= MAX_DEVICES || dn < 0)
{
DBG (1, "sanei_usb_close: dn >= MAX_DEVICES || dn < 0\n");
return;
}
if (!devices[dn].open)
{
DBG (1, "sanei_usb_close: device %d already closed or never opened\n",
dn);
return;
}
if (devices[dn].method == sanei_usb_method_scanner_driver)
close (devices[dn].fd);
else
#ifdef HAVE_LIBUSB
{
#if 0
/* Should only be done in case of a stall */
usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_in_ep);
usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_out_ep);
/* be careful, we don't know if we are in DATA0 stage now */
usb_resetep(devices[dn].libusb_handle, devices[dn].bulk_in_ep);
usb_resetep(devices[dn].libusb_handle, devices[dn].bulk_out_ep);
#endif
/* HACK FOR PERFECTION 2450 */
usb_reset(devices[dn].libusb_handle) ;
usb_release_interface (devices[dn].libusb_handle,
devices[dn].interface_nr);
usb_close (devices[dn].libusb_handle);
}
#else
DBG (1, "sanei_usb_close: libusb support missing\n");
#endif
devices[dn].open = SANE_FALSE;
return;
}
------------------------------------------------------------------
------------------------------------------------------------------