Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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];
        }
Beispiel #4
0
 public override void Deserialize(byte[] bytes)
 {
     Endpoint = KnxHpai.Parse(bytes);
 }