From: Thimo Eichstaedt Date: Tue, 3 Nov 2009 16:39:21 +0000 (+0100) Subject: Set initial baudrate on correct interface instead of always the first one (Thimo... X-Git-Tag: v0.17~27 X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=commitdiff_plain;h=ef6f483889aa3d719a676f7f32303c4232941e57;hp=8af5bbc7a631bd63e9f3c3d0f702c1cfe6a27196 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. --- 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"); }