From e6a26ee148587327478d9a82624a820c907b6e16 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期三, 04 十一月 2020 14:58:15 +0800 Subject: [PATCH] 20201104 --- HDL_ON/DriverLayer/CRC.cs | 37 +++++++++++++------------------------ 1 files changed, 13 insertions(+), 24 deletions(-) diff --git a/HDL_ON/DriverLayer/CRC.cs b/HDL_ON/DriverLayer/CRC.cs index fc19256..636025a 100644 --- a/HDL_ON/DriverLayer/CRC.cs +++ b/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>鏂癈RC</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]); -- Gitblit v1.8.0