Set initial baudrate on correct interface instead of always the first one (Thimo...
authorThimo Eichstaedt <abc@digithi.de>
Tue, 3 Nov 2009 16:39:21 +0000 (17:39 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Tue, 3 Nov 2009 16:39:21 +0000 (17:39 +0100)
From libftdi mailinglist mail:
1) in ftdi_usb_open_dev() the baudrate is set to 9600, but that is done
too early (before the interface is set). So the baudrate of the first
interface is always modified, even if you opened a different one.

src/ftdi.c

index 9f12c41..d2c4a11 100644 (file)
@@ -454,12 +454,6 @@ int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct usb_device *dev)
         ftdi_error_return(-6, "ftdi_usb_reset failed");
     }
 
-    if (ftdi_set_baudrate (ftdi, 9600) != 0)
-    {
-        ftdi_usb_close_internal (ftdi);
-        ftdi_error_return(-7, "set baudrate failed");
-    }
-
     // Try to guess chip type
     // Bug in the BM type chips: bcdDevice is 0x200 for serial == 0
     if (dev->descriptor.bcdDevice == 0x400 || (dev->descriptor.bcdDevice == 0x200
@@ -489,6 +483,12 @@ int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct usb_device *dev)
             break;
     }
 
+    if (ftdi_set_baudrate (ftdi, 9600) != 0)
+    {
+        ftdi_usb_close_internal (ftdi);
+        ftdi_error_return(-7, "set baudrate failed");
+    }
+
     ftdi_error_return(0, "all fine");
 }