Article View: borland.public.cppbuilder.nativeapi
Article #15547eternal 'ReadIntervalTimeOut' com port
From: david
Date: Tue, 24 Jun 2003 21:06
Date: Tue, 24 Jun 2003 21:06
72 lines
2741 bytes
2741 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 the 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()
{
COMMTIMEOUTS new_timeouts = {0};
bool fSuccess;
hCom = NULL;
hCom = CreateFile( "COM1",
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);
}
OBJECT PROPERTIES
-------------------------
private :
DCB dcb;
HANDLE hCom;
COMMTIMEOUTS old_timeouts;
thaks for all
Technical Details
Message-ID:
<3ef8bbd6@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!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,42e81fe87bbd2b5d,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-24 14:04:04 PST From: "david" <dmarquezl@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: eternal 'ReadIntervalTimeOut' com port Date: Tue, 24 Jun 2003 17:06:56 -0400 Lines: 75 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: <3ef8bbd6@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1056488406 200.50.121.180 (24 Jun 2003 14:00:06 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail