From f2e7df4cb8330ef0ee2c92f396a17e0e9beb26ea Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 5 Mar 2016 17:08:16 -0800 Subject: [PATCH] Better error messing on boot loader port open fail --- src/VehicleSetup/PX4FirmwareUpgradeThread.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/VehicleSetup/PX4FirmwareUpgradeThread.cc b/src/VehicleSetup/PX4FirmwareUpgradeThread.cc index a06185951..ebb0105ae 100644 --- a/src/VehicleSetup/PX4FirmwareUpgradeThread.cc +++ b/src/VehicleSetup/PX4FirmwareUpgradeThread.cc @@ -218,14 +218,15 @@ bool PX4FirmwareUpgradeThreadWorker::_findBootloader(const QGCSerialPortInfo& po _bootloaderPort = new QextSerialPort(QextSerialPort::Polling); - Q_CHECK_PTR(_bootloaderPort); if (radioMode) { _bootloaderPort->setBaudRate(BAUD115200); } // Wait a little while for the USB port to initialize. + bool openFailed = true; for (int i=0; i<10; i++) { if (_bootloader->open(_bootloaderPort, portInfo.systemLocation())) { + openFailed = false; break; } else { QGC::SLEEP::msleep(100); @@ -236,6 +237,16 @@ bool PX4FirmwareUpgradeThreadWorker::_findBootloader(const QGCSerialPortInfo& po QGC::SLEEP::msleep(2000); } + if (openFailed) { + qCDebug(FirmwareUpgradeLog) << "Bootloader open port failed:" << _bootloader->errorString(); + if (errorOnNotFound) { + emit error(_bootloader->errorString()); + } + _bootloaderPort->deleteLater(); + _bootloaderPort = NULL; + return false; + } + if (_bootloader->sync(_bootloaderPort)) { bool success; -- 2.22.0