X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_SEMBLACK,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Message-Id: <1337876268.2629209054@as03.cooltoad.com> From: "thunderboy42" To: cygwin AT cygwin DOT com Subject: Re: Reading data from ttyS fails Date: Thu, 24 May 2012 19:17:48 +0200 X-Abuse-to: abuse AT coolgoose DOT com 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 Hello Corinna, I used a part from http://en.wikibooks.org/wiki/Serial_Programming/termios for testting because my 'original' is a little bit complicated. (see the source at the end) But I think I found the problem in "fhandler_serial.cc". There was some code added for leaving the method raw_read when there are no more chars received and the serial port was opened in non blocking mode (code starting at line 86). But I think it would be a good idea to deliver the chars received until then, so I build my own cygwin1.dll with the following changes in fhandler_serial.cc: 88,94c88 - PurgeComm (get_handle (), PURGE_RXABORT); - if (tot == 0) - { - tot = -1; - set_errno (EAGAIN); - } - goto out; --- + break; This works for me now. Thanks, T.B. -------------------------------- #include #include #include #include #include #include int main(int argc,char** argv) { struct termios tio; int tty_fd; unsigned char c='D'; memset(&tio,0,sizeof(tio)); tio.c_iflag=0; tio.c_oflag=0; tio.c_cflag=CS8|CREAD|CLOCAL; tio.c_lflag=0; tio.c_cc[VMIN]=1; tio.c_cc[VTIME]=5; tty_fd=open("/dev/ttyS0", O_RDWR | O_NONBLOCK); cfsetospeed(&tio,B115200); // 115200 baud cfsetispeed(&tio,B115200); // 115200 baud tcsetattr(tty_fd,TCSANOW,&tio); while (c!='q') { if (read(tty_fd,&c,1)>0) write(STDOUT_FILENO,&c,1); } close(tty_fd); } -- 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