Thanks mario for quick reply. There more problem with QNX neutrino, some function which is ommon to the c/c++ programming no logger support anymore. Some of it:
/* MIG4NTO kbhit Use tcischars() instead. /
/ MIG4NTO getch Do a read() with echo off. */
if (kbhit() && getch() == 0x1b)
return 0;
Could you please give me converting code to QNX 6.30?
Anyone? Plz…
Well they may be “common” but they are non standard functions. They are not part of the C or C++ standard nor of any standard for that matter. If you look at the QNX4 documentation you will notice these 2 functions are under the “Watcom” Classification. That means they are not portable across compiler. Granted QNX6 should have been more friendly to QNX4 programmers
The help and description given by the migration tool is informative enough, I think.
To replace kbdhit use tcischars( stdin ), check the doc on tcischars…
As for getch, you need to use read(stdin, …) but turn echo off by using tcgetattr() and tcsetattr().
Alternatively you could rework your application to use io_notify to get rid of that nasty polling for key press…
Hai mario,
Actually my english was not good, sorry for typoerror, I’ve still problem to set struct termios variable.
What should I do to turn echo off? Is this code valid?
You forget to read the documentation on tcsetattr in which you would have find out that you need to set the second argument (i’ll let you figure out what value it should be set).
You would have probably figure it out have you check the return value of each functions and check for errors. tcsetattr() return -1 and set errno to EINVAL which in the docs says “The argument action is invalid, or one of the members of termios_p is invalid”. Can’t get any better then that.
You will also notice that read will not return unless you press return, I’ll give you a tip ICANON.
I highly suggest you throughly read the tcgetattr, tcsetattr and terrmio documentation, it’s all in there. Doc on tcsetattr even has a nice code sample!