示例#1
0
        /// <summary>
        /// Sends a chunk of firmware data to Blaze
        /// </summary>
        /// <param name="blaze"></param>
        /// <param name="index"></param>
        /// <param name="chunk"></param>
        /// <returns></returns>
        public static bool WriteFirmwareChunk(Blaze blaze, ushort index, List <byte> chunk)
        {
            ByteList data = new ByteList();

            data.AddUInt16(index);
            data.AddRange(chunk);

            return(blaze.Write(BlazeCommand.WriteFirmwareChunk, data.ToArray()));
        }
示例#2
0
文件: Blaze.cs 项目: vipsaini/Blaze
        internal bool Write(BlazeCommand command, params byte[] data)
        {
            ByteList byteList = new ByteList();
            ushort   length   = 0;

            if (data != null)
            {
                length = (ushort)data.Length;
            }

            // Add a '$' sync character
            byteList.Add(36);
            byteList.Add((byte)command);
            byteList.AddUInt16(length);

            if (length > 0)
            {
                byteList.AddRange(data);
            }

            ushort csum = 0;

            if (_checksum != null)
            {
                // Don't count the
                csum = _checksum.Calculate(byteList, 0, byteList.Count);
            }

            byteList.Add((byte)(csum >> 8));
            byteList.Add((byte)csum);

            byteList.TrimExcess();

            _replyReceived.Reset();

            _startTime = Environment.TickCount;

            if (_dataBuffer != null)
            {
                _dataBuffer.Clear();
            }

            _provider.Write(byteList);

            bool flag = _replyReceived.WaitOne(_provider.Timeout);

            _endTime = Environment.TickCount;

            return(flag);
        }