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
@@ -214,7 +214,7 @@ AttitudeEstimatorQ::~AttitudeEstimatorQ()
do {
/* wait 20ms */
usleep(20000);
px4_usleep(20000);
/* if we have given up, kill it */
if (++i > 50) {
@@ -282,7 +282,7 @@ void AttitudeEstimatorQ::task_main()
if (ret < 0) {
// Poll error, sleep and try again
usleep(10000);
px4_usleep(10000);
PX4_WARN("POLL ERROR");
continue;
@@ -76,7 +76,7 @@ CameraFeedback::~CameraFeedback()
do {
/* wait 20ms */
usleep(20000);
px4_usleep(20000);
/* if we have given up, kill it */
if (++i > 50) {
+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); }
}
}
}
@@ -441,7 +441,7 @@ int do_accel_calibration(orb_advert_t *mavlink_log_pub)
if (res == PX4_OK) {
/* if there is a any preflight-check system response, let the barrage of messages through */
usleep(200000);
px4_usleep(200000);
calibration_log_info(mavlink_log_pub, CAL_QGC_DONE_MSG, sensor_name);
@@ -450,7 +450,7 @@ int do_accel_calibration(orb_advert_t *mavlink_log_pub)
}
/* give this message enough time to propagate */
usleep(600000);
px4_usleep(600000);
return res;
}
@@ -121,7 +121,7 @@ int do_airspeed_calibration(orb_advert_t *mavlink_log_pub)
}
calibration_log_critical(mavlink_log_pub, "[cal] Ensure sensor is not measuring wind");
usleep(500 * 1000);
px4_usleep(500 * 1000);
while (calibration_counter < calibration_count) {
@@ -198,7 +198,7 @@ int do_airspeed_calibration(orb_advert_t *mavlink_log_pub)
calibration_log_info(mavlink_log_pub, "[cal] Offset of %d Pascal", (int)diff_pres_offset);
/* wait 500 ms to ensure parameter propagated through the system */
usleep(500 * 1000);
px4_usleep(500 * 1000);
calibration_log_critical(mavlink_log_pub, "[cal] Blow across front of pitot without touching");
@@ -277,7 +277,7 @@ int do_airspeed_calibration(orb_advert_t *mavlink_log_pub)
/* Wait 2sec for the airflow to stop and ensure the driver filter has caught up, otherwise
* the followup preflight checks might fail. */
usleep(2e6);
px4_usleep(2e6);
normal_return:
calibrate_cancel_unsubscribe(cancel_sub);
+1 -1
View File
@@ -120,7 +120,7 @@ static uint8_t _auth_method_arm_req_check()
}
/* 0.5ms */
usleep(500);
px4_usleep(500);
now = hrt_absolute_time();
}
+10 -10
View File
@@ -605,7 +605,7 @@ enum detect_orientation_return detect_orientation(orb_advert_t *mavlink_log_pub,
/* not still, reset still start time */
if (t_still != 0) {
calibration_log_info(mavlink_log_pub, "[cal] detected motion, hold still...");
usleep(200000);
px4_usleep(200000);
t_still = 0;
}
}
@@ -739,16 +739,16 @@ calibrate_return calibrate_from_orientation(orb_advert_t *mavlink_log_pub,
}
calibration_log_info(mavlink_log_pub, "[cal] pending:%s", pendingStr);
usleep(20000);
px4_usleep(20000);
calibration_log_info(mavlink_log_pub, "[cal] hold vehicle still on a pending side");
usleep(20000);
px4_usleep(20000);
enum detect_orientation_return orient = detect_orientation(mavlink_log_pub, cancel_sub, sub_accel,
lenient_still_position);
if (orient == DETECT_ORIENTATION_ERROR) {
orientation_failures++;
calibration_log_info(mavlink_log_pub, "[cal] detected motion, hold still...");
usleep(20000);
px4_usleep(20000);
continue;
}
@@ -757,14 +757,14 @@ calibrate_return calibrate_from_orientation(orb_advert_t *mavlink_log_pub,
orientation_failures++;
set_tune(TONE_NOTIFY_NEGATIVE_TUNE);
calibration_log_info(mavlink_log_pub, "[cal] %s side already completed", detect_orientation_str(orient));
usleep(20000);
px4_usleep(20000);
continue;
}
calibration_log_info(mavlink_log_pub, CAL_QGC_ORIENTATION_DETECTED_MSG, detect_orientation_str(orient));
usleep(20000);
px4_usleep(20000);
calibration_log_info(mavlink_log_pub, CAL_QGC_ORIENTATION_DETECTED_MSG, detect_orientation_str(orient));
usleep(20000);
px4_usleep(20000);
orientation_failures = 0;
// Call worker routine
@@ -775,9 +775,9 @@ calibrate_return calibrate_from_orientation(orb_advert_t *mavlink_log_pub,
}
calibration_log_info(mavlink_log_pub, CAL_QGC_SIDE_DONE_MSG, detect_orientation_str(orient));
usleep(20000);
px4_usleep(20000);
calibration_log_info(mavlink_log_pub, CAL_QGC_SIDE_DONE_MSG, detect_orientation_str(orient));
usleep(20000);
px4_usleep(20000);
// Note that this side is complete
side_data_collected[orient] = true;
@@ -787,7 +787,7 @@ calibrate_return calibrate_from_orientation(orb_advert_t *mavlink_log_pub,
// temporary priority boost for the white blinking led to come trough
rgbled_set_color_and_mode(led_control_s::COLOR_WHITE, led_control_s::MODE_BLINK_FAST, 3, 1);
usleep(200000);
px4_usleep(200000);
}
if (sub_accel >= 0) {
+3 -3
View File
@@ -140,17 +140,17 @@ bool calibrate_cancel_check(orb_advert_t *mavlink_log_pub, ///< uORB handle to w
#define calibration_log_info(_pub, _text, ...) \
do { \
mavlink_and_console_log_info(_pub, _text, ##__VA_ARGS__); \
usleep(10000); \
px4_usleep(10000); \
} while(0);
#define calibration_log_critical(_pub, _text, ...) \
do { \
mavlink_log_critical(_pub, _text, ##__VA_ARGS__); \
usleep(10000); \
px4_usleep(10000); \
} while(0);
#define calibration_log_emergency(_pub, _text, ...) \
do { \
mavlink_log_emergency(_pub, _text, ##__VA_ARGS__); \
usleep(10000); \
px4_usleep(10000); \
} while(0);
+2 -2
View File
@@ -79,7 +79,7 @@ int do_esc_calibration(orb_advert_t *mavlink_log_pub, struct actuator_armed_s *a
break;
} else {
usleep(50000);
px4_usleep(50000);
}
}
@@ -188,7 +188,7 @@ int do_esc_calibration(orb_advert_t *mavlink_log_pub, struct actuator_armed_s *a
}
}
usleep(50_ms);
px4_usleep(50_ms);
}
Out:
+2 -2
View File
@@ -539,7 +539,7 @@ int do_gyro_calibration(orb_advert_t *mavlink_log_pub)
}
/* if there is a any preflight-check system response, let the barrage of messages through */
usleep(200000);
px4_usleep(200000);
if (res == PX4_OK) {
calibration_log_info(mavlink_log_pub, CAL_QGC_DONE_MSG, sensor_name);
@@ -551,7 +551,7 @@ int do_gyro_calibration(orb_advert_t *mavlink_log_pub)
orb_unsubscribe(worker_data.sensor_correction_sub);
/* give this message enough time to propagate */
usleep(600000);
px4_usleep(600000);
return res;
}
+9 -9
View File
@@ -246,23 +246,23 @@ int do_mag_calibration(orb_advert_t *mavlink_log_pub)
case calibrate_return_ok:
/* if there is a any preflight-check system response, let the barrage of messages through */
usleep(200000);
px4_usleep(200000);
calibration_log_info(mavlink_log_pub, CAL_QGC_PROGRESS_MSG, 100);
usleep(20000);
px4_usleep(20000);
calibration_log_info(mavlink_log_pub, CAL_QGC_DONE_MSG, sensor_name);
usleep(20000);
px4_usleep(20000);
break;
default:
calibration_log_critical(mavlink_log_pub, CAL_QGC_FAILED_MSG, sensor_name);
usleep(20000);
px4_usleep(20000);
break;
}
}
/* give this message enough time to propagate */
usleep(600000);
px4_usleep(600000);
return result;
}
@@ -497,7 +497,7 @@ static calibrate_return mag_calibration_worker(detect_orientation_return orienta
calibration_log_info(worker_data->mavlink_log_pub,
"[cal] %s side calibration: progress <%u>",
detect_orientation_str(orientation), new_progress);
usleep(20000);
px4_usleep(20000);
_last_mag_progress = new_progress;
}
@@ -519,7 +519,7 @@ static calibrate_return mag_calibration_worker(detect_orientation_return orienta
detect_orientation_str(orientation));
worker_data->done_count++;
usleep(20000);
px4_usleep(20000);
calibration_log_info(worker_data->mavlink_log_pub, CAL_QGC_PROGRESS_MSG, progress_percentage(worker_data));
}
@@ -559,7 +559,7 @@ calibrate_return mag_calibrate_all(orb_advert_t *mavlink_log_pub)
calibration_log_info(mavlink_log_pub,
"[cal] %s side done, rotate to a different side",
detect_orientation_str(static_cast<enum detect_orientation_return>(i)));
usleep(100000);
px4_usleep(100000);
}
}
@@ -891,7 +891,7 @@ calibrate_return mag_calibrate_all(orb_advert_t *mavlink_log_pub)
calibration_log_info(mavlink_log_pub, "[cal] mag #%u scale: x:%.2f y:%.2f z:%.2f",
cur_mag, (double)mscale.x_scale, (double)mscale.y_scale, (double)mscale.z_scale);
#endif
usleep(200000);
px4_usleep(200000);
}
}
}
+1 -1
View File
@@ -54,7 +54,7 @@
int do_trim_calibration(orb_advert_t *mavlink_log_pub)
{
int sub_man = orb_subscribe(ORB_ID(manual_control_setpoint));
usleep(400000);
px4_usleep(400000);
struct manual_control_setpoint_s sp;
bool changed;
orb_check(sub_man, &changed);
+10 -10
View File
@@ -77,7 +77,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC_MAP_TRANS_SW PARAMETER MISSING."); }
/* give system time to flush error message in case there are more */
usleep(100000);
px4_usleep(100000);
map_fail_count++;
} else {
@@ -102,7 +102,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: PARAM %s MISSING.", rc_map_mandatory[j]); }
/* give system time to flush error message in case there are more */
usleep(100000);
px4_usleep(100000);
map_fail_count++;
j++;
continue;
@@ -115,7 +115,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: %s >= NUMBER OF CHANNELS.", rc_map_mandatory[j]); }
/* give system time to flush error message in case there are more */
usleep(100000);
px4_usleep(100000);
map_fail_count++;
}
@@ -123,7 +123,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: mandatory %s is unmapped.", rc_map_mandatory[j]); }
/* give system time to flush error message in case there are more */
usleep(100000);
px4_usleep(100000);
map_fail_count++;
}
@@ -176,7 +176,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: RC%d_MIN < %u.", i + 1, RC_INPUT_LOWEST_MIN_US); }
/* give system time to flush error message in case there are more */
usleep(100000);
px4_usleep(100000);
}
if (param_max > RC_INPUT_HIGHEST_MAX_US) {
@@ -185,7 +185,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: RC%d_MAX > %u.", i + 1, RC_INPUT_HIGHEST_MAX_US); }
/* give system time to flush error message in case there are more */
usleep(100000);
px4_usleep(100000);
}
if (param_trim < param_min) {
@@ -194,7 +194,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: RC%d_TRIM < MIN (%d/%d).", i + 1, (int)param_trim, (int)param_min); }
/* give system time to flush error message in case there are more */
usleep(100000);
px4_usleep(100000);
}
if (param_trim > param_max) {
@@ -203,7 +203,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: RC%d_TRIM > MAX (%d/%d).", i + 1, (int)param_trim, (int)param_max); }
/* give system time to flush error message in case there are more */
usleep(100000);
px4_usleep(100000);
}
/* assert deadzone is sane */
@@ -211,7 +211,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: RC%d_DZ > %u.", i + 1, RC_INPUT_MAX_DEADZONE_US); }
/* give system time to flush error message in case there are more */
usleep(100000);
px4_usleep(100000);
count++;
}
@@ -231,7 +231,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
(total_fail_count > 1) ? "s" : "", channels_failed, (channels_failed > 1) ? "s" : "");
}
usleep(100000);
px4_usleep(100000);
}
return total_fail_count + map_fail_count;
+1 -1
View File
@@ -727,7 +727,7 @@ void Ekf2::run()
if (ret < 0) {
// Poll error, sleep and try again
usleep(10000);
px4_usleep(10000);
continue;
} else if (ret == 0) {
@@ -181,7 +181,7 @@ void TemperatureCalibration::task_main()
// make sure the system updates the changed parameters
param_notify_changes();
usleep(300000); // wait a bit for the system to apply the parameters
px4_usleep(300000); // wait a bit for the system to apply the parameters
hrt_abstime next_progress_output = hrt_absolute_time() + 1e6;
@@ -205,7 +205,7 @@ void TemperatureCalibration::task_main()
if (ret < 0) {
// Poll error, sleep and try again
usleep(10000);
px4_usleep(10000);
continue;
} else if (ret == 0) {
@@ -89,7 +89,7 @@ GroundRoverAttitudeControl::~GroundRoverAttitudeControl()
do {
/* wait 20ms */
usleep(20000);
px4_usleep(20000);
/* if we have given up, kill it */
if (++i > 50) {
@@ -403,7 +403,7 @@ int gnd_att_control_main(int argc, char *argv[])
/* avoid memory fragmentation by not exiting start handler until the task has fully started */
while (att_gnd_control::g_control == nullptr || !att_gnd_control::g_control->task_running()) {
usleep(50000);
px4_usleep(50000);
printf(".");
fflush(stdout);
}
@@ -103,7 +103,7 @@ GroundRoverPositionControl::~GroundRoverPositionControl()
do {
/* wait 20ms */
usleep(20000);
px4_usleep(20000);
/* if we have given up, kill it */
if (++i > 50) {
@@ -523,7 +523,7 @@ int gnd_pos_control_main(int argc, char *argv[])
/* avoid memory fragmentation by not exiting start handler until the task has fully started */
while (gnd_control::g_control == nullptr || !gnd_control::g_control->task_running()) {
usleep(50000);
px4_usleep(50000);
printf(".");
fflush(stdout);
}
@@ -140,7 +140,7 @@ int landing_target_estimator_thread_main(int argc, char *argv[])
while (!thread_should_exit) {
est.update();
usleep(1000000 / landing_target_estimator_UPDATE_RATE_HZ);
px4_usleep(1000000 / landing_target_estimator_UPDATE_RATE_HZ);
}
PX4_DEBUG("exiting");
+2 -2
View File
@@ -300,7 +300,7 @@ int LogWriterFile::write_message(LogType type, void *ptr, size_t size, uint64_t
while ((ret = write(type, ptr, 0, dropout_start)) == -1) {
unlock();
notify();
usleep(3000);
px4_usleep(3000);
lock();
}
}
@@ -314,7 +314,7 @@ int LogWriterFile::write_message(LogType type, void *ptr, size_t size, uint64_t
while ((ret = write(type, uptr, write_size, 0)) == -1) {
unlock();
notify();
usleep(3000);
px4_usleep(3000);
lock();
}
+14 -14
View File
@@ -345,7 +345,7 @@ Mavlink::~Mavlink()
do {
/* wait 20ms */
usleep(20000);
px4_usleep(20000);
/* if we have given up, kill it */
if (++i > 50) {
@@ -465,7 +465,7 @@ Mavlink::destroy_all_instances()
while (inst_to_del->_task_running) {
printf(".");
fflush(stdout);
usleep(10000);
px4_usleep(10000);
iterations++;
if (iterations > 1000) {
@@ -701,7 +701,7 @@ int Mavlink::mavlink_open_uart(int baud, const char *uart_name, bool force_flow_
/* back off 1800 ms to avoid running into the USB setup timing */
while (_mode == MAVLINK_MODE_CONFIG &&
hrt_absolute_time() < 1800U * 1000U) {
usleep(50000);
px4_usleep(50000);
}
/* open uart */
@@ -734,7 +734,7 @@ int Mavlink::mavlink_open_uart(int baud, const char *uart_name, bool force_flow_
}
}
usleep(100000);
px4_usleep(100000);
_uart_fd = ::open(uart_name, O_RDWR | O_NOCTTY);
}
@@ -1457,7 +1457,7 @@ Mavlink::configure_stream_threadsafe(const char *stream_name, const float rate)
if (!_task_should_exit) {
/* wait for previous subscription completion */
while (_subscribe_to_stream != nullptr) {
usleep(MAIN_LOOP_DELAY / 2);
px4_usleep(MAIN_LOOP_DELAY / 2);
}
/* copy stream name */
@@ -1471,7 +1471,7 @@ Mavlink::configure_stream_threadsafe(const char *stream_name, const float rate)
/* wait for subscription */
do {
usleep(MAIN_LOOP_DELAY / 2);
px4_usleep(MAIN_LOOP_DELAY / 2);
} while (_subscribe_to_stream != nullptr);
delete[] s;
@@ -2280,7 +2280,7 @@ Mavlink::task_main(int argc, char *argv[])
while (!_task_should_exit) {
/* main loop */
usleep(_main_loop_delay);
px4_usleep(_main_loop_delay);
perf_begin(_loop_perf);
@@ -2667,28 +2667,28 @@ void Mavlink::check_radio_config()
if (fs) {
/* switch to AT command mode */
usleep(1200000);
px4_usleep(1200000);
fprintf(fs, "+++\n");
usleep(1200000);
px4_usleep(1200000);
if (_param_radio_id.get() > 0) {
/* set channel */
fprintf(fs, "ATS3=%u\n", _param_radio_id.get());
usleep(200000);
px4_usleep(200000);
} else {
/* reset to factory defaults */
fprintf(fs, "AT&F\n");
usleep(200000);
px4_usleep(200000);
}
/* write config */
fprintf(fs, "AT&W");
usleep(200000);
px4_usleep(200000);
/* reboot */
fprintf(fs, "ATZ");
usleep(200000);
px4_usleep(200000);
// XXX NuttX suffers from a bug where
// fclose() also closes the fd, not just
@@ -2779,7 +2779,7 @@ Mavlink::start(int argc, char *argv[])
unsigned count = 0;
while (ic == Mavlink::instance_count() && count < limit) {
::usleep(sleeptime);
px4_usleep(sleeptime);
count++;
}
+2 -2
View File
@@ -2638,7 +2638,7 @@ MavlinkReceiver::receive_thread(void *arg)
if (_mavlink->get_protocol() == UDP || _mavlink->get_protocol() == TCP) {
// make sure mavlink app has booted before we start using the socket
while (!_mavlink->boot_complete()) {
usleep(100000);
px4_usleep(100000);
}
fds[0].fd = _mavlink->get_socket_fd();
@@ -2662,7 +2662,7 @@ MavlinkReceiver::receive_thread(void *arg)
/* non-blocking read. read may return negative values */
if ((nread = ::read(fds[0].fd, buf, sizeof(buf))) < (ssize_t)character_count) {
const unsigned sleeptime = character_count * 1000000 / (_mavlink->get_baudrate() / 10);
usleep(sleeptime);
px4_usleep(sleeptime);
}
}
@@ -849,7 +849,7 @@ MulticopterAttitudeControl::run()
if (pret < 0) {
PX4_ERR("poll error %d, %d", pret, errno);
/* sleep a bit before next try */
usleep(100000);
px4_usleep(100000);
continue;
}
+1 -1
View File
@@ -234,7 +234,7 @@ Navigator::run()
} else if (pret < 0) {
/* this is undesirable but not much we can do - might want to flag unhappy status */
PX4_ERR("poll error %d, %d", pret, errno);
usleep(10000);
px4_usleep(10000);
continue;
} else {
+2 -2
View File
@@ -875,7 +875,7 @@ uint64_t Replay::handleTopicDelay(uint64_t next_file_time, uint64_t timestamp_of
// if some topics have a timestamp smaller than the log file start, publish them immediately
if (cur_time < publish_timestamp && next_file_time > _file_start_time) {
usleep(publish_timestamp - cur_time);
px4_usleep(publish_timestamp - cur_time);
}
return publish_timestamp;
@@ -948,7 +948,7 @@ bool ReplayEkf2::handleTopicUpdate(Subscription &sub, void *data, std::ifstream
// introduce some breaks to make sure the logger can keep up
if (++_topic_counter == 50) {
usleep(1000);
px4_usleep(1000);
_topic_counter = 0;
}
+1 -1
View File
@@ -641,7 +641,7 @@ Sensors::run()
_voted_sensors_update.initialize_sensors();
}
usleep(1000);
px4_usleep(1000);
continue;
}
@@ -271,7 +271,7 @@ AirspeedSim::read(cdev::file_t *filp, char *buffer, size_t buflen)
}
/* wait for it to complete */
usleep(_conversion_interval);
px4_usleep(_conversion_interval);
/* run the collection phase */
if (OK != collect()) {
+3 -3
View File
@@ -198,7 +198,7 @@ GPSSIM::~GPSSIM()
/* spin waiting for the task to stop */
for (unsigned i = 0; (i < 10) && (_task != -1); i++) {
/* give it another 100ms */
usleep(100000);
px4_usleep(100000);
}
/* well, kill it anyway, though this will probably crash */
@@ -301,7 +301,7 @@ GPSSIM::receive(int timeout)
} else {
usleep(timeout);
px4_usleep(timeout);
return 0;
}
}
@@ -371,7 +371,7 @@ GPSSIM::print_info()
print_message(_report_gps_pos);
}
usleep(100000);
px4_usleep(100000);
}
void
+1 -1
View File
@@ -220,7 +220,7 @@ extern "C" {
break;
} else {
usleep(100000);
px4_usleep(100000);
}
}
+2 -2
View File
@@ -336,7 +336,7 @@ void Simulator::handle_message(mavlink_message_t *msg, bool publish)
unsigned usleep_delay = (sysdelay - min_delay) / _realtime_factor;
// extend by the realtime factor to avoid drift
usleep(usleep_delay);
px4_usleep(usleep_delay);
hrt_stop_delay_delta(exact_delay);
px4_sim_stop_delay();
}
@@ -838,7 +838,7 @@ void Simulator::pollForMAVLinkMessages(bool publish, int udp_port)
if (pret < 0) {
PX4_WARN("simulator mavlink: poll error %d, %d", pret, errno);
// sleep a bit before next try
usleep(100000);
px4_usleep(100000);
continue;
}
+1 -1
View File
@@ -316,7 +316,7 @@ void uORB::DeviceMaster::showTop(char **topic_filter, int num_filters)
}
}
usleep(200000);
px4_usleep(200000);
}
#endif
+1 -1
View File
@@ -593,7 +593,7 @@ uORB::DeviceNode::appears_updated(SubscriberData *sd)
/* block if in simulation mode */
while (px4_sim_delay_enabled()) {
usleep(100);
px4_usleep(100);
}
/* assume it doesn't look updated */
@@ -455,12 +455,12 @@ int uORBTest::UnitTest::pub_test_multi2_main()
}
}
usleep(100 * 1000);
px4_usleep(100 * 1000);
int message_counter = 0, num_messages = 50 * num_instances;
while (message_counter++ < num_messages) {
usleep(2); //make sure the timestamps are different
px4_usleep(2); //make sure the timestamps are different
orb_advert_t &pub = orb_pub[data_next_idx];
data_topic.time = hrt_absolute_time();
@@ -472,11 +472,11 @@ int uORBTest::UnitTest::pub_test_multi2_main()
data_next_idx = (data_next_idx + 1) % num_instances;
if (data_next_idx == 0) {
usleep(50 * 1000);
px4_usleep(50 * 1000);
}
}
usleep(100 * 1000);
px4_usleep(100 * 1000);
_thread_should_exit = true;
for (int i = 0; i < num_instances; ++i) {
@@ -528,9 +528,9 @@ int uORBTest::UnitTest::test_multi2()
// Relax timing requirement for Darwin CI system
#ifdef __PX4_DARWIN
usleep(10000);
px4_usleep(10000);
#else
usleep(1000);
px4_usleep(1000);
#endif
if (last_time >= msg.time && last_time != 0) {
@@ -767,11 +767,11 @@ int uORBTest::UnitTest::pub_test_queue_main()
}
message_counter += burst_counter;
usleep(20 * 1000); //give subscriber a chance to catch up
px4_usleep(20 * 1000); //give subscriber a chance to catch up
}
_num_messages_sent = t.val;
usleep(100 * 1000);
px4_usleep(100 * 1000);
_thread_should_exit = true;
orb_unadvertise(ptopic);
@@ -162,7 +162,7 @@ int uORBTest::UnitTest::latency_test(orb_id_t T, bool print)
}
/* simulate >800 Hz system operation */
usleep(1000);
px4_usleep(1000);
}
if (pubsub_task < 0) {
+3 -3
View File
@@ -387,7 +387,7 @@ static int vmount_thread_main(int argc, char *argv[])
} else {
//wait for parameter changes. We still need to wake up regularily to check for thread exit requests
usleep(1e6);
px4_usleep(1e6);
}
if (test_input && test_input->finished()) {
@@ -478,7 +478,7 @@ int vmount_main(int argc, char *argv[])
int counter = 0;
while (!thread_running && vmount_task >= 0) {
usleep(5000);
px4_usleep(5000);
if (++counter >= 100) {
break;
@@ -504,7 +504,7 @@ int vmount_main(int argc, char *argv[])
thread_should_exit = true;
while (thread_running) {
usleep(100000);
px4_usleep(100000);
}
return 0;
@@ -120,7 +120,7 @@ VtolAttitudeControl::~VtolAttitudeControl()
do {
/* wait 20ms */
usleep(20000);
px4_usleep(20000);
/* if we have given up, kill it */
if (++i > 50) {
@@ -590,7 +590,7 @@ void VtolAttitudeControl::task_main()
if (pret < 0) {
PX4_ERR("poll error %d, %d", pret, errno);
/* sleep a bit before next try */
usleep(100000);
px4_usleep(100000);
continue;
}