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

Method sendDataBlock

app/src/IO/FileTransmission/YMODEM.cpp:308–337  ·  view source on GitHub ↗

* @brief Reads and sends the next 1K data block. */

Source from the content-addressed store, hash-verified

306 * @brief Reads and sends the next 1K data block.
307 */
308void IO::Protocols::YMODEM::sendDataBlock()
309{
310 m_lastBlockStart = m_file.pos();
311
312 QByteArray data = m_file.read(1024);
313 if (data.isEmpty()) {
314 m_yState = YState::WaitingForFirstEOTResponse;
315 Q_EMIT writeRequested(QByteArray(1, static_cast<char>(kEOT)));
316 Q_EMIT statusMessage(tr("Sending first EOT…"));
317 m_timeoutTimer.start(m_timeoutMs);
318 return;
319 }
320
321 m_lastBlockBytes = data.size();
322
323 while (data.size() < 1024)
324 data.append(static_cast<char>(0x1A));
325
326 QByteArray packet = buildBlock(data, m_blockNumber);
327 Q_EMIT writeRequested(packet);
328 m_bytesSent = qMin(m_bytesSent + m_lastBlockBytes, m_fileSize);
329 Q_EMIT progressChanged(m_bytesSent, m_fileSize);
330 Q_EMIT statusMessage(tr("Sending block %1 (%2/%3 bytes)")
331 .arg(QString::number(m_blockNumber),
332 QString::number(m_bytesSent),
333 QString::number(m_fileSize)));
334
335 m_yState = YState::WaitingForDataAck;
336 m_timeoutTimer.start(m_timeoutMs);
337}

Callers

nothing calls this directly

Calls 6

posMethod · 0.80
isEmptyMethod · 0.80
readMethod · 0.45
startMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected