Last active
May 16, 2017 05:43
-
-
Save MareArts/5676517d8822edc7e00da7e74429cfcb to your computer and use it in GitHub Desktop.
two types of check sum calculation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://study.marearts.com/2017/05/two-types-of-check-sum.html | |
//intel method | |
unsigned char CalcChecksum(unsigned char *data, int leng) | |
{ | |
unsigned char csum; | |
csum = 0xFF; | |
for (; leng > 0; leng--) | |
csum += *data++; | |
return ~csum; | |
} | |
//motorora method | |
unsigned char CalcChecksum2(unsigned char *data, int leng) | |
{ | |
unsigned char csum; | |
csum = 0; | |
for (; leng > 0; leng--) | |
csum += *data++; | |
return 0xFF - csum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://study.marearts.com/2017/05/two-types-of-check-sum.html