Article View: borland.public.cppbuilder.nativeapi
Article #15541Handling Com Port error
From: david
Date: Tue, 24 Jun 2003 16:30
Date: Tue, 24 Jun 2003 16:30
74 lines
2643 bytes
2643 bytes
Hi,
I'm trying to use the com port, but when I read this buffer and there are
not data, the handle don`t return tghe control to the next code line.
Here is my source code.
------------------------
bool TCom::ReciveBin( unsigned char *argAStr_Data, unsigned long
argul_BytesWait , unsigned long &argul_BytesReturned)
{
ReadFile ( hCom, argAStr_Data, argul_BytesWait , &argul_BytesReturned,
NULL );
if ( argul_BytesWait == argul_BytesReturned )
return true;
else
return false;
}
My handle and com sets are:
bool TCom::OpenPortDefault()
{
DCB dcb;
HANDLE hCom;
COMMTIMEOUTS new_timeouts = {0};
COMMTIMEOUTS old_timeouts;
bool fSuccess;
hCom = NULL;
hCom = CreateFile( gAStr_PuertoCom.c_str(),
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
NULL );
if( hCom == INVALID_HANDLE_VALUE )
return false;
else
return true;
fSuccess = GetCommState( hCom, &dcb );
dcb.fBinary = true;
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY ;
dcb.StopBits = ONESTOPBIT ;
fSuccess = SetCommState(hCom, &dcb);
GetCommTimeouts(hCom,&old_timeouts);
new_timeouts.ReadIntervalTimeout = 250;
new_timeouts.ReadTotalTimeoutConstant = 1000;
new_timeouts.ReadTotalTimeoutMultiplier = 1000;
new_timeouts.WriteTotalTimeoutMultiplier = 0;
new_timeouts.WriteTotalTimeoutConstant = 0;
SetCommTimeouts(hCom, &new_timeouts);
}
thaks for all
Technical Details
Message-ID:
<3ef87b08@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,3260389474eb6b2e,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-24 10:00:25 PST From: "david" <dmarquezl@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Handling Com Port error Date: Tue, 24 Jun 2003 12:30:25 -0400 Lines: 76 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 200.50.121.180 Message-ID: <3ef87b08@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1056471816 200.50.121.180 (24 Jun 2003 09:23:36 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail