+1.585.321.5800
SOURce:FILe:CHECKsum
Function
This command sends the file checksum to the unit. A simple arithmetic checksum is calculated by adding the characters in the file as binary unsigned 8-bit integers. The resulting sum is then negated.
Command Syntax
SOURce:FILe:LENgth
Note
This command not allowed during scenario execution, and will result in the error code “-190,"Execution in progress"”.
The checksum is calculated using the following algorithm, presented here in a Python language example. The array s passed in must be read from a file opened with attributes read and binary (rb).
def cksum(s): sum = 0 for c in s: sum += ord(c) sum &= 255 sum = -sum return sum
An example in C is shown below. Again, the char *Data array is read from a file and is a binary array of unsigned 8-bit char values.
unsigned char CalcChecksum(const char *Data, unsigned Length) { unsigned char sum = 0; unsigned char chksum; unsigned i; for (i = 0; i < Length; ++i) { sum += Data[i]; } chksum = -sum; return chksum; }