Data Sheet

UM7 DATASHEET
Rev. 1.6 Released 1/10/2016
37
{
// Packet has data and is a batch. This means it contains ‘batch_length' registers, each
// of which has a length of 4 bytes
data_length = 4*batch_length;
}
else // Packet has data but is not a batch. This means it contains one register (4 bytes)
{
data_length = 4;
}
}
else // Packet has no data
{
data_length = 0;
}
// At this point, we know exactly how long the packet is. Now we can check to make sure
// we have enough data for the full packet.
if( (rx_length packet_index) < (data_length + 5) )
{
return 3;
}
// If we get here, we know that we have a full packet in the buffer. All that remains is to pull
// out the data and make sure the checksum is good.
// Start by extracting all the data
packet->Address = rx_data[packet_index + 4];
packet->PT = PT;
// Get the data bytes and compute the checksum all in one step
packet->data_length = data_length;
uint16_t computed_checksum = ‘s’ + ‘n’ + ‘p’ + packet_data->PT + packet_data->Address;
for( index = 0; index < data_length; index++ )
{
// Copy the data into the packet structure’s data array
packet->data[index] = rx_data[packet_index + 5 + index];