mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +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,6 +1336,11 @@ bool VoxlEsc::updateOutputs(uint16_t outputs[MAX_ACTUATORS],
|
|||||||
|
|
||||||
uint8_t num_writes = 0;
|
uint8_t num_writes = 0;
|
||||||
|
|
||||||
|
// Don't do these faster than 20Hz
|
||||||
|
if (hrt_elapsed_time(&_last_uart_passthru) > 50_ms) {
|
||||||
|
_last_uart_passthru = hrt_absolute_time();
|
||||||
|
|
||||||
|
// Don't do more than a few writes each check
|
||||||
while (_esc_serial_passthru_sub.updated() && (num_writes < 4)) {
|
while (_esc_serial_passthru_sub.updated() && (num_writes < 4)) {
|
||||||
mavlink_tunnel_s uart_passthru{};
|
mavlink_tunnel_s uart_passthru{};
|
||||||
_esc_serial_passthru_sub.copy(&uart_passthru);
|
_esc_serial_passthru_sub.copy(&uart_passthru);
|
||||||
@@ -1347,6 +1352,7 @@ bool VoxlEsc::updateOutputs(uint16_t outputs[MAX_ACTUATORS],
|
|||||||
|
|
||||||
num_writes++;
|
num_writes++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
perf_count(_output_update_perf);
|
perf_count(_output_update_perf);
|
||||||
|
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ private:
|
|||||||
Battery _battery;
|
Battery _battery;
|
||||||
static constexpr unsigned _battery_report_interval{100_ms};
|
static constexpr unsigned _battery_report_interval{100_ms};
|
||||||
hrt_abstime _last_battery_report_time;
|
hrt_abstime _last_battery_report_time;
|
||||||
|
hrt_abstime _last_uart_passthru{0};
|
||||||
|
|
||||||
bool _device_initialized{false};
|
bool _device_initialized{false};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user