From 1035eb6574ac4062333e756a1ba4f47a4bfa9855 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Thu, 18 Jan 2018 02:13:29 +0100 Subject: Add antenna selection to config --- TODO | 18 +++++++----------- doc/example.ini | 8 ++++++++ src/ConfigParser.cpp | 9 ++++++--- src/output/SDRDevice.h | 2 ++ src/output/Soapy.cpp | 13 +++++++++++-- src/output/UHD.cpp | 21 ++++++++++++--------- 6 files changed, 46 insertions(+), 25 deletions(-) diff --git a/TODO b/TODO index ac0a877..cff3a99 100644 --- a/TODO +++ b/TODO @@ -27,7 +27,7 @@ Clean up and separate GPS and refclk checks. * Ensure muting is set properly at startup. * Ensure synchronous is taken in account. -Add antenna selection to config. +*done* Add antenna selection to config. Test RC entries. @@ -53,6 +53,12 @@ Tests, both with B200 and LimeSDR: - Proper teardown - DPD server +Smaller things +-------------- + +Remove GuardIntervalInserter implementation for window==0, as it was shown both are equivalent. + + Replace all prints to stderr ---------------------------- We have a nice logging subsystem, use it to avoid that fprintf(stderr, ...) and @@ -84,13 +90,3 @@ The CIC Equaliser was used for the USRP1 to compensate for spectrum flatness. It is not documented, and its effect poorly explained. Review if still needed, and document appropriately. - -Add metadata to flowgraph -------------------------- -The flowgraph does not support metadata. This is why the timestamp has this -kludge with the delay queue, so that the timestamps are delayed properly -depending on what is included in the flowgraph. - -Without metadata inside the flowgraph, it is more difficult to pipeline the DSP -processing to make use of many-core systems, because the timestamp cannot be -carried alongside the data it corresponds to. diff --git a/doc/example.ini b/doc/example.ini index d919f4a..b0bf022 100644 --- a/doc/example.ini +++ b/doc/example.ini @@ -190,6 +190,11 @@ txgain=40 ; More information and measurements available on: ; http://wiki.opendigitalradio.org/index.php/USRP_B200_Measurements +; You can set what TX and RX antennas to use. This will depend on the +; USRP model you are using. +;tx_antenna= +;rx_antenna=RX2 + ; Settings for a USRP B100: ;device= @@ -271,6 +276,9 @@ master_clock_rate=32768000 txgain=40 ;frequency=234208000 channel=13C +; You can set what TX antenna to use. This will depend on the +; SDR device you are using. +;tx_antenna= ; Used for SFN with the UHD output [delaymanagement] diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index a4219af..5f3f61e 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -3,7 +3,7 @@ Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2017 + Copyright (C) 2018 Matthias P. Braendli, matthias.braendli@mpb.li http://opendigitalradio.org @@ -244,6 +244,8 @@ static void parse_configfile( } sdr_device_config.txgain = pt.get("uhdoutput.txgain", 0.0); + sdr_device_config.tx_antenna = pt.get("uhdoutput.tx_antenna", ""); + sdr_device_config.rx_antenna = pt.get("uhdoutput.rx_antenna", "RX2"); sdr_device_config.rxgain = pt.get("uhdoutput.rxgain", 0.0); sdr_device_config.frequency = pt.get("uhdoutput.frequency", 0); std::string chan = pt.get("uhdoutput.channel", ""); @@ -295,6 +297,7 @@ static void parse_configfile( outputsoapy_conf.masterClockRate = pt.get("soapyoutput.master_clock_rate", 0); outputsoapy_conf.txgain = pt.get("soapyoutput.txgain", 0.0); + outputsoapy_conf.tx_antenna = pt.get("soapyoutput.tx_antenna", ""); outputsoapy_conf.lo_offset = pt.get("soapyoutput.lo_offset", 0.0); outputsoapy_conf.frequency = pt.get("soapyoutput.frequency", 0); std::string chan = pt.get("soapyoutput.channel", ""); @@ -421,9 +424,7 @@ void parse_args(int argc, char **argv, mod_settings_t& mod_settings) break; case 'o': mod_settings.tist_offset_s = strtod(optarg, NULL); -#if defined(HAVE_OUTPUT_UHD) mod_settings.sdr_device_config.enableSync = true; -#endif break; case 'm': mod_settings.dabMode = strtol(optarg, NULL, 0); @@ -445,6 +446,8 @@ void parse_args(int argc, char **argv, mod_settings_t& mod_settings) mod_settings.sdr_device_config.pps_src = "none"; mod_settings.sdr_device_config.pps_polarity = "pos"; mod_settings.useUHDOutput = true; +#else + throw std::invalid_argument("Cannot select UHD output, not compiled in!"); #endif break; case 'V': diff --git a/src/output/SDRDevice.h b/src/output/SDRDevice.h index bcd5a39..bd1a518 100644 --- a/src/output/SDRDevice.h +++ b/src/output/SDRDevice.h @@ -53,6 +53,8 @@ using complexf = std::complex; struct SDRDeviceConfig { std::string device; std::string subDevice; // For UHD + std::string tx_antenna; + std::string rx_antenna; long masterClockRate = 32768000; unsigned sampleRate = 2048000; diff --git a/src/output/Soapy.cpp b/src/output/Soapy.cpp index 44f8f58..8ee420e 100644 --- a/src/output/Soapy.cpp +++ b/src/output/Soapy.cpp @@ -71,23 +71,32 @@ Soapy::Soapy(SDRDeviceConfig& config) : m_device->setMasterClockRate(m_conf.masterClockRate); etiLog.level(info) << "SoapySDR master clock rate set to " << + std::fixed << std::setprecision(4) << m_device->getMasterClockRate()/1000.0 << " kHz"; m_device->setSampleRate(SOAPY_SDR_TX, 0, m_conf.sampleRate); etiLog.level(info) << "SoapySDR:Actual TX rate: " << + std::fixed << std::setprecision(4) << m_device->getSampleRate(SOAPY_SDR_TX, 0) / 1000.0 << " ksps."; tune(m_conf.lo_offset, m_conf.frequency); m_conf.frequency = m_device->getFrequency(SOAPY_SDR_TX, 0); etiLog.level(info) << "SoapySDR:Actual frequency: " << - m_conf.frequency / 1000.0 << - " kHz."; + std::fixed << std::setprecision(3) << + m_conf.frequency / 1000.0 << " kHz."; m_device->setGain(SOAPY_SDR_TX, 0, m_conf.txgain); etiLog.level(info) << "SoapySDR:Actual tx gain: " << + std::fixed << std::setprecision(2) << m_device->getGain(SOAPY_SDR_TX, 0); + if (not m_conf.tx_antenna.empty()) { + m_device->setAntenna(SOAPY_SDR_TX, 0, m_conf.tx_antenna); + } + etiLog.level(info) << "SoapySDR:Actual tx antenna: " << + m_device->getAntenna(SOAPY_SDR_TX, 0); + const std::vector channels({0}); m_tx_stream = m_device->setupStream(SOAPY_SDR_TX, "CF32", channels); m_device->activateStream(m_tx_stream); diff --git a/src/output/UHD.cpp b/src/output/UHD.cpp index 8876b0e..2c571fd 100644 --- a/src/output/UHD.cpp +++ b/src/output/UHD.cpp @@ -159,10 +159,10 @@ UHD::UHD(SDRDeviceConfig& config) : tune(m_conf.lo_offset, m_conf.frequency); m_conf.frequency = m_usrp->get_tx_freq(); - etiLog.level(info) << std::fixed << std::setprecision(3) << + etiLog.level(debug) << std::fixed << std::setprecision(3) << "OutputUHD:Actual TX frequency: " << m_conf.frequency; - etiLog.level(info) << std::fixed << std::setprecision(3) << + etiLog.level(debug) << std::fixed << std::setprecision(3) << "OutputUHD:Actual RX frequency: " << m_usrp->get_tx_freq(); m_usrp->set_tx_gain(m_conf.txgain); @@ -175,18 +175,21 @@ UHD::UHD(SDRDeviceConfig& config) : m_usrp->set_rx_rate(m_conf.sampleRate); etiLog.log(debug, "OutputUHD:Actual RX Rate: %f sps.", m_usrp->get_rx_rate()); - m_usrp->set_rx_antenna("RX2"); - etiLog.log(debug, "OutputUHD:Set RX Antenna: %s", + if (not m_conf.rx_antenna.empty()) { + m_usrp->set_rx_antenna(m_conf.rx_antenna); + } + etiLog.log(debug, "OutputUHD:Actual RX Antenna: %s", m_usrp->get_rx_antenna().c_str()); + if (not m_conf.tx_antenna.empty()) { + m_usrp->set_tx_antenna(m_conf.tx_antenna); + } + etiLog.log(debug, "OutputUHD:Actual TX Antenna: %s", + m_usrp->get_tx_antenna().c_str()); + m_usrp->set_rx_gain(m_conf.rxgain); etiLog.log(debug, "OutputUHD:Actual RX Gain: %f", m_usrp->get_rx_gain()); - /* TODO - uhdFeedback = std::make_shared( - m_usrp, m_conf.dpdFeedbackServerPort, m_conf.sampleRate); - */ - const uhd::stream_args_t stream_args("fc32"); //complex floats m_rx_stream = m_usrp->get_rx_stream(stream_args); m_tx_stream = m_usrp->get_tx_stream(stream_args); -- cgit v1.2.3