wxr
2020-11-04 e6a26ee148587327478d9a82624a820c907b6e16
HDL_ON/DriverLayer/CRC.cs
@@ -4,18 +4,8 @@
namespace HDL_ON
{
    /// <summary>
    /// CRC 的摘要说明。
    /// </summary>
    public class CRC
    {
        public CRC()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        #region crctab
        private static ushort[] crctab = new ushort[256]
        {  
@@ -52,14 +42,14 @@
          0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
          0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
        };
        #endregion
      #endregion
        /// <summary>
        /// CRC校验公式
        /// </summary>
        /// <param name="crc">CRC</param>
        /// <param name="cp">发送的数据序列</param>
        /// <returns>新CRC</returns>
      /// <summary>
      /// CRC校验公式
      /// </summary>
      /// <param name="crc">CRC</param>
      /// <param name="cp">发送的数据序列</param>
      /// <returns>新CRC</returns>
      private static void xcrc(ref byte height,ref byte low,byte cp)
        {
            ushort t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0;
@@ -72,18 +62,17 @@
         low = (byte)(t6 % 256);
        }
        /// <summary>
        /// 添加CRC校验字
        /// </summary>
        /// <param name="bufin">信息串</param>
        /// <param name="n">不包括校验字的串总长度</param>
        public static void ConCRC(ref byte[] bufin, byte start, int n)
      /// <summary>
      /// 添加CRC校验字
      /// </summary>
      /// <param name="bufin">信息串</param>
      /// <param name="n">不包括校验字的串总长度</param>
      public static void ConCRC(ref byte[] bufin, byte start, int n)
        {
          
         byte height = 0;
         byte low = 0;
            byte i;
            //n个数据的CRC校验
            for (i = start; i < n; i++)
            {
            xcrc(ref height,ref low, bufin[i]);