WIN32API串口测试程序的问题
问题描述:
1
OnInitial() { //同步操作方式 hCon = CreateFile(g_ctrPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); //设置消息[code=C/C++]
UINT SendToSeri(LPVOID param) { WriteFile(hCon,buffer_send,256,&dw_send,NULL); return 0; }
UINT RecvFromSeri(LPVOID param){ BOOL bResult =FALSE; DWORD dwEvent=0; DWORD dwError; SetCommMask(hCon, EV_BREAK|EV_CTS|EV_DSR|EV_ERR|EV_RING|EV_RLSD|EV_RXCHAR|EV_RXFLAG|EV_TXEMPTY); while(TRUE) { bResult=WaitCommEvent(hCon,&dwEvent,NULL);//问题所在的地方 if (bResult) { AfxMessageBox("OK");//用来判断程序是否走到这一步 switch(dwEvent) { case EV_RXCHAR: { AfxMessageBox("OK");//用来判断程序是否走到这一步 } } }}
bResult=WaitCommEvent(hCon,&dwEvent,NULL);
bResult=WaitCommEvent(hCon,&dwEvent,NULL);