[ECOS] Select() issues

Andre-John Mas ajmas@sympatico.ca
Tue Jan 9 20:21:00 GMT 2007


Hi,

We have a solution working on the AdderII platform, using eCos.
One component of the application is a serial terminal, with
termios support. While putting the UI through its paces we
came across a small issue:

If we hit enter a number of times prior to the first select()
call, select() does not return when a key is pressed. I
thought that it could be to a full UART buffer, but trying

cin.ignore()

or

tcflush(fd,TCIOFLUSH)

prior to the select does not fix the issue.

My code looks something as follows:

   struct termios ts, ots; /* termios setting, old termios setting */
   int            fd = STDIN_FILENO;
   struct timeval tv;
   struct timeval *tvPtr = NULL;

   tcgetattr( fd, &ts );
   ots = ts;
   ts.c_flag &= ~(ICANON);
   tcsetattr(fd, TCSAFLUSH, &ts);

   if ( this->timeout > -1 )
   {
       tv.tv_sec = this->timeout;
       tv.tv_usec = 0;
       tvPtr = &tv;
   }

   FD_ZERO( &fds );
   FD_SET( STDIN_FILENO, &fds );

   int result = select(fd + 1, &fds, NULL, NULL, tvPtr);

Am I missing something? Any help would be appreciated.

Andre



-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list