mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
dshot: timeout if commands are not processed
This commit is contained in:
parent
e53d2907d7
commit
682db4b8ac
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user