#define STX         0x02
#define ETX         0x03

short int calculate_lrc(char *packet)
{
    char *lrc_ptr;
    short int lrc = 0;

    lrc_ptr = packet;

    if( ! (lrc_ptr = strchr (lrc_ptr, STX )) )
        return (-1);

    ++lrc_ptr;

    do {

        lrc ^= *lrc_ptr++;

    } while (*lrc_ptr != ETX);

    lrc ^= *lrc_ptr;

    return lrc;
 
} 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326201
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to