Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Date: Tue, 17 May 2005 16:43:34 -0400
From: Christopher Faylor <cgf-no-personal-reply-please@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Serial programming -  Writing bytes in a blocking mode - Problem with  tcdrain() ?
Message-ID: <20050517204334.GA7435@trixie.casa.cgf.cx>
Reply-To: cygwin@cygwin.com
References: <OFAFBFF454.20BD9FD5-ONC1257003.00336351@cetenasa.es>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <OFAFBFF454.20BD9FD5-ONC1257003.00336351@cetenasa.es>
User-Agent: Mutt/1.5.8i

On Mon, May 16, 2005 at 10:22:00AM +0100, pbenito@cemitec.com wrote:
>I'm trying to use the serial port with Cygwin, and here is my problem:
>
>I can successfully write on the line, but I need to switch the RTS and DTR
>lines just AFTER the last byte is written in the line. I put the bytes that
>I want in the line with the command Write and I wait for the last byte to
>be written with tcdrain() and then I switch the RTS and RTS lines. But when
>I see the signals in the oscilloscope I realized that the tcdrain call is
>not waiting till the output buffer is empty and I switch the RTS and DTR
>lines before I write all the bytes !! I attach my code, is it something
>wrong with it or is there a problem with the tcdrain call in cygwin? On a
>Linux box, tcdrain call seems to work fine...
>
> I'm running Cygwin v1.65 on a Windows XP SP2 machine.
>
>Thanks for your help

Corinna and I looked at the implementation of tcdrain in cygwin.  It's pretty
simple.  It just calls FlushFileBuffers and, according to Microsoft:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/read_and_write_operations.asp

it should be doing the right thing.

I wonder if you're just seeing the effects of a buffer on the comm
device itself not draining even though Windows has flushed everything
from its own memory.
--
Christopher Faylor			spammer? ->	aaaspam@sourceware.org
Cygwin Co-Project Leader				aaaspam@duffek.com
TimeSys, Inc.

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

