/// <summary> /// Deserializes the specified bytes. /// </summary> /// <param name="bytes">The bytes.</param> public override void Deserialize(byte[] bytes) { var hpaiLength = (int)bytes[2]; // get the length for the "HostProtocolAddressInformation // var hpaiBytes = new byte[hpaiLength]; // extract the hpai bytes Array.Copy(bytes, 2, hpaiBytes, 0, hpaiLength); // parse the host protocol address information this.CommunicationChannel = bytes[0]; this.HostProtocolAddressInfo = KnxHpai.Parse(hpaiBytes); }
public void SerializeDeserializeKnxHpai() { var hpai = new KnxHpai { HostProtocolCode = HostProtocolCode.IPV4_UDP, IpAddress = IPAddress.Parse("192.168.2.1"), Port = 3060 }; var array = hpai.ToByteArray(); var deserializedHpai = KnxHpai.Parse(array); Assert.AreEqual(hpai.HostProtocolCode, deserializedHpai.HostProtocolCode); Assert.AreEqual(hpai.IpAddress, deserializedHpai.IpAddress); Assert.AreEqual(hpai.Port, deserializedHpai.Port); }
public override void Deserialize(byte[] bytes) { this.CommunicationChannel = bytes[0]; //this.State = (ErrorCode)Enum.Parse(typeof(ErrorCode), (((int)bytes[1]).ToString())); this.State = (ErrorCode)bytes[1]; if (this.State != ErrorCode.NoError) { return; } var hpaiLength = (int)bytes[2]; // get the length for the "HostProtocolAddressInformation // var hpaiBytes = new byte[hpaiLength]; // extract the hpai bytes Array.Copy(bytes, 2, hpaiBytes, 0, hpaiLength); // parse the host protocol address information this.HostProtocolAddressInfo = KnxHpai.Parse(hpaiBytes); // the connection type is written behind the hpai //this.ConnectionType = // (ConnectionType)Enum.Parse(typeof(ConnectionType), (((int)bytes[hpaiLength + 2]).ToString())); this.ConnectionType = (ConnectionType)bytes[hpaiLength + 2]; }
public override void Deserialize(byte[] bytes) { Endpoint = KnxHpai.Parse(bytes); }