libftdi Archives

Subject: patch to libftdi-1.0 git head, fix opening of multiple devices

From: derRolf@xxxxxxxxxxxxxx
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Thu, 17 Jan 2013 08:06:15 +0100
Hello,

I had sent this patch again at the end of last year. It is needed to open 
multiple devices from a single process. The problem is that when in the list of 
devices a device at the start of the list has already been opened, the reading 
of device parameters for the already opened device fails. Currently the list is 
then not traversed any further and open returns with an error. The patch 
changes that so the list of devices is searched for the device to open until 
the list end.

Please apply or comment.

Rolf

>From 96efe597d9848609a6e8528450bd5317702cc752 Mon Sep 17 00:00:00 2001
From: Rolf Fiedler <derRolf@xxxxxxxxxxxxxx>
Date: Tue, 15 Jan 2013 11:17:36 +0100
Subject: [PATCH] add support to find and open multiple devices from same
 process

---
 src/ftdi.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index 92190a0..af7a573 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -717,8 +717,9 @@ int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int 
vendor, int product,
             {
                 if (libusb_get_string_descriptor_ascii(ftdi->usb_dev, 
desc.iProduct, (unsigned char *)string
                 {
-                    ftdi_usb_close_internal (ftdi);
-                    ftdi_error_return_free_device_list(-8, "unable to fetch 
product description", devs);
+                   ftdi_usb_close_internal (ftdi);
+                   continue; // try next device, this may already have been 
opened
+                    //ftdi_error_return_free_device_list(-8, "unable to fetch 
product description", devs);
                 }
                 if (strncmp(string, description, sizeof(string)) != 0)
                 {
@@ -731,7 +732,8 @@ int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int 
vendor, int product,
                 if (libusb_get_string_descriptor_ascii(ftdi->usb_dev, 
desc.iSerialNumber, (unsigned char *)s
                 {
                     ftdi_usb_close_internal (ftdi);
-                    ftdi_error_return_free_device_list(-9, "unable to fetch 
serial number", devs);
+                   continue; // try next device, this may already have been 
opened
+                    //ftdi_error_return_free_device_list(-9, "unable to fetch 
serial number", devs);
                 }
                 if (strncmp(string, serial, sizeof(string)) != 0)
                 {
-- 
1.7.10.2 (Apple Git-33) 

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

Current Thread