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

Method processBinByte

app/src/IO/FileTransmission/ZMODEM.cpp:319–351  ·  view source on GitHub ↗

* @brief Processes one byte of an incoming binary header (ZDLE-decoded). */

Source from the content-addressed store, hash-verified

317 * @brief Processes one byte of an incoming binary header (ZDLE-decoded).
318 */
319void IO::Protocols::ZMODEM::processBinByte(quint8 ch)
320{
321 static constexpr int kMaxBinHeaderBytes = 128;
322
323 if (m_headerBuf.size() >= kMaxBinHeaderBytes) [[unlikely]] {
324 m_parseState = ParseState::Idle;
325 m_headerBuf.clear();
326 m_zdleEscape = false;
327 return;
328 }
329
330 if (m_zdleEscape) {
331 m_headerBuf.append(static_cast<char>(ch ^ 0x40));
332 m_zdleEscape = false;
333 } else if (ch == kZDLE) {
334 m_zdleEscape = true;
335 return;
336 } else {
337 m_headerBuf.append(static_cast<char>(ch));
338 }
339
340 if (m_headerBuf.size() < m_headerBytesExpected)
341 return;
342
343 quint8 type = static_cast<quint8>(m_headerBuf[0]);
344 quint32 arg = static_cast<quint32>(static_cast<quint8>(m_headerBuf[1]))
345 | (static_cast<quint32>(static_cast<quint8>(m_headerBuf[2])) << 8)
346 | (static_cast<quint32>(static_cast<quint8>(m_headerBuf[3])) << 16)
347 | (static_cast<quint32>(static_cast<quint8>(m_headerBuf[4])) << 24);
348
349 parseReceivedHeader(type, arg);
350 m_parseState = ParseState::Idle;
351}
352
353//--------------------------------------------------------------------------------------------------
354// Configuration

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.45
clearMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected