Serial Communications Protocol Specifications - Swissvacuum.com
Serial Communications Protocol Specifications - Swissvacuum.com
Serial Communications Protocol Specifications - Swissvacuum.com
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
C LANGUAGE<br />
- 15 -<br />
The following examples show how to initialize the CRC table and how to <strong>com</strong>pute the CRC bytes to be added at the<br />
end of the packet to be sent to the controller.<br />
#define CRC16 0xA001<br />
static unsigned char TABLE1[256], TABLE2[256];<br />
//Initialize tables for the calculation of the CRC<br />
static void InitCRC()<br />
{<br />
unsigned char i;<br />
unsigned int mask, crc, mem;<br />
}<br />
for(mask=0;mask 8); /* hibyte */<br />
}<br />
//Calculate the CRC<br />
static unsigned int CalcCRC(unsigned char *buf, unsigned char size)<br />
{<br />
unsigned char car,i;<br />
unsigned char crc0,crc1;<br />
crc0 = 0xff;<br />
crc1 = 0xff;<br />
for(i=0;i