The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



CRC16ofBuffer


Unit:SDL_dstruct
Class:none
Declaration:function CRC16ofBuffer (Buffer: TBytes; NumData: integer; CRC16Mode: TCRC16Mode): word;

The function CRC16ofBuffer calculates a 16-bit CRC of the byte array Buffer; the algorithm is based on the following polynomial:

X16+X12+X5+1.

The parameter Numdata specifies the number of bytes contained in the buffer. All NumData bytes in the buffer are processed and the cyclic redundancy code is returned by the function. The parameter CRC16Mode determines which type of CRC-16 should be calculated: crcZModem creates a CRC as used in ZModem, crcCCITT creates a CRC according to the standard of CCITT. Please note that the only difference between these two CRCs is the initialization.

Example: The expression "crc16 := CRC16ofBuffer(@astring[1], length(astring), crcZModem);" generates the 16 bit CRC (compatible with ZModem) of the string astring and copies the result into the variable crc16.

Please note that the string variable astring has to be a zero terminated long string (must not be a string of type ShortString).



Last Update: 2015-May-30