I am using the serial tutorial there. I am trying to perform overlapped communication so I can monitor both a keyboard event and the event where the CTS line changes state.
Here is my code:
Code:
SetCommMask(serial,EV_CTS);
osReader.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
EscapeCommFunction(serial,SETRTS);
printf("\n\nConnecting... (F1 to quit)\n");
printlog("Establishing connection...");
DWORD BytesReadOV;
int err;
unsigned int undef = 1;
while(undef & 1){
dwRes = WaitForSingleObject(osReader.hEvent, 100);
if(dwRes == WAIT_TIMEOUT){
if(kbhit()){
if(getch() == 0x00){
if(getch() == KEY_F1) undef = -1;
}
}
}
if(dwRes == WAIT_OBJECT_0){
undef = 0;
}
if(undef == -1){
printf(" cancelled!");
CancelIo(s);
CloseHandle(s);
close_connection();
exit(-1);
}
}
Anyone see something I didnt do right?
PS: The osReader is an OVERLAPPED structure and the serial HANDLE is set for overlapped IO.

