public byte ReadByte() { byte b = 0; if (ReadSwitch == ReadWay.RS232) { b = RS232Obj.ReadByte(); } else if (ReadSwitch == ReadWay.File) { b = FileObj.ReadByte(); } byte[] bs = { b }; if (ReadSwitch != ReadWay.None && IsLog == true && FileObj != null && FileObj.IsOpen == true) { FileObj.WriteBytes(bs, 0, 1); } return(b); }
//接收数据 void SerialObject_OnReceviceByte() { while (SerialObject != null && SerialObject.BufferByteNum > 0) { Buffer.InsertObject(SerialObject.ReadByte()); while (Buffer.Amount > 0) { if (Buffer[0] != S1) { Buffer.FetchObject(); _LostByteNum++; } else { break; } } if (CheckFrame()) { AnalyseProtocol(); } } }