From 984e68d76e6e199608aded66ed3c032a3db2fe32 Mon Sep 17 00:00:00 2001 From: px4dev Date: Sat, 26 Jan 2013 12:27:42 -0800 Subject: Add an ioctl for fetching the number of PWM outputs --- apps/drivers/drv_pwm_output.h | 3 +++ apps/drivers/px4io/px4io.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/apps/drivers/drv_pwm_output.h b/apps/drivers/drv_pwm_output.h index fe08d3fe5..23883323e 100644 --- a/apps/drivers/drv_pwm_output.h +++ b/apps/drivers/drv_pwm_output.h @@ -103,6 +103,9 @@ ORB_DECLARE(output_pwm); /** set update rate in Hz */ #define PWM_SERVO_SET_UPDATE_RATE _IOC(_PWM_SERVO_BASE, 2) +/** get the number of servos in *(unsigned *)arg */ +#define PWM_SERVO_GET_COUNT _IOC(_PWM_SERVO_BASE, 3) + /** set a single servo to a specific value */ #define PWM_SERVO_SET(_servo) _IOC(_PWM_SERVO_BASE, 0x20 + _servo) diff --git a/apps/drivers/px4io/px4io.cpp b/apps/drivers/px4io/px4io.cpp index 1678ed0de..61c9a793d 100644 --- a/apps/drivers/px4io/px4io.cpp +++ b/apps/drivers/px4io/px4io.cpp @@ -974,6 +974,10 @@ PX4IO::ioctl(file *filep, int cmd, unsigned long arg) } break; + case PWM_SERVO_GET_COUNT: + *(unsigned *)arg = _max_actuators; + break; + case PWM_SERVO_SET(0) ... PWM_SERVO_SET(PWM_OUTPUT_MAX_CHANNELS): { unsigned channel = cmd - PWM_SERVO_SET(0); -- cgit v1.2.3