Replacing usleep with px4_usleep

This is a step towards isolating time from the system.
This commit is contained in:
Julian Oes
2018-12-22 10:32:18 +01:00
parent e485885344
commit 5b9dea5604
112 changed files with 339 additions and 305 deletions
+10 -10
View File
@@ -310,7 +310,7 @@ int commander_main(int argc, char *argv[])
unsigned i;
for (i = 0; i < max_wait_steps; i++) {
usleep(max_wait_us / max_wait_steps);
px4_usleep(max_wait_us / max_wait_steps);
if (thread_running) {
break;
@@ -1629,7 +1629,7 @@ Commander::run()
* so lets reset to a classic non-usb state.
*/
mavlink_log_critical(&mavlink_log_pub, "USB disconnected, rebooting.")
usleep(400000);
px4_usleep(400000);
px4_shutdown_request(true, false);
}
}
@@ -2101,7 +2101,7 @@ Commander::run()
&mavlink_log_pub, &status_flags, arm_requirements, hrt_elapsed_time(&commander_boot_timestamp));
if (arming_ret != TRANSITION_CHANGED) {
usleep(100000);
px4_usleep(100000);
print_reject_arm("NOT ARMING: Preflight checks failed");
}
}
@@ -2556,7 +2556,7 @@ Commander::run()
arm_auth_update(now, params_updated || param_init_forced);
usleep(COMMANDER_MONITORING_INTERVAL);
px4_usleep(COMMANDER_MONITORING_INTERVAL);
}
thread_should_exit = true;
@@ -3574,19 +3574,19 @@ void *commander_low_prio_loop(void *arg)
if (((int)(cmd.param1)) == 1) {
answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub);
usleep(100000);
px4_usleep(100000);
/* reboot */
px4_shutdown_request(true, false);
} else if (((int)(cmd.param1)) == 2) {
answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub);
usleep(100000);
px4_usleep(100000);
/* shutdown */
px4_shutdown_request(false, false);
} else if (((int)(cmd.param1)) == 3) {
answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub);
usleep(100000);
px4_usleep(100000);
/* reboot to bootloader */
px4_shutdown_request(true, true);
@@ -3733,7 +3733,7 @@ void *commander_low_prio_loop(void *arg)
#ifdef __PX4_QURT
// TODO FIXME: on snapdragon the save happens too early when the params
// are not set yet. We therefore need to wait some time first.
usleep(1000000);
px4_usleep(1000000);
#endif
int ret = param_save_default();
@@ -4115,7 +4115,7 @@ void Commander::battery_status_check()
if (battery.warning == battery_status_s::BATTERY_WARNING_EMERGENCY) {
mavlink_log_critical(&mavlink_log_pub, "DANGEROUSLY LOW BATTERY, SHUT SYSTEM DOWN");
usleep(200000);
px4_usleep(200000);
int ret_val = px4_shutdown_request(false, false);
@@ -4123,7 +4123,7 @@ void Commander::battery_status_check()
mavlink_log_critical(&mavlink_log_pub, "SYSTEM DOES NOT SUPPORT SHUTDOWN");
} else {
while (1) { usleep(1); }
while (1) { px4_usleep(1); }
}
}
}