Example #1
0
        public override void deserialize(byte[] packet)
        {
            NCCFeatures = new NCCFeatures();

            base.deserialize(packet);
            NCCFeatures.deserialize(payLoad[0], payLoad[1], payLoad[2], payLoad[3]);
            byte numberSupportedInterfaces = payLoad[4];

            SupportedInterfaces = new SupportedInterfacesEnum[numberSupportedInterfaces];
            short pos = 5;

            for (int i = 0; i < numberSupportedInterfaces; i++)
            {
                SupportedInterfaces[i] = (SupportedInterfacesEnum)Enum.ToObject(typeof(SupportedInterfacesEnum), payLoad[pos]);
                pos++;
            }
            MaxLogicalConnections = payLoad[pos];
            pos++;
            MaxRoutingTableSize = ToShort(payLoad[pos], payLoad[pos + 1]);
            pos = (short)(pos + 2);
            MaxControlPacketPayloadSize = payLoad[pos];
            pos++;
            MaxSizeForLargeParameters = ToShort(payLoad[pos], payLoad[pos + 1]);
            pos            = (short)(pos + 2);
            ManufacturerId = payLoad[pos];
            pos++;
            ManufacturerSpecificInformation = new byte[4];
            Array.Copy(payLoad, pos, ManufacturerSpecificInformation, 0, 4);
            pos = (short)(pos + 4);
        }
Example #2
0
        public override byte[] serialize()
        {
            if (SupportedInterfaces == null)
            {
                SupportedInterfaces = new SupportedInterfacesEnum[0];
            }

            if (ManufacturerSpecificInformation == null)
            {
                ManufacturerSpecificInformation = new byte[4];
            }

            if (NCCFeatures == null)
            {
                throw new Exception("NCCFeatures not initialised");
            }

            if (ManufacturerSpecificInformation.Length != 4)
            {
                throw new Exception("ManufacturerSpecificInformation > 4");
            }

            byte[][] serOut = new byte[4][];
            serOut[0] = NCCFeatures.serialize();

            serOut[1]    = new byte[SupportedInterfaces.Length + 1];
            serOut[1][0] = (byte)SupportedInterfaces.Length;
            for (int i = 0; i < SupportedInterfaces.Length; i++)
            {
                serOut[1][i + 1] = (byte)SupportedInterfaces[i];
            }

            serOut[2]    = new byte[7];
            serOut[2][0] = MaxLogicalConnections;
            serOut[2][1] = FromShortMSB(MaxRoutingTableSize);;
            serOut[2][2] = FromShortLSB(MaxRoutingTableSize);;
            serOut[2][3] = MaxControlPacketPayloadSize;
            serOut[2][4] = FromShortMSB(MaxSizeForLargeParameters);;
            serOut[2][5] = FromShortLSB(MaxSizeForLargeParameters);;
            serOut[2][6] = ManufacturerId;

            serOut[3] = ManufacturerSpecificInformation;

            payLoad = serOut.SelectMany(x => x).ToArray();

            return(base.serialize());
        }