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

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.

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.

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 != ’
'))
return (rc);
}
return (rc);
}/* waitForUserInputWithTimeout */