mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 11:03:33 +08:00
voxl_esc: Limit frequency of UART passthru writes to 20Hz
This commit is contained in:
committed by
Eric Katzfey
parent
ecb222c7e7
commit
5e54d727fc
@@ -1336,16 +1336,22 @@ bool VoxlEsc::updateOutputs(uint16_t outputs[MAX_ACTUATORS],
|
||||
|
||||
uint8_t num_writes = 0;
|
||||
|
||||
while (_esc_serial_passthru_sub.updated() && (num_writes < 4)) {
|
||||
mavlink_tunnel_s uart_passthru{};
|
||||
_esc_serial_passthru_sub.copy(&uart_passthru);
|
||||
// Don't do these faster than 20Hz
|
||||
if (hrt_elapsed_time(&_last_uart_passthru) > 50_ms) {
|
||||
_last_uart_passthru = hrt_absolute_time();
|
||||
|
||||
if (_uart_port.write(uart_passthru.payload, uart_passthru.payload_length) != uart_passthru.payload_length) {
|
||||
PX4_ERR("Failed to send mavlink tunnel data to esc");
|
||||
return false;
|
||||
// Don't do more than a few writes each check
|
||||
while (_esc_serial_passthru_sub.updated() && (num_writes < 4)) {
|
||||
mavlink_tunnel_s uart_passthru{};
|
||||
_esc_serial_passthru_sub.copy(&uart_passthru);
|
||||
|
||||
if (_uart_port.write(uart_passthru.payload, uart_passthru.payload_length) != uart_passthru.payload_length) {
|
||||
PX4_ERR("Failed to send mavlink tunnel data to esc");
|
||||
return false;
|
||||
}
|
||||
|
||||
num_writes++;
|
||||
}
|
||||
|
||||
num_writes++;
|
||||
}
|
||||
|
||||
perf_count(_output_update_perf);
|
||||
|
||||
Reference in New Issue
Block a user