39 #include <px4_platform_common/time.h> 40 #include <px4_platform_common/px4_config.h> 42 #include <sys/types.h> 50 #include <arch/board/board.h> 72 printf(
"failed opening /dev/pwm_servo\n");
75 printf(
"Servo readback, pairs of values should match defaults\n");
81 warnx(
"PWM_SERVO_GET_COUNT");
83 (void)close(servo_fd);
87 for (
unsigned i = 0; i < servo_count; i++) {
88 result = ioctl(servo_fd,
PWM_SERVO_GET(i), (
unsigned long)&pos);
91 printf(
"failed reading channel %u\n", i);
107 int pwm_values[] = {1200, 1300, 1900, 1700, 1500, 1250, 1800, 1400};
110 for (
unsigned i = 0; (i < servo_count) && (i <
sizeof(pwm_values) /
sizeof(pwm_values[0])); i++) {
114 (void)close(servo_fd);
118 warnx(
"channel %d set to %d", i, pwm_values[i]);
122 warnx(
"servo count: %d", servo_count);
126 for (
unsigned i = 0; (i < servo_count) && (i <
sizeof(pwm_values) /
sizeof(pwm_values[0])); i++) {
127 pwm_out.
values[i] = pwm_values[i];
165 for (
unsigned i = 0; (i < servo_count) && (i <
sizeof(pwm_values) /
sizeof(pwm_values[0])); i++) {
166 if (
abs(rc_input.
values[i] - pwm_values[i]) > 10) {
167 warnx(
"comparison fail: RC: %d, expected: %d", rc_input.
values[i], pwm_values[i]);
168 (void)close(servo_fd);
174 warnx(
"failed reading RC input data");
175 (void)close(servo_fd);
181 warnx(
"PPM LOOPBACK TEST PASSED SUCCESSFULLY!");
int orb_copy(const struct orb_metadata *meta, int handle, void *buffer)
uint16_t servo_position_t
Servo output signal type, value is actual servo output pulse width in microseconds.
#define PWM_SERVO_GET_COUNT
get the number of servos in *(unsigned *)arg
#define PWM_SERVO_SET(_servo)
set a single servo to a specific value
int test_ppm_loopback(int argc, char *argv[])
int orb_subscribe(const struct orb_metadata *meta)
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
#define PWM_OUTPUT0_DEVICE_PATH
uint16_t values[PWM_OUTPUT_MAX_CHANNELS]
#define PWM_SERVO_SET_DISARMED_PWM
set the PWM value when disarmed - should be no PWM (zero) by default
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
#define PWM_SERVO_GET(_servo)
get a single specific servo value
int orb_check(int handle, bool *updated)
Dual< Scalar, N > abs(const Dual< Scalar, N > &a)