Yokogawa Button Operated MV2000 User Manual
Page 123
5-4
IM MV1000-17E
• File
• Display data (binary), event data (binary), and setup data files can be used on the
DXA120 DAQSTANDARD that comes with the package. For details, see the DXA120
DAQSTANDARD User’s Manual IM04L41B01-61E.
• Files in a general format can be opened using commercially-sold software programs.
• Other files are in text format. You can use any text editor to open these files.
Calculating the Sum Value
If you set the CS command parameter to 1 (enabled), the MV transmits the checksum
value only during serial communications. The checksum is used in TCP/IP and is derived
according to the following algorithm.
Buffer for Calculating the Sum Value
• The header sum is calculated from the data length, flag, and ID (fixed to 6 bytes).
• The data sum 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) indicated in the figure above are summed as unsigned two-byte integers (unsigned
short). If the digit overflows, 1 is added. Finally, the result is bit-wise inverted.
Sample Function
Below is a sample function that determines and returns the sum value. Your program
can compare the value returned by the sample function with the header sum of the
output binary header section and the data sum of the output binary footer section to
see if they are correct.
/*
* Sum Calculation Function (for a 32-bit CPU)
*
* Parameter buff
: Pointer to the head of the data for calculating the sum
*
len
: Length of the data for calculating the sum
* Returned value
: The 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 odd. */
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++; 5.1 Response Syntax