EasyManua.ls Logo

YOKOGAWA GX10

YOKOGAWA GX10
216 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
App-7
IM 04L51B01-17EN
Appendix
1
2
App
Appendix 5 Check Sum Calculation Method
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) sum = sum - 0xffff;
return ((~sum) & 0xffff);
}

Table of Contents

Related product manuals