Properly set the interface to be used for libftdi variant of the ft2232
driver.

Signed-off-by: Michael Walle <[email protected]>
---
 urjtag/src/tap/usbconn/libftdi.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/urjtag/src/tap/usbconn/libftdi.c b/urjtag/src/tap/usbconn/libftdi.c
index 5232452..6daee8b 100644
--- a/urjtag/src/tap/usbconn/libftdi.c
+++ b/urjtag/src/tap/usbconn/libftdi.c
@@ -359,6 +359,22 @@ usbconn_ftdi_common_open (urj_usbconn_t *conn, 
urj_log_level_t ll)
     struct ftdi_context *fc = p->fc;
     int status;
 
+    /* keep same interface numbers as in libftd2xx, where the index is zero
+     * based. In libfdti 0 is a special one 'ANY' and the index is one based.
+     */
+    status = ftdi_set_interface(fc, p->interface + 1);
+    if (status < 0)
+    {
+        urj_error_set (URJ_ERROR_FTD,
+                _("%s(): ftdi_set_interface() failed: %s"),
+                __func__, ftdi_get_error_string (fc));
+        ftdi_deinit (fc);
+        /* mark ftdi layer as not initialized */
+        p->fc = NULL;
+
+        return URJ_STATUS_FAIL;
+    }
+
     /* use command line string for desc= as serial number and try to
        open a matching device */
     status = ftdi_usb_open_desc (fc, p->vid, p->pid, NULL, p->serial);
-- 
1.7.2.3


------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
UrJTAG-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/urjtag-development

Reply via email to