I'm working with VxWorks on the Intel platform, using a standard PC
hardware together with the PC486 BSP.
Is there any way to write a kbhit() function for the PC console?
I've tried already with ioctl() calls, but this does not seem to work.
Any idea?
TIA, Peter K.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
>Is there any way to write a kbhit() function for the PC console?
>I've tried already with ioctl() calls, but this does not seem to work.
Try this. Not tested on Intel platforms...
Harald
/***************************************************************************
* getKey
***************************************************************************/
int getKey(void)
{
int key;
int options;
/* Save options. */
options = ioctl(0, FIOGETOPTIONS, 0);
/* Enter raw mode. */
ioctl(0, FIOSETOPTIONS, OPT_TERMINAL & ~OPT_LINE & ~OPT_ECHO);
while (!(key = keyhit()))
{
taskDelay (sysClkRateGet() / 10);
} /* while !keyhit() */
/* Leave raw mode. */
ioctl(0, FIOSETOPTIONS, options);
return key;
} /* getKey */
/***************************************************************************
* keyhit
***************************************************************************/
int keyhit(void)
{
int nread = 0;
int oneChar;
/* probe STDIN to see if there are characters */
ioctl(0, FIONREAD, (int) &nread);
if (nread)
{
/* got a char; flush all the characters entered */
for (; nread; nread--)
oneChar = getchar();
return oneChar;
}
return 0;
} /* keyhit */
> Try this. Not tested on Intel platforms...
>
Thanks Harald, I guess this works for serial ports (tyCo).
It does however not work for the PC console (the keyboard of a standard
PC).
- Peter K.
The boot loader accepts non-blocking keyboard user input at
the "press any key to stop auto-boot ...." prompt, and you can
use the same method.
Aleph-Null
---
C programmers never die, they are just cast into void.
Replace 127.0.0.1 with usa.net when replying by e-mail
On Wed, 30 Jun 1999 06:58:07 GMT, peter...@my-deja.com wrote:
>Hello all,
>
>I'm working with VxWorks on the Intel platform, using a standard PC
>hardware together with the PC486 BSP.
>
>Is there any way to write a kbhit() function for the PC console?
>I've tried already with ioctl() calls, but this does not seem to work.
>
>Any idea?
>
>TIA, Peter K.