diff options
author | Lorenz Meier <lorenz@px4.io> | 2015-04-07 19:04:19 +0200 |
---|---|---|
committer | Lorenz Meier <lorenz@px4.io> | 2015-04-07 19:04:19 +0200 |
commit | f8c8876642857520e85ec8ca027146c11b4301e3 (patch) | |
tree | efb4bd4841e185e982df683e3810889faf5c4ab0 /src/drivers | |
parent | de3888bed75347eb8aefdc6cb7dbeeedff749988 (diff) | |
parent | 6bd94f15a89c8252e1d04350e043c764483647b7 (diff) | |
download | px4-firmware-f8c8876642857520e85ec8ca027146c11b4301e3.tar.gz px4-firmware-f8c8876642857520e85ec8ca027146c11b4301e3.tar.bz2 px4-firmware-f8c8876642857520e85ec8ca027146c11b4301e3.zip |
Merge pull request #1819 from PX4/chan16
Support 16 channels on IO via S.BUS
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/px4io/px4io.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index 1512566fa..3bd2c06a4 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -1693,14 +1693,20 @@ PX4IO::io_publish_pwm_outputs() uint16_t ctl[_max_actuators]; int ret = io_reg_get(PX4IO_PAGE_SERVOS, 0, ctl, _max_actuators); - if (ret != OK) + if (ret != OK){ return ret; + } + + unsigned maxouts = sizeof(outputs.output) / sizeof(outputs.output[0]); + unsigned actuator_max = (_max_actuators > maxouts) ? maxouts : _max_actuators; + /* convert from register format to float */ - for (unsigned i = 0; i < _max_actuators; i++) + for (unsigned i = 0; i < actuator_max; i++){ outputs.output[i] = ctl[i]; + } - outputs.noutputs = _max_actuators; + outputs.noutputs = actuator_max; /* lazily advertise on first publication */ if (_to_outputs == 0) { @@ -2016,13 +2022,13 @@ PX4IO::print_status(bool extended_status) printf("vrssi %u\n", io_reg_get(PX4IO_PAGE_STATUS, PX4IO_P_STATUS_VRSSI)); } - printf("actuators"); + printf("actuators (including S.BUS)"); for (unsigned i = 0; i < _max_actuators; i++) printf(" %hi", int16_t(io_reg_get(PX4IO_PAGE_ACTUATORS, i))); printf("\n"); - printf("servos"); + printf("hardware servo ports"); for (unsigned i = 0; i < _max_actuators; i++) printf(" %u", io_reg_get(PX4IO_PAGE_SERVOS, i)); |