写了一个串口程序,接收部分没有问题,有串口调试助手,用我写的程序发送数据,串口调试助手接收没有数据,是不是的写数据部分有问题啊,求指教
BOOL CYBcommDlg::WriteData()
{
DWORD dwBytesWritten=100;
// DWORD dwErrorFlags;
// COMSTAT ComStat;
OVERLAPPED m_osWrite;
BOOL bWriteStat;
UpdateData(TRUE);
char *buffer=m_writedata.GetBuffer(0);
bWriteStat=WriteFile(hCom,buffer,dwBytesWritten,
&dwBytesWritten,&m_osWrite);
if(!bWriteStat)
{
if(GetLastError()==ERROR_IO_PENDING)
{
WaitForSingleObject(m_osWrite.hEvent,1000);
return dwBytesWritten;
}
return 0;
}
return dwBytesWritten;
} |