beautypg.com

Yokogawa Removable Chassis DX1000N User Manual

Page 188

background image

4-4

IM 04L41B01-17E

• File

• Display data, event data, and setup data files can be used on the DXA120

DAQSTANDARD Software that comes with the package. For details, see the user’s
manuals of the DXA120 DAQSTANDARD (IM04L41B01-63EN and IM04L41B01-
64EN).

• Files that are in common formats can be opened using software programs that are

sold commercially.

• Other formats are written in ASCII code. A text editor can be used to open these

types of files.

Calculating the Sum Value

If you set the parameter of the CS command to 1 (enabled), the checksum value is
output only during serial communications. The check sum is the same as that used in
the TCP/IP and is derived according to the following algorithm.

Buffer on Which the Sum Value Is Calculated

• For the header sum, it is calculated from “data length + flag + identifier” (fixed to 6

bytes).

• For the data sum, it is calculated from the binary data.

1 byte

0

(1)

(2)

(3)

(4)

(6)

(5)

Padding

If the data length of the buffer is odd, a zero is padded so that it is even. (1) through (6)

are summed as unsigned two-byte integers (unsigned short). If the digit overflows a 1
is added. Finally, the result is bit-wise inverted.

Sample Program

The sum value is determined using the following sample program, and the calculated

result is returned. The sum determined by the sample program can be compared with
the header sum of the output binary header section and the data sum of the output
binary footer section.

/*

* Sum Calculation Function (for a 32-bit CPU)

*

* Parameter buff

: Pointer to the top of the data on which the sum is calculated

*

len

: Length of the data on which the sum is calculated

* Returned value

: Calculated sum

*/
int cksum(unsigned char *buff, int len)
{
unsigned short *p;

/* Pointer to the next two-byte data word in the buffer that is

to be summed. */

unsigned int csum;

/* Checksum value */

int i;
int odd;
csum = 0;

/* Initialize. */

odd = len%2;

/* Check whether the number of data points is even. */

len >>= 1;

/* Determine the number of data points using a “short”

data type. */

p = (unsigned short *)buff;

for(i=0;i

/* Sum using an unsigned short data type. */

csum += *p++;

4.1 Response Syntax

This manual is related to the following products: