mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 06:53:34 +08:00
Add an ioctl for fetching the number of PWM outputs
This commit is contained in:
@@ -103,6 +103,9 @@ ORB_DECLARE(output_pwm);
|
|||||||
/** set update rate in Hz */
|
/** set update rate in Hz */
|
||||||
#define PWM_SERVO_SET_UPDATE_RATE _IOC(_PWM_SERVO_BASE, 2)
|
#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 */
|
/** set a single servo to a specific value */
|
||||||
#define PWM_SERVO_SET(_servo) _IOC(_PWM_SERVO_BASE, 0x20 + _servo)
|
#define PWM_SERVO_SET(_servo) _IOC(_PWM_SERVO_BASE, 0x20 + _servo)
|
||||||
|
|
||||||
|
|||||||
@@ -974,6 +974,10 @@ PX4IO::ioctl(file *filep, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PWM_SERVO_GET_COUNT:
|
||||||
|
*(unsigned *)arg = _max_actuators;
|
||||||
|
break;
|
||||||
|
|
||||||
case PWM_SERVO_SET(0) ... PWM_SERVO_SET(PWM_OUTPUT_MAX_CHANNELS): {
|
case PWM_SERVO_SET(0) ... PWM_SERVO_SET(PWM_OUTPUT_MAX_CHANNELS): {
|
||||||
|
|
||||||
unsigned channel = cmd - PWM_SERVO_SET(0);
|
unsigned channel = cmd - PWM_SERVO_SET(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user