Re: Serial thread problems
"Kahlua" <edward.frederick@verizon.net> wrote in message
news:ba21131f-7eaa-4a04-a1b2-9e4c3b4f1791@l64g2000hse.googlegroups.com...
if(WaitCommEvent(hCom, &dwEventMask, NULL)){
AfxMessageBox("Error 2 reading comm port");
}
if (!ReadFile (hCom, &chread, 1, &dwRead, &ovl)){
AfxMessageBox("Error reading data");
}
Bar[i] = chread;
}
::PostMessage(hDlg, MY_SERIAL, (WPARAM)0, (LPARAM)0);
}
return TRUE;
}
When a 10h is received the thread is supposed to read 33 more bytes to
a unsigned char string in Bar[]
I have verifyied that the 10h is received but I get "Error 2 reading
comm port" 2 times.
Please guide me.
The help for WaitCommEvent says: "If the function fails, the return value is
zero. To get extended error information, call GetLastError."
What does GetLastError return when the failure occurs?
And why are you calling WaitCommEvent at all? You can simply call ReadFile
and it will return when it has a character.
--
Scott McPhillips [VC++ MVP]