From e5193fdcae64a6c06a7fa2ce61206fd897e0173c Mon Sep 17 00:00:00 2001 From: Rene Rebe Date: Fri, 15 Jul 2005 09:02:02 +0000 Subject: [PATCH] Added support to set the USB timeout. --- ChangeLog | 6 ++++++ include/sane/sanei_usb.h | 9 ++++++++- sanei/sanei_usb.c | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b70a23617..b745e2b49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ + +2005-07-15 Rene Rebe + + * include/sane/sanei_usb.h sanei/sanei_usb.c: Added support to set + the USB timeout. + 2005-07-10 Henning Meier-Geinitz * backend/gt68xx.c backend/gt68xx_devices.c diff --git a/include/sane/sanei_usb.h b/include/sane/sanei_usb.h index 988bcd15a..9ee3d6778 100644 --- a/include/sane/sanei_usb.h +++ b/include/sane/sanei_usb.h @@ -1,5 +1,5 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2003 Rene Rebe (sanei_read_int) + Copyright (C) 2003, 2005 Rene Rebe (sanei_read_int,sanei_set_timeout) Copyright (C) 2001, 2002 Henning Meier-Geinitz This file is part of the SANE package. @@ -229,6 +229,13 @@ extern SANE_Status sanei_usb_open (SANE_String_Const devname, SANE_Int * dn); */ extern void sanei_usb_close (SANE_Int dn); +/** Set the libusb timeout for bulk and interrupt reads. + * + * @param timeout the new timeout in ms + */ +#define HAVE_SANEI_USB_SET_TIMEOUT +extern void sanei_usb_set_timeout (SANE_Int timeout); + /** Initiate a bulk transfer read. * * Read up to size bytes from the device to buffer. After the read, size diff --git a/sanei/sanei_usb.c b/sanei/sanei_usb.c index 0bf52956d..567d7dba1 100644 --- a/sanei/sanei_usb.c +++ b/sanei/sanei_usb.c @@ -1,5 +1,5 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2003 Rene Rebe (sanei_read_int) + Copyright (C) 2003 Rene Rebe (sanei_read_int,sanei_set_timeout) Copyright (C) 2001 - 2003 Henning Meier-Geinitz Copyright (C) 2001 Frank Zago (sanei_usb_control_msg) This file is part of the SANE package. @@ -108,7 +108,7 @@ device_list_type; static device_list_type devices[MAX_DEVICES]; #ifdef HAVE_LIBUSB -static int libusb_timeout = 30 * 1000; /* 30 seconds */ +static int libusb_timeout = 30 * 1000; /* 5 seconds was 30 * 1000 */ #endif /* HAVE_LIBUSB */ #if defined (__linux__) @@ -913,6 +913,16 @@ sanei_usb_close (SANE_Int dn) return; } +void +sanei_usb_set_timeout (SANE_Int timeout) +{ +#ifdef HAVE_LIBUSB + libusb_timeout = timeout; +#else + DBG (1, "sanei_usb_close: libusb support missing\n"); +#endif /* HAVE_LIBUSB */ +} + SANE_Status sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size) {