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

Method processBin32Byte

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

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

Source from the content-addressed store, hash-verified

280 * @brief Processes one byte of an incoming binary-32 header (ZDLE-decoded).
281 */
282void IO::Protocols::ZMODEM::processBin32Byte(quint8 ch)
283{
284 static constexpr int kMaxBinHeaderBytes = 128;
285
286 if (m_headerBuf.size() >= kMaxBinHeaderBytes) [[unlikely]] {
287 m_parseState = ParseState::Idle;
288 m_headerBuf.clear();
289 m_zdleEscape = false;
290 return;
291 }
292
293 if (m_zdleEscape) {
294 m_headerBuf.append(static_cast<char>(ch ^ 0x40));
295 m_zdleEscape = false;
296 } else if (ch == kZDLE) {
297 m_zdleEscape = true;
298 return;
299 } else {
300 m_headerBuf.append(static_cast<char>(ch));
301 }
302
303 if (m_headerBuf.size() < m_headerBytesExpected)
304 return;
305
306 quint8 type = static_cast<quint8>(m_headerBuf[0]);
307 quint32 arg = static_cast<quint32>(static_cast<quint8>(m_headerBuf[1]))
308 | (static_cast<quint32>(static_cast<quint8>(m_headerBuf[2])) << 8)
309 | (static_cast<quint32>(static_cast<quint8>(m_headerBuf[3])) << 16)
310 | (static_cast<quint32>(static_cast<quint8>(m_headerBuf[4])) << 24);
311
312 parseReceivedHeader(type, arg);
313 m_parseState = ParseState::Idle;
314}
315
316/**
317 * @brief Processes one byte of an incoming binary header (ZDLE-decoded).

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.45
clearMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected