diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-08-12 15:35:05 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-08-12 15:35:05 +0200 |
commit | 62959d4d01b441c9bf7057417b319dc0888615a8 (patch) | |
tree | 32e5544d97b23c5fef2c6cbad37a7805f588be81 /src | |
parent | 3f4aef60c88b1e570dd30bc47a13d5340073e9a9 (diff) | |
parent | 0c0c8e943a2ec70a91386b65c17c563b6e40a782 (diff) | |
download | px4-firmware-62959d4d01b441c9bf7057417b319dc0888615a8.tar.gz px4-firmware-62959d4d01b441c9bf7057417b319dc0888615a8.tar.bz2 px4-firmware-62959d4d01b441c9bf7057417b319dc0888615a8.zip |
Merge pull request #1266 from PX4/norc
Fix NO RC handling (fixes #1263)
Diffstat (limited to 'src')
-rw-r--r-- | src/drivers/px4io/px4io.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index d93009c47..32069cf09 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -136,6 +136,15 @@ public: virtual int init(); /** + * Initialize the PX4IO class. + * + * Retrieve relevant initial system parameters. Initialize PX4IO registers. + * + * @param disable_rc_handling set to true to forbid override / RC handling on IO + */ + int init(bool disable_rc_handling); + + /** * Detect if a PX4IO is connected. * * Only validate if there is a PX4IO to talk to. @@ -580,6 +589,12 @@ PX4IO::detect() } int +PX4IO::init(bool rc_handling_disabled) { + _rc_handling_disabled = rc_handling_disabled; + return init(); +} + +int PX4IO::init() { int ret; @@ -778,6 +793,11 @@ PX4IO::init() if (_rc_handling_disabled) { ret = io_disable_rc_handling(); + if (ret != OK) { + log("failed disabling RC handling"); + return ret; + } + } else { /* publish RC config to IO */ ret = io_set_rc_config(); @@ -1175,6 +1195,7 @@ PX4IO::io_set_arming_state() int PX4IO::disable_rc_handling() { + _rc_handling_disabled = true; return io_disable_rc_handling(); } @@ -2613,24 +2634,25 @@ start(int argc, char *argv[]) errx(1, "driver alloc failed"); } - if (OK != g_dev->init()) { - delete g_dev; - g_dev = nullptr; - errx(1, "driver init failed"); - } + bool rc_handling_disabled = false; /* disable RC handling on request */ if (argc > 1) { if (!strcmp(argv[1], "norc")) { - if (g_dev->disable_rc_handling()) - warnx("Failed disabling RC handling"); + rc_handling_disabled = true; } else { warnx("unknown argument: %s", argv[1]); } } + if (OK != g_dev->init(rc_handling_disabled)) { + delete g_dev; + g_dev = nullptr; + errx(1, "driver init failed"); + } + #ifdef CONFIG_ARCH_BOARD_PX4FMU_V1 int dsm_vcc_ctl; |