From 6e9c8837fb8f2c855a06400686239ec1878de0e3 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Fri, 16 Aug 2024 09:04:09 -0400 Subject: [PATCH] add more verbose logging if the modem reports it does not have space for frames and if the local controller queue is full; --- src/host/Host.DMR.cpp | 10 +++++++++- src/host/Host.NXDN.cpp | 4 ++++ src/host/Host.P25.cpp | 4 ++++ src/host/dmr/Control.cpp | 15 +++++++++++++++ src/host/dmr/Control.h | 6 ++++++ src/host/dmr/Slot.cpp | 16 ++++++++++++++++ src/host/dmr/Slot.h | 5 +++++ src/host/nxdn/Control.cpp | 16 ++++++++++++++++ src/host/nxdn/Control.h | 5 +++++ src/host/p25/Control.cpp | 16 ++++++++++++++++ src/host/p25/Control.h | 5 +++++ 11 files changed, 101 insertions(+), 1 deletion(-) diff --git a/src/host/Host.DMR.cpp b/src/host/Host.DMR.cpp index 795a4342..460041ea 100644 --- a/src/host/Host.DMR.cpp +++ b/src/host/Host.DMR.cpp @@ -276,6 +276,10 @@ void* Host::threadDMRWriter1(void* arg) host->m_lastDstId = host->m_dmr->getLastDstId(1U); host->m_lastSrcId = host->m_dmr->getLastSrcId(1U); } + } else { + if (host->m_dmr->isQueueFull(1U)) { + LogError(LOG_HOST, "PANIC; modem->hasDMRSpace1() = %u, and DMR slot 1 queue is full!", ret); + } } } } @@ -497,7 +501,7 @@ void* Host::threadDMRWriter2(void* arg) // to the modem bool ret = host->m_modem->hasDMRSpace2(); if (ret) { - uint32_t nextLen = host->m_dmr->peekFrameLength(1U); + uint32_t nextLen = host->m_dmr->peekFrameLength(2U); if (host->m_dmrCtrlChannel) { if (host->m_dmrDedicatedTxTestTimer.hasExpired() && !host->m_dmrDedicatedTxTestTimer.isPaused()) { host->m_dmrDedicatedTxTestTimer.pause(); @@ -536,6 +540,10 @@ void* Host::threadDMRWriter2(void* arg) host->m_lastDstId = host->m_dmr->getLastDstId(2U); host->m_lastSrcId = host->m_dmr->getLastSrcId(2U); } + } else { + if (host->m_dmr->isQueueFull(2U)) { + LogError(LOG_HOST, "PANIC; modem->hasDMRSpace2() = %u, and DMR slot 2 queue is full!", ret); + } } } } diff --git a/src/host/Host.NXDN.cpp b/src/host/Host.NXDN.cpp index 35d4bcec..12fa8a8e 100644 --- a/src/host/Host.NXDN.cpp +++ b/src/host/Host.NXDN.cpp @@ -213,6 +213,10 @@ void* Host::threadNXDNWriter(void* arg) host->m_lastDstId = host->m_nxdn->getLastDstId(); host->m_lastSrcId = host->m_nxdn->getLastSrcId(); } + } else { + if (host->m_nxdn->isQueueFull()) { + LogError(LOG_HOST, "PANIC; modem->hasNXDNSpace() = %u, and NXDN queue is full!", ret); + } } } } diff --git a/src/host/Host.P25.cpp b/src/host/Host.P25.cpp index 5af51fb7..0aa1b90c 100644 --- a/src/host/Host.P25.cpp +++ b/src/host/Host.P25.cpp @@ -259,6 +259,10 @@ void* Host::threadP25Writer(void* arg) else { nextLen = 0U; } + } else { + if (host->m_p25->isQueueFull()) { + LogError(LOG_HOST, "PANIC; modem->hasP25Space() = %u, and P25 queue is full!", ret); + } } } diff --git a/src/host/dmr/Control.cpp b/src/host/dmr/Control.cpp index c1533f70..8e1f77d5 100644 --- a/src/host/dmr/Control.cpp +++ b/src/host/dmr/Control.cpp @@ -303,6 +303,21 @@ uint32_t Control::peekFrameLength(uint32_t slotNo) } } +/* Helper to determine whether or not the internal frame queue is full. */ + +bool Control::isQueueFull(uint32_t slotNo) +{ + switch (slotNo) { + case 1U: + return m_slot1->isQueueFull(); + case 2U: + return m_slot2->isQueueFull(); + default: + LogError(LOG_DMR, "DMR, invalid slot, slotNo = %u", slotNo); + return true; + } +} + /* Get a data frame for slot, from data ring buffer. */ uint32_t Control::getFrame(uint32_t slotNo, uint8_t* data) diff --git a/src/host/dmr/Control.h b/src/host/dmr/Control.h index cfdc551d..3d1e56d1 100644 --- a/src/host/dmr/Control.h +++ b/src/host/dmr/Control.h @@ -147,6 +147,12 @@ namespace dmr * @returns uint32_t Length of frame data retrieved. */ uint32_t peekFrameLength(uint32_t slotNo); + /** + * @brief Helper to determine whether or not the internal frame queue is full. + * @param slotNo DMR slot number. + * @returns bool True if frame queue is full, otherwise false. + */ + bool isQueueFull(uint32_t slotNo); /** * @brief Get frame data from data ring buffer. * @param slotNo DMR slot number. diff --git a/src/host/dmr/Slot.cpp b/src/host/dmr/Slot.cpp index 4ff67e50..cadcfb46 100644 --- a/src/host/dmr/Slot.cpp +++ b/src/host/dmr/Slot.cpp @@ -330,6 +330,22 @@ uint32_t Slot::peekFrameLength() return len; } +/* Helper to determine whether or not the internal frame queue is full. */ + +bool Slot::isQueueFull() +{ + if (m_txQueue.isEmpty() && m_txImmQueue.isEmpty()) + return false; + + // tx immediate queue takes priority + if (!m_txImmQueue.isEmpty()) { + return !m_txImmQueue.hasSpace(DMR_FRAME_LENGTH_BYTES); + } + else { + return !m_txQueue.hasSpace(DMR_FRAME_LENGTH_BYTES); + } +} + /* Get frame data from data ring buffer. */ uint32_t Slot::getFrame(uint8_t* data) diff --git a/src/host/dmr/Slot.h b/src/host/dmr/Slot.h index 209c522f..02d17baa 100644 --- a/src/host/dmr/Slot.h +++ b/src/host/dmr/Slot.h @@ -138,6 +138,11 @@ namespace dmr * @returns uint32_t Length of frame data retrieved. */ uint32_t peekFrameLength(); + /** + * @brief Helper to determine whether or not the internal frame queue is full. + * @returns bool True if frame queue is full, otherwise false. + */ + bool isQueueFull(); /** * @brief Get frame data from data ring buffer. * @param[out] data Buffer to store frame data. diff --git a/src/host/nxdn/Control.cpp b/src/host/nxdn/Control.cpp index 13bab34a..2944ea43 100644 --- a/src/host/nxdn/Control.cpp +++ b/src/host/nxdn/Control.cpp @@ -483,6 +483,22 @@ uint32_t Control::peekFrameLength() return len; } +/* Helper to determine whether or not the internal frame queue is full. */ + +bool Control::isQueueFull() +{ + if (m_txQueue.isEmpty() && m_txImmQueue.isEmpty()) + return false; + + // tx immediate queue takes priority + if (!m_txImmQueue.isEmpty()) { + return !m_txImmQueue.hasSpace(NXDN_FRAME_LENGTH_BYTES); + } + else { + return !m_txQueue.hasSpace(NXDN_FRAME_LENGTH_BYTES); + } +} + /* Get frame data from data ring buffer. */ uint32_t Control::getFrame(uint8_t* data) diff --git a/src/host/nxdn/Control.h b/src/host/nxdn/Control.h index 716413c6..0bae153d 100644 --- a/src/host/nxdn/Control.h +++ b/src/host/nxdn/Control.h @@ -150,6 +150,11 @@ namespace nxdn * @returns uint32_t Length of frame data retrieved. */ uint32_t peekFrameLength(); + /** + * @brief Helper to determine whether or not the internal frame queue is full. + * @returns bool True if frame queue is full, otherwise false. + */ + bool isQueueFull(); /** * @brief Get frame data from data ring buffer. * @param[out] data Buffer to store frame data. diff --git a/src/host/p25/Control.cpp b/src/host/p25/Control.cpp index e3449796..7906ca88 100644 --- a/src/host/p25/Control.cpp +++ b/src/host/p25/Control.cpp @@ -697,6 +697,22 @@ uint32_t Control::peekFrameLength() return len; } +/* Helper to determine whether or not the internal frame queue is full. */ + +bool Control::isQueueFull() +{ + if (m_txQueue.isEmpty() && m_txImmQueue.isEmpty()) + return false; + + // tx immediate queue takes priority + if (!m_txImmQueue.isEmpty()) { + return !m_txImmQueue.hasSpace(P25_LDU_FRAME_LENGTH_BYTES); + } + else { + return !m_txQueue.hasSpace(P25_LDU_FRAME_LENGTH_BYTES); + } +} + /* Get frame data from data ring buffer. */ uint32_t Control::getFrame(uint8_t* data) diff --git a/src/host/p25/Control.h b/src/host/p25/Control.h index 3c4a2f8e..f4781ac1 100644 --- a/src/host/p25/Control.h +++ b/src/host/p25/Control.h @@ -160,6 +160,11 @@ namespace p25 * @returns uint32_t Length of frame data retrieved. */ uint32_t peekFrameLength(); + /** + * @brief Helper to determine whether or not the internal frame queue is full. + * @returns bool True if frame queue is full, otherwise false. + */ + bool isQueueFull(); /** * @brief Get frame data from data ring buffer. * @param[out] data Buffer to store frame data.