delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/09/05/10:42:39

X-Spam-Check-By: sourceware.org
Date: Tue, 5 Sep 2006 10:42:27 -0400 (EDT)
From: Igor Peshansky <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Ernesto Paiser <paiser AT esrf DOT fr>
cc: cygwin AT cygwin DOT com
Subject: Re: read() blocking and TIOCINQ
In-Reply-To: <44FD61EB.1090002@esrf.fr>
Message-ID: <Pine.GSO.4.63.0609051038130.22373@access1.cims.nyu.edu>
References: <44EABC07 DOT 3010305 AT esrf DOT fr> <Pine DOT GSO DOT 4 DOT 63 DOT 0608220936070 DOT 14509 AT access1 DOT cims DOT nyu DOT edu> <44FD61EB DOT 1090002 AT esrf DOT fr>
MIME-Version: 1.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Ugh, top-posting...  Reformatted.

On Tue, 5 Sep 2006, Ernesto Paiser wrote:

> Igor Peshansky wrote:
> > 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
>
> Hello Igor,
> Sorry for my incomplete question.
> I attach to you the following file that could be compiled with gcc in
> CYGWIN.
> Accepted commands start by '?' character, and when the device is not
> connected on the serial line the function read(...) blocks:
>
>
>    DEVICE test program
>    -------------------
>
> Type your commands ('.' to quit):
> >> Enter command: ?ver
>
>
> Then, blocked....:-((
>
>
> Note that in our computers the serial line name is COMn not /dev/ttySn.

And therein lies your problem.  When you use COMn, you get access to the
raw Windows device, without Cygwin's POSIX emulation, so it's not
surprising that ioctl() doesn't work.

> I tried before with /dev/ttySn and I receive file not found as answer.

That's probably because COMn = /dev/ttyS{n-1} (e.g., COM1 -> /dev/ttyS0).
HTH,
	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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019