CRC 16-CCITT with lookup table

2019-06-13 06:10发布

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条回答
forever°为你锁心
2楼-- · 2019-06-13 07:04

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/?

查看更多
登录 后发表回答