Re: problem with select() - 2.4.5

From: Thomas Speck (Thomas.Speck@univ-rennes1.fr)
Date: Fri Jun 22 2001 - 14:53:05 EST


On Fri, 22 Jun 2001, Thomas Speck wrote:

>
> Hi !
> I have a problem with reading from a serial port using select() under
> 2.4.5. What I am doing is basically the following:
>
> fd_set readfds;
> struct timeval timeout;
> int s;
>
> serialfd = open("/dev/ttyS0", O_RDWR );
>
> init_serial(B9600);
>
> timeout.tv_sec = 2; /* ! */
> timeout.tv_usec = 0;
> FD_ZERO(&readfds);
> FD_SET(serialfd,&readfds);
>
> s=select(serialfd+1, &readfds, NULL, NULL, &timeout);
> ...
>
> But s is always equal to 0 even when I am sure there are data to read.
> If I use
>
> s=select(serialfd+1, NULL, &writefds, NULL, &timeout);
>
> (with the corresponding initialisation of writefds) it returns s=1 and I
> can write to the serial port. I can see that since the lights of the modem
> are flashing.
> I noticed that behavior since I tried to send some "ATZ" with the
> write-function but I never got the "OK" back.
>
> However, the same programme works under 2.2.19.

Probably I should have given the init_serial() as well; So here it is:
(it is basically the one from the serial-programming-howto)

int init_serial(tcflag_t baud)
{
        struct termios tio;
        tcgetattr(serialfd,&tio);
        tio.c_cflag = baud | CLOCAL;
        tio.c_iflag = IGNPAR;
        tio.c_oflag = 0;
        tio.c_lflag = 0;
        tio.c_cc[VTIME] = 0;
        tio.c_cc[VMIN] = 1;
        tcflush(serialfd, TCIFLUSH);
        tcsetattr(serialfd,TCSANOW,&tio);
        return 0;
}

Thank you for any help

--
Thomas

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jun 23 2001 - 21:00:39 EST