From adb51cf1e775445a863fc2cc25dc9c6f408fbffb Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Thu, 10 Apr 2008 22:21:21 +0200 Subject: [PATCH] fix usb_reset. sharing the cable between applications is still possible. --- Makefile | 4 ++-- usb-driver.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) 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; -- 2.39.2