Ejemplo n.º 1
0
        /// <summary>
        /// 将要发送的命令变成字节数组,用于带序列号的测试
        /// </summary>
        /// <returns></returns>
        public override List <byte> GetBytesEx()
        {
            //先计算Payload长度
            UpdatePayloadLength(0);
            //命令头部(payload length(含)之前)
            List <byte> basebuffer = base.GetBytesEx();
            //取checksum字节
            uint checksum = CRC32.CalcCRC32Partial(basebuffer, basebuffer.Count, CRC32.CRC32_SEED);

            checksum ^= CRC32.CRC32_SEED;
            byte[] arrChecksum = StructConverter.StructureToByte <uint>(checksum);
            basebuffer.AddRange(arrChecksum);
            return(basebuffer);
        }
Ejemplo n.º 2
0
        public List <byte> GetBytesDebug()
        {
            byte payloadLength = (byte)(m_PumpPackages.Count * this.m_Channel);

            this.m_Direction = 0;
            //先计算Payload长度
            UpdatePayloadLength(payloadLength);
            //命令头部(payload length(含)之前)
            List <byte> basebuffer = base.GetBytes();

            for (int i = 0; i < m_PumpPackages.Count; i++)
            {
                basebuffer.AddRange(m_PumpPackages[i].GetBytes());
            }
            //取checksum字节
            uint checksum = CRC32.CalcCRC32Partial(basebuffer, basebuffer.Count, CRC32.CRC32_SEED);

            checksum ^= CRC32.CRC32_SEED;
            byte[] arrChecksum = StructConverter.StructureToByte <uint>(checksum);
            basebuffer.AddRange(arrChecksum);
            return(basebuffer);
        }