Hi there!

I'm sorry for imprecise subject, but I really have no clue how to describe
shortly...

My setup is IGEPv2 board with DM3730 SoC which has usb device connected
on EHCI controler via hub running linux-4.6. This device acts as serial-usb
converter and feeds IGEP with data. After some time some IGEPs are unable
to read data from ttyACM0, select claims no data are available, although
device is still transmitting. After ttyACM0 is closed and reopened, there
are those data available device sent while port was closed - no more data
are read, those device transmitted since port was opened and read after
next close and reopen. No other process has ttyACM0 opened.
To test above behaviour:

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

int main(int argc, char *argv[])
{
        int fd;
        struct termios tio;

        fd = open("/dev/ttyACM0", O_CLOEXEC | O_NOCTTY | O_RDWR);
        if (fd == -1) {
                printf("open (%d): %s\n", errno, strerror(errno));
                return EXIT_FAILURE;
        }

        memset(&tio, 0, sizeof (struct termios));
        if (tcgetattr(fd, &tio) != 0) {
                printf("tcgetattr (%d): %s\n", errno, strerror(errno));
                return EXIT_FAILURE;
        }
        cfsetspeed(&tio, B115200);
        cfmakeraw(&tio);
        tio.c_cflag |= CLOCAL | CREAD;
        tio.c_cc[VMIN] = 1;
        tio.c_cc[VTIME] = 0;
        if (tcsetattr(fd, TCSANOW, &tio) != 0) {
                printf("tcgetattr (%d): %s\n", errno, strerror(errno));
                return EXIT_FAILURE;
        }

        while (1) {
                char buf[4096];
                ssize_t l = read(fd, buf, sizeof(buf) - 1);
                switch (l) {
                case -1:
                        printf("read %d: %s\n", errno, strerror(errno));
                        return EXIT_FAILURE;
                case 0:
                        printf("empty read?\n");
                        continue;
                default:
                        buf[l] = '\0';
                        printf("%s", buf);
                        break;
                }
        }

        return EXIT_SUCCESS;
}

Once ttyACM0 starts behave strangely, read() returns only what's in buffer 
before
ttyACM0 was opened and then hangs infinitely. As this bug is hard to trigger, 
has
anyone clue where to start debugging?

thank you,
        ladis
--
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