Article View: borland.public.cppbuilder.nativeapi
Article #2288Re: Slow Read From Serial Port
From: Oliver Rutsch
Date: Wed, 21 Mar 2007 09:08
Date: Wed, 21 Mar 2007 09:08
39 lines
2715 bytes
2715 bytes
Hi Phil, > I'm have an application that communicates with an embedded controller > via the serial port, either directly with a serial cable or via > modem. > > When I'm connected directly with a serial cable the communications > work fine. At a baudrate of 19200 I can send/receive 100 messages > per sec. But when I connect with a modem at 19200 the communications > slow down significantly. I'm only able to send/receive about 8 > messages per sec. Of course I didn't expect to match the speed of a > direct connection, but I'm off by more than a factor of 10. > > I am using overlapped communications. The delay seems to be in the > GetOverlappedResut( ) of my GetChar() routine. I added some debug > statements, and the GetOverlappedResult( ) functions takes about 150 > ms to return when I use a modem. Can anyone advise me in how to > speed this up. > I think your problem is not the GetOverlappedResult function (but I agree here with Michel's suggestions) but latency issues. It depends on how you're talking with your device. If you do it in the way "command to device - wait for answer from device - next command" then the overall latency is your problem, not the burst speed of the modem connection. The problem here is that you can't do very much in this case if you don't want to change the way your device communication works. This problem is well known and in some protocols like TCP/IP it is resolved through some sophisticated algorithms like the sliding windows technique. You'll find a lot of documentation in the net about TCP/IP and maybe you can adapt some of the techniques used here in your communication protocol. Bye, -- Dipl. Ing. Oliver Rutsch EMail: orutsch@sympatec.com Sympatec GmbH
Technical Details
Message-ID:
<4600f62f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<46002b03$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d1cd2b38aa5bb326 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Wed, 21 Mar 2007 10:08:29 +0100 From: Oliver Rutsch <orutsch@sympatec.com> User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Slow Read From Serial Port References: <46002b03$1@newsgroups.borland.com> In-Reply-To: <46002b03$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 217.5.250.34 Message-ID: <4600f62f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1174468143 217.5.250.34 (21 Mar 2007 02:09:03 -0800) Lines: 39 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail