关于串口的打开出错!
if (!m_Com.Create(NULL,style,CRect(0,0,0,0),this,IDC_MSCOMM))
{
TRACE0("Failed to create OLE Communications Control\n");
return -1; //fail to create
}
if(m_Com.GetPortOpen())
m_Com.SetPortOpen(FALSE);
m_Com.SetCommPort(1); //选择COM0
m_Com.SetInBufferSize(4096); //设置输入缓冲区的大小,Bytes
m_Com.SetOutBufferSize(4096); //设置输入缓冲区的大小,Bytes
if(!m_Com.GetPortOpen()) //打开串口
m_Com.SetPortOpen(TRUE);
m_Com.SetInputMode(1); //设置输入方式为二进制方式
m_Com.SetSettings("38400,n,8,1"); //设置波特率等参数57600
m_Com.SetRThreshold(1);
m_Com.SetInputLen(0);
为什么每次m_Com.GetPortOpen得到的串口状态都是0,有的时候我的串口明明已经是打开了!
是不是m_Com.Create(NULL,style,CRect(0,0,0,0),this,IDC_MSCOMM))的问题?