//以下是将接收的字符加在字符串的最后,这里费时很多 //但考虑到数据需要保存成文件,所以没有用List Control int nLen=m_ctrlReceiveData.GetWindowTextLength(); m_ctrlReceiveData.SetSel(nLen, nLen); m_ctrlReceiveData.ReplaceSel(str); nLen+=str.GetLength();m_ReceiveData+=str;串口助手源代码里这一段话是不是能看出数据存储到哪里了呢??我看不太懂
int nLen=m_ctrlReceiveData.GetWindowTextLength(); m_ctrlReceiveData.SetSel(nLen, nLen); m_ctrlReceiveData.ReplaceSel(str); nLen+=str.GetLength();m_ReceiveData+=str; 接收到的数据就存到m_ReceiveData里了,因此你可以这么改: int a[20]; a[i]=atoi(str);//你把str改成char类型,这个好象是CString类型 i++;//这是接收字符数,每接收一个就加一
你的意思是这段代码直接改成: int nLen=m_ctrlReceiveData.GetWindowTextLength(); m_ctrlReceiveData.SetSel(nLen, nLen); m_ctrlReceiveData.ReplaceSel(str); nLen+=str.GetLength(); m_ReceiveData+=str; int a[20]; a[i]=atoi(str);//这里的str改成char类型 i++;是直接改成这样吗?数据就以整形储存在a[i]里了??
1。
手动保存串口里的数据到文本文件里,这个一般串口助手都有这个功能,然后你的程序再读取这个文本文件里的数据送到数组或直接送到TEECHART控件
2。
你的程序直接找到串口助手的窗口,然后再得到显示数据的控件窗口,直接从这个窗口里得到接收的数据,再送到数组或直接送到TEECHART控件
//但考虑到数据需要保存成文件,所以没有用List Control
int nLen=m_ctrlReceiveData.GetWindowTextLength();
m_ctrlReceiveData.SetSel(nLen, nLen);
m_ctrlReceiveData.ReplaceSel(str);
nLen+=str.GetLength();m_ReceiveData+=str;串口助手源代码里这一段话是不是能看出数据存储到哪里了呢??我看不太懂
m_ctrlReceiveData.SetSel(nLen, nLen);
m_ctrlReceiveData.ReplaceSel(str);
nLen+=str.GetLength();m_ReceiveData+=str;
接收到的数据就存到m_ReceiveData里了,因此你可以这么改:
int a[20];
a[i]=atoi(str);//你把str改成char类型,这个好象是CString类型
i++;//这是接收字符数,每接收一个就加一
int nLen=m_ctrlReceiveData.GetWindowTextLength();
m_ctrlReceiveData.SetSel(nLen, nLen);
m_ctrlReceiveData.ReplaceSel(str);
nLen+=str.GetLength();
m_ReceiveData+=str;
int a[20];
a[i]=atoi(str);//这里的str改成char类型
i++;是直接改成这样吗?数据就以整形储存在a[i]里了??