public class myCheack { private static int[] i16CRCTalbeAbs = { 0x0000, 0xcc01, 0xd801, 0x1400, 0xf001, 0x3c00, 0x2800, 0xe401, 0xa001, 0x6c00, 0x7800,0xb401, 0x5000, 0x9c01, 0x8801, 0x4400}; public int Crc16_Check(byte[] uchMsg, int usDataLen) { int i16Crc; int i; byte byTmp; if (uchMsg == null) return (0); i16Crc = 0xffff; for (i = 0; i < usDataLen; i++) { byTmp = uchMsg[i]; i16Crc = (int)(i16CRCTalbeAbs[(byTmp ^ i16Crc) & 15] ^ (i16Crc >> 4)); i16Crc = (int)(i16CRCTalbeAbs[((byTmp >> 4) ^ i16Crc) & 15] ^ (i16Crc >> 4)); } i16Crc = (int)(((i16Crc >> 8) & 0x00ff) | ((i16Crc << 8) & 0xff00)); return (i16Crc); } }
MDBUS_CRC16
猜你喜欢
转载自blog.csdn.net/cqg_blog/article/details/79013935
今日推荐
周排行