internal static PacketPrefix FromBytes(byte[] array, int start) { if (array.Length < start + Length) return null; for (int cI = 0; cI < _startSeq.Length; cI++) if (array[start + cI] != _startSeq[cI]) return null; int cp = start + _startSeq.Length; PacketPrefix prefix = new PacketPrefix(); prefix.ServiceNumber = BitConverter.ToInt16(array, cp); cp = cp + 2; prefix.DataLength = BitConverter.ToInt64(array, cp); cp = cp + 8; byte[] tIdBytes = new byte[16]; Buffer.BlockCopy(array, cp, tIdBytes, 0, 16); prefix.TransferID = new Guid(tIdBytes); cp = cp + 16; prefix.TransferNumber = BitConverter.ToInt16(array, cp); return prefix; }
internal void SetReciving(PacketPrefix packetPrefix) { Prefix = packetPrefix; State = States.Reciving; }
internal Tx(object dataFrame = null, Int16 serviceNumber = 0, Guid? transferId = null, Int16 transferNumber = 0) : base() { Prefix = new PacketPrefix() { ServiceNumber = serviceNumber, TransferID = transferId ?? Guid.NewGuid(), TransferNumber = transferNumber }; Suffix = new PacketSuffix(); DataFrame = dataFrame; }
private void BeginRx(PacketPrefix prefix) { if (_cRx != null) { _cRx.SetInterrupted(); if (OnRxCompleted != null) OnRxCompleted(_cRx); _cRx = null; } _rxTimeout.Interval = Base.Options.InterpreterOptions.PacketSegmentReciveTimeOut.TotalMilliseconds; _cRx = new Packet.Rx(Base); _cRx.SetReciving(prefix); if (OnRxBeginn != null) OnRxBeginn(_cRx); }