diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index b47674dffb..8fd1fdb543 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -186,8 +186,6 @@ public: virtual int init(); - void dsm_bind_ioctl(); - int set_mode(Mode mode); Mode get_mode() { return _mode; } @@ -339,7 +337,7 @@ private: uint16_t raw_rc_values_local[input_rc_s::RC_INPUT_MAX_CHANNELS], hrt_abstime now, bool frame_drop, bool failsafe, unsigned frame_drops, int rssi); - void dsm_bind_ioctl(int dsmMode); + void set_rc_scan_state(RC_SCAN _rc_scan_state); void rc_io_invert(); void rc_io_invert(bool invert); @@ -1488,9 +1486,27 @@ PX4FMU::cycle() // Check for a DSM pairing command if (((unsigned int)cmd.command == vehicle_command_s::VEHICLE_CMD_START_RX_PAIR) && ((int)cmd.param1 == 0)) { - dsm_bind_ioctl((int)cmd.param2); - } + if (!_armed.armed) { + int dsm_bind_mode = (int)cmd.param2; + int dsm_bind_pulses = 0; + + if (dsm_bind_mode == 0) { + dsm_bind_pulses = DSM2_BIND_PULSES; + + } else if (dsm_bind_mode == 1) { + dsm_bind_pulses = DSMX_BIND_PULSES; + + } else { + dsm_bind_pulses = DSMX8_BIND_PULSES; + } + + ioctl(nullptr, DSM_BIND_START, dsm_bind_pulses); + + } else { + PX4_WARN("system armed, bind request rejected"); + } + } } #endif @@ -1793,18 +1809,8 @@ void PX4FMU::update_params() update_pwm_rev_mask(); update_pwm_trims(); - int32_t dsm_bind_val; param_t param_handle; - /* see if bind parameter has been set, and reset it to -1 */ - param_get(param_handle = param_find("RC_DSM_BIND"), &dsm_bind_val); - - if (dsm_bind_val > -1) { - dsm_bind_ioctl(dsm_bind_val); - dsm_bind_val = -1; - param_set(param_handle, &dsm_bind_val); - } - // maximum motor slew rate parameter param_handle = param_find("MOT_SLEW_MAX"); @@ -2459,7 +2465,7 @@ PX4FMU::pwm_ioctl(file *filp, int cmd, unsigned long arg) case DSM_BIND_START: /* only allow DSM2, DSM-X and DSM-X with more than 7 channels */ - PX4_INFO("pwm_ioctl: DSM_BIND_START, arg: %lu", arg); + PX4_INFO("DSM_BIND_START: DSM%s RX", (arg == 0) ? "2" : ((arg == 1) ? "-X" : "-X8")); if (arg == DSM2_BIND_PULSES || arg == DSMX_BIND_PULSES || @@ -2483,6 +2489,7 @@ PX4FMU::pwm_ioctl(file *filp, int cmd, unsigned long arg) ret = OK; } else { + PX4_ERR("DSM bind failed"); ret = -EINVAL; } @@ -2926,26 +2933,6 @@ PX4FMU::gpio_ioctl(struct file *filp, int cmd, unsigned long arg) return ret; } -void -PX4FMU::dsm_bind_ioctl(int dsmMode) -{ - if (!_armed.armed) { -// mavlink_log_info(&_mavlink_log_pub, "[FMU] binding DSM%s RX", (dsmMode == 0) ? "2" : ((dsmMode == 1) ? "-X" : "-X8")); - PX4_INFO("[FMU] binding DSM%s RX", (dsmMode == 0) ? "2" : ((dsmMode == 1) ? "-X" : "-X8")); - int ret = ioctl(nullptr, DSM_BIND_START, - (dsmMode == 0) ? DSM2_BIND_PULSES : ((dsmMode == 1) ? DSMX_BIND_PULSES : DSMX8_BIND_PULSES)); - - if (ret) { -// mavlink_log_critical(&_mavlink_log_pub, "binding failed."); - PX4_ERR("binding failed."); - } - - } else { -// mavlink_log_info(&_mavlink_log_pub, "[FMU] system armed, bind request rejected"); - PX4_WARN("[FMU] system armed, bind request rejected"); - } -} - int PX4FMU::fmu_new_mode(PortMode new_mode) { @@ -3043,24 +3030,17 @@ namespace void bind_spektrum() { - int fd; - - fd = open(PX4FMU_DEVICE_PATH, O_RDWR); + int fd = open(PX4FMU_DEVICE_PATH, O_RDWR); if (fd < 0) { PX4_ERR("open fail"); return; } - PX4_INFO("bind_Spektrum RX"); - /* specify 11ms DSMX. RX will automatically fall back to 22ms or DSM2 if necessary */ - if (ioctl(fd, DSM_BIND_START, DSMX8_BIND_PULSES)) { - PX4_ERR("binding failed."); - } + ioctl(fd, DSM_BIND_START, DSMX8_BIND_PULSES); close(fd); - } int fmu_new_i2c_speed(unsigned bus, unsigned clock_hz) diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index 0e15781041..4f240facff 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -1049,18 +1049,6 @@ PX4IO::task_main() parameter_update_s pupdate; orb_copy(ORB_ID(parameter_update), _t_param, &pupdate); - int32_t dsm_bind_val; - param_t dsm_bind_param; - - /* see if bind parameter has been set, and reset it to -1 */ - param_get(dsm_bind_param = param_find("RC_DSM_BIND"), &dsm_bind_val); - - if (dsm_bind_val > -1) { - dsm_bind_ioctl(dsm_bind_val); - dsm_bind_val = -1; - param_set(dsm_bind_param, &dsm_bind_val); - } - if (!_rc_handling_disabled) { /* re-upload RC input config as it may have changed */ io_set_rc_config(); diff --git a/src/modules/sensors/rc_params.c b/src/modules/sensors/rc_params.c index 1e21734875..b4e2a587da 100644 --- a/src/modules/sensors/rc_params.c +++ b/src/modules/sensors/rc_params.c @@ -1096,18 +1096,6 @@ PARAM_DEFINE_FLOAT(RC18_DZ, 0.0f); */ PARAM_DEFINE_INT32(RC_RL1_DSM_VCC, 0); /* Relay 1 controls DSM VCC */ -/** - * DSM binding trigger. - * - * @value -1 Inactive - * @value 0 Start DSM2 bind - * @value 1 Start DSMX bind - * @min -1 - * @max 1 - * @group Radio Calibration - */ -PARAM_DEFINE_INT32(RC_DSM_BIND, -1); - /** * RC channel count *