2
CVS4 Component Video Switch
For comparison, here are the same examples and their associated CRC-8 checkcodes:
LI 2,3:16
LI 3,2:114
IL 2,3:22
KJ 2,3:145
Source Code Example of Calculating a Checksum
The following is a simple “C” program that calculates the checksum of the string “TestString” and
then prints the initial string with the calculated checksum appended to it.
#include "stdio.h"
int main( void)
{
char
TestString[] = "LI 2,3";
unsigned char cksum;
int
index;
char
token = ';';
cksum = 0; // initialize checksum
// Checksum all of 'TestString[]'
index = 0;
while (TestString[index] != '\0')
cksum += TestString[index++];
// Add the checksum token character ';' to checksum
cksum += token;
// Print the results
printf( "%s%c%u", TestString, token, (unsigned char)cksum);
return (0);
}
Checksums and CRC-8’s
(Cont’d)