MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / pollInputPins

Method pollInputPins

src/core/SerialPortController.cpp:463–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461
462#ifdef HAVE_SERIALPORT
463void SerialPortController::pollInputPins()
464{
465 if (!m_port.isOpen()) return;
466
467 auto pinState = m_port.pinoutSignals();
468
469 if (m_port.error() != QSerialPort::NoError) {
470 qCWarning(lcDevices) << "SerialPortController: pinoutSignals() error:"
471 << m_port.errorString();
472 return;
473 }
474
475 bool cts = pinState.testFlag(QSerialPort::ClearToSendSignal);
476 bool dsr = pinState.testFlag(QSerialPort::DataSetReadySignal);
477 bool dcd = pinState.testFlag(QSerialPort::DataCarrierDetectSignal);
478
479 bool ctsActive = m_ctsActiveHigh ? cts : !cts;
480 bool dsrActive = m_dsrActiveHigh ? dsr : !dsr;
481 bool dcdActive = m_dcdActiveHigh ? dcd : !dcd;
482
483 bool debounceOk = m_debounceTimer.elapsed() >= DEBOUNCE_MS;
484
485 bool hasPttInput = (m_ctsFn == InputFunction::PttInput
486 || m_dsrFn == InputFunction::PttInput
487 || m_dcdFn == InputFunction::PttInput);
488 if (hasPttInput) {
489 if (pinState != m_lastRawPins || debounceOk != m_lastDebounceLogged || !m_pollLogged) {
490 m_lastRawPins = pinState;
491 m_lastDebounceLogged = debounceOk;
492 qCDebug(lcDevices)
493 << "SerialPortController poll:"
494 << "raw=" << Qt::hex << static_cast<int>(pinState)
495 << "CTS=" << cts << "DSR=" << dsr << "DCD=" << dcd
496 << "ctsActive=" << ctsActive << "dsrActive=" << dsrActive << "dcdActive=" << dcdActive
497 << "lastCts=" << m_lastCtsActive << "lastDsr=" << m_lastDsrActive << "lastDcd=" << m_lastDcdActive
498 << "debounceOk=" << debounceOk
499 << "debounceElapsed=" << m_debounceTimer.elapsed() << "ms"
500 << "ctsFn=" << static_cast<int>(m_ctsFn)
501 << "dsrFn=" << static_cast<int>(m_dsrFn)
502 << "dcdFn=" << static_cast<int>(m_dcdFn)
503 << "ctsPolActiveHigh=" << m_ctsActiveHigh
504 << "dsrPolActiveHigh=" << m_dsrActiveHigh
505 << "dcdPolActiveHigh=" << m_dcdActiveHigh;
506 }
507 }
508
509 if (!m_pollLogged) {
510 m_pollLogged = true;
511 qCDebug(lcDevices) << "SerialPortController: first poll — raw pinoutSignals ="
512 << Qt::hex << static_cast<int>(pinState)
513 << "DSR=" << dsr << "CTS=" << cts << "DCD=" << dcd;
514 }
515
516 // ── PTT input ────────────────────────────────────────────────────────
517 if (m_ctsFn == InputFunction::PttInput && ctsActive != m_lastCtsActive && debounceOk) {
518 qCDebug(lcDevices) << "SerialPortController: CTS PTT edge →" << ctsActive;
519 m_lastCtsActive = ctsActive;
520 m_debounceTimer.restart();

Callers

nothing calls this directly

Calls 2

isOpenMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected