Skip to content

Commit

Permalink
fix: consider endianess for uint16_t payload length
Browse files Browse the repository at this point in the history
  • Loading branch information
vtx22 committed Mar 9, 2025
1 parent 51deba7 commit 504412a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/sparq_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,15 @@ struct sparq_message_header_t
{
signature = buffer[0];
control = buffer[1];
payload_length = (buffer[2] << 8) + buffer[3];
if ((bool)(control & (uint8_t)sparq_header_control_t::LSB_FIRST) == sparq_is_little_endian())
{
payload_length = (buffer[2] << 8) + buffer[3];
}
else
{
payload_length = (buffer[3] << 8) + buffer[2];
}

checksum = buffer[4];
}

Expand Down

0 comments on commit 504412a

Please sign in to comment.