ezeio2:scriptref:calccrc

Calculate a CRC/checksum of a buffer

Description

CalcCRC( buffer{}, length, mode=CRC16_XMODEM )

Calculates the CRC over length bytes in the buffer

Parameters

buf{} Data buffer
length Number of bytes in the buffer to perform the calculation on
mode (optional) CRC algorithm. See below. Default to CRC16_XMODEM

Possible modes:

CRC16_MODBUS Modbus 0x8005, initiated with 0xFFFF
CRC16_CCITT CCITT 0x1021, initiated with 0x1D0F
CRC16_ARC ARC 0x8005, initiated with 0x0000
CRC16_XMODEM CCITT 0x1021, initiated with 0x0000
CRC16_MCRF4XX Microchip 0x1021, initiated with 0xFFFF
CRC32_JAMCRC 32 bit CRC

Return value

The function returns the calculated CRC

Example usage

    new myString{} = "123456789";
    new crc;
 
    crc = CalcCRC(myString, 9, CRC16_MCRF4XX);
 
    // crc is now 0x6F91       
  • ezeio2/scriptref/calccrc.txt
  • Last modified: 2026-12-01 00:07
  • by andreh