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)
|
static inline uint8_t calcChecksum(const Message &msg)
|
||||||
{
|
{
|
||||||
uint8_t checksum = msg.start;
|
uint8_t checksum = msg.start;
|
||||||
checksum ^= msg.number;
|
|
||||||
checksum ^= msg.size;
|
for (uint16_t i = 1; i < 5 + msg.size; ++i) {
|
||||||
checksum ^= msg.token;
|
checksum ^= *(reinterpret_cast<const uint8_t *>(&msg) + i);
|
||||||
for (uint8_t i = 0; i < msg.size; ++i)
|
}
|
||||||
checksum ^= msg.body[i];
|
|
||||||
|
|
||||||
return checksum;
|
return checksum;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user