Home/Support/Support Forum/Wait for user input with timeout (serial console) Digi Connect ME9210
New and improved user forum site coming soon
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Wait for user input with timeout (serial console) Digi Connect ME9210

0 votes
I've a Digi Connect ME9210 connected via serial console for debugging things. After boot I want to wait for 1-2s to give the user a chance to Enter some key (dont matter what key). After 1-2s without any key the programm must continues. How could I do this? scanf wait forever.
asked Mar 23 in NET+OS by ottelo New to the Community (3 points)

Please log in or register to answer this question.

2 Answers

0 votes
 
Best answer
it is already implemented in the serial dialog. When the board boots it displays a dialog and waits 5 seconds for a key press. Just look in dialog.c and do the same.
answered Mar 23 by LeonidM Veteran of the Digi Community (4,490 points)
selected Mar 29 by ottelo
0 votes
I copied the code from dialog.c -> checkKeyboardInput()

and put it into applicationStart(). But the function hangs until I enter a key.


The function content is:

static char waitForUserInputWithTimeout(unsigned long timeout)
{
unsigned int i;
char rc=0xff;

for (i=0; i < timeout; i++)
{
tx_thread_sleep(BSP_TICKS_PER_SECOND);
rc=0;
rc= (char) getchar();
if ((rc != 0xff) && (rc != '\n'))
return (rc);
}
return (rc);
}/* waitForUserInputWithTimeout */
answered Apr 5 by ottelo New to the Community (3 points)
...