X-Spam-Check-By: sourceware.org Date: Tue, 22 Aug 2006 09:40:40 -0400 (EDT) From: Igor Peshansky Reply-To: cygwin AT cygwin DOT com To: Ernesto Paiser cc: cygwin AT cygwin DOT com Subject: Re: read() blocking and TIOCINQ In-Reply-To: <44EABC07.3010305@esrf.fr> Message-ID: References: <44EABC07 DOT 3010305 AT esrf DOT fr> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: 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 Tue, 22 Aug 2006, Ernesto Paiser wrote: > Hello Corinna, FYI, this is a mailing list, and unless you're replying to a specific message, you're actually talking to many people. > I have problems with read() function blocking and > waiting for characters on serial line with cygwin: > > Here are some code fragments: > ======================================================== > fd = open(sl, O_RDWR | O_NOCTTY | O_NONBLOCK | O_NDELAY) > > newpio.c_cflag = brate | CS8 | CLOCAL | CREAD; > newpio.c_iflag = IGNPAR | ICRNL; > newpio.c_oflag = 0; > newpio.c_lflag = 0; > newpio.c_cc[VTIME] = 1; > newpio.c_cc[VMIN] = 0; > ... > > n = ioctl(fd, TIOCINQ, &n); //It gives me an error (return -1) why??!!! > > and > > n = read(fd, buffer, 1); <<< HERE IS BLOCKING!!! > ======================================================== > > TIOCINQ is working on CYGWIN, > > Is there another way to solve this problem??? Please post a complete compilable test case that reproduces the problem. For example, in the above code, it's unclear what the variable sl contains (and I suspect it contains "COM1", which is a no-no -- you should be using "/dev/ttyS0"). Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu | igor AT watson DOT ibm DOT com ZZZzz /,`.-'`' -. ;-;;,_ Igor Peshansky, Ph.D. (name changed!) |,4- ) )-,_. ,\ ( `'-' old name: Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte." "But no -- you are no fool; you call yourself a fool, there's proof enough in that!" -- Rostand, "Cyrano de Bergerac" -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/