From ccd5a5a9d8c27f6bfca90f33ddbc18f66d163d3a Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Sat, 17 Aug 2024 15:24:07 -0400 Subject: [PATCH] be extremely aggressive about clearing buffers in PANIC overflow of modem and internal; --- src/host/Host.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/src/host/Host.cpp b/src/host/Host.cpp index 3d1fda30..fa2de070 100644 --- a/src/host/Host.cpp +++ b/src/host/Host.cpp @@ -1718,8 +1718,18 @@ void* Host::threadWatchdog(void* arg) if (host->m_modem->gotModemStatus() && !host->m_modem->hasDMRSpace1() && host->m_dmr->isQueueFull(1U) && !host->m_dmrBeaconDurationTimer.isRunning()) { - LogError(LOG_HOST, "PANIC; DMR, has no DMR slot 1 FIFO space, and DMR slot 1 queue is full!"); + std::lock_guard lock(m_clockingMutex); + + LogError(LOG_HOST, "PANIC; DMR, has no DMR slot 1 FIFO space, and DMR slot 1 queue is full! Resetting states."); + + host->setState(STATE_IDLE); + host->m_modem->writeDMRStart(false); host->m_modem->clearDMRFrame1(); + + // respect the fixed mode state + if (host->m_fixedMode) { + host->setState(STATE_DMR); + } } if (host->m_dmrTx2WatchdogTimer.isRunning()) @@ -1731,8 +1741,18 @@ void* Host::threadWatchdog(void* arg) if (host->m_modem->gotModemStatus() && !host->m_modem->hasDMRSpace2() && host->m_dmr->isQueueFull(2U) && !host->m_dmrBeaconDurationTimer.isRunning()) { - LogError(LOG_HOST, "PANIC; DMR, has no DMR slot 2 FIFO space, and DMR slot 2 queue is full!"); + std::lock_guard lock(m_clockingMutex); + + LogError(LOG_HOST, "PANIC; DMR, has no DMR slot 2 FIFO space, and DMR slot 2 queue is full! Resetting states."); + + host->setState(STATE_IDLE); + host->m_modem->writeDMRStart(false); host->m_modem->clearDMRFrame2(); + + // respect the fixed mode state + if (host->m_fixedMode) { + host->setState(STATE_DMR); + } } } @@ -1747,8 +1767,18 @@ void* Host::threadWatchdog(void* arg) if (host->m_modem->gotModemStatus() && !host->m_modem->hasP25Space(P25DEF::P25_LDU_FRAME_LENGTH_BYTES) && host->m_p25->isQueueFull() && !host->m_p25CtrlChannel && !host->m_p25BcastDurationTimer.isRunning()) { - LogError(LOG_HOST, "PANIC; P25, modem has no P25 FIFO space, and internal P25 queue is full!"); + std::lock_guard lock(m_clockingMutex); + + LogError(LOG_HOST, "PANIC; P25, modem has no P25 FIFO space, and internal P25 queue is full! Resetting states."); + + host->setState(STATE_IDLE); host->m_modem->clearP25Frame(); + host->m_p25->reset(); + + // respect the fixed mode state + if (host->m_fixedMode) { + host->setState(STATE_P25); + } } } @@ -1763,8 +1793,18 @@ void* Host::threadWatchdog(void* arg) if (host->m_modem->gotModemStatus() && !host->m_modem->hasNXDNSpace() && host->m_nxdn->isQueueFull() && !host->m_nxdnCtrlChannel && !host->m_nxdnBcastDurationTimer.isRunning()) { - LogError(LOG_HOST, "PANIC; NXDN, modem has no NXDN FIFO space, and NXDN queue is full!"); + std::lock_guard lock(m_clockingMutex); + + LogError(LOG_HOST, "PANIC; NXDN, modem has no NXDN FIFO space, and NXDN queue is full! Resetting states."); + + host->setState(STATE_IDLE); host->m_modem->clearNXDNFrame(); + host->m_nxdn->reset(); + + // respect the fixed mode state + if (host->m_fixedMode) { + host->setState(STATE_NXDN); + } } } }