background image

2

CVS4 Component Video Switch 

25

CVS4 Component Video Switch

Checksums and CRC-8 Checkcodes Defined

The use of a checksums or CRC-8 checkcodes can increase the reliability of communications 

between the controller and any Zektor device.
A checksum is calculated by using an unsigned byte as an accumulator, and adding together all 

the ASCII characters of a command string, up to and including the ‘;’ character, while ignoring 

any overflow, and appending it as a decimal parameter to the end of the command.
A CRC-8 checkcode is calculated in a very similar way, but a CRC-8 algorithm is used instead of 

a simply adding together the ASCII characters. The CRC-8 byte is initialized to ‘FF’ hex, and the 

resultant value is sent inverted (one's compliment). 
The CRC polynomial used is:  x^8 +x^6 +x^3 +x^2 +1. 
This polynomial was determined through exhaustive tests, to be the best CRC-8 polynomial for 

arbitrarily lengthed bit streams.
See paper entitled: “Cyclic Redundancy Code (CRC) Polynomial Selection For Embedded 

Networks” by Philip Koopman & Tridib Chakravarty. <http://www.ece.cmu.edu/~koopman/roses/

dsn04/koopman04_crc_poly_embedded.pdf>
Another source of CRC information is the CRC entry on Wikipedia, the free encyclopedia: 

<http://en.wikipedia.org/wiki/Cyclic_redundancy_check>

Differences between a Checksum and a CRC-8 Checkcode

A CRC is capable of finding many more and different types of errors than a checksum can. 

A good description of its capability is described in the above referenced articles, but a simple 

example show some of the differences well.
Here’s an example of the intended command string:

LI 2,3

Here’s some examples of the original and some badly formed strings, of the above example, and 

their associated checksums:

LI 2,3;129

LI 3,2;129

IL 2,3;129

KJ 2,3;129

Notice that every checksum is the same. Checksums cannot detected data being out of order.

Checksums cannot detect errors where two bits, in the same position in two different bytes, are 

flipped. Checksums are not a very robust way to check for communication errors. 

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

Checksums and CRC-8’s 

(Cont’d)

Summary of Contents for CVS4

Page 1: ...Z E K T O R Home Theater Switches Digital Video Component Video Multichannel Audio Rev 2 07 25 2006 High Definition Component Video Switch CVS4 Supplement to the CVS4 User Guide...

Page 2: ...ttings 19 Control Settings HDS4 2 Version 20 Extended Control Settings 21 Checksums and CRC 8 s 24 Checksums and CRC 8 Checkcodes Defined 24 Differences between a Checksum and a CRC 8 Checkcode 24 Sou...

Page 3: ...n this case the value defaults to the current setting leaving the value unchanged The K I S S Continued space before the comma is optional Most commands can be queried for their current settings by su...

Page 4: ...wed before the and characters but NOT after them The checksum must immediately follow the character and a CRC 8 checkcode must immediately follow the character anything else including whitespace will...

Page 5: ...R LF Notice that in the first example a checksum was not appended to the LI command When issuing a command the checksum and CRC 8 codes are sent on a command by command basis Anytime a checksum or a C...

Page 6: ...ghout the com munication sequence First the LI CR command was issued by the controller While looking for an Acknowledgement or Error Response string an unsolicited Query Response is received indicatin...

Page 7: ...Checkcode did not match the calculated one The command will be ingnored Error 5 The number of parameters given does not match the number allowed by this command Error 6 To prevent conflicts between th...

Page 8: ...HDS4 2 there is no space after the command in the response string Note 3 For backward compatibility with the HDS4 2 this response string is sent in the Asyn chronous mode when a channel status has ch...

Page 9: ...Where dim Current DIM level setting bright Current BRIGHT level settings The intensities range from 0 Off to 44 Maximum brightness Note For backward compatibility with the HDS4 2 there is no space af...

Page 10: ...earn they are IR Cmd Description 1 Power Toggle 2 Select Input 1 3 Select Input 2 4 Select Input 3 5 Select Input 4 6 Discrete Power On 7 Discrete Power Off 8 Sequence Through Inputs Setting an ircmd...

Page 11: ...ess of any possible setup state it might be in The 0 button code is also device independent It use and value does not change between Zek tor devices like the other codes may and most likely will Query...

Page 12: ...ro keeps the CVS4 from responding to IR codes however the front panel sensor remains operational and any codes received can still be queried for by using the IR command Disabling the IR jack by settin...

Page 13: ...al Value 128 64 32 16 8 4 2 1 Bit Position 7 6 5 4 3 2 1 0 Name CTL LMO IRC IRR BTN LIN SEL PWR Factory Settings 0 0 0 0 0 0 1 1 PWR 1 Power State has changed SEL 1 Selection Input Output Mapping has...

Page 14: ...Checksum and a CRC 8 Checkcode A CRC is capable of finding many more and different types of errors than a checksum can A good description of its capability is described in the above referenced articl...

Page 15: ...detection characteristics So x 8 x 6 x 3 x 2 1 101001101 14D hex Ignore X 8 01001101 4D hex Reverse bit order 10110010 B2 hex define CRC8_POLY 0xB2 polynomial mask define CRC8_INIT 0xFF initial value...

Page 16: ...28 CVS4 Component Video Switch 29 CVS4 Component Video Switch This page left intentionaly nearly blank This page left intentionaly nearly blank...

Page 17: ...Z E K T O R Z E K T O R 12675 Danielson Ct Suite 401 Poway CA 92064 858 748 8250 www zektor com...

Reviews: