private short HandleControlFrame(TlMsgOutCtl tlMsgOutCtl, FlowControlFrame frame)
        {
            if (frame.ErrorCode != 0 || tlMsgOutCtl.nTxState != 0)
            {
                // Error
                return(0);
            }

            Array.Copy(frame.AckdFrameBitmask, 0, tlMsgOutCtl.vTxAckdFrameBitmask, 0, 8);
            frameValidator.MarkTransactionOkPackets(tlMsgOutCtl);

            short highestOkFrameCount = GetHighestOkFrameCnt(tlMsgOutCtl.nTxFrameCnt, tlMsgOutCtl.vTxBackLogCtr);

            Debug.WriteLine(String.Format("Highest OK Frame Count {0}", highestOkFrameCount));
            if (highestOkFrameCount == tlMsgOutCtl.nTxFrameCnt)
            {
                tlMsgOutCtl.nTxFrameCnt = 0;
                tlMsgOutCtl.nTxState    = 0;
                Debug.WriteLine(">>--------TX MSG SUCCESS----------<<");
                return(1);
            }
            else
            {
                tlMsgOutCtl.nTxLatencyMs        = (short)Math.Max(frame.TransactionLatency, 10);
                tlMsgOutCtl.nTxUnackdFrameLimit = frame.UnackdFrameLimit;
                tlMsgOutCtl.nTxState            = 2;
                Debug.WriteLine(String.Format("Waiting for {0} of {1}", highestOkFrameCount, tlMsgOutCtl.nTxFrameCnt));
                return(0);
            }
        }
Пример #2
0
        internal static FlowControlFrame CreateFlowControlFrame(byte[] data)
        {
            FlowControlFrame frame = new FlowControlFrame
            {
                ErrorCode          = data[1],
                UnackdFrameLimit   = data[2],
                TransactionLatency = data[3]
            };

            Array.Copy(data, 4, frame.AckdFrameBitmask, 0, BITMASK_LENGTH);
            return(frame);
        }
Пример #3
0
        public FlowControlFrame BuildControlFrame(byte[] bitmap)
        {
            FlowControlFrame flowControlFrame = new FlowControlFrame();

            flowControlFrame.HasMessageTypeByte_b4 = true;
            flowControlFrame.FrameType             = FrameType.CONTROL;
            flowControlFrame.UnackdFrameLimit      = 8;
            flowControlFrame.TransactionLatency    = 0;
            Array.Copy(bitmap, 0, flowControlFrame.AckdFrameBitmask, 0, 8);
            byte[] var3 = flowControlFrame.AckdFrameBitmask;
            Debug.WriteLine("Bitmask: " + var3.ToByteString());
            return(flowControlFrame);
        }
Пример #4
0
        public Frame CreateFrameFromBytes(byte[] data)
        {
            FrameType frameType = getFrameTypeFromHeaderByte(data[0]);
            Frame     tlFrame   = null;

            switch (frameType)
            {
            case FrameType.SINGLE:     // 0
                tlFrame = SingleFrame.CreateSingleFrame(data);
                break;

            case FrameType.FIRST:    // 1
            case FrameType.CONS:     // 2
                tlFrame = FirstConsFrame.CreateFirstConsFrame(data);
                break;

            case FrameType.CONTROL:     // 3
                tlFrame = FlowControlFrame.CreateFlowControlFrame(data);
                break;

            case FrameType.INFO:     // 4
                tlFrame = InfoFrame.CreateInfoFrame(data);
                break;
            }

            if (tlFrame != null)
            {
                tlFrame.FrameType             = frameType;
                tlFrame.HasMessageTypeByte_b4 = (data[0] & 16) > 0;
                tlFrame.SubFrameCountOrIndex  = data[0] >> 1 & 3;
                tlFrame.IsSubFrameCount       = (data[0] & 1) > 0;
            }

            return(tlFrame);

            //string yourByteString = Convert.ToString(headerByte, 2).PadLeft(8, '0');
        }