Mail Archives: cygwin/2012/04/10/14:40:05
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.
Cheers,
Peter
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -