c#串口数据接收问题??求高手解释!!
//串口接收数据 private void serialPort1_DataReceived(object sender, e)
{
while (serialPort1.BytesToRead > 0)
{
ReceiveData += serialPort1.ReadExisting();
}
safeAddtrText(ReceiveData);//显示数据的委托
ReceiveData = "";
}
//委托的实现
private void
safeAddtrText(string text)
{
if (this.InvokeRequired)
{
_SafeAddtrTextCall callALL =
delegate(string s)
{
//if (txtBoxAllReceive.Text.Length > 2048)
// txtBoxAllReceive.Text = "";
//txtBoxAllReceive.Text += s + " ";
txtBoxAllReceive.AppendText(s);
};
this.Invoke(callALL, text);
}
}
private void button2_Click(object sender, EventArgs e)
{
string[] receive=new string[10];
for (int j = 0; j < 10;)
{
if (ReceiveData.Length == 18)
{
receive[j] = ReceiveData;
j++;
}
}
}
receive[]中得到的数据一直是一个数据没改变?????????