带查找表的CRC 16-CCITT [英] CRC 16-CCITT with lookup table

查看:525
本文介绍了带查找表的CRC 16-CCITT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我对CRC的了解以及Java的实现是这样的:

So what I know about CRC, and also did a Java implementation is this:

例如具有一个初始消息为16位多项式

Having an initial message as a 16-bit polynomial, for instance

0x0617
65
0000.0110.0001.0111

这个得到另外16个0位

this one gets another 16 of 0 bits

0000.0110.0001.0111|0000.0000.0000.0000

然后有除数

0x1021
0001.0000.0010.0001 (0, 5, 12)

我们在初始消息中每个"1"的开头声明它,并在各位之间进行XOR运算,直到初始消息中不再有1.在我们的示例中,总共将有6个XOR.

We allign it at the start of each "1" in our initial message, and do XOR between the bits, until there are no more 1s in the initial message. In total, there will be 6 XORs in our example.

CRC将是我们消息的最后16位,或除法的其余部分.在这种情况下,为101011110110000.

The CRC will be the last 16 bits of our message, or the remainder of the division. In this case, 101011110110000.

我的问题是,如何通过查询表实现此目的?有人可以给我看一个有关如何计算多项式的数值示例吗?

My question is, how can I implement this with a look-up table? Can someone show me a numerical example on my polynomial on how it is calculated?

推荐答案

我今天一直在研究此问题,并创建了适用于任何CRC的代码,您可以在crc.h文件中找到许多不同的CRC,有些他们中的测试和工作.该代码是用C语言完成的,因此在Java中使用它应该不会有很多问题.

I have been today working on this Issue and have created a code that works for any CRC, you will find many different CRCs in the crc.h file, some of them tested and working. The code is done in C, so you should not have many problems to use it in Java.

要使用任何类型的CRC,查询表都是动态生成的,可以将A_crcLookupTable数组放在监视窗口中,如果希望将其包含为常量,则可以从该数组中复制值.

To be able to use any kind of CRC, the lookup table is generated dynamically, you can put the A_crcLookupTable array in the watch window and copy the values from the array if you want to include it as a constant.

我希望它可以帮助您: https://sourceforge.net/projects/crccalculator/files/CRC/?

I hope it helps you: https://sourceforge.net/projects/crccalculator/files/CRC/?

这篇关于带查找表的CRC 16-CCITT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆