Skip to content

Instantly share code, notes, and snippets.

@MareArts
Last active May 16, 2017 05:43
Show Gist options
  • Save MareArts/5676517d8822edc7e00da7e74429cfcb to your computer and use it in GitHub Desktop.
Save MareArts/5676517d8822edc7e00da7e74429cfcb to your computer and use it in GitHub Desktop.
two types of check sum calculation
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;
}
@MareArts
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment