Questions tagged [crc16]

CRC16 is a 16-bit Cyclic Redundancy Check code, used mainly as an error detection method during data transmission.

A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data. Blocks of data entering these systems get a short check value attached, based on the remainder of a polynomial division of their contents; on retrieval the calculation is repeated, and corrective action can be taken against presumed data corruption if the check values do not match. Because the check value has a fixed length, the function that generates it is occasionally used as a hash function.wikipedia

The most commonly used polynomial lengths are:

  • CRC-8: 9 bits
  • CRC-16: 17 bits
  • CRC-32: 33 bits
  • CRC-64: 65 bits

A truly excellent tutorial on CRC's is Ross Williams' "Painless Guide to CRC Detection Algorithms", which can also be found here, here, here, here, and here.

323 questions
2
votes
2 answers

MySQL function to calculate CRC16

I'm working on a system that uses a large MySQL database and I need to calculate crc16 based on some columns in the table. But I can't find any function that helps me. MySQL only has crc32, but I need CRC16 / ARC. I tried to create an SQL code to…
diegodsp
  • 882
  • 8
  • 12
2
votes
2 answers

Which CRC algorithm is this (used by BBC micro tape filing system)?

Is there a well-known name for this CRC implementation? This code is in C, but this is the same CRC computation that's used for the tape filing system of the BBC micro, I think. But the BBC micro documentation doesn't specify the name of the…
James Youngman
  • 3,623
  • 2
  • 19
  • 21
2
votes
1 answer

CRC16 CCITT code - how to adapt manufacturer sample source

I try to create a code that would read data from RFID reader module. In order to do this I need to do CRC16 CCITT calculation. I have found C source code for the CRC16 checksum calculation in the reader manufacturer application technical datasheet…
bzc0fq
  • 579
  • 1
  • 3
  • 18
2
votes
1 answer

CRC error detection and undetected error probabilities

If we have a large file, let 's say 1 Petabyte, what's the best CRC that can detect all the errors? Is 32bits enough? I also heard that undetected error rate (packet or chunk) is= BitR* BER * 0.5^k which K is the FSC of the CRC. in CRC 32 k is 31 I…
Arash
  • 225
  • 1
  • 11
2
votes
1 answer

calculate CRC for Modbus RTU from strings

I have string: 02 03 04 50 00 01. I need to calculate the CRC for this string. I have a function that counts a CRC: public static UInt16 ModRTU_CRC(ushort[] buf, int len) { UInt16 crc = 0xFFFF; for (int pos = 0; pos…
2
votes
2 answers

Issues calculating CRC16 MCRF4XX for more than 1 byte

I've been trying to perform CRC16 MCRF4XX in my code however I've managed to do it correctly for only 1 byte. I've followed this guide, for the specific method: http://www.piclist.com/techref/method/error/quickcrc16.htm and i've tested the same byte…
Barak
  • 23
  • 5
2
votes
2 answers

Understanting an efficient CRC-CCITT-16 implementation

I came across an allegedly very efficient and elegant CRC implementation and I am trying to really understand all the steps. I understand the CRC-CCITT 0x1021 implementations that iterate over each bit, but I am struggling to get this one. This is…
Gabriel
  • 167
  • 1
  • 2
  • 11
2
votes
1 answer

What does CCITT stand for?

In the context of the 16-bit Cyclic Redundancy Check (CRC-16) CCITT algorithm, which uses the generator polynomial x¹⁶ + x¹² + x⁵ + 1, what does "CCITT" stand for? I can't seem to find this initialism written out in full.
Code Doggo
  • 2,146
  • 6
  • 33
  • 58
2
votes
1 answer

How to calculate CRC16-CCITT/KERMIT in both C# and C

I am working on calculating a CRC16-CCITT/KERMIT so that I can check data integrity on transmissions of 64-byte data packets between a C# Winforms Application and a microcontroller (PSoC5LP/Arm Cortex-M3). I'm close, but just not quite getting the…
K_Trenholm
  • 482
  • 5
  • 20
2
votes
1 answer

How can I convert C++ code of a CRC16-CCITT algorithm to Python code?

I have an example code for CRC16-CCITT algorithm written in C++ and I need help converting it to Python. Example C++ code: #include using namespace std; unsigned short calculateCRC(unsigned char data[], unsigned int length) { …
beluga
  • 53
  • 6
2
votes
4 answers

CRC calculation reduction

I have one math and programming related question about CRC calculations, to avoid recompute full CRC for a block when you must change only a small portion of it. My problem is the following: I have a 1K block of 4 byte structures, each one…
PeppeA82
  • 41
  • 10
2
votes
2 answers

Computing CRC16 with reflected / bit reversed input in C

I want to compute the reflected CRC16 of the CCITT polynomial 0x1021 starting from 0xC6C6 (no XOR at end, also known as CRC16-A on this page https://crccalc.com) in two different ways with (embedded) C. For the two alternatives, I want to use the…
Aldinjo
  • 394
  • 1
  • 7
  • 21
2
votes
1 answer

CRC-16 and primitive polynomials

I am trying to calculate the maximal data block length of CRC-16. It is not clear to me if the polynomial 0x8005 is a primitive polynomial. Is CRC-16 using a primitive polynomial or not?
z1naOK9nu8iY5A
  • 903
  • 7
  • 22
2
votes
1 answer

Parallel CRC CCITT 16 Kermit in VHDL

I am trying to implement CCITT 16 true type (Kermit) in VHDL language. Here are the parameters: width=16 poly=0x1021 init=0x0000 refin=true refout=true xorout=0x0000 check=0x2189 residue=0x0000 name="KERMIT" I have 32-bit data and want to generate…
2
votes
2 answers

Compute the crc16 of a bytearray / userdata in lua

I am writing a Wireshark protocol dissector in lua. The protocol it parses contains a crc16 checksum. The dissector should check whether the crc is correct. I have found a crc16 implementation written in C already with the lua wrapper code here. I…
Christopher K.
  • 1,015
  • 12
  • 18