aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/px4io/px4io.cpp
diff options
context:
space:
mode:
authorJulian Oes <julian@oes.ch>2013-10-04 13:00:12 +0200
committerJulian Oes <julian@oes.ch>2013-10-04 13:00:12 +0200
commitbaa49080547d740959f96174023a9cd5312924f1 (patch)
treea86471f05602037bfb517be6f552912222ca8b0b /src/drivers/px4io/px4io.cpp
parent9493c7a45c43bf7e8581765e3e2a93503a9f1e09 (diff)
downloadpx4-firmware-baa49080547d740959f96174023a9cd5312924f1.tar.gz
px4-firmware-baa49080547d740959f96174023a9cd5312924f1.tar.bz2
px4-firmware-baa49080547d740959f96174023a9cd5312924f1.zip
Changes to pwm systemcmd, basic functionality there, needs polishing
Diffstat (limited to 'src/drivers/px4io/px4io.cpp')
-rw-r--r--src/drivers/px4io/px4io.cpp104
1 files changed, 1 insertions, 103 deletions
diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp
index 0fed99692..add20c551 100644
--- a/src/drivers/px4io/px4io.cpp
+++ b/src/drivers/px4io/px4io.cpp
@@ -1748,6 +1748,7 @@ PX4IO::ioctl(file * /*filep*/, int cmd, unsigned long arg)
case PWM_SERVO_SET_MIN_PWM: {
struct pwm_output_values* pwm = (struct pwm_output_values*)arg;
+ warnx("Set min values");
set_min_values(pwm->values, pwm->channel_count);
}
break;
@@ -2381,110 +2382,7 @@ px4io_main(int argc, char *argv[])
exit(0);
}
- if (!strcmp(argv[1], "min")) {
- if (argc < 3) {
- errx(1, "min command needs at least one channel value (PWM)");
- }
-
- int iofd = open(PWM_OUTPUT_DEVICE_PATH, 0);
- struct pwm_output_values pwm;
-
- if (iofd > 0) {
-
- pwm.channel_count = 0;
-
- for (unsigned i = 0; i < sizeof(pwm.values) / sizeof(pwm.values[0]); i++)
- {
- /* set channel to commanline argument or to 900 for non-provided channels */
- if (argc > i + 2) {
- pwm.values[i] = atoi(argv[i+2]);
- if (pwm.values[i] < 900 || pwm.values[i] > 1200) {
- errx(1, "value out of range of 900 < value < 1200. Aborting.");
- }
- pwm.channel_count++;
- }
- }
-
- int ret = ioctl(iofd, PWM_SERVO_SET_MIN_PWM, (long unsigned int)&pwm);
-
- if (ret != OK)
- errx(ret, "failed setting min values");
- } else {
- errx(1, "not loaded");
- }
- exit(0);
- }
-
- if (!strcmp(argv[1], "max")) {
-
- if (argc < 3) {
- errx(1, "max command needs at least one channel value (PWM)");
- }
-
- int iofd = open(PWM_OUTPUT_DEVICE_PATH, 0);
- struct pwm_output_values pwm;
-
- if (iofd > 0) {
-
- pwm.channel_count = 0;
-
- for (int i = 0; i < sizeof(pwm.values) / sizeof(pwm.values[0]); i++)
- {
- /* set channel to commanline argument or to 2100 for non-provided channels */
- if (argc > i + 2) {
- pwm.values[i] = atoi(argv[i+2]);
- if (pwm.values[i] < 1800 || pwm.values[i] > 2100) {
- errx(1, "value out of range of 1800 < value < 2100. Aborting.");
- }
- pwm.channel_count++;
- }
- }
-
- int ret = ioctl(iofd, PWM_SERVO_SET_MAX_PWM, (long unsigned int)&pwm);
-
- if (ret != OK)
- errx(ret, "failed setting max values");
- } else {
- errx(1, "not loaded");
- }
- exit(0);
- }
-
- if (!strcmp(argv[1], "idle") || !strcmp(argv[1], "disarmed")) {
-
- if (argc < 3) {
- errx(1, "max command needs at least one channel value (PWM)");
- }
-
- int iofd = open(PWM_OUTPUT_DEVICE_PATH, 0);
- struct pwm_output_values pwm;
-
- if (iofd > 0) {
-
- pwm.channel_count = 0;
-
- for (unsigned i = 0; i < sizeof(pwm.values) / sizeof(pwm.values[0]); i++)
- {
- /* set channel to commanline argument or to 0 for non-provided channels */
- if (argc > i + 2) {
- pwm.values[i] = atoi(argv[i+2]);
- if (pwm.values[i] < 900 || pwm.values[i] > 2100) {
- errx(1, "value out of range of 900 < value < 2100. Aborting.");
- }
- pwm.channel_count++;
- }
- }
-
- int ret = ioctl(iofd, PWM_SERVO_SET_DISARMED_PWM, (long unsigned int)&pwm);
-
- if (ret != OK)
- errx(ret, "failed setting idle values");
- } else {
- errx(1, "not loaded");
- }
- exit(0);
- }
if (!strcmp(argv[1], "recovery")) {