当前位置: 首页>>代码示例>>C#>>正文


C# Frame.DeleteFromFront方法代码示例

本文整理汇总了C#中Frame.DeleteFromFront方法的典型用法代码示例。如果您正苦于以下问题:C# Frame.DeleteFromFront方法的具体用法?C# Frame.DeleteFromFront怎么用?C# Frame.DeleteFromFront使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Frame的用法示例。


在下文中一共展示了Frame.DeleteFromFront方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadFromFrameHeader

 /// <summary>
 /// Decode message from frame header
 /// </summary>
 /// <param name="frame">Frame containing message</param>
 /// <returns>True on success</returns>
 public bool ReadFromFrameHeader(Frame frame)
 {
     if (frame == null || frame.LengthDataUsed < cLength)
         return false;
     byte Header = frame.ReadByte(0);
     if ((Type)(Header >> 2) != Type.Data)
         return false;
     frame.DeleteFromFront(1);
     return true;
 }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:15,代码来源:Messages_custom.cs

示例2: HandleLowerLayerDataIndication

        public void HandleLowerLayerDataIndication(object sender, ushort originatorShortAddr, ushort targetShortAddr, Frame sdu)
        {
            FragmentationMessage fragMsg = null;
            FragmentHeader header;

            lock (_lock)
            {
                if ((!_started) || (sdu.LengthDataUsed < 2))
                {
                    Frame.Release(ref sdu);
                    return;
                }

                // extract fragment header.
                header = FragmentHeader.Decode(sdu.ReadUInt16(0));
                sdu.DeleteFromFront(2);
                FragmentationMessageAssociationSet associations;
                switch (header.Type)
                {
                    case FragmentType.DATA:
                        associations = _inboundAssociations;
                        if (associations == null)
                        {
                            Frame.Release(ref sdu);
                            return;
                        }

                        fragMsg = (InboundFragmentationMessage)associations.GetFragmentationMessage(originatorShortAddr, targetShortAddr);
                        if (fragMsg != null)
                        {
                            // there is already one message with this peer. Check freshness.
                            if (fragMsg.MessageNumber != header.MessageSeqNumber)
                            {
                                int sqnOld = (int)fragMsg.MessageNumber;
                                int sqnNew = (int)header.MessageSeqNumber;
                                int diff = (sqnNew > sqnOld) ? sqnNew - sqnOld : sqnNew - sqnOld + 256;
                                if ((header.MessageSeqNumber == 0) || (diff < 128))
                                {
                                    // data received is most recent.
                                    fragMsg.Dispose();
                                    fragMsg = null;
                                }
                                else
                                {
                                    // data received is old stuff.
                                    Frame.Release(ref sdu);
                                    return;
                                }
                            }
                        }

                        if (fragMsg == null)
                        {
                            // new message must be started
                            fragMsg = new InboundFragmentationMessage(originatorShortAddr, targetShortAddr,
                                header.MessageSeqNumber, _lowerLayerDataRequest, _lowerMtu, _lowerHead, _lowerTail, _timer);
                            fragMsg.FragmentationMessageTerminated += this.HandleFragmentationMessageTerminated;
                            associations.SetFragmentationMessage(originatorShortAddr, targetShortAddr, fragMsg);
                        }
                        break;
                    case FragmentType.ACK:
                        associations = _outboundAssociations;
                        if (associations == null)
                        {
                            Frame.Release(ref sdu);
                            return;
                        }

                        fragMsg = (OutboundFragmentationMessage)associations.GetFragmentationMessage(targetShortAddr, originatorShortAddr);
                        if ((fragMsg == null) || (fragMsg.MessageNumber != header.MessageSeqNumber))
                        {
                            //no one waiting for this segment. Discard.
#if DEBUG
                            Trace.Print("No one waiting for this segment. Discard.");
#endif

                            Frame.Release(ref sdu);
                            return;
                        }
                        break;
                    default:
                        break;
                }
            }

            // release the lock before calling method in FragmentMessage class
            if (fragMsg != null)
            {
                fragMsg.HandleReceivedFragment(header, ref sdu);

            }
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:92,代码来源:Fragmentation.cs

示例3: ReadFromFrameHeader

            /// <summary>
            /// Decode message from frame header
            /// </summary>
            /// <param name="frame">Frame containing message</param>
            /// <returns>True on success</returns>
            public bool ReadFromFrameHeader(Frame frame)
            {
                if (frame == null || frame.LengthDataUsed < cLengthMin)
                    return false;

                byte b = frame.ReadByte(0);
                if ((b >> 6) != (byte)Dispatch.Mesh ||
                    (b & 32) == 0 ||
                    (b & 16) == 0)
                    return false;
                HopsLeft = (byte)(b & 15);
                if (HopsLeft < 15)
                {
                    originatorAddress = frame.ReadUInt16Canonical(1);
                    finalAddress = frame.ReadUInt16Canonical(3);
                    frame.DeleteFromFront(cLengthMin);
                }
                else
                {
                    if (frame.LengthDataUsed < cLengthMax)
                        return false;
                    HopsLeft = frame.ReadByte(1);
                    originatorAddress = frame.ReadUInt16Canonical(2);
                    finalAddress = frame.ReadUInt16Canonical(4);
                    frame.DeleteFromFront(cLengthMax);
                }

                return true;
            }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:34,代码来源:Messages_6LoWPAN.cs

示例4: WriteTXFIFO

        /// <summary>
        /// Write to the TXFIFO.
        /// </summary>
        /// <param name="len">The number of bytes to write</param>
        /// <param name="buf">The buffer to write from    </param>
        private void WriteTXFIFO(Frame frame)
        {
            if (frame.LengthHeaderAvail < 2)
                throw new ArgumentException();

            lock (_hal)
            {
                int len = frame.LengthDataUsed; // including fcs when not using autoFcs
                if (_hal.AutoFCS)
                    len += 2;
                _txWriteCmd[1] = (byte)len;
                frame.AppendToFront(_txWriteCmd, 0, 2);
                _hal.Write(frame);
                frame.DeleteFromFront(2);
                _txFrame = frame;
            }
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:22,代码来源:CC2420.Driver.cs


注:本文中的Frame.DeleteFromFront方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。