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
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