This is the mail archive of the
mailing list for the Cygwin project.
Re: Problem with reading nonblocking /dev/com in 1.7.10 and up
- From: Peter Rosin <peda at lysator dot liu dot se>
- To: cygwin at cygwin dot com
- Date: Tue, 10 Apr 2012 20:39:35 +0200
- Subject: Re: Problem with reading nonblocking /dev/com in 1.7.10 and up
- References: <4F847921.email@example.com>
On 2012-04-10 20:17, Abdul Muis wrote:
> I have notice that I could not read serial device (/dev/com4 or
> /dev/ttyS3) with non blocking mode since 1.7.10 and up. I used to read
> serial data while doing openGL visualization. In which, the openGL
> display was not changed due to blocking mode reading.
> The command is
> fcntl(fd, F_SETFL, FNDELAY); // set reading as non blocking mode, should
> return '0' if no data comming
> n=read(fd, &test, 10); // starting from 1.7.10 always return -1 although
> there is incoming data
I don't know and haven't tried lately (no serial ports connected at the
moment), but in the past I have successfully used:
long flags = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
FNDELAY is probably a non-posix name that in practice is equivalent to
O_NONBLOCK, but more importantly I think you should OR the flag in without
clobbering all other flags.
However, I last tested that before 1.7.10, so my version may well behave
just like your code.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple