From 8e97b8f5fb23496da17d56b2773c8e5642f763f8 Mon Sep 17 00:00:00 2001 From: Nate Weibley Date: Fri, 5 Feb 2016 19:29:01 -0500 Subject: [PATCH] Improve final conditions and speed up fragment acquisition --- src/ViewWidgets/LogDownloadController.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ViewWidgets/LogDownloadController.cc b/src/ViewWidgets/LogDownloadController.cc index c008070d0..a4399e4f8 100644 --- a/src/ViewWidgets/LogDownloadController.cc +++ b/src/ViewWidgets/LogDownloadController.cc @@ -275,8 +275,9 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui qWarning() << "Received log data for wrong log"; return; } - bool result = false; + bool result = false; + uint32_t timeout_time = kTimeOutMilliseconds; if(ofs <= _downloadData->entry->size()) { // Check for a gap qint64 pos = _downloadData->file.pos(); @@ -287,6 +288,8 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui const int32_t gap = _downloadData->gaps.take(ofs) - count; if (gap > 0) { _downloadData->gaps[ofs+count] = qMax(static_cast(gap), _downloadData->gaps.value(ofs+count, 0)); + } else { + timeout_time = 20; } } else if (pos < ofs) { // Mind the gap @@ -314,7 +317,7 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui //-- reset retries _retries = 0; //-- Reset timer - _timer.start(kTimeOutMilliseconds); + _timer.start(timeout_time); //-- Do we have it all? if(_logComplete()) { _downloadData->entry->setStatus(QString("Downloaded")); @@ -539,6 +542,8 @@ LogDownloadController::_prepareLogDownload() if(!_downloadData->file.resize(entry->size())) { qWarning() << "Failed to allocate space for log file:" << _downloadData->filename; } else { + // Force ourselves to request the last few bytes if we have any gaps so we end cleanly + _downloadData->gaps.insert(entry->size()-MAVLINK_MSG_LOG_DATA_FIELD_DATA_LEN, MAVLINK_MSG_LOG_DATA_FIELD_DATA_LEN); _downloadData->elapsed.start(); result = true; } -- 2.22.0