From ef6f483889aa3d719a676f7f32303c4232941e57 Mon Sep 17 00:00:00 2001 From: Thimo Eichstaedt Date: Tue, 3 Nov 2009 17:39:21 +0100 Subject: [PATCH] Set initial baudrate on correct interface instead of always the first one (Thimo Eichstaedt) 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 | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ftdi.c b/src/ftdi.c index 9f12c41..d2c4a11 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -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"); } -- 1.7.1