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
4
votes
2 answers

Automating linker configuration in IAR Embedded Workbench

I am working on a firmware project in which i have to do a crc16 check for flash integrity. The crc is calculated using IAR Xlink linker and kept at the end of the flash. Again crc is calculated at run time from the code and compared with the stored…
OnkarK
  • 127
  • 2
  • 9
4
votes
3 answers

Convert C to PHP for CRC16 Function

I need help in converting C code into PHP. The following is the C Code: static const U16 crctab16[] = { 0x0000, 0x1189, ... }; U16 GetCrc16(const U8* pData, int nLength) { U16 fcs = 0xffff; while(nLength > 0) { fcs = (fcs >> 8) ^…
Heru S
  • 1,283
  • 2
  • 17
  • 28
4
votes
3 answers

CRC-ITU calculation in c#

I'm new to C#. I need to calculate CRC-ITU for the packet recieved from GPS devices. There is C code provided in the documentation but i don't know how to port it to C#, anyone could help me? here is CRC-ITU algorithm in C : static const U16…
3
votes
3 answers

How do CRC algorithms work for CCITT16 and how to get one for CCITT8

I'm looking to implement a CRC-8 checksum - and in reading up on CRC in general I came across this algorithm for CCITT-16 (polynomial X^16 + X^12 + X^5 + 1): unsigned char ser_data; static unsigned int crc; crc = (unsigned char)(crc >> 8) | (crc…
mr_van
  • 105
  • 1
  • 2
  • 10
3
votes
2 answers

Impact of data padding on CRC calculation

I am calculating CRC on a large chunk of data every cycle in hardware (64B per cycle). In order to parallelize the CRC calculation, I want to calculate the CRC for small data chunks and then XOR them in parallel. Approach: We divide the data into…
sharvil111
  • 4,301
  • 1
  • 14
  • 29
3
votes
1 answer

Why does the same bitwise calculation yield different results in Java and JavaScript?

Problem: I need to calculate a CRC16 for hex codes like this one: 08010000016B40D8EA30010000000000000000000000000000000105021503010101425E0F01F10000601A014E000000000000000001 For this, I have a working solution in JavaScript. Due to new…
Lapskaus
  • 1,709
  • 1
  • 11
  • 22
3
votes
1 answer

Convert CRC16 CCITT code from C to Python

I want to do a Python implementation (actually MicroPython) of a specific checksum calculation based on CRC16-CCITT. It will be used on a microcontroller to check data integrity over a serial connection. The algorithm is available as C…
chiefenne
  • 565
  • 2
  • 15
  • 30
3
votes
2 answers

How to convert string to bytes in Python (Closed)

I am using crc-16 and libscrc library in python I want to change the string into bytes For example: a = '32' b = '45' c = '54' d = '78' e = '43' f = '21' ---------------------------- encode to ----------------------------------- Expected…
CripsyBurger
  • 361
  • 1
  • 3
  • 13
3
votes
1 answer

Verification of a CRC checksum against zero

I had some contact with the CRC-16 checksum in the past and was accustomed to verifying it by recalculating the CRC-16 checksum over the file I want to verify, plus the 2 bytes of the CRC-16 itself. If the result was zero, then the file integrity…
user9564464
  • 173
  • 2
  • 16
3
votes
1 answer

Why do I get different CRC16 result between C# and VB.NET?

I converted a C# code to VB.NET for CRC16 calculation. However, I got different result on C# and VB.NET. I am confused! Can someone please point me to the right direction? //C# Codes UInt16 CalculateCRC(Byte dchar, UInt16 crc16) { …
Albert Tobing
  • 169
  • 2
  • 14
3
votes
2 answers

How can I ignore unicode values and and keep the format '\x##'?

I'm working on creating packets to send to a device serially. I want to keep the formatting as I've typed it without having it converted to unicode characters. my_thing = b'\xb4\x75' print(my_thing) (Actual Output)>>> b'\xb4u' (Wanted Output)>>>…
3
votes
1 answer

boost crc yields different output each time

Background I am trying to calculate CRC-16/CRC2 for a given byte array using boost crc lib. Note: I am a beginner at best in C++ development #include #include #include namespace APP{ class CrcUtil{ …
raidensan
  • 1,099
  • 13
  • 31
3
votes
1 answer

CRC16 in Python

How do I calculate CRC16 in Python? In Perl I would write something like: use Digest::CRC "crc16"; $result = crc16($str); How do I do same thing in Python?
rmflow
  • 4,445
  • 4
  • 27
  • 41
3
votes
1 answer

Javascript CRC16 sample code or implementation

can anybody share a link or sample code to implement checksum for string in javascript? Thanks a lot in advance
user2060221
  • 41
  • 1
  • 2
3
votes
1 answer

How to get Good CRC16 from string in java?

I am trying to get CRC16 from string in android application using following code static int crc16(final byte[] buffer) { int crc = 0xFFFF; for (int j = 0; j < buffer.length ; j++) { crc = ((crc >>> 8) | (crc << 8) )& 0xffff; crc ^=…
Jignesh Ansodariya
  • 12,583
  • 24
  • 81
  • 113
1 2
3
21 22