🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2284

Slow Read From Serial Port

#2284
From: Phil
Date: Tue, 20 Mar 2007 18:42
46 lines
2319 bytes
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.

Here's the relevent code:

overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
overlapped.hEvent = NULL;

ibytes = 0;
ierr = ERROR_IO_PENDING;
if (!ReadFile(hcomm, xbyte, 1, &ibytes, &overlapped))
    {
    ierr = GetLastError();
    }

while ((!ibytes) &&
            (clock() < (int)timeout) &&
            ((ierr == ERROR_IO_PENDING) ||
            (ierr == ERROR_IO_INCOMPLETE)))
    {
    if (!GetOverlappedResult(hcomm, &overlapped, &ibytes, true))  //  about 
150ms to return
         {
        ierr = GetLastError();
        }
    }

return(ibytes != 0);


Thanks in advance for your help,
Phil
 
Technical Details
Message-ID: <46002b03$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d1cd2b38aa5bb326,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Phil" <phil@camusinc.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Slow Read From Serial Port
Date: Tue, 20 Mar 2007 14:42:04 -0400
Lines: 48
Organization: Camus
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
NNTP-Posting-Host: 216.54.107.58
Message-ID: <46002b03$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1174416131 216.54.107.58 (20 Mar 2007 11:42:11 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail