Overlapped I/O on XP

D

donna rigas

Hi -

I'm using overlapped i/o on Windows 98 and on XP
and am getting different results.

Here's the code snippet:

// read the command id and the message length
BOOL rc;
ResetEvent(m_SerialRecvOL.hEvent);
rc = ReadFile(m_hSerialPort, &buf[1], 6, pBytesRead,
(LPOVERLAPPED) &m_SerialRecvOL);
if (!rc && GetLastError() == ERROR_IO_PENDING) {
waitStatus = WaitForSingleObject(
m_SerialRecvOL.hEvent, 5000);
if (status == WAIT_OBJECT_0){
GetOverlappedResult(m_hSerialPort,
&m_SerialRecvOL, pBytesRead, FALSE);
rc = TRUE;
}
}

On windows 98, ReadFile returns with rc = false
and pBytesRead = 0 and then the operation is
successfully completed later and GetOverlappedResult
fills in pBytesRead with 6 to indicate 6 bytes read.

On XP, ReadFile returns right away with rc = true
and *pBytesRead = 3. I don't get all my data (6 bytes),
yet the call to ReadFile indicates that it's done
even though it only reads 3 bytes.

Can anyone tell me what I'm missing here?

Thanks,
Donna Rigas
ioline corporation
 
D

Doug Forster

Hi,

I think this is normal for a serial port. You need to keep reading until no
more data arrives, or you have the data you are expecting. Not sure
specifically why W98 and XP behaviour differs but this is hardly surprising
as XP is a NT derivative so completely different underlying code.

PS This is not really a suitable NG for this subject

Cheers

Doug Forster
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top