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.

278 questions
55
votes
7 answers

Function to Calculate a CRC16 Checksum

I'm working on a library to provide simple reliable communication over an RS232 or RS485 connection. Part of this code involves using a CRC16 checksum on the data to detect corruption from line noise. I've created a function to calculate a CRC16…
Jonathan Lamothe
  • 663
  • 1
  • 5
  • 5
25
votes
2 answers

Trying to reverse engineer a packet checksum/CRC/hash

I have an old, no longer manufactured electronic device with a serial port. I am trying to reverse engineer the data packet CRC/checksum/hash used in this device. Anyone with keen eyes, sharp math skills out there who might be able to crack this…
MSunstrum
  • 251
  • 3
  • 4
18
votes
2 answers

How to generate a CRC-16 from C#

I am trying to generate a CRC-16 using C#. The hardware I am using for RS232 requires the input string to be HEX. The screenshot below shows the correct conversion, For a test, I need 8000 to be 0xC061, however the C# method that generates CRC-16…
dynamicuser
  • 1,422
  • 3
  • 23
  • 49
13
votes
4 answers

Calculating Modbus RTU CRC 16

I'm implementing a software where I read and write data in Modbus RTU protocolo via serial. For that, I need to calculate the two CRC byte at the end of the string of bytes, but I'm being incapable of doing this. Searching throughout the web, I…
Momergil
  • 2,055
  • 4
  • 23
  • 53
11
votes
3 answers

CRC16 checksum: HCS08 vs. Kermit vs. XMODEM

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. It calls the…
Potatoswatter
  • 126,977
  • 21
  • 238
  • 404
9
votes
3 answers

CRC-CCITT Implementation

I am using the following function to generate a CRC sum and it doesn't appear to be returning the same checksum when compared to online CRC-CCITT calculators. This function specifically uses the XMODEM CRC generation with a 0x8408 polynomial with an…
AlphabetaPhi
  • 91
  • 1
  • 1
  • 2
8
votes
2 answers

Function to calculate CRC16 (Modbus) value

Using C#.net,WPF application.I'm going to connect to a device (MODBUS protocol), I have to calculate CRC (CRC16). Function which i use calculate normal crc16 and value is correct,but i want the value for CRC16(modbus) one. Help me to sort out.
user2720620
  • 105
  • 1
  • 1
  • 6
8
votes
2 answers

How to calculate crc16 in php

I need help in converting CRC code written in Ojective C to PHP. The following is the Objective C code static UInt16 CRC16_Table[] = { 0x0000, 0x2110, 0x4220, 0x6330, 0x8440, 0xa550, 0xc660, 0xe770, 0x0881, 0x2991, 0x4aa1, 0x6bb1, 0x8cc1,…
Amjad khan
  • 113
  • 1
  • 1
  • 7
7
votes
1 answer

Library for CRC16 checksum in Elixir

I need to calculate CRC 16 of a string in elixir. Is there an existing library for the purpose?
Kshitij Mittal
  • 2,328
  • 1
  • 20
  • 34
7
votes
1 answer

How to calculate CRC 16 with polynomial x16 + x12 + x5 + 1

I am trying to interface with some system and in their specs they require to calculate CRC 16 for serial communication. Here is an extract from documentation "16 bit CCITT CRC of the message utilizing the standard polynomial, X16 +X12 +X5 +1. Seed…
fenix2222
  • 4,323
  • 3
  • 31
  • 54
6
votes
7 answers

CRC-CCITT 16-bit Python Manual Calculation

Problem I am writing code for an embedded device. A lot of solutions out there for CRC-CCITT 16-bit calculations require libraries. Given that using libraries is almost impossible and a drain on its resources, a function is required. Possible…
Alex Stewart
  • 640
  • 3
  • 12
  • 29
6
votes
4 answers

crc16 implementation java

I am having problems with calculating CRC-16 implementation of a byte array in java. Basically I am trying to send bytes to a RFID that starts writing to a tag. I can see the checksum value of array by looking tcpdump command on mac. But my goal is…
Ali Yucel Akgul
  • 1,012
  • 7
  • 25
  • 49
5
votes
3 answers

How to calculate CRC16 CCITT in PHP HEX?

I'm trying to use a PHP CRC16 CCITT function to calculate the checksum. A device sends me a PACKET with Checksum included: 10 00 00 00 00 00 00 00 12 51 09 08 00 18 00 04 02 14 00 0c 00 0c 02 1c 00 02 00 00 00 00 00 00 a0 77 The checksum is at…
Drace
  • 691
  • 7
  • 22
5
votes
6 answers

How to use table based CRC-16 code?

I was hoping someone might be able to shed some light on why my CRC-16 implementation does not seem to run correctly on Visual Studio? I got the algorithm from a manual for a specific device, and wrote the int main() myself. There are always 'type'…
user_name
  • 63
  • 1
  • 2
  • 8
5
votes
3 answers

CCITT CRC 16 Bit Start Value 0xffff

I need to calculate a CCITT 16 bit checksum value for data passed as a parameter together with the length. If I fill my array TempStr with the test data "123456789", use the polynomial 0x8408 with the length excluding the null termination character,…
Ruaan Volschenk
  • 675
  • 2
  • 11
  • 23
1
2 3
18 19