X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Message-ID: <4F847E67.2@lysator.liu.se> Date: Tue, 10 Apr 2012 20:39:35 +0200 From: Peter Rosin User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Problem with reading nonblocking /dev/com in 1.7.10 and up References: <4F847921 DOT 8020506 AT ui DOT ac DOT id> In-Reply-To: <4F847921.8020506@ui.ac.id> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT 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. 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