Browse Source

vmount: rate-limit the update of the outputs

This avoids a busy-loop if the input is listening for vehicle commands and
the output publishes vehicle commands.
sbg
Beat Küng 8 years ago
parent
commit
73d23742ea
  1. 6
      src/drivers/vmount/vmount.cpp

6
src/drivers/vmount/vmount.cpp

@ -222,6 +222,7 @@ static int vmount_thread_main(int argc, char *argv[]) @@ -222,6 +222,7 @@ static int vmount_thread_main(int argc, char *argv[])
g_thread_data = &thread_data;
int last_active = 0;
hrt_abstime last_output_update = 0;
while (!thread_should_exit) {
@ -342,6 +343,10 @@ static int vmount_thread_main(int argc, char *argv[]) @@ -342,6 +343,10 @@ static int vmount_thread_main(int argc, char *argv[])
}
}
hrt_abstime now = hrt_absolute_time();
if (now - last_output_update > 10000) { // rate-limit the update of outputs
last_output_update = now;
//update output
int ret = thread_data.output_obj->update(control_data);
@ -351,6 +356,7 @@ static int vmount_thread_main(int argc, char *argv[]) @@ -351,6 +356,7 @@ static int vmount_thread_main(int argc, char *argv[])
}
thread_data.output_obj->publish();
}
} else {
//wait for parameter changes. We still need to wake up regularily to check for thread exit requests

Loading…
Cancel
Save