Esempio n. 1
0
        internal static InfoFrame CreateInfoFrame(byte[] data)
        {
            InfoFrame frame = new InfoFrame
            {
                InfoFrmType    = data[1],
                ProtoVersion   = data[2],
                MaxPacketLen   = data[3],
                MaxPacketCount = data[4],
                CapaFlags0     = data[5],
                CapaFlags1     = data[6],
                ModeFlags0     = data[7],
                ModeFlags1     = data[8],
                CtrlFlags0     = data[9],
                CtrlFlags1     = data[10],
                Cmd            = data[11],
                RsHi           = data[12],
                RsLo           = data[13],
                TsHi           = data[14],
                TsLo           = data[15]
            };

            return(frame);
        }
Esempio n. 2
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');
        }