static unsigned short crc16_update(unsigned short crc, unsigned char a)
{
int i;
crc ^= a;
for (i = 0; i < 8; ++i)
{
if (crc & 1)
{
crc = (crc >> 1) ^ 0xA001;
}
else
{
crc = (crc >> 1);
}
}
return crc;
}
//------------------
static unsigned short getChk(unsigned char * b,int len)
{
unsigned short crc=0xffff;
while(len--)
{
crc=crc16_update(crc,*b++);
}
return crc;
}