Sensors, Electronics and Prototyping

Understand checksum value

Welcome to Redshift Labs Forums UM7 Product Support Understand checksum value

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1180
    MatteoRM
    Guest

    Hi,

    i’ve an UM7 and i’m trying to implement it on my system.I’m using Binary Packet and i’ve a question about checksum.

    “The two checksum bytes consist of the unsigned 16-bit sum of all preceding bytes in the packet, including the packet header. ”

    I don’t understand it.So,i have to sum the value of pt,address and databytes(PT+ADDRESS+DATABYTES) and check if it is equal to checksum1 or checksum 0(or checksum 0 appended to checksum1?)?

    Thanks!

    #1185
    till
    Guest

    hi matteo,

    Please see UM7 Datasheet page 37:

    uint16_t computed_checksum = 's' + 'n' + 'p' + packet_data->PT + packet_data->Address;
    for( index = 0; index < data_length; index++ ) {
      packet->data[index] = rx_data[packet_index + 5 + index];
      computed_checksum += packet->data[index];
    }
    uint16_t received_checksum = (rx_data[packet_index + 5 + data_length] << 8);
    received_checksum |= rx_data[packet_index + 6 + data_length];
    

    checksum1 and checksum0 are just the two bytes making up the 16-bit short integer. you take a 16-bit integer initialized to 0 and then add the value of each byte in the packet to calculate the checksum.

    the received checksum consists of two bytes which you have to combine to a 16-bit integer.

    regards,

    -till

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘UM7 Product Support’ is closed to new topics and replies.