Hello guys,
I've found a following problems on BeagleBoard and Kernel 3.0.8 with gadget serial driver.

Attached is a small program, which opens gadget serial tty at /dev/ttyGS0. USB is NOT connected to host. Then it fills it's output fifo up. Before closing, it flushes the output fifo. But despite that, call to close function on last line blocks for 15seconds!

To me it looks like fifo flushing doesn't work. If I do this on regular serial port on PC and if I remove output fifo flushing, close also blocks (as I have flow control set). But if the flushing is present, close returns immediately on PC.

On gadget serial, it always block for 15s.

So it looks to me like a bug in gadget serial driver. Or is there any other cleanup, which I should do? Or at least some option how to lower the timeout value?

thank you and best regards

Petr Masek

////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <termios.h>
#include <fcntl.h>
#include <errno.h>

int main(void)
{
    int fd = open("/dev/ttyGS0", O_NOCTTY | O_RDWR | O_NONBLOCK);

    if (fd < 0) {
        printf("Serial device open error!\n");
        return -1;
    }

    struct termios newtio;

    bzero(&newtio,sizeof(struct termios));
newtio.c_cflag = B9600 | CS8 | CRTSCTS | CLOCAL | CREAD | NOFLSH;
    newtio.c_iflag      = IGNPAR;
    newtio.c_oflag      = 0;
    newtio.c_lflag      = 0;
    newtio.c_cc[VMIN]   = 0;
    newtio.c_cc[VTIME]  = 0;

    tcsetattr(fd,TCSANOW,&newtio);

        int ret = 0;
        while (ret >= 0) {
                const char buffer[32] = "Hello World!\n";

                ret = write(fd, buffer, strlen(buffer));
                if ((ret < 0) && (errno == EWOULDBLOCK)) printf("FIFO Full!\n");
        }

        tcflush(fd, TCOFLUSH);

    close(fd);
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to