Browse Source

FTPManager bugfix: Continue when EOF Nak is out of sequence (#10418)

Without the patch the FTPManager is stuck when an EOF NAK is
received out of sequence in a burst transmission, e.g.
when the previous data packet is lost. With the EOF the
server will stop further transmissions but the client is
not waiting on anything.

Now the burst is restarted at the last received offset.

Closes: #10418
QGC4.4
Friedrich Beckmann 2 years ago committed by Beat Küng
parent
commit
aa666d468f
  1. 20
      src/Vehicle/FTPManager.cc

20
src/Vehicle/FTPManager.cc

@ -391,18 +391,22 @@ void FTPManager::_burstReadFileAckOrNak(const MavlinkFTP::Request* ackOrNak) @@ -391,18 +391,22 @@ void FTPManager::_burstReadFileAckOrNak(const MavlinkFTP::Request* ackOrNak)
emit commandProgress((float)(_downloadState.bytesWritten) / (float)_downloadState.fileSize);
}
} else if (ackOrNak->hdr.opcode == MavlinkFTP::kRspNak) {
if (ackOrNak->hdr.seqNumber != _expectedIncomingSeqNumber) {
qCDebug(FTPManagerLog) << "_burstReadFileAckOrNak: Disregarding Nak due to incorrect sequence actual:expected" << ackOrNak->hdr.seqNumber << _expectedIncomingSeqNumber;
return;
}
MavlinkFTP::ErrorCode_t errorCode = static_cast<MavlinkFTP::ErrorCode_t>(ackOrNak->data[0]);
if (errorCode == MavlinkFTP::kErrEOF) {
// Burst sequence has gone through the whole file
qCDebug(FTPManagerLog) << "_burstReadFileAckOrNak EOF";
_advanceStateMachine();
} else {
if (ackOrNak->hdr.seqNumber != _expectedIncomingSeqNumber) {
qCDebug(FTPManagerLog) << "_burstReadFileAckOrNak: EOF Nak"
"with incorrect sequence nr actual:expected"
<< ackOrNak->hdr.seqNumber << _expectedIncomingSeqNumber;
/* We have received the EOF Nak but out of sequence, i.e. data is missing */
_expectedIncomingSeqNumber = ackOrNak->hdr.seqNumber;
_burstReadFileWorker(true); /* Retry from last expected offset */
} else {
qCDebug(FTPManagerLog) << "_burstReadFileAckOrNak EOF";
_advanceStateMachine();
}
} else { /* Don't care is this is out of sequence */
qCDebug(FTPManagerLog) << "_burstReadFileAckOrNak: Nak -" << _errorMsgFromNak(ackOrNak);
_downloadComplete(tr("Download failed"));
}

Loading…
Cancel
Save