为什么我写得串口通信程序的速度比较慢?
if (!PurgeComm(hFile,PURGE_RXCLEAR | PURGE_TXCLEAR )) return -1;
if(!SetCommMask(hFile, EV_RXFLAG)) return -2; //设定监视消息
//写操作
if (!WriteFile(hFile,pstrWrite,lWriteSize,&ulWriteNumber,NULL)) return -3;
//读操作
while (true)
{
WaitCommEvent(hFile,&dwEvtMask,NULL);
if (dwEvtMask==EV_RXFLAG)
{
if (!ClearCommError(hFile, &dwError,comstat)) return -4;
if (ReadFile(hFile,pstrRead,comstat.cbInQue,&ulReadNumber,NULL))
}
我用WaitCommEvent(hFile,&dwEvtMask,NULL);等待的事件是dcb中设的一个字符。
我用串口调试助手大概只要0.9秒就能接受到,可是我的程序需要1.7秒左右,这是为什么?