From 9a9441fbd581bf684f6d548f0f6500ce4a5635cf Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Wed, 21 Aug 2024 09:03:54 -0400 Subject: [PATCH] extend W3AXLs implementation for space in blocks to the air interface modems as well (even though the modem firmware doesn't support it yet), for future proofing purposes; --- src/host/modem/Modem.cpp | 14 ++++++++++++-- src/host/modem/Modem.h | 4 +++- src/host/modem/ModemV24.cpp | 9 +++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/host/modem/Modem.cpp b/src/host/modem/Modem.cpp index 69756a5b..50e38994 100644 --- a/src/host/modem/Modem.cpp +++ b/src/host/modem/Modem.cpp @@ -740,6 +740,9 @@ void Modem::clock(uint32_t ms) bool p25Enable = (m_buffer[3U] & 0x08U) == 0x08U; bool nxdnEnable = (m_buffer[3U] & 0x10U) == 0x10U; + // flag indicating if free space is being reported in 16-byte blocks instead of LDUs + bool spaceInBlocks = (m_buffer[3U] & 0x80) == 0x80; + m_modemState = (DVM_STATE)m_buffer[4U]; m_tx = (m_buffer[5U] & 0x01U) == 0x01U; @@ -806,12 +809,19 @@ void Modem::clock(uint32_t ms) m_cd = (m_buffer[5U] & 0x40U) == 0x40U; - // spaces from the modem are returned in "logical" frame count, not raw byte size + // spaces from the modem are returned in "logical" frame count, or a block size, not raw byte size + // for DMR and NXDN, becuase the protocols use fixed length frames we always return + // space in frame count m_dmrSpace1 = m_buffer[7U] * (DMRDEF::DMR_FRAME_LENGTH_BYTES + 2U); m_dmrSpace2 = m_buffer[8U] * (DMRDEF::DMR_FRAME_LENGTH_BYTES + 2U); - m_p25Space = m_buffer[10U] * (P25DEF::P25_LDU_FRAME_LENGTH_BYTES);//(P25DEF::P25_PDU_FRAME_LENGTH_BYTES); m_nxdnSpace = m_buffer[11U] * (NXDDEF::NXDN_FRAME_LENGTH_BYTES); + // P25 free space can be reported as 16-byte blocks or frames based on the flag above + if (spaceInBlocks) + m_p25Space = m_buffer[10U] * P25_BUFFER_BLOCK_SIZE; + else + m_p25Space = m_buffer[10U] * (P25DEF::P25_LDU_FRAME_LENGTH_BYTES); + if (m_dumpModemStatus) { LogDebug(LOG_MODEM, "Modem::clock(), CMD_GET_STATUS, isHotspot = %u, dmr = %u / %u, p25 = %u / %u, nxdn = %u / %u, modemState = %u, tx = %u, adcOverflow = %u, rxOverflow = %u, txOverflow = %u, dacOverflow = %u, dmrSpace1 = %u, dmrSpace2 = %u, p25Space = %u, nxdnSpace = %u", m_isHotspot, dmrEnable, m_dmrEnabled, p25Enable, m_p25Enabled, nxdnEnable, m_nxdnEnabled, m_modemState, m_tx, adcOverflow, rxOverflow, txOverflow, dacOverflow, m_dmrSpace1, m_dmrSpace2, m_p25Space, m_nxdnSpace); diff --git a/src/host/modem/Modem.h b/src/host/modem/Modem.h index eb52bec7..179773db 100644 --- a/src/host/modem/Modem.h +++ b/src/host/modem/Modem.h @@ -273,7 +273,9 @@ namespace modem const uint32_t MAX_DAC_OVERFLOW = 128U; const uint32_t MODEM_POLL_TIME = 125U; - + + const uint32_t P25_BUFFER_BLOCK_SIZE = 16U; + /** @} */ // --------------------------------------------------------------------------- diff --git a/src/host/modem/ModemV24.cpp b/src/host/modem/ModemV24.cpp index 31878db2..cc080e35 100644 --- a/src/host/modem/ModemV24.cpp +++ b/src/host/modem/ModemV24.cpp @@ -216,7 +216,7 @@ void ModemV24::clock(uint32_t ms) bool p25Enable = (m_buffer[3U] & 0x08U) == 0x08U; bool nxdnEnable = (m_buffer[3U] & 0x10U) == 0x10U; - // Flag indicating if free space is being reported in 16-byte blocks instead of LDUs + // flag indicating if free space is being reported in 16-byte blocks instead of LDUs bool spaceInBlocks = (m_buffer[3U] & 0x80) == 0x80; m_modemState = (DVM_STATE)m_buffer[4U]; @@ -285,6 +285,7 @@ void ModemV24::clock(uint32_t ms) m_cd = (m_buffer[5U] & 0x40U) == 0x40U; + // spaces from the modem are returned in "logical" frame count, or a block size, not raw byte size // DMR and NXDN space are always 0U since the board doesn't support them m_dmrSpace1 = 0U; m_dmrSpace2 = 0U; @@ -292,13 +293,9 @@ void ModemV24::clock(uint32_t ms) // P25 free space can be reported as 16-byte blocks or frames based on the flag above if (spaceInBlocks) - { - m_p25Space = m_buffer[10U] * 16U; - } + m_p25Space = m_buffer[10U] * P25_BUFFER_BLOCK_SIZE; else - { m_p25Space = m_buffer[10U] * (P25DEF::P25_LDU_FRAME_LENGTH_BYTES); - } if (m_dumpModemStatus) { LogDebug(LOG_MODEM, "ModemV24::clock(), CMD_GET_STATUS, isHotspot = %u, dmr = %u / %u, p25 = %u / %u, nxdn = %u / %u, modemState = %u, tx = %u, adcOverflow = %u, rxOverflow = %u, txOverflow = %u, dacOverflow = %u, dmrSpace1 = %u, dmrSpace2 = %u, p25Space = %u, nxdnSpace = %u",