From 7b4101b9755081d574158434c79471a59b4b27a0 Mon Sep 17 00:00:00 2001 From: Tim Sawyer Date: Tue, 3 Mar 2026 17:08:40 -0800 Subject: [PATCH] Port V24 pre-#7 startup baseline onto master --- .gitignore | 3 +++ src/host/Host.P25.cpp | 7 ++++++- src/host/modem/Modem.cpp | 9 +++++++-- src/host/modem/ModemV24.cpp | 11 ++++------- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 247a1564..531f09d4 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ _deps # Ignore thumbnails created by windows Thumbs.db +# Ignore macOS Finder metadata files +.DS_Store + # Ignore files created by clang-check *.plist diff --git a/src/host/Host.P25.cpp b/src/host/Host.P25.cpp index 1db6a6ba..9c5f3e71 100644 --- a/src/host/Host.P25.cpp +++ b/src/host/Host.P25.cpp @@ -255,6 +255,11 @@ void* Host::threadP25Writer(void* arg) if (nextLen > 0U) { bool ret = host->m_modem->hasP25Space(nextLen); + // V.24 modem status space can lag at call start; do not block + // initial Net->RF voice frames on stale p25Space accounting. + if (!ret && host->m_modem->isV24Connected()) { + ret = true; + } if (ret) { bool imm = false; uint32_t len = host->m_p25->getFrame(data, &imm); @@ -267,7 +272,7 @@ void* Host::threadP25Writer(void* arg) // if the state is P25; write P25 frame data if (host->m_state == STATE_P25) { - host->m_modem->writeP25Frame(data, len); + host->m_modem->writeP25Frame(data, len, imm); afterWriteCallback(); diff --git a/src/host/modem/Modem.cpp b/src/host/modem/Modem.cpp index 18a95e3f..3ff080d4 100644 --- a/src/host/modem/Modem.cpp +++ b/src/host/modem/Modem.cpp @@ -1517,7 +1517,10 @@ bool Modem::writeP25Frame(const uint8_t* data, uint32_t length, bool imm) uint32_t len = length + 2U; // write or buffer P25 data to air interface - if (m_p25Space >= length) { + // + // For V.24/DFSI, the modem status space value may lag call startup; do + // not block initial Net->RF frames solely on stale p25Space. + if (m_p25Space >= length || isV24Connected()) { if (m_debug) LogDebugEx(LOG_MODEM, "Modem::writeP25Frame()", "immediate write (len %u)", length); if (m_trace) @@ -1529,7 +1532,9 @@ bool Modem::writeP25Frame(const uint8_t* data, uint32_t length, bool imm) return false; } - m_p25Space -= length; + if (m_p25Space >= length) { + m_p25Space -= length; + } } else { return false; diff --git a/src/host/modem/ModemV24.cpp b/src/host/modem/ModemV24.cpp index eb2b9e2a..695464ef 100644 --- a/src/host/modem/ModemV24.cpp +++ b/src/host/modem/ModemV24.cpp @@ -394,10 +394,11 @@ void ModemV24::clock(uint32_t ms) int len = 0; // write anything waiting to the serial port - if (!m_txImmP25Queue.isEmpty()) + // + // Keep normal queue first for startup consistency with older behavior. + len = writeSerial(&m_txP25Queue); + if (len == 0 && !m_txImmP25Queue.isEmpty()) len = writeSerial(&m_txImmP25Queue); - else - len = writeSerial(&m_txP25Queue); if (m_debug && len > 0) { LogDebug(LOG_MODEM, "Wrote %u-byte message to the serial V24 device", len); } else if (len < 0) { @@ -496,10 +497,6 @@ int ModemV24::writeSerial(RingBuffer* queue) return 0U; } - // check available modem space - if (m_p25Space < len) - return 0U; - std::lock_guard lock(m_txP25QueueLock); // get current timestamp