예제 #1
0
        public static SingleFrame CreateSingleFrame(byte[] data)
        {
            SingleFrame frame = new SingleFrame();

            Array.Copy(data, 1, frame.Payload, 0, PAYLOAD_LENGTH);
            return(frame);
        }
예제 #2
0
        public SingleFrame BuildSingleFrame(byte[] data)
        {
            SingleFrame singleFrm = new SingleFrame();

            singleFrm.FrameType             = FrameType.SINGLE;
            singleFrm.HasMessageTypeByte_b4 = true;

            singleFrm.IsSubFrameCount      = true;
            singleFrm.SubFrameCountOrIndex = 0;

            Array.Copy(data, 0, singleFrm.Payload, 0, 19);
            return(singleFrm);
        }
예제 #3
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');
        }