beautypg.com

Grass Valley RSAT1 User Manual

Page 30

background image

Satellite Panel RSAT1

6. Annex

Operating Instructions - Rev. 3 / 7.2002

25

The lf character is optional.

unsigned char chksum, chk;

int i;

chksum = toascii(length) + type;

for ( i = 0; i < (length – 2 ); i++)

{

chksum += data[i];

}

chk = chksum & 0x3F;

The function char() simply adds a space (0x20) to the number.

The function toascii() converts the number into the ascii character. The datagram
length is therefore restricted to 9 bytes. The new text (t) command makes it neces-
sary to change the toascii() function. Allowed characters for the Length field are
now ’0’ .. ’9’ plus ’:’ .. ’~’ where a Lenght of ’:’ means 10 bytes and so on until ’~’
which means 78 bytes.

unsigned char toascii(size_t count)

{

unsigned char retval = ’0’;

if ( count <= (size_t) (’~’ – ’0’) )

{

retval += (unsigned char) count);

}

else

{

// error

}

return retval;

}