CRC16校验和:HCS08 vs.Kermit vs.XMODEM [英] CRC16 checksum: HCS08 vs. Kermit vs. XMODEM
问题描述
我正在尝试将CRC16错误检测添加到Motorola HCS08微控制器应用程序.我的校验和不匹配.一个在线CRC计算器既提供了我在PC程序中看到的结果,又提供了我在微观上看到的结果.
I'm trying to add CRC16 error detection to a Motorola HCS08 microcontroller application. My checksums don't match, though. One online CRC calculator provides both the result I see in my PC program and the result I see on the micro.
它将微型计算机的结果称为"XModem",将PC的结果称为"Kermit".
It calls the micro's result "XModem" and the PC's result "Kermit."
这两个古老的协议指定使用CRC16的方式有什么区别?
What is the difference between the way those two ancient protocols specify the use of CRC16?
推荐答案
您可以使用相同的基本代码库来实现16位IBM,CCITT,XModem,Kermit和CCITT 1D0F.请参见使用代码的 http://www.acooke.org/cute/16bitCRCAl0.html 来自 http://www.barrgroup.com/Embedded-系统/操作方法/CRC计算C代码
you can implement 16 bit IBM, CCITT, XModem, Kermit, and CCITT 1D0F using the same basic code base. see http://www.acooke.org/cute/16bitCRCAl0.html which uses code from http://www.barrgroup.com/Embedded-Systems/How-To/CRC-Calculation-C-Code
下表显示了它们之间的区别:
the following table shows how they differ:
name polynomial initial val reverse byte? reverse result? swap result?
CCITT 1021 ffff no no no
XModem 1021 0000 no no no
Kermit 1021 0000 yes yes yes
CCITT 1D0F 1021 1d0f no no no
IBM 8005 0000 yes yes no
其中反向字节"是指每个字节在处理之前都进行了位反转; 反转结果"是指16位结果在处理后被反转. 交换结果"表示处理后将结果中的两个字节交换.
where 'reverse byte' means that each byte is bit-reversed before processing; 'reverse result' means that the 16 bit result is bit-reversed after processing; 'swap result' means that the two bytes in the result are swapped after processing.
以上所有内容均通过针对 http://www.lammertbies的测试向量进行了验证.nl/comm/info/crc-calculation.html (如果那是错误的,我们都会迷路...).
all the above was validated with test vectors against http://www.lammertbies.nl/comm/info/crc-calculation.html (if that is wrong, we are all lost...).
因此,在您的特定情况下,可以通过以下方式将XModem的代码转换为Kermit:对每个字节进行位反转,对最终结果进行位反转,然后交换结果中的两个字节.
so, in your particular case, you can convert code for XModem to Kermit by bit-reversing each byte, bit reversing the final result, and then swapping the two bytes in the result.
[我相信,但还没有检查或弄清楚细节,反转每个字节等同于反转多项式(加上一些额外的细节).这就是为什么您会在不同的地方看到基本上相同的算法的完全不同的解释的原因.
[i believe, but haven't checked or worked out the details, that reversing each byte is equivalent to reversing the polynomial (plus some extra details). which is why you'll see very different explanations in different places for what is basically the same algorithm.
此外,上述方法效率不高,但对测试很有帮助.如果您想提高效率,最好的办法就是将以上内容转换为查找表.]
also, the approach above is not efficient, but is good for testing. if you want efficient the best thing to do is translate the above to lookup-tables.]
编辑我在上面称为CCITT的内容记录在 RevEng目录作为CCITT-FALSE.有关更多信息,请参阅上面的链接上对我的博客文章的更新.
edit what i have called CCITT above is documented in the RevEng catalogue as CCITT-FALSE. for more info, see the update to my blog post at the link above.
这篇关于CRC16校验和:HCS08 vs.Kermit vs.XMODEM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!