aboutsummaryrefslogtreecommitdiff
path: root/apps/drivers/px4fmu/fmu.cpp
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-12-18 00:29:22 -0800
committerpx4dev <px4@purgatory.org>2012-12-18 00:29:22 -0800
commitb8044d978672c3ee760189fb6e532b0514a09446 (patch)
tree1656ed8ddb8b20d836e92d9f6b56a87c3f80f746 /apps/drivers/px4fmu/fmu.cpp
parent6d0bea0298100d4ecf6630c239aa549bb338cc7b (diff)
downloadpx4-firmware-b8044d978672c3ee760189fb6e532b0514a09446.tar.gz
px4-firmware-b8044d978672c3ee760189fb6e532b0514a09446.tar.bz2
px4-firmware-b8044d978672c3ee760189fb6e532b0514a09446.zip
use <err.h> more consistently in the fmu driver.
Diffstat (limited to 'apps/drivers/px4fmu/fmu.cpp')
-rw-r--r--apps/drivers/px4fmu/fmu.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/apps/drivers/px4fmu/fmu.cpp b/apps/drivers/px4fmu/fmu.cpp
index 61dd418f8..f96aab45a 100644
--- a/apps/drivers/px4fmu/fmu.cpp
+++ b/apps/drivers/px4fmu/fmu.cpp
@@ -60,6 +60,7 @@
#include <drivers/boards/px4fmu/px4fmu_internal.h>
#include <systemlib/systemlib.h>
+#include <systemlib/err.h>
#include <systemlib/mixer/mixer.h>
#include <drivers/drv_mixer.h>
@@ -800,13 +801,14 @@ test(void)
fd = open(PWM_OUTPUT_DEVICE_PATH, 0);
- if (fd < 0) {
- puts("open fail");
- exit(1);
- }
+ if (fd < 0)
+ errx(1, "open fail");
- ioctl(fd, PWM_SERVO_ARM, 0);
- ioctl(fd, PWM_SERVO_SET(0), 1000);
+ if (ioctl(fd, PWM_SERVO_ARM, 0) < 0) err(1, "servo arm failed");
+ if (ioctl(fd, PWM_SERVO_SET(0), 1000) < 0) err(1, "servo 1 set failed");
+ if (ioctl(fd, PWM_SERVO_SET(1), 1200) < 0) err(1, "servo 2 set failed");
+ if (ioctl(fd, PWM_SERVO_SET(2), 1400) < 0) err(1, "servo 3 set failed");
+ if (ioctl(fd, PWM_SERVO_SET(3), 1600) < 0) err(1, "servo 4 set failed");
close(fd);
@@ -816,10 +818,8 @@ test(void)
void
fake(int argc, char *argv[])
{
- if (argc < 5) {
- puts("fmu fake <roll> <pitch> <yaw> <thrust> (values -100 .. 100)");
- exit(1);
- }
+ if (argc < 5)
+ errx(1, "fmu fake <roll> <pitch> <yaw> <thrust> (values -100 .. 100)");
actuator_controls_s ac;
@@ -833,10 +833,8 @@ fake(int argc, char *argv[])
orb_advert_t handle = orb_advertise(ORB_ID_VEHICLE_ATTITUDE_CONTROLS, &ac);
- if (handle < 0) {
- puts("advertise failed");
- exit(1);
- }
+ if (handle < 0)
+ errx(1, "advertise failed");
exit(0);
}
@@ -891,11 +889,11 @@ fmu_main(int argc, char *argv[])
if (argc > i + 1) {
pwm_update_rate_in_hz = atoi(argv[i + 1]);
} else {
- fprintf(stderr, "missing argument for pwm update rate (-u)\n");
+ errx(1, "missing argument for pwm update rate (-u)");
return 1;
}
} else {
- fprintf(stderr, "pwm update rate currently only supported for mode_pwm, mode_pwm_gpio\n");
+ errx(1, "pwm update rate currently only supported for mode_pwm, mode_pwm_gpio");
}
}
}
@@ -915,5 +913,5 @@ fmu_main(int argc, char *argv[])
fprintf(stderr, "FMU: unrecognised command, try:\n");
fprintf(stderr, " mode_gpio, mode_serial, mode_pwm [-u pwm_update_rate_in_hz], mode_gpio_serial, mode_pwm_serial, mode_pwm_gpio\n");
- return -EINVAL;
+ exit(1);
}