Fix checksum discarding high-order byte of size field
This commit is contained in:
parent
c5b3614733
commit
9ba16e71e1
@ -31,11 +31,10 @@ static inline bool receiveByte(uint8_t &data, uint16_t timeout = 1000)
|
||||
static inline uint8_t calcChecksum(const Message &msg)
|
||||
{
|
||||
uint8_t checksum = msg.start;
|
||||
checksum ^= msg.number;
|
||||
checksum ^= msg.size;
|
||||
checksum ^= msg.token;
|
||||
for (uint8_t i = 0; i < msg.size; ++i)
|
||||
checksum ^= msg.body[i];
|
||||
|
||||
for (uint16_t i = 1; i < 5 + msg.size; ++i) {
|
||||
checksum ^= *(reinterpret_cast<const uint8_t *>(&msg) + i);
|
||||
}
|
||||
|
||||
return checksum;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user