🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: COM Port Issue

#3466
From: Remy Lebeau (TeamB)
Date: Wed, 14 Jun 2006 16:55
34 lines
2000 bytes
"Jeff" <Jeff@nospam.com> wrote in message
news:44902db2@newsgroups.borland.com...

> The problem we're having is that we can't test the buffer for
> data without pulling the data out of the buffer.

Yes, you can.  Look at SetCommMask() and WaitCommEvent() so your reading can
be driven off of COM port events.  When data is available, you will get
EV_RXCHAR events.  Microsoft has a very detailed article on MSDN about how
to properly read from a COM port using COM event masks and error handling.

> Is there a way to test for data in the buffer without pulling it out?

Not specifically, no.

> Err_Ret_Code = (ReadFile(TShComm, InBuff, 10, &dwBytesRead, NULL));
> if (InBuff[0] == '\0') //If no data is returned then return -1

That is not the correct way to know if data ws put into a buffer.  You
should be checking the dwBytesRead value instead:

    if( ReadFile(TShComm, InBuff, 10, &dwBytesRead, NULL) )
    {
        if( dwBytesRead )
            // there is data in the buffer
        else
            // there is no data in the buffer
    }
    else
        // error in reading


Gambit
Technical Details
Message-ID: <44903fc2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.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
References: <44902db2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8d933165dffecbd7
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <44902db2@newsgroups.borland.com>
Subject: Re: COM Port Issue
Date: Wed, 14 Jun 2006 09:55:04 -0700
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <44903fc2$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1150304194 68.69.17.41 (14 Jun 2006 09:56:34 -0700)
Path: arc1-ca.pugleaf.net!g2news2.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