From: Michael Gernoth Date: Thu, 10 Apr 2008 20:21:21 +0000 (+0200) Subject: fix usb_reset. sharing the cable between applications is still possible. X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver/commitdiff_plain/adb51cf1e775445a863fc2cc25dc9c6f408fbffb?ds=inline fix usb_reset. sharing the cable between applications is still possible. --- diff --git a/Makefile b/Makefile index 1575da5..de3216d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ #Add -DFORCE_PC3_IDENT to CFLAGS to force the identification of #a Parallel Cable III -#Add -DNO_USB_RESET to disable the hard reset of the cable on -#close of the device +#Add -DNO_USB_RESET to disable the hard reset of the cable when +#opening the device CFLAGS=-Wall -fPIC -DUSB_DRIVER_VERSION="\"$(shell stat -c '%y' usb-driver.c |cut -d\. -f1)\"" #-DFORCE_PC3_IDENT -DNO_USB_RESET LIBS=-ldl -lusb -lpthread diff --git a/usb-driver.c b/usb-driver.c index a0524bf..942cdc1 100644 --- a/usb-driver.c +++ b/usb-driver.c @@ -450,8 +450,15 @@ static int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { ret = (*ioctl_func) (fd, request, wdioctl); #else if (usbdevice) { - if (!usb_devhandle) + if (!usb_devhandle) { usb_devhandle = usb_open(usbdevice); +#ifndef NO_USB_RESET + if (usb_devhandle) { + usb_reset(usb_devhandle); + usb_devhandle = usb_open(usbdevice); + } +#endif + } usbinterface = usbdevice->config[0].interface[usi->dwInterfaceNum].altsetting[usi->dwAlternateSetting].bInterfaceNumber; usbalternate = usi->dwAlternateSetting;