I noticed a problem using version 1.3.1 of the ftdi_sio driver
<http://prdownloads.sourceforge.net/ftdi-usb-sio/ftdi_sio-1.3.1.tar.gz?download>
when the FTDI USB to serial converter (I have tried FT8U232AM and
FT232BM) is connected to a UHCI hub using the "alternate" UHCI
driver (uhci.o).

The problem occurs when performing a large write to the serial port,
e.g. using the following program:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#define BLOCKSIZE 65536

int main(int argc, char **argv)
{
        char *name;
        int fd;
        struct termios termios;
        unsigned char *block;
        size_t total_written;
        ssize_t writ;
        int numwrites;

        if (argc != 2) {
                fprintf(stderr, "usage: xxx device\n");
                return 2;
        }
        name = argv[1];
        fd = open(name, O_WRONLY);
        if (fd < 0) {
                perror(name);
                return 1;
        }
        tcgetattr(fd, &termios);
        cfmakeraw(&termios);
        termios.c_cflag &= ~CRTSCTS;
        termios.c_cflag |= CLOCAL;
        cfsetospeed(&termios, B38400);
        cfsetispeed(&termios, 0);
        tcsetattr(fd, TCSANOW, &termios);
        block = malloc(BLOCKSIZE);
        if (!block) {
                fprintf(stderr, "malloc failed\n");
                return 1;
        }
        memset(block, 0x55, BLOCKSIZE);
        numwrites = 0;
        for (total_written = 0; total_written < BLOCKSIZE; total_written++) 
{
                writ = write(fd, block+total_written, BLOCKSIZE - total_written);
                if (writ < 0) {
                        perror("write");
                        break;
                }
                total_written += writ;
                printf("%d: %ld (%lu)\n", numwrites, writ, total_written);
                numwrites++;
        }
        tcdrain(fd);
        close(fd);
        printf("Number of writes was %d\n", numwrites);
        
        return 0;
}

Serial port activity stops when the ftdi_sio driver runs out of URBs
(it has a pool of 32 urbs for writing to the serial port). For some
reason, the driver no longer gets write bulk callbacks. The program
is stuck waiting for the write to complete.

If the program is killed, closing the serial port, it seems that the
characters in all those write urbs finally get transmitted and the
driver finally gets its 32 write bulk callbacks.

If I repeat the test using the normal UHCI driver (usb-uhci) this 
problem does not occur.  Also if I connect the FTDI serial 
converter to an OHCI hub using the usb-ohci driver, the problem 
does not occur.

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <[EMAIL PROTECTED]>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to