CRCTable

(Engine-Level Function)

Description Returns a buffer containing a CRC table.
Returns Buffer
Usage Script or steady state.
Function Groups String and Buffer
Related to: CRC
Format CRCTable(Polynomial, Length, Shift)
Parameters  
Polynomial
Required. A long expression that gives the bit pattern of the generating polynomial. For Allen-Bradley® and Modicon®, Polynomial = 0b1000000000000101, which corresponds to the expression:

x^16 + x^15 + x^2 + 1

To determine the value of Polynomial for a given generator expression, drop the highest order term, and represent each term present by a 1 in the bit position equal to its exponent.

For example, x^16 + x^12 + x^5 + 1 would have a Polynomial value of 0b0001000000100001. The first 1 corresponds to x^12, the second to x^5, and the last to 1 (which is x^0). This polynomial is used by the XMODEM protocol.
Length
Required. Any numeric expression giving the byte length of the CRC accumulator register (usually 2 or 4). The CRCTable buffer returned is 256 * Length + 1 bytes long.
Shift
Any numeric expression that is 0 for right-shifted CRC calculations (such as Allen-Bradley® or Modicon®), and 1 for left-shifted CRC calculations (such as XMODEM).
Comments

This function is part of the driver toolkit.

(See: Bitwise Parameters & Operations)

Example:

  CheckTable = CRCTable(0b1000000000000101
                        { Polynomial: x^16 + x^15 + x^2 + 1 }, 
                        2 { 16 bit CRC register }, 
                        0 { Right-shifted CRC calculations }); 

This generates a CRC look-up table for use with the CRC function.