#region CRC12校验
/// <summary>
/// CRC12校验
/// </summary>
/// <param name="lenth"></param>
/// <param name="RXBUFFER"></param>
/// <returns></returns>
public static byte[] crc12(int lenth, byte[] RXBUFFER)
{
int crc12out = 0;
int i, j;
for (j = 0; j < lenth; j++)
{
for (i = 0; i < 8; i++)
{
int uio = (RXBUFFER[j] & (0x80 >> i));
if ((RXBUFFER[j] & (0x80 >> i)) != 0)
{
crc12out |= 0x1;
}
if (crc12out >= 0x1000) crc12out ^= 0x180d;
{
crc12out <<= 1;
}
}
}
for (i = 0; i < 12; i++)
{
if (crc12out >= 0x1000) crc12out ^= 0x180d;
crc12out <<= 1;
}
crc12out >>= 1;
byte[] temdata = new byte[2] { (byte)(crc12out >> 8), (byte)(crc12out & 0xFF) };
return temdata;
}
#endregion
C# CRC12校验
最新推荐文章于 2023-06-09 20:12:45 发布