# USB Serial port FTDI works very slow, FreeBSD 8.2



## Radiolab (May 8, 2011)

Hello,

Please help me on following case:

FreeBSD 8.2-STABLE, kernel and world build from cvs RELENG_8.

Kernel options:


```
device      uftdi
device      ucom
device      uart
device      puc
```

PC has installed hardware - motherboard serial port, multiport board based on Oxford chip, FTDI FT232BM usb serial port.

Problem: when I use FTDI port, it works very slow - opening, setting parameters, especially writing. Motherboard serial port and Oxford work fine. 

My serial port code based on this manual. 

Here parts of code I'm using:

```
...

//open serial device
fdCOM = open (port, O_RDWR | O_NOCTTY | O_NONBLOCK);

....

//set params, flush buf
tcgetattr (fdCOM, &oldtioA);
bzero (&newtioA, sizeof (newtioA));
newtioA.c_cflag = CS8 | CLOCAL | CREAD;
newtioA.c_iflag = IGNPAR;
newtioA.c_oflag = 0;
newtioA.c_lflag = 0;
newtioA.c_cc[VTIME] = 0;
newtioA.c_cc[VMIN] = 1;
cfsetispeed (&newtioA, BAUDRATE);
cfsetospeed (&newtioA, BAUDRATE);
tcsetattr (fdCOM, TCSANOW, &newtioA);
tcflush (fdCOM, TCIFLUSH);

...

//writing
write(fdCOM, buf, 4);
tcdrain(fdCOM);
```


So, the time between write and return from tcdrain is about 700ms! And this time doesn't depend on baudrate or number of written  bytes.


----------

