Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read() is blocking

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

I read successfully the serial port buffer until there are no characters left. At this point, the function read() is waiting for another charater. The problem is that there won't be any.
Do you know how to detect this infinite state of waiting?
(I use Linux).

thank you!

thomas
 
While opening the device file you can set the NO DELAY property.
like -


#include<fctnl.h>
~~~
~~~
file_ptr = open( &quot;/dev/modem_file&quot;, (O_RDWR|O_NDELAY));
OR
file_ptr = open( &quot;/dev/modem_file&quot;, (O_RDWR|O_NONBLOCK));

This will make the read to return if there is no data

CHeers
byk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top