* @brief Starts an XMODEM file transfer. */
| 71 | * @brief Starts an XMODEM file transfer. |
| 72 | */ |
| 73 | void 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. |
nothing calls this directly
no test coverage detected