Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

kbhit() on PC486

153 views
Skip to first unread message

peter...@my-deja.com

unread,
Jun 30, 1999, 3:00:00 AM6/30/99
to
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.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Harald Grundner

unread,
Jun 30, 1999, 3:00:00 AM6/30/99
to
In article <7lcf5s$6hi$1...@nnrp1.deja.com>, peter...@my-deja.com wrote:

>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 */

peter...@my-deja.com

unread,
Jun 30, 1999, 3:00:00 AM6/30/99
to
In article <harald.grundner-...@mac03.ri.dasa.de>,
harald....@ri.dasa.de (Harald Grundner) wrote:

> 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.

Aleph-Null

unread,
Jul 1, 1999, 3:00:00 AM7/1/99
to
You already have source code that does exactly that -
take a look at the boot loader source at bootConfig.c
(in my setup it's located at \tornado\target\config\all).

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.

0 new messages