MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / handleTimeout

Method handleTimeout

app/src/IO/FileTransmission/XMODEM.cpp:358–391  ·  view source on GitHub ↗

* @brief Handles a timeout while waiting for a receiver response. */

Source from the content-addressed store, hash-verified

356 * @brief Handles a timeout while waiting for a receiver response.
357 */
358void IO::Protocols::XMODEM::handleTimeout()
359{
360 Q_ASSERT(m_maxRetries > 0);
361 Q_ASSERT(m_timeoutMs >= 1000);
362
363 if (!isActive())
364 return;
365
366 ++m_retryCount;
367 if (m_retryCount >= m_maxRetries) {
368 sendCancel();
369 resetState();
370 Q_EMIT statusMessage(tr("Transfer timed out"));
371 Q_EMIT finished(false, tr("Timeout: no response from receiver"));
372 return;
373 }
374
375 Q_EMIT statusMessage(tr("Timeout, retrying (%1/%2)…")
376 .arg(QString::number(m_retryCount), QString::number(m_maxRetries)));
377
378 if (m_state == State::WaitingForEOTAck) {
379 sendEOT();
380 } else if (m_state == State::WaitingForAck) {
381 m_bytesSent = qMax<qint64>(0, m_bytesSent - m_lastBlockBytes);
382 if (!m_file.seek(m_lastBlockStart)) [[unlikely]] {
383 m_file.close();
384 Q_EMIT finished(false, tr("Failed to seek in file"));
385 return;
386 }
387 sendBlock();
388 } else if (m_state == State::WaitingForStart) {
389 m_timeoutTimer.start(m_timeoutMs);
390 }
391}
392
393/**
394 * @brief Builds a complete XMODEM block with header, data, and CRC.

Callers

nothing calls this directly

Calls 3

resetStateFunction · 0.85
closeMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected