hai all,
a usermode question, but guru’s here can help me…
i am opening the COM port for asynchronuous I/O using the following stmt.
m_hPort =
CreateFile(m_szPortName,GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_FL
AG_OVERLAPPED,0);
and a manual reset event is created for Async i/o
if(!(m_hReadEvent = CreateEvent(0,TRUE,FALSE,0)))
and in another function, i am placing an asychronous read for 256 bytes from
the port, The problem i am facing is…
when the first byte comes to the port, WaitForSingleObject() returns and
again at WaitForSingleObject()it waits for the second byte. but even after
second byte is reached at the port the WaitForSingleObject() function is not
returnning and the program stucks.
memset(&m_OverlappedRead,0,sizeof(OVERLAPPED));
m_OverlappedRead.hEvent = m_hReadEvent;
if(::ReadFile(m_hPort,m_lpszReadBuffer,256,&dwBytesRead,&m_OverlappedRead))
ReadComplete(dwBytesRead);
do
{
DWORD dwReturnStatus =
WaitForSingleObject(m_hReadEvent,INFINITE);
switch(dwReturnStatus)
{
case WAIT_OBJECT_0:
if(!GetOverlappedResult(m_hPort,&m_OverlappedRead,&dwBytesRead,FALSE))
//Error
ResetEvent(m_OverlappedRead.hEvent);
nCompletionFlag = GENERIC_READ;
break;
default:
};
}
while(true);
am i doing right or missing something?
regards
Deepu.L.R