How to read from serial port without blocking?

bridged with qdn.public.qnxrtp.newuser
Post Reply
Shayne Powell

How to read from serial port without blocking?

Post by Shayne Powell » Thu Aug 07, 2003 1:13 am

Hello,

Can anyone tell me how I can read from the serial port without the read
function blocking, or if it does, it only blocks for a very short time? The
1/10th of a second available in readcond() is still too slow. I need to get
it up to a rate of approximately 100Hz (0.01sec). Alternatively, do I need
to have another process or thread continually waking up the blocked read
function?

Thanks for your help.

Shayne

Rennie Allen

Re: How to read from serial port without blocking?

Post by Rennie Allen » Thu Aug 07, 2003 2:07 am

Shayne Powell wrote:
Hello,

Can anyone tell me how I can read from the serial port without the read
function blocking, or if it does, it only blocks for a very short time? The
1/10th of a second available in readcond() is still too slow. I need to get
it up to a rate of approximately 100Hz (0.01sec). Alternatively, do I need
to have another process or thread continually waking up the blocked read
function?
Have your tried opening the port non-block (see docs for open, flag O_NONBLOCK).
I have never needed to do this, but I have always assumed it would work if I did.

Rennie

David Gibbs

Re: How to read from serial port without blocking?

Post by David Gibbs » Thu Aug 07, 2003 5:25 pm

Shayne Powell <s2.powell@qut.edu.au> wrote:
Hello,

Can anyone tell me how I can read from the serial port without the read
function blocking, or if it does, it only blocks for a very short time? The
1/10th of a second available in readcond() is still too slow. I need to get
it up to a rate of approximately 100Hz (0.01sec). Alternatively, do I need
to have another process or thread continually waking up the blocked read
function?
Open with O_NONBLOCK, then use either select() or io_notify() to get
notification when there is data available to read() (rather than polling).

-David
--
QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Post Reply

Return to “qdn.public.qnxrtp.newuser”