JCL Help:Crc16@TCrc16Table@array of Byte@Integer@Word

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Calculates or checks a 16 Bit CRC.


Pascal

 function Crc16_P(X: PJclByteArray; N: Integer; Crc: Word = 0): Word; overload;
function Crc16(const X: array of Byte; N: Integer; Crc: Word = 0): Word; overload;
function Crc16(const Crc16Table: TCrc16Table; const X: array of Byte; N: Integer; Crc: Word = 0): Word; overload;
function Crc16_A(const Crc16Table: TCrc16Table; const X: array of Byte; Crc: Word = 0): Word; overload;


Parameters

Parameters Description
X: PJclByteArray The array which contains the data. With Crc16 and Crc16_A this is an open array parameter, with CrC16_P this is a pointer to the first byte of the array of bytes.
N: Integer The number of elements in X. Crc16_A calculates the checksum of all bytes in the array X.
Crc: Word = 0 (optional) if not defined or = 0: Crc16 calculates the CRC for the data array transmitted; if CRC is defined: the CRC value is checked against the data and the result is 0 if the CRC was correct.


Return Value

  • If on input CRC not defined or = 0: The result is the created CRC.
  • If on input CRC is defined: The result is 0 if the CRC was OK, otherwise the function returns the residuum for the correction function.


Description

16 Bit CRC function. Calculates or checks a CRC. Independently from the size of the data array, with a 16 bit CRC any single and double bit error can be detected. By far most multiple bit errors are detected, too: E.g. all even (or odd) count of bit errors (depending on the polynomial used) and all burst errors with up to 16 bits length (so any sequence of up to two incorrect bytes) are detected. Burst error with a length of more than 16 are detected with a probability of 99,99998474 %. All this is true only if an appropriate polynomial is used. By default the 16 Bit CRC "generator polynomial" suggested by the CCITT is used: x^16 + x^12 + x^5 + 1 ($11021). This polynomial has a "maximum cycle" and is used to protect data on floppy disks, too. The default starting value is $FFFF. By InitCrc16 a different polynomial and starting value can be defined.


See Also

CheckCrc16 InitCrc16 Crc32


About

Unit

JclMath


Donator

Michael Schnell


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page