那你知道WriteFile向串口写数据时,写不了
void CView2::CtrlSer()
{
BYTE str[17]={'@','0','0','W','R','0','2','0','0','0','0','0','1',0,0,'*',13};
Xor(str,12);
CString order;
for(int i=0;i<17;i++)
{
order+=str[i];
}
order+="*\r";
OVERLAPPED m_osWrite;
memset(&m_osWrite,0,sizeof(OVERLAPPED));
m_osWrite.hEvent=CreateEvent(NULL,TRUE,FALSE,NULL);
DWORD dwBytesWrite=20;
DWORD dwErrorBlags;
BOOL bWriteStat;
COMSTAT comstat;
ClearCommError(hCom,&dwErrorBlags,&comstat);
//////////////////////////////////////////////////////////////////////////////////
bWriteStat=WriteFile(hCom,order,strlen(order),&dwBytesWrite,&m_osWrite);
if(!bWriteStat)
{
if(GetLastError()==ERROR_IO_PENDING)
{
WaitForSingleObject(m_osWrite.hEvent,1000);
}
}
/////////////////////////////////////////////////////////////////////////////////////
}
::::bWriteStat 总是FALSE啊,无法写串口是什么原因啊