OnCommunication(WPARAM ch, LPARAM port)函数中如何进行数据提取并且处理
源代码是这样的![](zzz/editor/img/code.gif)
static long rxdatacount=0; //该变量用于接收字符计数 LONG CSCOMMDlg::OnCommunication(WPARAM ch, LPARAM port) { if (port <= 0 || port > 16) return -1; rxdatacount++; //接收的字节计数 CString strTemp; strTemp.Format("%ld",rxdatacount); strTemp="RX:"+strTemp; //byte RecevieData[1000]; // unsigned short int i; if(m_bStopDispRXData) //如果选择了“停止显示”接收数据,则返回 return -1; //注意,这种情况下,计数仍在继续,只是不显示 //若设置了“自动清空”,则达到50行后,自动清空接收编辑框中显示的数据 if((m_ctrlAutoClear.GetCheck())&&(m_ctrlReceiveData.GetLineCount()>=50)) { m_ReceiveData.Empty(); UpdateData(FALSE); } //如果没有“自动清空”,数据行达到400后,也自动清空 //因为数据过多,影响接收速度,显示是最费CPU时间的操作 if(m_ctrlReceiveData.GetLineCount()>400) { m_ReceiveData.Empty(); m_ReceiveData="***The Length of the Text is too long, Emptied Automaticly!!!***\r\n"; UpdateData(FALSE); } //如果选择了"十六进制显示",则显示十六进制值 CString str; if(m_ctrlHexReceieve.GetCheck()) str.Format("%02X ",ch); else str.Format("%c",ch); //以下是将接收的字符加在字符串的最后,这里费时很多 //但考虑到数据需要保存成文件,所以没有用List Control int nLen=m_ctrlReceiveData.GetWindowTextLength(); m_ctrlReceiveData.SetSel(nLen, nLen); m_ctrlReceiveData.ReplaceSel(str); nLen+=str.GetLength(); m_ReceiveData+=str; return0;然后我通过OnCommunication,从串口接收到一段16进制数据(数据都存在m_ReceiveData中)
01 03 0C 1A E0 09 C4 03 E8 01 90 00 32 00 00 E7 A6 (数据之间有空格)
然后我要取出其中的四位 1A E0然后合并在一起1AE0并且转换成十进制代表 我要怎么来实现啊