libftdi Archives

Subject: [Resent/Corrected] Interface can not be changed on an already open device

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 4 Oct 2011 14:37:48 +0200
The last patch had errors. Please use this one
-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
>From 1d2277ee0698bd695e84535354a647bdee861d1a Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 30 Sep 2011 12:44:14 +0200
Subject: Interface can not be changed on an already open device

---
 src/ftdi.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index 1f45e95..64c06eb 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -149,12 +149,20 @@ struct ftdi_context *ftdi_new(void)
     \retval  0: all fine
     \retval -1: unknown interface
     \retval -2: USB device unavailable
+    \retval -3: Device already open, Interface can't be set in that state
 */
 int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface 
interface)
 {
     if (ftdi == NULL)
         ftdi_error_return(-2, "USB device unavailable");
 
+    if (ftdi->usb_dev != NULL)
+    {
+        if ((ftdi->index != interface) && ((ftdi->index == INTERFACE_A) && 
(interface !=  INTERFACE_ANY)))
+            
+            ftdi_error_return(-3, "Interface can not be changed on an already 
open device");
+    }
+
     switch (interface)
     {
         case INTERFACE_ANY:
-- 
1.7.3.4


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

Current Thread