private uint crc_16(uint【】 Array,/* uint【】 Rcvbuf,*/ int Len)
{
uint【】 Rcvbuf = new uint【2】;
uint IX, IY, CRC;
CRC = 0xFFFF;//set all
if (Len <= 0)
CRC = 0;
else
{
Len--;
for (IX = 0; IX <= Len; IX++)
{
CRC = CRC ^ (Array【IX】);
for (IY = 0; IY <= 7; IY++)
{
if ((CRC & 1) != 0)
CRC = (CRC >> 1) ^ 0xA001;
else
CRC = CRC >> 1; //
}
}
}
Rcvbuf【0】 = (CRC & 0xff00) >> 8;//高位置
Rcvbuf【1】 = (CRC & 0x00ff); //低位置
CRC = Rcvbuf【0】 << 8;
CRC += Rcvbuf【1】;
return CRC;
}