Hi Denis,
On Thursday, 15. May 2014 15:25:26 Denis Sirotkin wrote:
> I suppose that this is because there is call get_strings_and_reopen()
> which calls ftdi_usb_get_strings() which calls libusb_open() for already
> opened device. A solution may be to call ftdi_usb_close_internal() from
> ftdi_usb_get_strings() function before reopen it or to check if it is
> already opened and don't open twice. I tried both but prefer second and
> simple do like this:
>
> --- libftdi1-1.1/src/ftdi.c.orig 2014-02-05 22:24:11.000000000 +0600
> +++ libftdi1-1.1/src/ftdi.c 2014-05-15 14:42:13.534444380 +0600
> @@ -413,8 +413,9 @@
> if ((ftdi==NULL) || (dev==NULL))
> return -1;
>
> - if (libusb_open(dev, &ftdi->usb_dev) < 0)
> - ftdi_error_return(-4, "libusb_open() failed");
> + if (ftdi->usb_dev == NULL)
> + if (libusb_open(dev, &ftdi->usb_dev) < 0)
> + ftdi_error_return(-4, "libusb_open() failed");
>
> if (libusb_get_device_descriptor(dev, &desc) < 0)
> ftdi_error_return(-11, "libusb_get_device_descriptor() failed");
I've commited an almost identical fix on your behalf. Thanks!
It's quite a "brain puzzle" to follow the call stack from all the layers,
but your solution looks correct to me :)
Cheers,
Thomas
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|