mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-13 19:17:34 +08:00
dshot: timeout if commands are not processed
This commit is contained in:
@@ -242,9 +242,18 @@ int DShot::send_command_thread_safe(const dshot_command_t command, const int num
|
||||
cmd.num_repetitions = num_repetitions;
|
||||
_new_command.store(&cmd);
|
||||
|
||||
hrt_abstime timestamp_for_timeout = hrt_absolute_time();
|
||||
|
||||
// wait until main thread processed it
|
||||
while (_new_command.load()) {
|
||||
px4_usleep(1000);
|
||||
|
||||
if (hrt_elapsed_time(×tamp_for_timeout) < 2_s) {
|
||||
px4_usleep(1000);
|
||||
|
||||
} else {
|
||||
_new_command.store(nullptr);
|
||||
PX4_WARN("DShot command timeout!");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user