From 3c85caa482ab648f4056e171cb4d557907e2f754 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Fri, 19 Jun 2026 12:38:15 -0400 Subject: [PATCH] surprising news to me the V.24 modem FW does not actually set byte 5 of the GET_STATUS opcode, so will never properly flag transmit status, as such I have implemented some faux handling in the host itself to emulate the behavior, this is done by flagging Tx once we start successfully writing data over V.24 (this can be misleading if the data is sent to our V.24 modem but the V.24 modem never sends it to a Quantar); --- src/host/modem/ModemV24.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/host/modem/ModemV24.cpp b/src/host/modem/ModemV24.cpp index b9f39f06..0fc57a7e 100644 --- a/src/host/modem/ModemV24.cpp +++ b/src/host/modem/ModemV24.cpp @@ -413,6 +413,11 @@ void ModemV24::clock(uint32_t ms) LogError(LOG_MODEM, "Failed to write to serial port!"); } + // if both queues are empty -- unset the Tx flag since the modem won't be transmitting anything + if (m_txImmP25Queue.isEmpty() && m_txP25Queue.isEmpty()) { + m_tx = false; + } + // clear an RX call in progress flag if we're longer than our timeout value now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); if (m_rxCallInProgress && (now - m_rxLastFrameTime > m_callTimeout)) { @@ -489,8 +494,10 @@ int ModemV24::writeSerial(RingBuffer* queue) std::lock_guard lock(m_txP25QueueLock); // check empty - if (queue->isEmpty()) + if (queue->isEmpty()) { + m_tx = false; return 0U; + } // get length uint8_t length[2U]; @@ -504,6 +511,7 @@ int ModemV24::writeSerial(RingBuffer* queue) // this ensures we never get in a situation where we have length bytes stuck in the queue by themselves if (queue->dataSize() == 2U && len > queue->dataSize()) { queue->get(length, 2U); // ensure we pop bytes off + m_tx = false; return 0U; } @@ -554,6 +562,10 @@ int ModemV24::writeSerial(RingBuffer* queue) // only remove an entry once it was written successfully DECLARE_UINT8_ARRAY(discard, len + 11U); queue->get(discard, len + 11U); + + // bryanb: because m_tx may not be set by the V.24 modem -- we will indicate "Tx" state here based on + // whether we're actually writing data to the modem or not + m_tx = true; } return ret;