diff --git a/libraries/AP_BoardConfig/AP_BoardConfig.cpp b/libraries/AP_BoardConfig/AP_BoardConfig.cpp index 501ae21594..117821f648 100644 --- a/libraries/AP_BoardConfig/AP_BoardConfig.cpp +++ b/libraries/AP_BoardConfig/AP_BoardConfig.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef CONFIG_ARCH_BOARD_PX4FMU_V1 #define BOARD_PWM_COUNT_DEFAULT 2 @@ -68,6 +69,12 @@ const AP_Param::GroupInfo AP_BoardConfig::var_info[] PROGMEM = { // @Description: Disabling this option will disable the use of the safety switch on PX4 for arming. Use of the safety switch is highly recommended, so you should leave this option set to 1 except in unusual circumstances. // @Values: 0:Disabled,1:Enabled AP_GROUPINFO("SAFETYENABLE", 3, AP_BoardConfig, _safety_enable, 1), + + // @Param: SBUS_OUT + // @DisplayName: Enable use of SBUS output + // @Description: Enabling this option on a Pixhawk enables SBUS servo output from the SBUS output connector + // @Values: 0:Disabled,1:Enabled + AP_GROUPINFO("SBUS_OUT", 4, AP_BoardConfig, _sbus_out_enable, 0), #elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN #endif @@ -103,6 +110,16 @@ void AP_BoardConfig::init() if (_safety_enable.get() == 0) { hal.rcout->force_safety_off(); } + + if (_sbus_out_enable.get() == 1) { + fd = open("/dev/px4io", 0); + if (fd == -1 || ioctl(fd, SBUS_SET_PROTO_VERSION, 1) != 0) { + hal.console->printf("SBUS: Unable to setup SBUS output\n"); + } + if (fd != -1) { + close(fd); + } + } #elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN /* configure the VRBRAIN driver for the right number of PWMs */ diff --git a/libraries/AP_BoardConfig/AP_BoardConfig.h b/libraries/AP_BoardConfig/AP_BoardConfig.h index f68444134e..7d493a65c7 100644 --- a/libraries/AP_BoardConfig/AP_BoardConfig.h +++ b/libraries/AP_BoardConfig/AP_BoardConfig.h @@ -26,6 +26,7 @@ private: AP_Int8 _ser1_rtscts; AP_Int8 _ser2_rtscts; AP_Int8 _safety_enable; + AP_Int8 _sbus_out_enable; #endif #if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN