| Author |
Message |
|
|
Post subject: QNX6 does not support CONIO.H functions
Posted: May 15, 2008 - 04:27 PM
|
|
New Member
Joined: May 15, 2008
Posts: 9
|
|
There are a couple of functions that CONIO.H provided that QNX6 no longer supports. I need the abilities that getch() and kbhit() provided in my code, and I have tried to make the read() and tcischars() functions work with stdin, but these functions are looking for a file pointer and not a device. How should I approach this problem?
If anyone knows of function within qnx6 that respond in the same way as getch() and kbhit(), please reply. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: QNX6 does not support CONIO.H functions
Posted: May 16, 2008 - 08:20 PM
|
|
Senior Member
Joined: Dec 14, 2005
Posts: 103
|
|
Hello Bmclean,
Please consider the following sample code which provides the required functionality.
Thanks,
Yuriy
---------
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <errno.h>
int main(int argc, char** argv)
{
int bytes_to_read;
char buf [ BUFSIZ ];
struct termios termios_p;
// Set raw mode:
if (tcgetattr( 1, &termios_p ) == -1 )
{
perror ("tcgetattr");
return (-1);
}
if (cfmakeraw( &termios_p ) == -1 )
{
perror ("cfmakeraw");
return (-1);
}
if (tcsetattr( 1, TCSADRAIN, &termios_p )== -1)
{
perror ("tcsetattr");
return (-1);
}
for ( ; ; )
{
bytes_to_read = tcischars( 1); // kbhit
if (bytes_to_read == -1 )
{
perror ("tcischars");
return (-1);
}
if (bytes_to_read >0 )
{
fprintf (stderr, "kbhit %d", bytes_to_read);
read( 1, buf, bytes_to_read ) ; // getch()
}
}
return 0;
} |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: QNX6 does not support CONIO.H functions
Posted: May 20, 2008 - 12:59 PM
|
|
New Member
Joined: May 15, 2008
Posts: 9
|
|
This function does emulate the getch() and kbhit() functions, and I see if you save the termios struct before making it "raw" tou can restore it latter.
Thanks.
BMcLean |
Last edited by bmclean on May 23, 2008 - 01:31 PM; edited 1 time in total
|
| |
|
|
|
 |
|
|
Post subject: Re: RE: QNX6 does not support CONIO.H functions
Posted: May 22, 2008 - 05:31 PM
|
|
QNX Master
Joined: Jul 11, 2002
Posts: 600
|
|
|
bmclean wrote:
This function does emulate the getch() and kbhit() functions, but it causes the “\n” new line to insert the line feed only, missing the carriage return. I would imagine that there is some parameter in the termios struct that can change this, but I don’t know what this would be.
I think OPOST might be what you're looking for.
btw: these functions only ever appeared in QNX because the Watcom compiler (which came from DOS) brought them with it. There really is no place in an RTOS for a kbhit() function (select on READ is the proper solution). |
|
|
| |
|
|
|
 |
|
|
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group Credits |
|
|