利用CSerialport类编写的串口程序,可正常接收龚建伟老师的串口调试助手发出的十六制信息,但收不到S7200发出的信息。
以下是接收函数:
LONG CMy22Dlg::OnComm(WPARAM ch,LPARAM port)
{
CString strtemp1,strtemp2;
LONG len;
int n=0;
BYTE m_byte=0;
CByteArray ReceiveData;
//ReceiveData.SetSize(8);
strtemp1.Format("%d",ch);
n=atoi(strtemp1);
m_byte=n;
ReceiveData.Add(m_byte);
//count++;
len=ReceiveData.GetSize();
for(int k=0;k<len;k++)
{
BYTE bt=ReceiveData.GetAt(k);
rcv[k]=bt;
strtemp2.Format("%d",bt);
m_ReceiveMsg+=strtemp2+" ";
}
UpdateData(FALSE);
if(n==97)
{
//count=0;
ReceiveData.RemoveAll();
m_ReceiveMsg.Empty();
}
return 0;
}