aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/UHDDevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Transceiver52M/UHDDevice.cpp')
-rw-r--r--Transceiver52M/UHDDevice.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index a7bf53d..95e480b 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -42,7 +42,6 @@
#define SAMPLE_BUF_SZ (1 << 20)
#define UMTRX_VGA1_DEF -18
-#define UMTRX_VGA2_DEF 23
enum uhd_dev_type {
USRP1,
@@ -425,9 +424,23 @@ void uhd_device::init_gains()
{
uhd::gain_range_t range;
- range = usrp_dev->get_tx_gain_range();
- tx_gain_min = range.start();
- tx_gain_max = range.stop();
+ if (dev_type == UMTRX) {
+ std::vector<std::string> gain_stages = usrp_dev->get_tx_gain_names(0);
+ if (gain_stages[0] == "VGA") {
+ LOG(WARNING) << "Update your UHD version for a proper Tx gain support";
+ range = usrp_dev->get_tx_gain_range();
+ tx_gain_min = range.start();
+ tx_gain_max = range.stop();
+ } else {
+ range = usrp_dev->get_tx_gain_range("VGA2");
+ tx_gain_min = UMTRX_VGA1_DEF + range.start();
+ tx_gain_max = UMTRX_VGA1_DEF + range.stop();
+ }
+ } else {
+ range = usrp_dev->get_tx_gain_range();
+ tx_gain_min = range.start();
+ tx_gain_max = range.stop();
+ }
range = usrp_dev->get_rx_gain_range();
rx_gain_min = range.start();
@@ -519,7 +532,8 @@ double uhd_device::setTxGain(double db, size_t chan)
}
if (dev_type == UMTRX) {
- if (!usrp_dev->get_device()->get_tree()->exists("/mboards/0/dboards/A/tx_frontends/0/internal_gains/VGA1")) {
+ std::vector<std::string> gain_stages = usrp_dev->get_tx_gain_names(0);
+ if (gain_stages[0] == "VGA") {
LOG(WARNING) << "Update your UHD version for a proper Tx gain support";
usrp_dev->set_tx_gain(db, chan);
tx_gains[chan] = usrp_dev->get_tx_gain(chan);
@@ -529,13 +543,9 @@ double uhd_device::setTxGain(double db, size_t chan)
// configuration, optimal for the Tx signal quality.
// From our measurements, VGA1 must be 18dB plus-minus
// one and VGA2 is the best when 23dB or lower.
- std::string chan_name = "A";
- if (chan == 1) chan_name = "B";
- std::string tx_vga1_gain_path = "/mboards/0/dboards/" + chan_name + "/tx_frontends/0/internal_gains/VGA1/value";
- std::string tx_vga2_gain_path = "/mboards/0/dboards/" + chan_name + "/tx_frontends/0/internal_gains/VGA2/value";
- usrp_dev->get_device()->get_tree()->access<double>(tx_vga1_gain_path).set(UMTRX_VGA1_DEF);
- usrp_dev->get_device()->get_tree()->access<double>(tx_vga2_gain_path).set(UMTRX_VGA2_DEF);
- tx_gains[chan] = db;
+ usrp_dev->set_tx_gain(UMTRX_VGA1_DEF, "VGA1", chan);
+ usrp_dev->set_tx_gain(db-UMTRX_VGA1_DEF, "VGA2", chan);
+ tx_gains[chan] = usrp_dev->get_tx_gain(chan);
}
} else {
usrp_dev->set_tx_gain(db, chan);