CRC

(Engine-Level Function)

Description: Returns the cyclic redundancy check (CRC) value for a buffer.
Returns: Numeric
Usage: Script or steady state.
Function Groups: String and Buffer
Related to: CRCTable
Format: CRC(Buffer, Offset, Length, Table, Start)
Parameters:  
Buffer
Required. Any text expression for which to generate a CRC.
Offset
Required. Any numeric expression giving the offset from 0 in the buffer where the CRC calculation will start.
Length
Required. Any numeric expression giving the number of buffer bytes to include in the CRC. Length must not be greater than 65500.
Table
Required. 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
Required. Any numeric expression giving the initial value for the register used in the CRC calculation.
For most drivers this is 0 or 0xFFFF.
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.