CheckSum

The CheckSum function returns a checksum signature for the characters in a string.

Syntax

Variable = CheckSum (ChkSumString, ChkSumType, CheckSumSize, ChkSumOption1, ChkSumOption2, ChkSumOption3)

Remarks

The CheckSum function returns the checksum of a ClosedString A data type used when declaring a variable consisting of alphanumeric characters. into a variable. If the string for which the CheckSum is being calculated contains one or more null characters, the Size parameter should not be set to 0.

Parameters

ChkSumString (Checksum String)

The string value for which the checksum will be calculated. If a directory and filename are entered for this parameter (for example, CPU:checkfile.txt), the CheckSum will be performed on the file. All bytes in the file will be read, and the ChkSumSize parameter is ignored.

Type: ClosedString A data type used when declaring a variable consisting of alphanumeric characters.

ChkSumType (Checksum Method)

Specifies the method of the checksum calculation. The options are:

Code Description
1 CCITT CRC16 x16+x12+x5+1 (Xmodem, seed of 0).
2 CRC16 used by ModBus.
3 CRC16 used by ModBus with 0 initializer.
4 CCITT CRC32 used by Campbell Scientific BMP3 protocol.
5 Campbell Scientific signature.
6 Campbell Scientific signature nullifier.
7 Sum all the bytes and mod by 256.
8 Sum all the bytes and mod by 8192 (used by Campbell Scientific array-based dataloggers).
9 Checksum which performs exclusive OR on all the bytes; for example, first byte XOR second byte XOR third byte XOR… last byte.
10 CRC16 with seed of 0 and XOR polynomial of &hA001.
11 CRC16 with seed of &hFFFF and XOR polynomial of &hA001.
12 CRC16 with seed of 0 and XOR polynomial of &h8408.
13 CRC16 with seed of &hFFFF and XOR polynomial of &h8408.
14 CRC16 reverse bit order with seed of 0 and XOR polynomial of &hA001.
15 CRC16 reverse bit order with seed of &hFFFF and XOR polynomial of &hA001.
16 CRC16 reverse bit order with seed of 0 and XOR polynomial of &h8408.
17 CRC16 reverse bit order with seed of &hFFFF and XOR polynomial of &h8408.
18 CCITT CRC16 ITU/X25.
19 CRC16 UKMO (UK Met office).
22 CRC ClosedDNP3 Distributed Network Protocol is a set of communications protocols used between components in process automation systems. Its main use is in utilities such as electric and water companies. (note that DNP is little-Closedendian Endianness refers to byte order. With the little-endian format, bytes are ordered with the least significant byte (the "little end") first. With the big-endian format, bytes are ordered with the most significant byte ("big end") first. The CR300, GRANITE 9, and GRANITE 10 dataloggers use the little-endian format. The CR800, CR1000, CR3000, CR6, CR1000X, and GRANITE 6 use the big-endian format. Byte order when sending string variables as serial data is identical in big-endian and little-endian CSI dataloggers. Only numeric values sent as multiple bytes require attention to big-endian and little-endian issues. and the datalogger is big-endian. Use MoveBytes to convert Endianess.)
23 Returns the sum of all bytes with no masking.
24 Fletcher-16.
25 SHA1. This option requires an additional parameter that is a destination array that can hold 20 bytes.
26 SHA1, base 64 encoded. This option requires an additional parameter, typed as a string that can hold 29 characters. The result is null-terminated.
27 HMAC SHA1. This option requires three additional parameters: a destination array that can hold 20 bytes, a key, and the length of the key. If length is 0, the length of the key is used.
28 HMAC SHA1, base 64 encoded. This option requires three additional parameters: a destination array typed as a string that can hold 29 characters, a key, and the length of the key. If length is 0, the length of the key is used.
29 ClosedMD5 16 byte checksum of the TCP/IP VTP configuration.. This option requires an additional parameter that is a destination array that can hold 16 bytes.

ChkSumSize (Checksum Size)

Determines the size of the checksum. If 0 is entered the size of the string is used. However, if the string will contain null characters the size should not be set to 0.

Type: Variable or Expression

ChkSumOpt1 (Checksum Options)

Additional parameter for options 25-29

Type: Variable

ChkSumOpt2 (Checksum Options)

Additional parameter for options 27-28

Type: Variable

ChkSumOpt3 (Checksum Options)

Additional parameter for options 27-28

Type: Variable