Hi Juha, Calling FD_SET(fd, &rset) after timeout solves the problem. Thanks for your help.
Daniel Pereira de Carvalho Em sex., 20 de nov. de 2020 às 14:41, Juha Niskanen (Haltian) < juha.niska...@haltian.com> escreveu: > From POSIX: "If the timeout interval expires without the specified > condition being true for any of the specified file descriptors, the objects > pointed to by the readfds, writefds, and errorfds arguments shall have all > bits set to 0." > > If your select() timeouts on first loop iteration for any reason, then it > will timeout forever as you give it back all-zeroes descriptor set to > monitor. > > Best Regards, > Juha Niskanen > > > ________________________________ > From: Daniel Pereira Carvalho <daniel...@gmail.com> > Sent: Friday, November 20, 2020 7:26 PM > To: dev@nuttx.apache.org <dev@nuttx.apache.org> > Subject: Re: select()/pselect() function > > I will try pool() and see if the problem persists. > > Thanks > > Daniel Pereira de Carvalho > > > Em sex., 20 de nov. de 2020 às 14:18, Gregory Nutt <spudan...@gmail.com> > escreveu: > > > Okay, I got that wrong. I seldom used select(), it is just an > > additional layer on top of poll() which is much more efficient. > > > > On 11/20/2020 11:13 AM, Daniel Pereira Carvalho wrote: > > > Hi Greg, > > > > > > Thanks for the answer. I don't understand why I should use 1 instead of > > > fs + 1. The documentation says > > > > > > "nfds This argument should be set to the highest-numbered file > descriptor > > > in any of the three sets, plus 1. " > > > > > > In the portserial.c nfds was set to fd + 1 > > > > > > Daniel Pereira de Carvalho > > > > > > > > > Em sex., 20 de nov. de 2020 às 14:04, Gregory Nutt < > spudan...@gmail.com> > > > escreveu: > > > > > >>> fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY); > > >> ... > > >>> s_rc = select(fd + 1, &rset, NULL, NULL, &tv); > > >> The first argument should be 1, not fd + 1 > > >> > > >> > > >> > > >