beautypg.com

Example ‘c’ program, Example for basic program v 2.0 – Grass Valley XSwitch Feb 08 2006 User Manual

Page 38

background image

38

XSWITCH Installation and Operation Manual

Appendix A — Remote Activation

Value$, dummylength -3, 2))

Packet$ = Dstring$ + Chr$(LSB) + Chr$(MSB) ‘This is
the packet string
.

End

Where the input string is made up of single characters to represent the
field’s decimal value in the character’s own ASCII value AND the actual
command string for the XSWITCH.

Example ‘C’ Program

//====================================================
// UpdateCRC16()
//====================================================
// Calculated: X^16 + X^12 + X^5 + 1
//----------------------------------------------------
UINT UpdateCRC16( BYTE b, UINT crc )
{
unsigned int i;

// Calculate CRC
for( i = 0; i < 8; i++)
{

return crc;
}//end UpdateCRC16()

//====================================================
// CalcCRC16()
//====================================================
UINT CalcCRC16( LPBYTE buf, DWORD size )
{
UINT crc = 0;

//Calc CRC16 on buffer
for ( DWORD i = 0; i < size; i++ )
crc = UpdateCRC16 ( buf[i], crc);

}//end CalcCRC16()

Example for basic program V 2.0

Known command string to send: “2,L”

LEN is length of command string.

Known values:

DEST: 04 decimal value --> convert to ASCII character of