public bool bCrcCheck_SearchTable(byte[] bDataWithCRC, int nCrcBitLength)
{
int nCrcByteLength = nCrcBitLength / 8;
int nDataLength = bDataWithCRC.Length - nCrcByteLength;
ushort uNewCrc;
//if the last crccode is 0 then right
for (int i = 0; i < nDataLength; i++)
{
uNewCrc = uCrcLookupTable[bDataWithCRC[i]];
for (int j = 0; j < nCrcByteLength; j++)
{
uNewCrc = (ushort)(uNewCrc ^ (bDataWithCRC[i + j + 1] << (8 * (nCrcByteLength - 1 - j))));
}
for (int k = 1; k <= nCrcByteLength; k++)
bDataWithCRC[i + k] = (byte)(uNewCrc >> (8 * (nCrcByteLength - k)));
}
bool bRtn = true;
for (int i = 0; i < nCrcBitLength / 8; i++)
if (bDataWithCRC[bDataWithCRC.Length - nCrcBitLength / 8 + i] != 0)
bRtn = false;
return bRtn;
}
我调用bCrcCheck_SearchTable(bData,8)之后,bData里的数据也改变了。