JDS Uniphase SKB Series User Manual page 101

Fiberoptic switch module
Hide thumbs Also See for SKB Series:
Table of Contents

Advertisement

86
Application Notes
crc = crc << 1 ^ 0x1021;
else
crc = crc << 1;
}
}
/* zero high-order 16 bits and return low-order 16-bit of the CRC */
return (crc & 0xFFFF);
}
/****************************************************************************
*
FUNCTION
: main
* DESCRIPTION
: Calculate CRC-16 value for RS-485 PACKET AND CRC EXAMPLE
*
application note link-layer packet example.
*
INPUTS
: none.
*
RETURNS
: none.
*
SCOPE
: Global
****************************************************************************
*
NOTES
: WIN32 int is 32-bits - CRC value appears in the low-order *
*
16 bits.
***************************************************************************/
void main(void)
{
unsigned char Packet[256];
int crc;
/* Build RS-485 Link layer packet as per example */
Packet[0]
= 0x81;
Packet[1]
= 0x01;
Packet[2]
= 0x00;
Packet[3]
= 0x00;
Packet[4]
= 0x05;
Packet[5]
= 0x00;
Packet[6]
= 0x20;
Packet[7]
= 0x03;
Packet[8]
= 0x01;
Packet[9]
= 0x01;
Packet[10] = 0x02;
/* calculate the CRC */
crc = calc_crc16( Packet, 11);
/* output some stuff */
printf("\n\nCRC-16 Calculation Utility");
printf("\n\nCRC: %X", crc);
printf("\n\nAny key exits...");
/* get user input to exit */
getch();
/* exit in a sane fashion */
exit(1);
/* SOH
/* DEST
/* SRC
/* TYPE ( 0=DATA )
/* LEN (low byte)
/* LEN (high byte)
/* PAYLOAD 1 (opcode) */
/* PAYLOAD 2 (length) */
/* PAYLOAD 3 (switch) */
/* PAYLOAD 4 (input)
/* PAYLOAD 5 (output) */
*/
*/
*/
*/
*/
*/
*/
*
*
*
*
*
*
*

Advertisement

Table of Contents
loading

Table of Contents