CRC 16-CCITT with lookup table

风格不统一 提交于 2019-12-08 11:35:27

问题


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

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

0x0617
65
0000.0110.0001.0111

this one gets another 16 of 0 bits

0000.0110.0001.0111|0000.0000.0000.0000

Then, having the divisor,

0x1021
0001.0000.0010.0001 (0, 5, 12)

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.

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?


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/22693578/crc-16-ccitt-with-lookup-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!