From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3091 invoked by alias); 13 Oct 2003 19:56:25 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 3027 invoked from network); 13 Oct 2003 19:56:23 -0000 Received: from unknown (HELO esds.vss.fsi.com) (66.136.174.212) by sources.redhat.com with SMTP; 13 Oct 2003 19:56:23 -0000 Received: from eos.vss.fsi.com (eos [198.51.27.61]) by esds.vss.fsi.com (8.11.6+Sun/8.9.1) with ESMTP id h9DJuMs22091 for ; Mon, 13 Oct 2003 14:56:22 -0500 (CDT) Received: from localhost (ford@localhost) by eos.vss.fsi.com (8.11.6+Sun/8.11.6) with ESMTP id h9DJuM304612 for ; Mon, 13 Oct 2003 14:56:22 -0500 (CDT) X-Authentication-Warning: eos.vss.fsi.com: ford owned process doing -bs Date: Mon, 13 Oct 2003 20:10:00 -0000 From: Brian Ford X-X-Sender: ford@eos To: cygwin@cygwin.com Subject: Re: tcflush hang problem Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2003-10/txt/msg00744.txt.bz2 Sorry, my fingers aren't working. I keep accidentally replying to the sender rather than/in addition to the list. Cygwin's current tcflush implimentation is rather crude. Although, it may not be possible to do any better. PTC. if (queue == TCIFLUSH || queue == TCIOFLUSH) /* Input flushing by polling until nothing turns up (we stop after 1000 chars anyway) */ for (int max = 1000; max > 0; max--) { COMSTAT st; if (!PurgeComm (get_handle (), PURGE_RXABORT | PURGE_RXCLEAR)) break; low_priority_sleep (100); if (!ClearCommError (get_handle (), &ev, &st) || !st.cbInQue) break; } So, your not really hung. Just stuck for a long time. As a work around, tell the device to shut up first, then flush. On Mon, 13 Oct 2003, Martin Farnik wrote: > Hi. > I use CYGWIN_98-4.10 mine 1.5.5(0.94/3/2) 2003-09-20 16:31 i686 uknown > unknown Cygwin > > First i try to describe a situation: > I have a device which is connected with computer thru serial line. > Device is still sending data.These data isn't for my program.I have > open com port and let them go into buffer . When a want to talk with > device i flush input buffer, send it a command paket and device stop > sending data and wait for my next command. > Problem is when I want to flush INPUT buffer before I send a command. In > this point it hangs, maybe for buffer full. > Here is piece of code: > > -----I open port when i start program ----- > > fd = open(PORT0, O_RDWR | O_NOCTTY ); > tcgetattr(fd,&oldtio); /* save current port settings */ > > bzero(&newtio, sizeof(newtio)); > newtio.c_cflag = CS8 | CLOCAL | CREAD | CSTOPB; > newtio.c_iflag = 0; > newtio.c_oflag &= ~OPOST; > newtio.c_lflag = 0; > > newtio.c_cc[VTIME] = 1; > newtio.c_cc[VMIN] = 0; > > cfsetispeed(&newtio,B19200); > cfsetospeed(&newtio,B19200); > tcflush(fd, TCIFLUSH); > tcsetattr(fd,TCSANOW,&newtio); > ------------------------------------------------- > --this code is execute when a want to talk with device---- > > tcflush(fd, TCIFLUSH); <--------- in this point where it hangs > err = write (fd,iobuffer,10); > -- Brian Ford Senior Realtime Software Engineer VITAL - Visual Simulation Systems FlightSafety International Phone: 314-551-8460 Fax: 314-551-8444 -- 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/