AP_Generator: fixed misaligned access in RicenPower

This commit is contained in:
Andrew Tridgell 2020-07-06 08:20:38 +10:00
parent 90232fa6c0
commit 0c87b2d885
2 changed files with 2 additions and 2 deletions

View File

@ -112,8 +112,9 @@ bool AP_Generator_RichenPower::get_reading()
// calculate checksum....
uint16_t checksum = 0;
const uint8_t *checksum_buffer = &u.parse_buffer[2];
for (uint8_t i=0; i<5; i++) {
checksum += be16toh(checksum_buffer[i]);
checksum += be16toh_ptr(&checksum_buffer[2*i]);
}
if (checksum != be16toh(u.packet.checksum)) {

View File

@ -156,7 +156,6 @@ private:
struct RichenPacket packet;
};
RichenUnion u;
uint16_t *checksum_buffer = (uint16_t*)&u.parse_buffer[2];
uint8_t body_length;