CRC按照位直接计算,比较灵活可以修改生成多项式
unsigned char CFrameInput::GetCheckSum(unsigned char *crcData, int crcDataLen)
{
unsigned char crcPoly = 0x07; // 生成多项式
unsigned char crcResult = 0xFF;
unsigned char crcTemp = 0x00; //模拟寄存器
unsigned char *data = new unsigned char[crcDataLen+1]; // 多增加一个空间,用于加0
ACE_OS::memcpy(data, crcData, crcDataLen);
data[crcDataLen] = 0x00;
crcTemp = data[0];
for (int i=1; i<crcDataLen+1; i++)
{
unsigned char tempData = data[i];
int j = 0;
CRC8校验
最新推荐文章于 2023-12-11 23:16:54 发布