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
1
vote
1 answer

Wrong access to struct elements in Perl

I am writing a Perl script capable of loading a binary RAW file (.bin file extension), calculate the CRC-16 (unsigned short, 16bits ~ 2 bytes), and store this CRC in a file trailer, using the following commands: my $ctx = Digest::CRC->new( type =>…
1
vote
1 answer

CRC-16 specific example for serial connection

While working with the following PDF, there is an example in Section 4: CRC-16 Code and Example (page 95 or 91) that shows a serial packet with a CRC16 value of 133 (LSB) and 24 (MSB). However, I have tried different calculators, for…
CSE
  • 13
  • 3
1
vote
1 answer

CRC-16 output message check

I have a program that computes the CRC of characters using the CRC-16. The program is given below. #include #include #define CRC16 0x8005 uint16_t gen_crc16(const uint8_t *data, uint16_t size) { uint16_t out = 0; int bits_read =…
1
vote
1 answer

Converts CRC16 MySQL function to SQL Server

I have this function for calculating crc16, but it is in MySQL, can someone help me convert to SQL Server? I looked in several places, but I only find the crc32, this does not work for the generation of the PIX QRcode. Below is an example of the…
1
vote
2 answers

How to Calculate CRC Starting at Last Byte

I'm trying to implement a CRC-CCITT calculator in VHDL. I was able to initially do that; however, I recently found out that data is delivered starting at the least-significant byte. In my code, data is transmitted 7 bytes at a time through a frame.…
Shadi Z
  • 13
  • 3
1
vote
0 answers

crc calculation for modbus

Hi i am new to modbus RS485 i am unable to find the type of crc for the given polling query.I am having the following modbus protocol. 01 37 37 1D 30 30 33 1D 30 03 34 37 33 39 37 04 01 37 37 1D 31 31 31 1D 30 1D 1B 5B 43 03 36 34 38 32 38 04 01…
Sathish
  • 199
  • 1
  • 11
1
vote
1 answer

CRC16-CCITT Calculation

I was trying to create a CRC16-CCITT calculation in swift. But the values are not expected. I want to find out which one is wrong, my code or values of specification document. Can someone help me with this. According to Spec,(CRC16-CCITT) initial…
mmk
  • 182
  • 3
  • 18
1
vote
1 answer

decoding data from Binary to text in CRC-16 CCITT, i should input a codeword have it coded using crc generator,

After inputing codeword in sender's side have it coded with crc generator poly , on the reveiver side it has to be decoded and checked for error , and the error can be input manually. This is the sender side (without coding the input) It worked…
1
vote
2 answers

How to determine CRC16 initial checksum so resulting checksum is zero

Working on a SPI communication bus between an array of SAMD MCUs. I have an incoming packet which is something like { 0x00, 0xFF, 0x00, 0xFF }. The receiver chip performs CRC16 check on the incoming packet. Since I am expecting the exact same…
NikoDiYana
  • 31
  • 9
1
vote
1 answer

Debug checksum algorithm written in x86 16-bit assembly

I'm currently reverse engineering a software which computes a 2 bytes wide checksum for a given buffer of data. The code comes from a 16-bit DLL (NE format) and it was compiled with Borland C++. I suspect the checksum to be a CRC-16 with a poly of…
Spacebrain
  • 87
  • 12
1
vote
0 answers

Trying to migrate a code from Python to JavaScript and stuck at encoding/computing

Trying to migrate the following Python code to Javascript and failing: import binascii as ba import struct pData =…
NitayBZ
  • 11
  • 2
1
vote
1 answer

Crash when validating the CRC of a dynamic byte array | c

For an embedded system I am writing code in c to validate a received byte array based on the provided CRC. The system is active in an RTU Modbus. In my unit test I have the following (correct) byte array: unsigned char frame[7] = { 0x01, 0x04, 0x02,…
IAmFrenk
  • 43
  • 7
1
vote
1 answer

CRC16 calculation in Tcl

Im trying to compute the CRC16 of a binary file. I started by reading 2 Bytes from the Binary file and compute a CRC16 with a Polynome= 1021 and 0xFFFF Initial Value. I used a C code and tried to translate it to TCL. I couldnt use the bytes format…
ES87ME
  • 57
  • 1
  • 6
1
vote
1 answer

firemonkey android crc16 result mismatch with delphi for windows

in two different project i need to use crc16 checksum.one in windows and other in android.i used a code for windows and it worked prefect. showmessage( bin2crc16(HexToBin('1234')) ); //---> 0EC9 here is used function for winsows function…
peiman F.
  • 1,648
  • 1
  • 19
  • 42