Skip to content

Commit

Permalink
AP_RCProtocol: rename crc_sum8 to crc_sum8_with_carry
Browse files Browse the repository at this point in the history
the name "sum8" is usually used for "sum all bytes into a uint8_t discarding carry"
  • Loading branch information
peterbarker committed Nov 29, 2023
1 parent d34e604 commit 4ede307
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libraries/AP_RCProtocol/AP_RCProtocol_FPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void AP_RCProtocol_FPort::decode_downlink(const FPort_Frame &frame)
buf[3] = telem_data.packet.appid & 0xFF;
buf[4] = telem_data.packet.appid >> 8;
memcpy(&buf[5], &telem_data.packet.data, 4);
buf[9] = crc_sum8(&buf[0], 9);
buf[9] = crc_sum8_with_carry(&buf[0], 9);

// perform byte stuffing per FPort spec
uint8_t len = 0;
Expand Down Expand Up @@ -307,7 +307,7 @@ void AP_RCProtocol_FPort::_process_byte(uint32_t timestamp_us, uint8_t b)
bool AP_RCProtocol_FPort::check_checksum(void)
{
const uint8_t len = byte_input.buf[1]+2;
return crc_sum8(&byte_input.buf[1], len) == 0x00;
return crc_sum8_with_carry(&byte_input.buf[1], len) == 0x00;
}

// support byte input
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_RCProtocol/AP_RCProtocol_FPort2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void AP_RCProtocol_FPort2::decode_downlink(const FPort2_Frame &frame)
// get fresh telem_data in the next call
telem_data.available = false;
}
buf[9] = crc_sum8(&buf[1], 8);
buf[9] = crc_sum8_with_carry(&buf[1], 8);

uart->write(buf, sizeof(buf));
#endif
Expand Down Expand Up @@ -286,7 +286,7 @@ void AP_RCProtocol_FPort2::_process_byte(uint32_t timestamp_us, uint8_t b)
// check checksum byte
bool AP_RCProtocol_FPort2::check_checksum(void)
{
return crc_sum8(&byte_input.buf[1], byte_input.control_len-1) == 0;
return crc_sum8_with_carry(&byte_input.buf[1], byte_input.control_len-1) == 0;
}

// support byte input
Expand Down

0 comments on commit 4ede307

Please sign in to comment.