read() blocking and TIOCINQ

Ernesto Paiser paiser@esrf.fr
Tue Sep 5 11:47:00 GMT 2006


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.

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

Thank you for your help,

  Ernesto.

PS.: more details about CYGWIN

PAISER@tenerife ~
$ uname -a
CYGWIN_NT-5.1 tenerife 1.5.21(0.156/4/2) 2006-07-30 14:21 i686 Cygwin


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


-- 
Ernesto PAISER ____________________ paiser@esrf.fr
E.S.R.F. - European Synchrotron Radiation Facility
6 rue Jules Horowitz  BP 220 Grenoble CEDEX France
phone +33 4 76 88 23 48      fax +33 4 76 88 23 25
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: serial_tiocinq.c
URL: <http://cygwin.com/pipermail/cygwin/attachments/20060905/ccf0f696/attachment.c>
-------------- next part --------------
--
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/


More information about the Cygwin mailing list