diff --git a/host/calibrate/HostCal.cpp b/host/calibrate/HostCal.cpp index 1266dfac..573cc1ba 100644 --- a/host/calibrate/HostCal.cpp +++ b/host/calibrate/HostCal.cpp @@ -173,7 +173,8 @@ HostCal::HostCal(const std::string& confFile) : m_berUndecodableLC(0U), m_berUncorrectable(0U), m_timeout(300U), - m_timer(0U) + m_timer(0U), + m_hasFetchedStatus(false) { /* stub */ } @@ -288,10 +289,31 @@ int HostCal::run() m_rxAdjustedFreq = m_rxFrequency + m_rxTuning; m_txAdjustedFreq = m_txFrequency + m_txTuning; - LogInfo(" RX Tuning Offset: %dhz", m_rxTuning); - LogInfo(" TX Tuning Offset: %dhz", m_txTuning); - LogInfo(" RX Effective Frequency: %uhz", m_rxAdjustedFreq); - LogInfo(" TX Effective Frequency: %uhz", m_txAdjustedFreq); + m_rxInvert = modemConf["rxInvert"].as(false); + m_txInvert = modemConf["txInvert"].as(false); + m_pttInvert = modemConf["pttInvert"].as(false); + m_dcBlocker = modemConf["dcBlocker"].as(true); + + m_rxDCOffset = modemConf["rxDCOffset"].as(0); + m_txDCOffset = modemConf["txDCOffset"].as(0); + m_rxLevel = modemConf["rxLevel"].as(50.0F); + m_txLevel = modemConf["txLevel"].as(50.0F); + + m_dmrDiscBWAdj = modemConf["dmrDiscBWAdj"].as(0); + m_p25DiscBWAdj = modemConf["p25DiscBWAdj"].as(0); + m_dmrPostBWAdj = modemConf["dmrPostBWAdj"].as(0); + m_p25PostBWAdj = modemConf["p25PostBWAdj"].as(0); + + m_adfGainMode = (ADF_GAIN_MODE)modemConf["adfGainMode"].as(0U); + + m_dmrSymLevel3Adj = modemConf["dmrSymLvl3Adj"].as(0); + m_dmrSymLevel1Adj = modemConf["dmrSymLvl1Adj"].as(0); + m_p25SymLevel3Adj = modemConf["p25SymLvl3Adj"].as(0); + m_p25SymLevel1Adj = modemConf["p25SymLvl1Adj"].as(0); + + m_fdmaPreamble = (uint8_t)modemConf["fdmaPreamble"].as(80U); + m_dmrRxDelay = (uint8_t)modemConf["dmrRxDelay"].as(7U); + m_p25CorrCount = (uint8_t)modemConf["p25CorrCount"].as(5U); yaml::Node modemProtocol = modemConf["protocol"]; std::string portType = modemProtocol["type"].as("null"); @@ -347,6 +369,21 @@ int HostCal::run() LogInfo("Modem Parameters"); LogInfo(" UART Port: %s", uartPort.c_str()); LogInfo(" UART Speed: %u", uartSpeed); + LogInfo(" RX Invert: %s", m_rxInvert ? "yes" : "no"); + LogInfo(" TX Invert: %s", m_txInvert ? "yes" : "no"); + LogInfo(" PTT Invert: %s", m_pttInvert ? "yes" : "no"); + LogInfo(" DC Blocker: %s", m_dcBlocker ? "yes" : "no"); + LogInfo(" FDMA Preambles: %u (%.1fms)", m_fdmaPreamble, float(m_fdmaPreamble) * 0.2083F); + LogInfo(" DMR RX Delay: %u (%.1fms)", m_dmrRxDelay, float(m_dmrRxDelay) * 0.0416666F); + LogInfo(" P25 Corr. Count: %u (%.1fms)", m_p25CorrCount, float(m_p25CorrCount) * 0.667F); + LogInfo(" RX DC Offset: %d", m_rxDCOffset); + LogInfo(" TX DC Offset: %d", m_txDCOffset); + LogInfo(" RX Tuning Offset: %dhz", m_rxTuning); + LogInfo(" TX Tuning Offset: %dhz", m_txTuning); + LogInfo(" RX Effective Frequency: %uhz", m_rxAdjustedFreq); + LogInfo(" TX Effective Frequency: %uhz", m_txAdjustedFreq); + LogInfo(" RX Level: %.1f%%", m_rxLevel); + LogInfo(" TX Level: %.1f%%", m_txLevel); } else if (portType == UDP_PORT) { ::LogError(LOG_HOST, "Calibration mode is unsupported with a remote modem!"); @@ -377,35 +414,14 @@ int HostCal::run() return 1; } - m_rxInvert = modemConf["rxInvert"].as(false); - m_txInvert = modemConf["txInvert"].as(false); - m_pttInvert = modemConf["pttInvert"].as(false); - m_dcBlocker = modemConf["dcBlocker"].as(true); - - m_rxDCOffset = modemConf["rxDCOffset"].as(0); - m_txDCOffset = modemConf["txDCOffset"].as(0); - m_rxLevel = modemConf["rxLevel"].as(50.0F); - m_txLevel = modemConf["txLevel"].as(50.0F); - - m_dmrDiscBWAdj = modemConf["dmrDiscBWAdj"].as(0); - m_p25DiscBWAdj = modemConf["p25DiscBWAdj"].as(0); - m_dmrPostBWAdj = modemConf["dmrPostBWAdj"].as(0); - m_p25PostBWAdj = modemConf["p25PostBWAdj"].as(0); - - m_adfGainMode = (ADF_GAIN_MODE)modemConf["adfGainMode"].as(0U); - - m_dmrSymLevel3Adj = modemConf["dmrSymLvl3Adj"].as(0); - m_dmrSymLevel1Adj = modemConf["dmrSymLvl1Adj"].as(0); - m_p25SymLevel3Adj = modemConf["p25SymLvl3Adj"].as(0); - m_p25SymLevel1Adj = modemConf["p25SymLvl1Adj"].as(0); - - 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(); + writeRFParams(); getStatus(); + while (!m_hasFetchedStatus) { + m_modem->clock(0U); + sleep(5U); + } displayHelp(); printStatus(); @@ -559,8 +575,6 @@ int HostCal::run() writeRFParams(); } - - printStatus(); } break; @@ -581,8 +595,6 @@ int HostCal::run() writeRFParams(); } - - printStatus(); } break; @@ -637,8 +649,6 @@ int HostCal::run() writeRFParams(); } - - printStatus(); } } break; @@ -659,8 +669,6 @@ int HostCal::run() writeRFParams(); } - - printStatus(); } } break; @@ -681,8 +689,6 @@ int HostCal::run() writeRFParams(); } - - printStatus(); } } break; @@ -703,8 +709,6 @@ int HostCal::run() writeRFParams(); } - - printStatus(); } } break; @@ -729,8 +733,6 @@ int HostCal::run() writeRFParams(); } } - - printStatus(); } } break; @@ -915,6 +917,8 @@ int HostCal::run() break; case 'Q': case 'q': + m_mode = STATE_IDLE; + writeConfig(); end = true; break; @@ -1073,8 +1077,12 @@ bool HostCal::portModemHandler(Modem* modem, uint32_t ms, RESP_TYPE_DVM rspType, bool txOverflow = (buffer[5U] & 0x08U) == 0x08U; bool dacOverflow = (buffer[5U] & 0x20U) == 0x20U; - LogMessage(LOG_CAL, " - Diagnostic Values [Modem State: %u, Transmitting: %d, ADC Overflow: %d, Rx Overflow: %d, Tx Overflow: %d, DAC Overflow: %d, HS: %u]", - modemState, tx, adcOverflow, rxOverflow, txOverflow, dacOverflow, m_isHotspot); + if (m_hasFetchedStatus) { + LogMessage(LOG_CAL, " - Diagnostic Values [Modem State: %u, Transmitting: %d, ADC Overflow: %d, Rx Overflow: %d, Tx Overflow: %d, DAC Overflow: %d, HS: %u]", + modemState, tx, adcOverflow, rxOverflow, txOverflow, dacOverflow, m_isHotspot); + } + + m_hasFetchedStatus = true; } break; @@ -2092,6 +2100,7 @@ void HostCal::getStatus() /// /// Prints the current status of the calibration. /// +/// Flag indicating that the current modem status should be fetched. void HostCal::printStatus() { yaml::Node systemConf = m_conf["system"]; diff --git a/host/calibrate/HostCal.h b/host/calibrate/HostCal.h index faa822e4..04e5d69e 100644 --- a/host/calibrate/HostCal.h +++ b/host/calibrate/HostCal.h @@ -129,6 +129,8 @@ private: uint32_t m_timeout; uint32_t m_timer; + bool m_hasFetchedStatus; + /// Modem port open callback. bool portModemOpen(modem::Modem* modem); /// Modem port close callback.