Exemple #1
0
        public static void Request_EEPROM_Put(this ArduinoSession session, int index, byte[] bytes)
        {
            if (bytes == null || bytes.Length <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(bytes), "bytes 不能为空且长度必须大于0");
            }

            var indexBytes    = index.encode32BitSignedInteger();
            var encoder7Bytes = ByteArrayExtensions.Encoder7Bit(bytes);
            var command       = new List <byte>
            {
                Utility.SysExStart,
                EEPROM_DATA,
                EEPROM_PUT,
                indexBytes[0], //4  num steps, bits 0-6
                indexBytes[1], //5  num steps, bits 7-13
                indexBytes[2], //6  num steps, bits 14-20
                indexBytes[3], //7  num steps, bits 21-27
                indexBytes[4], //8  num steps, bits 28-32
                //(byte)white,
                //Utility.SysExEnd
            };

            command.AddRange(encoder7Bytes);

            command.Add(Utility.SysExEnd);

            session.Write(command.ToArray(), 0, command.Count);
        }