Appendix 5 Check Sum Calculation Method - YOKOGAWA GX10 User Manual

Gx series; gp series; gm series; smartdac+ communication command
Hide thumbs Also See for GX10:
Table of Contents

Advertisement

Appendix 5 Check Sum Calculation Method

IM 04L51B01-17EN
The check sum of binary data is calculated using an algorithm like the one shown below.
int CalcSum(unsigned char *buf, int len)
{
int
odd;
unsigned long
sum;
unsigned char
*p;
sum = 0;
odd = len & 1;
len >>= 1;
for (p = buf ; len ; len --, p += 2)
{
sum += (*p << 8) | *(p + 1);
}
if (odd)
sum += (*p << 8);
sum = (sum & 0xffff) + ((sum >> 16) & 0xffff);
if (sum > 0xffff)
return ((~sum) & 0xffff);
}
sum = sum - 0xffff;
1
2
App
App-7

Advertisement

Table of Contents
loading

This manual is also suitable for:

Gm10Gx20Gp20Gp10

Table of Contents