Exemplo n.º 1
0
        public byte[] GetBytesCemi()
        {
            if (IsExtended && Length > 256)
            {
                throw new Exception("Bei cEmi kann maximal 256 Bytes ausgelesen werden. (Angefordert waren " + Length + " bytes)[ExtendedFrame]");
            }

            if (!IsExtended && Length > 13)
            {
                throw new Exception("Bei cEmi kann maximal 13 Bytes ausgelesen werden. (Angefordert waren " + Length + " bytes)[StandardFrame]");
            }


            List <byte> data = new List <byte> {
                BitConverter.GetBytes(Length)[0]
            };

            byte[] addr = BitConverter.GetBytes(Address);
            data.Add(addr[1]);
            data.Add(addr[0]);

            Builders.TunnelRequest builder = new TunnelRequest();
            if (IsExtended)
            {
                builder.SetIsExtended();
            }
            builder.Build(UnicastAddress.FromString("0.0.0"), DestinationAddress, ApciTypes.MemoryRead, SequenceNumber, data.ToArray());
            data = new List <byte>()
            {
                0x11, 0x00
            };
            data.AddRange(builder.GetBytes());
            return(data.ToArray());
        }
Exemplo n.º 2
0
        public byte[] GetBytesCemi()
        {
            TunnelRequest builder = new TunnelRequest();
            List <byte>   data    = new List <byte> {
                Convert.ToByte(Data.Length)
            };

            byte[] addr = BitConverter.GetBytes(Convert.ToInt16(Address));
            Array.Reverse(addr);
            data.AddRange(addr);
            data.AddRange(Data);

            if (IsExtended)
            {
                builder.SetIsExtended();
            }
            builder.Build(UnicastAddress.FromString("0.0.0"), DestinationAddress, ApciTypes.MemoryWrite, SequenceNumber, data.ToArray());
            data = new List <byte>()
            {
                0x11, 0x00
            };
            data.AddRange(builder.GetBytes());
            return(data.ToArray());
        }