POSIX: fixes for use of open vs px4_open, etc

Fixes for the posix build when virtual devices are used.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-07-01 23:51:12 +02:00
committed by Lorenz Meier
parent af4cc8ec91
commit 28dd9759a6
8 changed files with 94 additions and 95 deletions
+4 -4
View File
@@ -268,7 +268,7 @@ static bool airspeedCheck(int mavlink_fd, bool optional)
}
out:
close(fd);
px4_close(fd);
return success;
}
@@ -279,10 +279,10 @@ static bool gnssCheck(int mavlink_fd)
int gpsSub = orb_subscribe(ORB_ID(vehicle_gps_position));
//Wait up to 2000ms to allow the driver to detect a GNSS receiver module
struct pollfd fds[1];
px4_pollfd_struct_t fds[1];
fds[0].fd = gpsSub;
fds[0].events = POLLIN;
if(poll(fds, 1, 2000) <= 0) {
if(px4_poll(fds, 1, 2000) <= 0) {
success = false;
}
else {
@@ -298,7 +298,7 @@ static bool gnssCheck(int mavlink_fd)
mavlink_and_console_log_critical(mavlink_fd, "PREFLIGHT FAIL: GPS RECEIVER MISSING");
}
close(gpsSub);
px4_close(gpsSub);
return success;
}
@@ -493,7 +493,7 @@ calibrate_return calibrate_from_orientation(int mavlink_fd,
}
if (sub_accel >= 0) {
close(sub_accel);
px4_close(sub_accel);
}
return result;
+20 -21
View File
@@ -362,7 +362,7 @@ int commander_main(int argc, char *argv[])
if (!strcmp(argv[1], "check")) {
int mavlink_fd_local = px4_open(MAVLINK_LOG_DEVICE, 0);
int checkres = prearm_check(&status, mavlink_fd_local);
close(mavlink_fd_local);
px4_close(mavlink_fd_local);
warnx("FINAL RESULT: %s", (checkres == 0) ? "OK" : "FAILED");
return 0;
}
@@ -371,14 +371,14 @@ int commander_main(int argc, char *argv[])
int mavlink_fd_local = px4_open(MAVLINK_LOG_DEVICE, 0);
arm_disarm(true, mavlink_fd_local, "command line");
warnx("note: not updating home position on commandline arming!");
close(mavlink_fd_local);
px4_close(mavlink_fd_local);
return 0;
}
if (!strcmp(argv[1], "disarm")) {
int mavlink_fd_local = px4_open(MAVLINK_LOG_DEVICE, 0);
arm_disarm(false, mavlink_fd_local, "command line");
close(mavlink_fd_local);
px4_close(mavlink_fd_local);
return 0;
}
@@ -389,10 +389,10 @@ int commander_main(int argc, char *argv[])
void usage(const char *reason)
{
if (reason) {
fprintf(stderr, "%s\n", reason);
PX4_INFO("%s\n", reason);
}
fprintf(stderr, "usage: commander {start|stop|status|calibrate|check|arm|disarm}\n\n");
PX4_INFO("usage: commander {start|stop|status|calibrate|check|arm|disarm}\n\n");
}
void print_status()
@@ -444,7 +444,7 @@ void print_status()
break;
}
close(state_sub);
px4_close(state_sub);
warnx("arming: %s", armed_str);
@@ -931,7 +931,6 @@ int commander_thread_main(int argc, char *argv[])
if (battery_init() != OK) {
mavlink_and_console_log_critical(mavlink_fd, "ERROR: BATTERY INIT FAIL");
}
mavlink_fd = px4_open(MAVLINK_LOG_DEVICE, 0);
/* vehicle status topic */
@@ -2166,7 +2165,7 @@ int commander_thread_main(int argc, char *argv[])
arm_tune_played = false;
}
fflush(stdout);
//fflush(stdout);
counter++;
int blink_state = blink_msg_state();
@@ -2200,18 +2199,18 @@ int commander_thread_main(int argc, char *argv[])
/* close fds */
led_deinit();
buzzer_deinit();
close(sp_man_sub);
close(offboard_control_mode_sub);
close(local_position_sub);
close(global_position_sub);
close(gps_sub);
close(sensor_sub);
close(safety_sub);
close(cmd_sub);
close(subsys_sub);
close(diff_pres_sub);
close(param_changed_sub);
close(battery_sub);
px4_close(sp_man_sub);
px4_close(offboard_control_mode_sub);
px4_close(local_position_sub);
px4_close(global_position_sub);
px4_close(gps_sub);
px4_close(sensor_sub);
px4_close(safety_sub);
px4_close(cmd_sub);
px4_close(subsys_sub);
px4_close(diff_pres_sub);
px4_close(param_changed_sub);
px4_close(battery_sub);
thread_running = false;
@@ -2977,7 +2976,7 @@ void *commander_low_prio_loop(void *arg)
}
}
close(cmd_sub);
px4_close(cmd_sub);
return NULL;
}
+4 -4
View File
@@ -243,7 +243,7 @@ static calibrate_return mag_calibration_worker(detect_orientation_return orienta
/* abort on request */
if (calibrate_cancel_check(worker_data->mavlink_fd, cancel_sub)) {
result = calibrate_return_cancelled;
close(sub_gyro);
px4_close(sub_gyro);
return result;
}
@@ -256,12 +256,12 @@ static calibrate_return mag_calibration_worker(detect_orientation_return orienta
}
/* Wait clocking for new data on all gyro */
struct pollfd fds[1];
px4_pollfd_struct_t fds[1];
fds[0].fd = sub_gyro;
fds[0].events = POLLIN;
size_t fd_count = 1;
int poll_ret = poll(fds, fd_count, 1000);
int poll_ret = px4_poll(fds, fd_count, 1000);
if (poll_ret > 0) {
struct gyro_report gyro;
@@ -281,7 +281,7 @@ static calibrate_return mag_calibration_worker(detect_orientation_return orienta
}
}
close(sub_gyro);
px4_close(sub_gyro);
uint64_t calibration_deadline = hrt_absolute_time() + worker_data->calibration_interval_perside_useconds;
unsigned poll_errcount = 0;
@@ -371,7 +371,7 @@ transition_result_t hil_state_transition(hil_state_t new_state, int status_pub,
break;
/* skip mavlink */
if (!strcmp("/dev/mavlink", devname)) {
if (!strcmp(MAVLINK_LOG_DEVICE, devname)) {
continue;
}