0

Hi all,

I am receiving the keyboard read/Terminate command from the client(PC) to the Board(Windows CE) through Serial Interface. I need to terminate the character reading from Keyboard if i receive Terminate Command. Termination/Continuation is been handled inside a thread. But whenever Terminate Command comes Character reads are continuing till the EOF(Enter from keyboard), which is not desired output.

Please provide help.
Reference Code which is inside my thread.

// From main
switch(command)
{
   case 'read_keyboard': createthread(....)
   break;

   case stop read: s_terminatecode =0;
   break;
}

// keyboard Read
DWORD WINAPI ReadKeyboard( LPVOID lpParam )
{

   while(CliProtocol::s_TerminateCode)
   {
     ch = getchar();
   }
}
3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by Ketsuekiame
0
ch = getchar();
if( ch == TerminatingCharacter)
{
   // flush all remaining characters
   while( (ch = getchar()) != EOF)
      ; // do nothing
}

Edited by Ancient Dragon: n/a

0

I did not get the above code...There is nothing as TerminatingCharacter Requirement is while Reading the characters if TerminatingCommand has come, then the Read should be stopped till that character, but getchar() or gets() will read till EOF....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.