Commit 8e97b8f5 authored by Nate Weibley's avatar Nate Weibley

Improve final conditions and speed up fragment acquisition

parent 68b77d7f
...@@ -275,8 +275,9 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui ...@@ -275,8 +275,9 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
qWarning() << "Received log data for wrong log"; qWarning() << "Received log data for wrong log";
return; return;
} }
bool result = false;
bool result = false;
uint32_t timeout_time = kTimeOutMilliseconds;
if(ofs <= _downloadData->entry->size()) { if(ofs <= _downloadData->entry->size()) {
// Check for a gap // Check for a gap
qint64 pos = _downloadData->file.pos(); qint64 pos = _downloadData->file.pos();
...@@ -287,6 +288,8 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui ...@@ -287,6 +288,8 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
const int32_t gap = _downloadData->gaps.take(ofs) - count; const int32_t gap = _downloadData->gaps.take(ofs) - count;
if (gap > 0) { if (gap > 0) {
_downloadData->gaps[ofs+count] = qMax(static_cast<uint32_t>(gap), _downloadData->gaps.value(ofs+count, 0)); _downloadData->gaps[ofs+count] = qMax(static_cast<uint32_t>(gap), _downloadData->gaps.value(ofs+count, 0));
} else {
timeout_time = 20;
} }
} else if (pos < ofs) { } else if (pos < ofs) {
// Mind the gap // Mind the gap
...@@ -314,7 +317,7 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui ...@@ -314,7 +317,7 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
//-- reset retries //-- reset retries
_retries = 0; _retries = 0;
//-- Reset timer //-- Reset timer
_timer.start(kTimeOutMilliseconds); _timer.start(timeout_time);
//-- Do we have it all? //-- Do we have it all?
if(_logComplete()) { if(_logComplete()) {
_downloadData->entry->setStatus(QString("Downloaded")); _downloadData->entry->setStatus(QString("Downloaded"));
...@@ -539,6 +542,8 @@ LogDownloadController::_prepareLogDownload() ...@@ -539,6 +542,8 @@ LogDownloadController::_prepareLogDownload()
if(!_downloadData->file.resize(entry->size())) { if(!_downloadData->file.resize(entry->size())) {
qWarning() << "Failed to allocate space for log file:" << _downloadData->filename; qWarning() << "Failed to allocate space for log file:" << _downloadData->filename;
} else { } 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(); _downloadData->elapsed.start();
result = true; result = true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment