char crcCACheck(char *p, char len)
{
short t_short =0;
for(int i=0; i<len; i++)
{
t_short +=*p++;
t_short += t_short >>8;
t_short &=0xFF;
}
return 0xFF - t_short;
}
校验的数据如下:
Len PhyId prim appId L/H D1 D2 D3 D4 CRC
08 8e 00 00 2f 18 ff e3 1b df
Len byte the value is the number of bytes in the frame, Len/CRC bytes are not included CRC byte this byte is summed after Len field to the byte in front of CRC with carry should be 0xFF. Every frame has a CRC byte, this byte is calculated with an add-with-carry method, bytes in frame are added from Len field, together with the carry value.
**Every frame has a Len byte, which calculate the frame bytes, does not include Len/CRC byte **
这是一段C代码(应该是C吧),写的是对crc校验,我想改写成python,一时无能为力,向各位大佬求助,十分感谢。