libftdi Archives

Subject: Issues in libftdi 0.16 and some solutions inside.

From: "Thimo E." <abc@xxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 10 Jul 2009 21:03:26 +0200
Dear all,

I am using libftdi 0.16 with a FT2232H and found some issues:

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.

2) in ftdi_convert_baudrate() the index is set in dependance of the chiptype. You should check not only for 2232C but for 2232H and 4232H, too. Otherwise you always modify the baudrate of the first interface on those chips, even if you wanted to change it for the second, third, .. interface on *232H chips.

3) The high-speed *232H chips use a packet size of 512 byte if they are connected to a high speed (USB 2.0) bus. But these chips can also be used on USB 1.1 busses and here the packet_size is 64 byte, like the old FTDI chips. This leads to corrupt received data.

Please find the attached patch which resolves issues 1) and 2).
Perhaps you'll find a good solution for for problem 3...

Best regards
 Thimo E.


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   
--- ftdi.c.orig 2009-05-06 17:34:19.000000000 +0200
+++ ftdi.c      2009-07-08 15:37:28.000000000 +0200
@@ -429,12 +429,6 @@
         ftdi_error_return(-6, "ftdi_usb_reset failed");
     }
 
-    if (ftdi_set_baudrate (ftdi, 9600) != 0)
-    {
-        usb_close (ftdi->usb_dev);
-        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
@@ -450,6 +444,12 @@
         ftdi->type = TYPE_2232H;
     else if (dev->descriptor.bcdDevice == 0x800)
         ftdi->type = TYPE_4232H;
+        
+    if (ftdi_set_baudrate (ftdi, 9600) != 0)
+    {
+        usb_close (ftdi->usb_dev);
+        ftdi_error_return(-7, "set baudrate failed");
+    }
 
     // Set default interface on dual/quad type chips
     switch(ftdi->type)
@@ -794,7 +794,7 @@
     }
     // Split into "value" and "index" values
     *value = (unsigned short)(encoded_divisor & 0xFFFF);
-    if (ftdi->type == TYPE_2232C)
+    if (ftdi->type == TYPE_2232C || ftdi->type == TYPE_2232H || ftdi->type == 
TYPE_4232H)
     {
         *index = (unsigned short)(encoded_divisor >> 8);
         *index &= 0xFF00;

Current Thread
  • Issues in libftdi 0.16 and some solutions inside., Thimo E. <=