C#实现串口通讯CRC算法

图片说明

如何实现目标字符输完,通过CRC算法 自动出来计算结果那个框

可以参考 http://www.cnblogs.com/armyfai/p/3566582.html

public override byte[] CRCCheck(byte[] instructions, uint start, uint length)
{
Instructions = instructions;
uint i, j;
uint crc16 = 0xFFFF;
length = length + start;
for (i = start; i < length; i++)
{
crc16 ^= instructions[i];
for (j = 0; j < 8; j++)
{
if ((crc16 & 0x01) == 1)
{
crc16 = (crc16 >> 1) ^ 0xA001;
}
else
{
crc16 = crc16 >> 1;
}
}
}
return BitConverter.GetBytes(crc16);
}
就是这样的,

http://blog.csdn.net/educast/article/details/7383868

 byte crcHi = 0xff;  // 高位初始化  
byte crcLo = 0xff;  // 低位初始化  
修改为
byte crcHi = 0xa0;  // 高位初始化  
byte crcLo = 0x01;  // 低位初始化  

http://blog.csdn.net/tx_yu/article/details/4789067