private void ParseInfo(IndividualEndianessBinaryReader br) { if (_infoLength > 0) { _information = br.ReadBytes(_infoLength); } }
public static AdditionalInformationField Parse(IndividualEndianessBinaryReader br) { if (br.Available < 2) { throw BufferSizeException.TooSmall("AdditionalInformationField"); } return(new AdditionalInformationField(br)); }
protected override void ParseServiceInformation(IndividualEndianessBinaryReader br) { ParseControlField1(br); ParseControlField2(br); ParseSourceAddress(br); ParseDestinationAddress(br); ParseAPDU(br); }
private void ParseLength(IndividualEndianessBinaryReader br) { _infoLength = br.ReadByte(); if (br.Available < _infoLength) { throw BufferSizeException.TooSmall("AdditionalFieldInfo"); } }
/// <summary> /// Create an <c>AdditionalInformationField</c> class by parsing raw data /// </summary> /// <param name="br">Reader with the associated byte array</param> protected AdditionalInformationField(IndividualEndianessBinaryReader br) { ParseType(br); ParseLength(br); if (br.Available < _infoLength) { throw BufferSizeException.TooSmall("AdditionalInformationField"); } ParseInfo(br); VerifyLength(_infoType, _infoLength); _size = 2 + _infoLength; }
protected void ParseAPDU(IndividualEndianessBinaryReader br) { // read length information and increase lenght by one due to TPCI/APCI encoding var len = br.ReadByte() + 1; if (br.Available < len) { throw BufferSizeException.TooBig("Cemi Frame - TCPI Data"); } _payload = br.ReadBytes(len); _apci = new Apci(_payload); }
private void ParseType(IndividualEndianessBinaryReader br) { var infotype = br.ReadByte(); if (Enum.IsDefined(typeof(AdditionalInfoType), infotype)) { _infoType = (AdditionalInfoType)infotype; } else { throw BufferFieldException.TypeUnknown("AdditionalInfoType", infotype); } }
protected void ParseDestinationAddress(IndividualEndianessBinaryReader br) { var dst = br.ReadU2be(); if (_controlField2.DestinationAddressType == AddressType.GroupAddress) { _destinationAddress = new GroupAddress(dst); } else { _destinationAddress = new IndividualAddress(dst); } }
public static bool TryParse(out CemiLData cemildata, IndividualEndianessBinaryReader br) { bool result = false; try { cemildata = new CemiLData(br); result = true; } catch { cemildata = null; result = false; } return(result); }
/// <summary> /// Creates a new cEMI L_Data Frame /// </summary> /// <param name="br">IndividualEndianessBinaryReader with the underlying buffer the frame is parsed from</param> protected CemiLData(IndividualEndianessBinaryReader br) : base(br) { }
public static CemiLData Parse(IndividualEndianessBinaryReader br) { return(new CemiLData(br)); }
protected void ParseSourceAddress(IndividualEndianessBinaryReader br) { var src = br.ReadU2be(); _sourceAddress = new IndividualAddress(src); }
protected void ParseControlField2(IndividualEndianessBinaryReader br) { var ctrl = br.ReadByte(); _controlField2 = new ControlField2(ctrl); }
protected void ParseControlField1(IndividualEndianessBinaryReader br) { var ctrl1 = br.ReadByte(); _controlField1 = new ControlField1(_messageCode, ctrl1); }
protected override bool VerifyBufferSize(IndividualEndianessBinaryReader br) { return(br.Size - br.Position >= MESSAGEMINLENGTH); }