From 1ca503d9fbf32e20065c62c5d191c8aaa7663ca3 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Thu, 20 Aug 2020 15:40:27 -0400 Subject: [PATCH] bootloader avoid syncing multiple times if first succeeded --- src/VehicleSetup/Bootloader.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/VehicleSetup/Bootloader.cc b/src/VehicleSetup/Bootloader.cc index 35cb960fb..72d937ef6 100644 --- a/src/VehicleSetup/Bootloader.cc +++ b/src/VehicleSetup/Bootloader.cc @@ -167,9 +167,10 @@ bool Bootloader::initFlashSequence(void) return false; } _port.setBaudRate(QSerialPort::Baud115200); - } - if (!_sync()) { - return false; + + if (!_sync()) { + return false; + } } return true; } @@ -330,6 +331,8 @@ bool Bootloader::_sendCommand(const uint8_t cmd, int responseTimeout) if (!_write(buf, 2)) { goto Error; } + _port.flush(); + if (!_getCommandResponse(responseTimeout)) { goto Error; } @@ -710,6 +713,10 @@ bool Bootloader::_sync(void) bool success = false; for (int i=0; i<3; i++) { success = _syncWorker(); + + if (success) { + return true; + } } return success; } -- 2.22.0