I am writing a serial communications program and have run into two problems.
First I need something similar to DOS’s kbhit() is there anything in QNX/C
that could help me. Secondly I would be a big bonus if i used a
non-blocking read call to read from the port. Right now I am using regular
read() is there another function which wouldn’t block while there is nothing
to read.
I am writing a serial communications program and have run into two problems.
First I need something similar to DOS’s kbhit() is there anything in QNX/C
that could help me. Secondly I would be a big bonus if i used a
non-blocking read call to read from the port. Right now I am using regular
read() is there another function which wouldn’t block while there is nothing
to read.
The GOD of reading serial port is “readcond()”, check your lib
reference.
The GOD of reading serial port is “readcond()”, check your lib
reference.
Of course, there also are portable ways of non-blocking or timed
reading, using the O_NONBLOCK flag or tcsetattr() and the cc_c[VTIME]
parameter in the termios structure…
I think I’ve posted this code snippet before but the following raw() and
unraw() functions will put a file descriptor into a mode where one can read
one character at a time as soon as it is typed.
Xiaodan Tang <> xtang@qnx.com> > wrote:
The GOD of reading serial port is “readcond()”, check your lib
reference.
Of course, there also are portable ways of non-blocking or timed
reading, using the O_NONBLOCK flag or tcsetattr() and the cc_c[VTIME]
parameter in the termios structure… >
I think I’ve posted this code snippet before but the following raw() and
unraw() functions will put a file descriptor into a mode where one can read
one character at a time as soon as it is typed.
“Wojtek Lerch” <> wojtek_l@yahoo.ca> > wrote in message
news:adllva$jil$> 1@nntp.qnx.com> …
Xiaodan Tang <> xtang@qnx.com> > wrote:
The GOD of reading serial port is “readcond()”, check your lib
reference.
Of course, there also are portable ways of non-blocking or timed
reading, using the O_NONBLOCK flag or tcsetattr() and the cc_c[VTIME]
parameter in the termios structure… >
I am writing a serial communications program and have run into two problems.
First I need something similar to DOS’s kbhit() is there anything in QNX/C
that could help me. Secondly I would be a big bonus if i used a
non-blocking read call to read from the port. Right now I am using regular
read() is there another function which wouldn’t block while there is nothing
to read.
check out select for the *nix way to do it, if you also have to receive messages
or other pulses check out, or you want a signal dropped on your process when the
serial port is ready for reading use ionotify