delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/04/10/14:17:44

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4F847921.8020506@ui.ac.id>
Date: Wed, 11 Apr 2012 01:17:05 +0700
From: Abdul Muis <muis AT ui DOT ac DOT id>
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: Problem with reading nonblocking /dev/com in 1.7.10 and up
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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

--------------000106010404010209060308
Content-Type: text/plain; charset=Shift_JIS
Content-Transfer-Encoding: 7bit

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

There is no problem with blocking mode, the program can read incoming data
fcntl(fd, F_SETFL, 0); // blocking mode
n=read(fd, &test, 10); // the program will stop here until incoming data
arrived

Before reporting this bug, I have tested in Windows 7 32bit, Windows 7
64bit.
luckily I have several cygwin version in different folder.
I have tested the program in version 1.7.9, 1.7.10, 1.7.11, and current
version 1.7.13 at both 32bit and 64bit Windows7.
The program can read in non blocking mode only in 1.7.9
In addition, although I compiled the program in 1.7.10 and put
cygwin1.dll (ver. 1.7.9) in the same folder, the program could read in
non blocking mode too. So, I suspect the bug is in cygwin1.dll in
version 1.7.10 and up.
Unfortunately, if I compiled the program in 1.7.11 and 1.7.13 then used
cygwin1.dll (ver. 1.7.9) the program stuck.

I notice in version 1.7.10, there are additional API_MINOR changed
(/usr/include/cygwin/version.h)

238: Export pthread_spin_destroy, pthread_spin_init, pthread_spin_lock,
pthread_spin_trylock, pthread_spin_unlock.
239: Export pthread_setschedprio.
240: Export ppoll.
241: Export pthread_attr_getstack, pthread_attr_getstackaddr,
pthread_getattr_np.
242: Export psiginfo, psignal, sys_siglist.
243: Export sysinfo.
244: Export clock_settime.
245: Export pthread_attr_getguardsize, pthread_attr_setguardsize,
pthread_attr_setstack, pthread_attr_setstackaddr.
246: Add CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID.
Export clock_getcpuclockid, pthread_getcpuclockid.
247: Export error, error_at_line, error_message_count, error_one_per_line,
error_print_progname.
248: Export __fpurge.
249: Export pthread_condattr_getclock, pthread_condattr_setclock.
250: Export clock_nanosleep.
251: RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND added.
252: CW_CVT_ENV_TO_WINENV added.
253: Export TIOCSCTTY, tcgetsid.
254: Export getgrouplist.
255: Export ptsname_r.
256: Add CW_ALLOC_DRIVE_MAP, CW_MAP_DRIVE_MAP, CW_FREE_DRIVE_MAP.
257: Export getpt.
258: Export get_current_dir_name.
259: Export pthread_sigqueue.

I don't know what kind of changed that made non blocking read failed. I
attached the program for testing.
I really hope next version will make it possible again.

Thanks in advanced for all efforts.
Kind regards,
Abdul Muis



--------------000106010404010209060308
Content-Type: text/plain; charset=Shift_JIS;
 name="readserial.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="readserial.c"

I2luY2x1ZGUgPHN0ZGlvLmg+CiNpb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
dGVzdFtpXSk7CgkJCQkgIHByaW50ZigiXG4iKTsKCQkJCX0gZWxzZQoJCQkJ
ICBwcmludGYoIiVkIFxuIixuKTsKCX0KICBjbG9zZShmZCk7CglyZXR1cm4g
MDsKfQo=


--------------000106010404010209060308
Content-Type: text/plain; charset=us-ascii

--
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
--------------000106010404010209060308--

- Raw text -


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