aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/UHDDevice.cpp
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-04-08 19:39:37 -0400
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2013-06-24 01:46:34 +0400
commit19a506dffa11a671b4dc8fef798a055595d3f16f (patch)
tree938223478eb0fccd4f740e6a46e75d3374d6aa76 /Transceiver52M/UHDDevice.cpp
parentfbd6e1c98541d6ed5fa591755b3196c1594209c2 (diff)
Transceiver52M: Use exception blocks for rate changes
UHD will throw if something goes awry in these sensitive sections, so we should catch and shutdown gracefully. There is no recovery if we can't set rates. Signed-off-by: Thomas Tsou <tom@tsou.cc>
Diffstat (limited to 'Transceiver52M/UHDDevice.cpp')
-rw-r--r--Transceiver52M/UHDDevice.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index 101363d..0bee8d1 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -391,12 +391,18 @@ int uhd_device::set_master_clk(double clk_rate)
{
double actual_clk_rt;
- // Set master clock rate
- usrp_dev->set_master_clock_rate(clk_rate);
- actual_clk_rt = usrp_dev->get_master_clock_rate();
+ try {
+ usrp_dev->set_master_clock_rate(clk_rate);
+ actual_clk_rt = usrp_dev->get_master_clock_rate();
+ } catch (const std::exception &ex) {
+ LOG(ALERT) << "UHD clock rate setting failed: " << clk_rate;
+ LOG(ALERT) << ex.what();
+ return -1;
+ }
if (actual_clk_rt != clk_rate) {
LOG(ALERT) << "Failed to set master clock rate";
+ LOG(ALERT) << "Requested clock rate " << clk_rate;
LOG(ALERT) << "Actual clock rate " << actual_clk_rt;
return -1;
}
@@ -416,8 +422,14 @@ int uhd_device::set_rates(double rate)
}
// Set sample rates
- usrp_dev->set_tx_rate(rate);
- usrp_dev->set_rx_rate(rate);
+ try {
+ usrp_dev->set_tx_rate(rate);
+ usrp_dev->set_rx_rate(rate);
+ } catch (const std::exception &ex) {
+ LOG(ALERT) << "UHD rate setting failed: " << rate;
+ LOG(ALERT) << ex.what();
+ return -1;
+ }
actual_smpl_rt = usrp_dev->get_tx_rate();
tx_offset = actual_smpl_rt - rate;