public static FirstConsFrame CreateFirstConsFrame(byte[] data) { // TODO: Will be overwritten from factory FirstConsFrame frame = new FirstConsFrame { IsSubFrameCount = (data[0] & 0x80) > 0, SubFrameCountOrIndex = (data[0] >> 5 & 3), // 0000 0011 HasMessageTypeByte_b4 = (data[0] & 8) > 0, //TODO: frame.frmeID_b765 = (byte)(data[0] & 7); FrameCountOrNuber = data[1] }; Array.Copy(data, 2, frame.Payload, 0, PAYLOAD_LENGTH); return(frame); }
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'); }