private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
//System.Threading.Thread.Sleep(100); //延时100ms等待数据接收完成
byte[] ReciveData = new byte[serialPort1.BytesToRead];
serialPort1.Read(ReciveData, 0, ReciveData.Length);
if (ReciveData[0] == 0xfe)
{
MessageBox.Show("数据错误!");
}
上面的程序运行到这个数组等于0xfe就会出现说程序数组越界,System.IndexOutOfRangeException,个位大神有没有碰到过类似的问题
|