From 65350497656e43ad270b41b72cece53a97fd6210 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Wed, 10 Mar 2021 20:12:13 +0000 Subject: [PATCH] support configuring the modem P25 sync correlation countdown from the host; --- config.yml | 1 + host/Host.cpp | 4 +++- host/calibrate/HostCal.cpp | 7 ++++++- host/calibrate/HostCal.h | 1 + modem/Modem.cpp | 13 +++++++++---- modem/Modem.h | 7 ++++--- modem/NullModem.cpp | 5 +++-- modem/NullModem.h | 2 +- p25/TrunkPacket.cpp | 7 ++++++- 9 files changed, 34 insertions(+), 13 deletions(-) diff --git a/config.yml b/config.yml index ffc2214e..d3d64b37 100644 --- a/config.yml +++ b/config.yml @@ -110,6 +110,7 @@ system: cosLockout: false fdmaPreamble: 80 dmrRxDelay: 7 + p25CorrCount: 8 rxDCOffset: 0 txDCOffset: 0 rxLevel: 50 diff --git a/host/Host.cpp b/host/Host.cpp index 2d2680e1..119cbeaa 100644 --- a/host/Host.cpp +++ b/host/Host.cpp @@ -1241,6 +1241,7 @@ bool Host::createModem() bool cosLockout = modemConf["cosLockout"].as(false); uint8_t fdmaPreamble = (uint8_t)modemConf["fdmaPreamble"].as(80U); uint8_t dmrRxDelay = (uint8_t)modemConf["dmrRxDelay"].as(7U); + uint8_t p25CorrCount = (uint8_t)modemConf["p25CorrCount"].as(4U); int rxDCOffset = modemConf["rxDCOffset"].as(0); int txDCOffset = modemConf["txDCOffset"].as(0); int dmrSymLevel3Adj = modemConf["dmrSymLvl3Adj"].as(0); @@ -1272,6 +1273,7 @@ bool Host::createModem() LogInfo(" COS Lockout: %s", cosLockout ? "yes" : "no"); LogInfo(" FDMA Preambles: %u (%.1fms)", fdmaPreamble, float(fdmaPreamble) * 0.2083F); LogInfo(" DMR RX Delay: %u (%.1fms)", dmrRxDelay, float(dmrRxDelay) * 0.0416666F); + LogInfo(" P25 Corr. Count: %u (%.1fms)", p25CorrCount, float(p25CorrCount) * 0.667F); LogInfo(" RX DC Offset: %d", rxDCOffset); LogInfo(" TX DC Offset: %d", txDCOffset); LogInfo(" RX Level: %.1f%%", rxLevel); @@ -1285,7 +1287,7 @@ bool Host::createModem() LogInfo(" Debug: yes"); } - m_modem = Modem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, dcBlocker, cosLockout, fdmaPreamble, dmrRxDelay, packetPlayoutTime, disableOFlowReset, trace, debug); + m_modem = Modem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, dcBlocker, cosLockout, fdmaPreamble, dmrRxDelay, p25CorrCount, packetPlayoutTime, disableOFlowReset, trace, debug); m_modem->setModeParams(m_dmrEnabled, m_p25Enabled); m_modem->setLevels(rxLevel, cwIdTXLevel, dmrTXLevel, p25TXLevel); m_modem->setSymbolAdjust(dmrSymLevel3Adj, dmrSymLevel1Adj, p25SymLevel3Adj, p25SymLevel1Adj); diff --git a/host/calibrate/HostCal.cpp b/host/calibrate/HostCal.cpp index c18b825f..1be6a40d 100644 --- a/host/calibrate/HostCal.cpp +++ b/host/calibrate/HostCal.cpp @@ -154,6 +154,7 @@ HostCal::HostCal(const std::string& confFile) : m_p25SymLevel1Adj(0), m_fdmaPreamble(80U), m_dmrRxDelay(7U), + m_p25CorrCount(5U), m_debug(false), m_mode(STATE_DMR_CAL), m_modeStr(DMR_CAL_STR), @@ -246,6 +247,7 @@ int HostCal::run() m_fdmaPreamble = (uint8_t)modemConf["fdmaPreamble"].as(80U); m_dmrRxDelay = (uint8_t)modemConf["dmrRxDelay"].as(7U); + m_p25CorrCount = (uint8_t)modemConf["p25CorrCount"].as(5U); writeConfig(); @@ -1650,6 +1652,8 @@ bool HostCal::writeConfig(uint8_t modeOverride) m_conf["system"]["modem"]["rxDCOffset"] = __INT_STR(m_rxDCOffset); buffer[17U] = (uint8_t)(m_rxDCOffset + 128); + buffer[14U] = (uint8_t)m_p25CorrCount; + int ret = m_serial.write(buffer, 17U); if (ret <= 0) return false; @@ -1781,7 +1785,8 @@ void HostCal::printStatus() m_rxLevel, m_txLevel, m_txDCOffset, m_rxDCOffset); LogMessage(LOG_CAL, " - DMR Symbol +/- 3 Level Adj.: %d, DMR Symbol +/- 1 Level Adj.: %d, P25 Symbol +/- 3 Level Adj.: %d, P25 Symbol +/- 1 Level Adj.: %d", m_dmrSymLevel3Adj, m_dmrSymLevel1Adj, m_p25SymLevel3Adj, m_p25SymLevel1Adj); - LogMessage(LOG_CAL, " - FDMA Preambles: %u (%.1fms), DMR Rx Delay: %u (%.1fms)", m_fdmaPreamble, float(m_fdmaPreamble) * 0.2083F, m_dmrRxDelay, float(m_dmrRxDelay) * 0.0416666F); + LogMessage(LOG_CAL, " - FDMA Preambles: %u (%.1fms), DMR Rx Delay: %u (%.1fms), P25 Corr. Count: %u (%.1fms)", m_fdmaPreamble, float(m_fdmaPreamble) * 0.2083F, m_dmrRxDelay, float(m_dmrRxDelay) * 0.0416666F, + m_p25CorrCount, float(m_p25CorrCount) * 0.667F); LogMessage(LOG_CAL, " - Operating Mode: %s", m_modeStr.c_str()); uint8_t buffer[50U]; diff --git a/host/calibrate/HostCal.h b/host/calibrate/HostCal.h index 2a9a9c45..4b3618ae 100644 --- a/host/calibrate/HostCal.h +++ b/host/calibrate/HostCal.h @@ -93,6 +93,7 @@ private: uint8_t m_fdmaPreamble; uint8_t m_dmrRxDelay; + uint8_t m_p25CorrCount; bool m_debug; diff --git a/modem/Modem.cpp b/modem/Modem.cpp index 79990a5f..9e153686 100644 --- a/modem/Modem.cpp +++ b/modem/Modem.cpp @@ -66,12 +66,13 @@ using namespace modem; /// Flag indicating whether the COS signal should be used to lockout the modem. /// Count of FDMA preambles to transmit before data. (P25/DMR DMO) /// Compensate for delay in receiver audio chain in ms. Usually DSP based. +/// P25 Correlation Countdown. /// Flag indicating whether the ADC/DAC overflow reset logic is disabled. /// Length of time in MS between packets to send to modem. /// Flag indicating whether modem DSP trace is enabled. /// Flag indicating whether modem DSP debug is enabled. Modem::Modem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, bool dcBlocker, - bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug) : + bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t p25CorrCount, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug) : m_port(port), m_dmrColorCode(0U), m_p25NAC(0x293U), @@ -83,6 +84,7 @@ Modem::Modem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, m_cosLockout(cosLockout), m_fdmaPreamble(fdmaPreamble), m_dmrRxDelay(dmrRxDelay), + m_p25CorrCount(p25CorrCount), m_rxLevel(0U), m_cwIdTXLevel(0U), m_dmrTXLevel(0U), @@ -1083,18 +1085,19 @@ bool Modem::sendCWId(const std::string& callsign) /// Flag indicating whether the COS signal should be used to lockout the modem. /// Count of FDMA preambles to transmit before data. (P25/DMR DMO) /// Compensate for delay in receiver audio chain in ms. Usually DSP based. +/// P25 Correlation Countdown. /// Length of time in MS between packets to send to modem. /// Flag indicating whether the ADC/DAC overflow reset logic is disabled. /// Flag indicating whether modem DSP trace is enabled. /// Flag indicating whether modem DSP debug is enabled. Modem* Modem::createModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, bool dcBlocker, - bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug) + bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t p25CorrCount, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug) { if (port == NULL_MODEM) { - return new NullModem(port, duplex, rxInvert, txInvert, pttInvert, dcBlocker, cosLockout, fdmaPreamble, dmrRxDelay, packetPlayoutTime, disableOFlowReset, trace, debug); + return new NullModem(port, duplex, rxInvert, txInvert, pttInvert, dcBlocker, cosLockout, fdmaPreamble, dmrRxDelay, p25CorrCount, packetPlayoutTime, disableOFlowReset, trace, debug); } else { - return new Modem(port, duplex, rxInvert, txInvert, pttInvert, dcBlocker, cosLockout, fdmaPreamble, dmrRxDelay, packetPlayoutTime, disableOFlowReset, trace, debug); + return new Modem(port, duplex, rxInvert, txInvert, pttInvert, dcBlocker, cosLockout, fdmaPreamble, dmrRxDelay, p25CorrCount, packetPlayoutTime, disableOFlowReset, trace, debug); } } @@ -1240,6 +1243,8 @@ bool Modem::writeConfig() buffer[16U] = (uint8_t)(m_txDCOffset + 128); buffer[17U] = (uint8_t)(m_rxDCOffset + 128); + buffer[14U] = m_p25CorrCount; + // Utils::dump(1U, "Written", buffer, 17U); int ret = m_serial.write(buffer, 17U); diff --git a/modem/Modem.h b/modem/Modem.h index 07c574e2..861c97d7 100644 --- a/modem/Modem.h +++ b/modem/Modem.h @@ -142,7 +142,7 @@ namespace modem RSN_INVALID_DMR_START = 14U, RSN_INVALID_DMR_RX_DELAY = 15U, - RSN_INVALID_P25_NAC = 16U, + RSN_INVALID_P25_CORR_COUNT = 16U, RSN_DMR_DISABLED = 63U, RSN_P25_DISABLED = 64U, @@ -167,7 +167,7 @@ namespace modem public: /// Initializes a new instance of the Modem class. Modem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, bool dcBlocker, - bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug); + bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t p25CorrCount, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug); /// Finalizes a instance of the Modem class. virtual ~Modem(); @@ -255,7 +255,7 @@ namespace modem /// Helper to create an instance of the Modem class. static Modem* createModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, bool dcBlocker, - bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug); + bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t p25CorrCount, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug); private: std::string m_port; @@ -274,6 +274,7 @@ namespace modem uint8_t m_fdmaPreamble; uint8_t m_dmrRxDelay; + uint8_t m_p25CorrCount; float m_rxLevel; float m_cwIdTXLevel; diff --git a/modem/NullModem.cpp b/modem/NullModem.cpp index 4d5efe63..28a9d00e 100644 --- a/modem/NullModem.cpp +++ b/modem/NullModem.cpp @@ -49,13 +49,14 @@ using namespace modem; /// Flag indicating whether the COS signal should be used to lockout the modem. /// Count of FDMA preambles to transmit before data. (P25/DMR DMO) /// Compensate for delay in receiver audio chain in ms. Usually DSP based. +/// P25 Correlation Countdown. /// Length of time in MS between packets to send to modem. /// Flag indicating whether the ADC/DAC overflow reset logic is disabled. /// Flag indicating whether modem DSP trace is enabled. /// Flag indicating whether modem DSP debug is enabled. NullModem::NullModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, bool dcBlocker, - bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug) : - Modem(port, duplex, rxInvert, txInvert, pttInvert, dcBlocker, cosLockout, fdmaPreamble, dmrRxDelay, packetPlayoutTime, disableOFlowReset, trace, debug) + bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t p25CorrCount, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug) : + Modem(port, duplex, rxInvert, txInvert, pttInvert, dcBlocker, cosLockout, fdmaPreamble, dmrRxDelay, p25CorrCount, packetPlayoutTime, disableOFlowReset, trace, debug) { /* stub */ } diff --git a/modem/NullModem.h b/modem/NullModem.h index cb22662b..19318aaf 100644 --- a/modem/NullModem.h +++ b/modem/NullModem.h @@ -45,7 +45,7 @@ namespace modem public: /// Initializes a new instance of the NullModem class. NullModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, bool dcBlocker, - bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug); + bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t p25CorrCount, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug); /// Finalizes a instance of the NullModem class. ~NullModem(); diff --git a/p25/TrunkPacket.cpp b/p25/TrunkPacket.cpp index 07b5979f..6f2b2f29 100644 --- a/p25/TrunkPacket.cpp +++ b/p25/TrunkPacket.cpp @@ -1847,7 +1847,7 @@ void TrunkPacket::queueRF_TSBK_Ctrl_MBF(uint8_t lco) else { SiteData site = it->second; - uint8_t cfva = P25_CFVA_CONV | P25_CFVA_NETWORK; + uint8_t cfva = P25_CFVA_NETWORK; if (m_adjSiteUpdateCnt[site.siteId()] == 0U) { cfva |= P25_CFVA_FAILURE; } @@ -1855,6 +1855,11 @@ void TrunkPacket::queueRF_TSBK_Ctrl_MBF(uint8_t lco) cfva |= P25_CFVA_VALID; } + uint8_t serviceClass = site.serviceClass(); + if ((serviceClass & P25_SVC_CLS_COMPOSITE) == P25_SVC_CLS_COMPOSITE) { + cfva |= P25_CFVA_CONV; + } + // transmit adjacent site broadcast m_rfTSBK.setLCO(TSBK_OSP_ADJ_STS_BCAST); m_rfTSBK.setAdjSiteCFVA(cfva);