求大神将这段c语言代码转成c#的
constWORDwCRCTalbeAbs[]={0x0000,0xCC01,0xD801,0x1400,0xF001,0x3C00,0x2800,0xE401,0xA0...
const WORD wCRCTalbeAbs[] =
{0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401, 0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400, };
WORD CRC16_2(BYTE* pchMsg, WORD wDataLen) { WORD wCRC = 0xFFFF; WORD i;BYTE chChar;
for (i = 0; i < wDataLen; i++) { chChar = *pchMsg++;
wCRC = wCRCTalbeAbs[(chChar ^ wCRC) & 15] ^ (wCRC >> 4);
wCRC = wCRCTalbeAbs[((chChar >> 4) ^ wCRC) & 15] ^ (wCRC >> 4);
} return wCRC;
}
谢谢 展开
{0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401, 0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400, };
WORD CRC16_2(BYTE* pchMsg, WORD wDataLen) { WORD wCRC = 0xFFFF; WORD i;BYTE chChar;
for (i = 0; i < wDataLen; i++) { chChar = *pchMsg++;
wCRC = wCRCTalbeAbs[(chChar ^ wCRC) & 15] ^ (wCRC >> 4);
wCRC = wCRCTalbeAbs[((chChar >> 4) ^ wCRC) & 15] ^ (wCRC >> 4);
} return wCRC;
}
谢谢 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询