串口数据的提取? 困扰中,请帮忙啊
请教:想把收到的最新的串口数据存到数组中,这个该怎么解决?这个是我做的,将NewData中的值赋给全局字符串str,发现会出问题,就是str = NewData.ToString();调试时发现 NewData中的数据并不是最新接到的数据,而是此时已经收到的全部数据,请问,我想收到最新收到的那些数据该怎么办?困扰好久了,多谢指教啊public delegate void UpdateString(object NewData);
public void UpdateRecevie(object NewData)
{
if (this.InvokeRequired)//等待异步
{
UpdateString _myInvoke = new UpdateString(UpdateRecevie);
this.Invoke(_myInvoke, new object[] { NewData });
}
else
{
txtReceive.AppendText(NewData.ToString());
txtReceive.SelectionStart = txtReceive.Text.Length - 1;
txtReceive.ScrollToCaret();
str = NewData.ToString();
strCompare(str );
}
}
private void strCompare(string str)
{
str0 = str;
str1 = str0.Substring(0,5);
str2 = str0.Substring(5,3);
addtxt.Text = str1;
temptxt.Text = str2;
}