Description: This function returns a buffer containing a CRC table.
Returns: Buffer
Usage: Script or Steady State
Format: CRCTable(Polynomial, Length, Shift)
Parameters: Polynomial { text } { required } { no default: }
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 { numeric } { required } { no default: }
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 { numeric } { required } { no default: }
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.
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.
See Also: