aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-02-18 10:37:32 +0100
committerLorenz Meier <lm@inf.ethz.ch>2014-02-21 08:37:12 +0100
commita91b68d8a52709c5ce3ce465cad3b7e5a5e34f66 (patch)
tree7e22e4c478e643fe538c65180e3afb38f8db5383
parent603069f16928f11c50597d97e0025f6dfc4cab4a (diff)
downloadpx4-firmware-a91b68d8a52709c5ce3ce465cad3b7e5a5e34f66.tar.gz
px4-firmware-a91b68d8a52709c5ce3ce465cad3b7e5a5e34f66.tar.bz2
px4-firmware-a91b68d8a52709c5ce3ce465cad3b7e5a5e34f66.zip
Fix DSM pairing error handling.
-rw-r--r--src/drivers/px4io/px4io.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp
index 13326e962..7c7b3dcb7 100644
--- a/src/drivers/px4io/px4io.cpp
+++ b/src/drivers/px4io/px4io.cpp
@@ -2112,14 +2112,24 @@ PX4IO::ioctl(file * /*filep*/, int cmd, unsigned long arg)
break;
case DSM_BIND_START:
- io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_power_down);
- usleep(500000);
- io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_set_rx_out);
- io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_power_up);
- usleep(72000);
- io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_send_pulses | (arg << 4));
- usleep(50000);
- io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_reinit_uart);
+
+ /* only allow DSM2, DSM-X and DSM-X with more than 7 channels */
+ if (arg == DSM2_BIND_PULSES ||
+ arg == DSMX_BIND_PULSES ||
+ arg == DSMX8_BIND_PULSES) {
+ io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_power_down);
+ usleep(500000);
+ io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_set_rx_out);
+ io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_power_up);
+ usleep(72000);
+ io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_send_pulses | (arg << 4));
+ usleep(50000);
+ io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_reinit_uart);
+
+ ret = OK;
+ } else {
+ ret = -EINVAL;
+ }
break;
case DSM_BIND_POWER_UP:
@@ -2612,7 +2622,7 @@ bind(int argc, char *argv[])
#endif
if (argc < 3)
- errx(0, "needs argument, use dsm2 or dsmx");
+ errx(0, "needs argument, use dsm2, dsmx or dsmx8");
if (!strcmp(argv[2], "dsm2"))
pulses = DSM2_BIND_PULSES;
@@ -2621,7 +2631,7 @@ bind(int argc, char *argv[])
else if (!strcmp(argv[2], "dsmx8"))
pulses = DSMX8_BIND_PULSES;
else
- errx(1, "unknown parameter %s, use dsm2 or dsmx", argv[2]);
+ errx(1, "unknown parameter %s, use dsm2, dsmx or dsmx8", argv[2]);
// Test for custom pulse parameter
if (argc > 3)
pulses = atoi(argv[3]);