dshot: timeout if commands are not processed

This commit is contained in:
Igor Mišić 2021-06-09 09:47:04 +02:00 committed by Beat Küng
parent e53d2907d7
commit 682db4b8ac

View File

@ -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(&timestamp_for_timeout) < 2_s) {
px4_usleep(1000);
} else {
_new_command.store(nullptr);
PX4_WARN("DShot command timeout!");
}
}
return 0;