This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Select() issues


Does tcflush(fd,TCIOFLUSH) actually work?

I did a few tests, removing the code for modifying the terminal
attributes and find that I pass straight through select, if I
had hit a few enters before getting to the tcflush statement.

Andre

On 9-Jan-07, at 15:21 , Andre-John Mas wrote:

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]