#include #define SYNC 0xAA #define EXCODE 0x55 int parsePayload( unsigned char *payload, unsigned char pLength ) { unsigned char bytesParsed = 0; unsigned char code; unsigned char length; unsigned char extendedCodeLevel; int i; /* Loop until all bytes are parsed from the payload[] array... */ while( bytesParsed < pLength ) { /* Parse the extendedCodeLevel, code, and length */ extendedCodeLevel = 0; while( payload[bytesParsed] == EXCODE ) { extendedCodeLevel++; bytesParsed++; } code = payload[bytesParsed++]; if( code & 0x80 ) length = payload[bytesParsed++]; else length = 1; /* TODO: Based on the extendedCodeLevel, code, length, * and the [CODE] Definitions Table, handle the next * "length" bytes of data from the payload as * appropriate for your application. */ printf( "EXCODE level: %d CODE: 0x%02X length: %d\n", extendedCodeLevel, code, length ); printf( "Data value(s):" ); for( i=0; i 169 ) continue; /* Collect [PAYLOAD...] bytes */ fread( payload, 1, pLength, stream ); /* Compute [PAYLOAD...] chksum */ checksum = 0; for( i=0; i