Description: This function returns the cyclic redundancy check (CRC) value for a buffer.
Returns: Numeric
Usage: Script or Steady State
Format: CRC(Buffer, Offset, Length, Table, Start)
Parameters: Buffer { text } { required } { no default: }
Any text expression for which to generate a CRC.
Offset { numeric } { required } { no default: }
Any numeric expression giving the offset from 0 to start the buffer CRC calculation.
Length { numeric } { required } { no default: }
Any numeric expression giving the number of buffer bytes to include in the CRC. Length must be less than or equal to 65500.
Table { text } { required } { no default: }
A text expression giving a CRC look-up table buffer. The length of the table buffer must be a multiple of 256 plus 1. A table can be generated automatically with the CRCTable function.
Start { numeric } { required } { no default: }
Any numeric expression giving the initial value for the register used in the CRC calculation. It is 0 for Allen-Bradley® protocols, and FFFF Hex for Modicon®.
Comments: CRC is a driver toolkit function.
Example:
checkSum = CRC(response { Text buffer },
0 { Start of the buffer },
20 { Number of bytes },
CheckTable { Look-up table buffer },
0 { Use Allen-Bradley™ protocols });
This gets the checksum for bytes 0 to 19 of the text buffer response, using the CheckTable CRC look-up table, and an initial accumulator value of 0.
See Also: