mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 10:26:52 +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;
|
cmd.num_repetitions = num_repetitions;
|
||||||
_new_command.store(&cmd);
|
_new_command.store(&cmd);
|
||||||
|
|
||||||
|
hrt_abstime timestamp_for_timeout = hrt_absolute_time();
|
||||||
|
|
||||||
// wait until main thread processed it
|
// wait until main thread processed it
|
||||||
while (_new_command.load()) {
|
while (_new_command.load()) {
|
||||||
|
|
||||||
|
if (hrt_elapsed_time(×tamp_for_timeout) < 2_s) {
|
||||||
px4_usleep(1000);
|
px4_usleep(1000);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_new_command.store(nullptr);
|
||||||
|
PX4_WARN("DShot command timeout!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user