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

Method startTransfer

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

* @brief Starts an XMODEM file transfer. */

Source from the content-addressed store, hash-verified

71 * @brief Starts an XMODEM file transfer.
72 */
73void IO::Protocols::XMODEM::startTransfer(const QString& filePath)
74{
75 Q_ASSERT(!filePath.isEmpty());
76 Q_ASSERT(m_maxRetries > 0);
77
78 if (isActive())
79 cancelTransfer();
80
81 m_file.setFileName(filePath);
82 if (!m_file.open(QIODevice::ReadOnly)) {
83 Q_EMIT finished(false, tr("Cannot open file: %1").arg(m_file.errorString()));
84 return;
85 }
86
87 m_fileSize = m_file.size();
88 m_bytesSent = 0;
89 m_blockNumber = 1;
90 m_retryCount = 0;
91 m_state = State::WaitingForStart;
92
93 Q_EMIT statusMessage(tr("Waiting for receiver…"));
94 Q_EMIT progressChanged(0, m_fileSize);
95
96 m_timeoutTimer.start(m_timeoutMs);
97}
98
99/**
100 * @brief Cancels the current transfer by sending CAN bytes.

Callers

nothing calls this directly

Calls 6

isEmptyMethod · 0.80
errorStringMethod · 0.80
setFileNameMethod · 0.45
openMethod · 0.45
sizeMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected