diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-01-23 08:45:29 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-01-23 08:45:29 +0100 |
commit | 8833f81b48aa738125b42a08aca05e3131cb8f8f (patch) | |
tree | b9bbba87d0f21137174f7754294cae0dc86f8ff9 | |
parent | a0db455334c0928b953ab088e868e72fa3fc08f7 (diff) | |
download | px4-firmware-8833f81b48aa738125b42a08aca05e3131cb8f8f.tar.gz px4-firmware-8833f81b48aa738125b42a08aca05e3131cb8f8f.tar.bz2 px4-firmware-8833f81b48aa738125b42a08aca05e3131cb8f8f.zip |
Do not make PX4IO start mandatory for forceupdate
-rw-r--r-- | src/drivers/px4io/px4io.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index 27ee1fb42..4844372b8 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -2367,8 +2367,10 @@ start(int argc, char *argv[]) /* create the driver - it will set g_dev */ (void)new PX4IO(interface); - if (g_dev == nullptr) + if (g_dev == nullptr) { + delete interface; errx(1, "driver alloc failed"); + } if (OK != g_dev->init()) { delete g_dev; @@ -2769,18 +2771,35 @@ px4io_main(int argc, char *argv[]) } if (g_dev == nullptr) { warnx("px4io is not started, still attempting upgrade"); - } else { - uint16_t arg = atol(argv[2]); - int ret = g_dev->ioctl(nullptr, PX4IO_REBOOT_BOOTLOADER, arg); - if (ret != OK) { - printf("reboot failed - %d\n", ret); - exit(1); + + /* allocate the interface */ + device::Device *interface = get_interface(); + + /* create the driver - it will set g_dev */ + (void)new PX4IO(interface); + + if (g_dev == nullptr) { + delete interface; + errx(1, "driver alloc failed"); } - // tear down the px4io instance - delete g_dev; + if (OK != g_dev->init()) { + delete g_dev; + g_dev = nullptr; + errx(1, "driver init failed"); + } + } + + uint16_t arg = atol(argv[2]); + int ret = g_dev->ioctl(nullptr, PX4IO_REBOOT_BOOTLOADER, arg); + if (ret != OK) { + printf("reboot failed - %d\n", ret); + exit(1); } + // tear down the px4io instance + delete g_dev; + // upload the specified firmware const char *fn[2]; fn[0] = argv[3]; |