libftdi-git Archives

Subject: A library to talk to FTDI chips branch, master, updated. v0.16-16-ga56ba2b

From: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
To: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 3 Nov 2009 17:55:49 +0100 (CET)
The branch, master has been updated
       via  a56ba2bd557e7c7804b288aee2dcc42c8037b03c (commit)
      from  1416eb1443005be219a8f76b6f05bff947ccce4a (commit)


- Log -----------------------------------------------------------------
commit a56ba2bd557e7c7804b288aee2dcc42c8037b03c
Author: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date:   Tue Nov 3 17:54:47 2009 +0100

    Fix usb_set_configuration() call on Windows 64.
    
    Based upon idea/findings by "NIL".

-----------------------------------------------------------------------

Summary of changes:
 src/ftdi.c |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index 5d6a221..d7f4bb0 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -400,6 +400,7 @@ int ftdi_usb_get_strings(struct ftdi_context * ftdi, struct 
usb_device * dev,
 int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct usb_device *dev)
 {
     int detach_errno = 0;
+    int config_val = 1;
     if (!(ftdi->usb_dev = usb_open(dev)))
         ftdi_error_return(-4, "usb_open() failed");
 
@@ -419,18 +420,25 @@ int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct 
usb_device *dev)
     // set configuration (needed especially for windows)
     // tolerate EBUSY: one device with one configuration, but two interfaces
     //    and libftdi sessions to both interfaces (e.g. FT2232)
-    if (dev->descriptor.bNumConfigurations > 0 &&
-            usb_set_configuration(ftdi->usb_dev, 
dev->config[0].bConfigurationValue) &&
-            errno != EBUSY)
+
+    if (dev->descriptor.bNumConfigurations > 0)
     {
-        ftdi_usb_close_internal (ftdi);
-        if (detach_errno == EPERM)
-        {
-            ftdi_error_return(-8, "inappropriate permissions on device!");
-        }
-        else
+        // libusb-win32 on Windows 64 can return a null pointer for a valid 
device
+        if (dev->config)
+            config_val = dev->config[0].bConfigurationValue;
+
+        if (usb_set_configuration(ftdi->usb_dev, config_val) &&
+            errno != EBUSY)
         {
-            ftdi_error_return(-3, "unable to set usb configuration. Make sure 
ftdi_sio is unloaded!");
+            ftdi_usb_close_internal (ftdi);
+            if (detach_errno == EPERM)
+            {
+                ftdi_error_return(-8, "inappropriate permissions on device!");
+            }
+            else
+            {
+                ftdi_error_return(-3, "unable to set usb configuration. Make 
sure ftdi_sio is unloaded!");
+            }
         }
     }
 #endif


hooks/post-receive
-- 
A library to talk to FTDI chips

--
libftdi-git - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread
  • A library to talk to FTDI chips branch, master, updated. v0.16-16-ga56ba2b, libftdi-git <=