aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/single_usrp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/single_usrp.cpp')
-rw-r--r--host/lib/usrp/single_usrp.cpp80
1 files changed, 52 insertions, 28 deletions
diff --git a/host/lib/usrp/single_usrp.cpp b/host/lib/usrp/single_usrp.cpp
index 7d053535e..5e57849b8 100644
--- a/host/lib/usrp/single_usrp.cpp
+++ b/host/lib/usrp/single_usrp.cpp
@@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
+#include "wrapper_utils.hpp"
#include <uhd/usrp/single_usrp.hpp>
#include <uhd/usrp/tune_helper.hpp>
#include <uhd/utils/assert.hpp>
@@ -32,10 +33,7 @@
using namespace uhd;
using namespace uhd::usrp;
-static inline freq_range_t add_dsp_shift(const freq_range_t &range, wax::obj dsp){
- double codec_rate = dsp[DSP_PROP_CODEC_RATE].as<double>();
- return freq_range_t(range.min - codec_rate/2.0, range.max + codec_rate/2.0);
-}
+const std::string single_usrp::ALL_GAINS = "";
/***********************************************************************
* Simple USRP Implementation
@@ -46,10 +44,6 @@ public:
_dev = device::make(addr);
}
- ~single_usrp_impl(void){
- /* NOP */
- }
-
device::sptr get_device(void){
return _dev;
}
@@ -145,6 +139,7 @@ public:
void set_rx_rate(double rate){
_rx_dsp()[DSP_PROP_HOST_RATE] = rate;
+ do_samp_rate_warning_message(rate, get_rx_rate(), "RX");
}
double get_rx_rate(void){
@@ -152,11 +147,15 @@ public:
}
tune_result_t set_rx_freq(double target_freq, size_t chan){
- return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(), chan, target_freq);
+ tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(), chan, target_freq);
+ do_tune_freq_warning_message(target_freq, get_rx_freq(chan), "RX");
+ return r;
}
tune_result_t set_rx_freq(double target_freq, double lo_off, size_t chan){
- return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(), chan, target_freq, lo_off);
+ tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(), chan, target_freq, lo_off);
+ do_tune_freq_warning_message(target_freq, get_rx_freq(chan), "RX");
+ return r;
}
double get_rx_freq(size_t chan){
@@ -167,16 +166,20 @@ public:
return add_dsp_shift(_rx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsp());
}
- void set_rx_gain(float gain, size_t chan){
- return _rx_gain_group(chan)->set_value(gain);
+ void set_rx_gain(float gain, const std::string &name, size_t chan){
+ return _rx_gain_group(chan)->set_value(gain, name);
+ }
+
+ float get_rx_gain(const std::string &name, size_t chan){
+ return _rx_gain_group(chan)->get_value(name);
}
- float get_rx_gain(size_t chan){
- return _rx_gain_group(chan)->get_value();
+ gain_range_t get_rx_gain_range(const std::string &name, size_t chan){
+ return _rx_gain_group(chan)->get_range(name);
}
- gain_range_t get_rx_gain_range(size_t chan){
- return _rx_gain_group(chan)->get_range();
+ std::vector<std::string> get_rx_gain_names(size_t chan){
+ return _rx_gain_group(chan)->get_names();
}
void set_rx_antenna(const std::string &ant, size_t chan){
@@ -195,6 +198,14 @@ public:
return _rx_subdev(chan)[SUBDEV_PROP_LO_LOCKED].as<bool>();
}
+ void set_rx_bandwidth(double bandwidth, size_t chan){
+ _rx_subdev(chan)[SUBDEV_PROP_BANDWIDTH] = bandwidth;
+ }
+
+ double get_rx_bandwidth(size_t chan){
+ return _rx_subdev(chan)[SUBDEV_PROP_BANDWIDTH].as<double>();
+ }
+
float read_rssi(size_t chan){
return _rx_subdev(chan)[SUBDEV_PROP_RSSI].as<float>();
}
@@ -202,10 +213,6 @@ public:
dboard_iface::sptr get_rx_dboard_iface(size_t chan){
return _rx_dboard(chan)[DBOARD_PROP_DBOARD_IFACE].as<dboard_iface::sptr>();
}
-
- void set_rx_bandwidth(float bandwidth, size_t chan) {
- _rx_subdev(chan)[SUBDEV_PROP_BANDWIDTH] = bandwidth;
- }
/*******************************************************************
* TX methods
@@ -224,6 +231,7 @@ public:
void set_tx_rate(double rate){
_tx_dsp()[DSP_PROP_HOST_RATE] = rate;
+ do_samp_rate_warning_message(rate, get_tx_rate(), "TX");
}
double get_tx_rate(void){
@@ -231,11 +239,15 @@ public:
}
tune_result_t set_tx_freq(double target_freq, size_t chan){
- return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(), chan, target_freq);
+ tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(), chan, target_freq);
+ do_tune_freq_warning_message(target_freq, get_tx_freq(chan), "TX");
+ return r;
}
tune_result_t set_tx_freq(double target_freq, double lo_off, size_t chan){
- return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(), chan, target_freq, lo_off);
+ tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(), chan, target_freq, lo_off);
+ do_tune_freq_warning_message(target_freq, get_tx_freq(chan), "TX");
+ return r;
}
double get_tx_freq(size_t chan){
@@ -246,16 +258,20 @@ public:
return add_dsp_shift(_tx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsp());
}
- void set_tx_gain(float gain, size_t chan){
- return _tx_gain_group(chan)->set_value(gain);
+ void set_tx_gain(float gain, const std::string &name, size_t chan){
+ return _tx_gain_group(chan)->set_value(gain, name);
+ }
+
+ float get_tx_gain(const std::string &name, size_t chan){
+ return _tx_gain_group(chan)->get_value(name);
}
- float get_tx_gain(size_t chan){
- return _tx_gain_group(chan)->get_value();
+ gain_range_t get_tx_gain_range(const std::string &name, size_t chan){
+ return _tx_gain_group(chan)->get_range(name);
}
- gain_range_t get_tx_gain_range(size_t chan){
- return _tx_gain_group(chan)->get_range();
+ std::vector<std::string> get_tx_gain_names(size_t chan){
+ return _tx_gain_group(chan)->get_names();
}
void set_tx_antenna(const std::string &ant, size_t chan){
@@ -274,6 +290,14 @@ public:
return _tx_subdev(chan)[SUBDEV_PROP_LO_LOCKED].as<bool>();
}
+ void set_tx_bandwidth(double bandwidth, size_t chan){
+ _tx_subdev(chan)[SUBDEV_PROP_BANDWIDTH] = bandwidth;
+ }
+
+ double get_tx_bandwidth(size_t chan){
+ return _tx_subdev(chan)[SUBDEV_PROP_BANDWIDTH].as<double>();
+ }
+
dboard_iface::sptr get_tx_dboard_iface(size_t chan){
return _tx_dboard(chan)[DBOARD_PROP_DBOARD_IFACE].as<dboard_iface::sptr>();
}