26
The checksum byte is the sum modulo 95 of all message characters beginning with the header
byte up to and including the trailer byte. The value 32 is subtracted from each character value
before taking the modulo 95 sum. The value 32 is added to the final sum to obtain the
checksum value. All values are in decimal.
Checksum = MOD [(character value - 32), 95] + 32
Below is a program, written in the ‘C’ programming language that illustrates the checksum
calculation.
char check_sum(char*,char);
char check_sum(array,mes_len)
/* return the checksum character for the message in array */
/* subtract 32 from each character before taking modulo 95 sum */
/* add 32 to the final sum */
/* mes_len = message length */
char array[32],mes_len;
{
char i,sum;
sum = 0;
for ( i = 0; i < mes_len; i++ ) {
sum = sum + ( array[i] - 32 );
if ( sum >= 95 ) sum = sum - 95;
}
return(sum + 32);
}