AP_FETtecOneWire: Fix state of CRC error counters after _fast_throttle_cmd_count overflow

This commit is contained in:
Dr.-Ing. Amilcar do Carmo Lucas 2021-08-17 19:22:11 +02:00 committed by Peter Barker
parent 2f4c79fd1e
commit 92a75661e0

View File

@ -418,9 +418,11 @@ void AP_FETtecOneWire::handle_message_telem(ESC &esc)
// update rpm and error rate // update rpm and error rate
float error_rate_pct = 0; float error_rate_pct = 0;
if (_fast_throttle_cmd_count) { if (_fast_throttle_cmd_count > _esc_count) {
error_rate_pct = (tlm.tx_err_count-esc.error_count_at_throttle_count_overflow)*(float)100/(float)_fast_throttle_cmd_count; error_rate_pct = (tlm.tx_err_count-esc.error_count_at_throttle_count_overflow)*(float)100/(float)_fast_throttle_cmd_count;
} else { } else {
// the telemetry is requested in a round-robin, sequential fashion
// so the in the first _esc_count times all ESCs get to initialize this
esc.error_count_at_throttle_count_overflow = tlm.tx_err_count; esc.error_count_at_throttle_count_overflow = tlm.tx_err_count;
} }
update_rpm(esc.servo_ofs, update_rpm(esc.servo_ofs,