|
我用MSP430发数据给PC,用串口助手能收到数据,但是用VC++,MSComm控件却显示不了,下面是控件接收部分代码(该控件与串口助手能正常通信)
void CMytestDlg::OnComm()
{
VARIANT variant_inp;
COleSafeArray safearray_inp;
LONG len,k;
BYTE rxdata[2048];
CString strtemp;
if(m_ctrlComm.GetCommEvent() == 2)
{
variant_inp = m_ctrlComm.GetInput();
safearray_inp = variant_inp;
len = safearray_inp.GetOneDimSize();
for(k=0;k
safearray_inp.GetElement(&k,rxdata + k);
for(k=0;k
{
BYTE bt = *(char*)(rxdata + k);
strtemp.Format("%c",bt);
m_strEditRXData += strtemp;
}
m_strEditRXData += strtemp;
}
UpdateData(FALSE);
}
|
|