|
|
|
@ -177,21 +177,6 @@ public:
@@ -177,21 +177,6 @@ public:
|
|
|
|
|
*/ |
|
|
|
|
int set_failsafe_values(const uint16_t *vals, unsigned len); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the minimum PWM signals when armed |
|
|
|
|
*/ |
|
|
|
|
int set_min_values(const uint16_t *vals, unsigned len); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the maximum PWM signal when armed |
|
|
|
|
*/ |
|
|
|
|
int set_max_values(const uint16_t *vals, unsigned len); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set an idle PWM signal that is active right after startup, even when SAFETY_SAFE |
|
|
|
|
*/ |
|
|
|
|
int set_idle_values(const uint16_t *vals, unsigned len); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Print IO status. |
|
|
|
|
* |
|
|
|
@ -391,6 +376,21 @@ private:
@@ -391,6 +376,21 @@ private:
|
|
|
|
|
*/ |
|
|
|
|
int mixer_send(const char *buf, unsigned buflen); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the minimum PWM signals when armed |
|
|
|
|
*/ |
|
|
|
|
int set_min_values(const uint16_t *vals, unsigned len); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the maximum PWM signal when armed |
|
|
|
|
*/ |
|
|
|
|
int set_max_values(const uint16_t *vals, unsigned len); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set an idle PWM signal that is active right after startup, even when SAFETY_SAFE |
|
|
|
|
*/ |
|
|
|
|
int set_idle_values(const uint16_t *vals, unsigned len); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle a status update from IO. |
|
|
|
|
* |
|
|
|
@ -1674,6 +1674,24 @@ PX4IO::ioctl(file * /*filep*/, int cmd, unsigned long arg)
@@ -1674,6 +1674,24 @@ PX4IO::ioctl(file * /*filep*/, int cmd, unsigned long arg)
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case PWM_SERVO_SET_DISARMED_PWM: { |
|
|
|
|
struct pwm_output_values* pwm = (struct pwm_output_values*)arg; |
|
|
|
|
set_idle_values(pwm->values, pwm->channel_count); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case PWM_SERVO_SET_MIN_PWM: { |
|
|
|
|
struct pwm_output_values* pwm = (struct pwm_output_values*)arg; |
|
|
|
|
set_min_values(pwm->values, pwm->channel_count); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case PWM_SERVO_SET_MAX_PWM: { |
|
|
|
|
struct pwm_output_values* pwm = (struct pwm_output_values*)arg; |
|
|
|
|
set_max_values(pwm->values, pwm->channel_count); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case PWM_SERVO_GET_COUNT: |
|
|
|
|
*(unsigned *)arg = _max_actuators; |
|
|
|
|
break; |
|
|
|
@ -2265,26 +2283,26 @@ px4io_main(int argc, char *argv[])
@@ -2265,26 +2283,26 @@ px4io_main(int argc, char *argv[])
|
|
|
|
|
errx(1, "min command needs at least one channel value (PWM)"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (g_dev != nullptr) { |
|
|
|
|
int iofd = open(PWM_OUTPUT_DEVICE_PATH, 0); |
|
|
|
|
struct pwm_output_values pwm; |
|
|
|
|
|
|
|
|
|
if (iofd > 0) { |
|
|
|
|
|
|
|
|
|
/* set values for first 8 channels, fill unassigned channels with 900. */ |
|
|
|
|
uint16_t min[8]; |
|
|
|
|
pwm.channel_count = 0; |
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < sizeof(min) / sizeof(min[0]); i++) |
|
|
|
|
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) { |
|
|
|
|
min[i] = atoi(argv[i+2]); |
|
|
|
|
if (min[i] < 900 || min[i] > 1200) { |
|
|
|
|
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."); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
/* a zero value will the default */ |
|
|
|
|
min[i] = 0; |
|
|
|
|
pwm.channel_count++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int ret = g_dev->set_min_values(min, sizeof(min) / sizeof(min[0])); |
|
|
|
|
int ret = ioctl(iofd, PWM_SERVO_SET_MIN_PWM, (long unsigned int)&pwm); |
|
|
|
|
|
|
|
|
|
if (ret != OK) |
|
|
|
|
errx(ret, "failed setting min values"); |
|
|
|
@ -2300,26 +2318,26 @@ px4io_main(int argc, char *argv[])
@@ -2300,26 +2318,26 @@ px4io_main(int argc, char *argv[])
|
|
|
|
|
errx(1, "max command needs at least one channel value (PWM)"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (g_dev != nullptr) { |
|
|
|
|
int iofd = open(PWM_OUTPUT_DEVICE_PATH, 0); |
|
|
|
|
struct pwm_output_values pwm; |
|
|
|
|
|
|
|
|
|
if (iofd > 0) { |
|
|
|
|
|
|
|
|
|
/* set values for first 8 channels, fill unassigned channels with 2100. */ |
|
|
|
|
uint16_t max[8]; |
|
|
|
|
pwm.channel_count = 0; |
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < sizeof(max) / sizeof(max[0]); i++) |
|
|
|
|
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) { |
|
|
|
|
max[i] = atoi(argv[i+2]); |
|
|
|
|
if (max[i] < 1800 || max[i] > 2100) { |
|
|
|
|
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."); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
/* a zero value will the default */ |
|
|
|
|
max[i] = 0; |
|
|
|
|
pwm.channel_count++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int ret = g_dev->set_max_values(max, sizeof(max) / sizeof(max[0])); |
|
|
|
|
int ret = ioctl(iofd, PWM_SERVO_SET_MAX_PWM, (long unsigned int)&pwm); |
|
|
|
|
|
|
|
|
|
if (ret != OK) |
|
|
|
|
errx(ret, "failed setting max values"); |
|
|
|
@ -2329,32 +2347,32 @@ px4io_main(int argc, char *argv[])
@@ -2329,32 +2347,32 @@ px4io_main(int argc, char *argv[])
|
|
|
|
|
exit(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!strcmp(argv[1], "idle")) { |
|
|
|
|
if (!strcmp(argv[1], "idle") || !strcmp(argv[1], "disarmed")) { |
|
|
|
|
|
|
|
|
|
if (argc < 3) { |
|
|
|
|
errx(1, "max command needs at least one channel value (PWM)"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (g_dev != nullptr) { |
|
|
|
|
int iofd = open(PWM_OUTPUT_DEVICE_PATH, 0); |
|
|
|
|
struct pwm_output_values pwm; |
|
|
|
|
|
|
|
|
|
if (iofd > 0) { |
|
|
|
|
|
|
|
|
|
/* set values for first 8 channels, fill unassigned channels with 0. */ |
|
|
|
|
uint16_t idle[8]; |
|
|
|
|
pwm.channel_count = 0; |
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < sizeof(idle) / sizeof(idle[0]); i++) |
|
|
|
|
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) { |
|
|
|
|
idle[i] = atoi(argv[i+2]); |
|
|
|
|
if (idle[i] < 900 || idle[i] > 2100) { |
|
|
|
|
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."); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
/* a zero value will the default */ |
|
|
|
|
idle[i] = 0; |
|
|
|
|
pwm.channel_count++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int ret = g_dev->set_idle_values(idle, sizeof(idle) / sizeof(idle[0])); |
|
|
|
|
int ret = ioctl(iofd, PWM_SERVO_SET_DISARMED_PWM, (long unsigned int)&pwm); |
|
|
|
|
|
|
|
|
|
if (ret != OK) |
|
|
|
|
errx(ret, "failed setting idle values"); |
|
|
|
|