Пример #1
0
        private void SendAdress(UInt32 address)
        {
            if (address % 4 != 0)
            {
                throw new ArgumentException("Must be 32-bit aligned", "address");
            }

            address = Endianess.ToBigEndian(address);
            byte cs = GenerateChecksum(address);

            port.Write(new byte[] { (byte)((address & 0x000000FF)),       // 1. Byte
                                    (byte)((address & 0x0000FF00) >> 8),  // 2. Byte
                                    (byte)((address & 0x00FF0000) >> 16), // 3. Byte
                                    (byte)((address & 0xFF000000) >> 24), // 4. Byte
                                    cs },                                 // 5. Byte
                       0, 5);

            if ((Command)port.ReadByte() != Command.Ack)
            {
                throw new InvalidOperationException("Invalid Address reported");
            }
        }