日期:2014-05-18 浏览次数:20854 次
bool R = true; private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) { if (!R) return; if (sReceiver.BytesToRead == 0) { return; } int ArraySum = sReceiver.BytesToRead; byte[] InputArray = new byte[ArraySum]; sReceiver.Read(InputArray, 0, ArraySum); foreach (byte b in InputArray) { if (b == 0xFF) { R = false; return; } //处理数据 } }