aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/UHDDevice.cpp
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-04-08 19:39:37 -0400
committerThomas Tsou <tom@tsou.cc>2013-10-18 13:03:41 -0400
commit7e06806ff0d2b4e0c8eceb75ec92ff41926a4e29 (patch)
tree21671e4a61a6c39e4e2b167837fdf78c0e6ef846 /Transceiver52M/UHDDevice.cpp
parentcb69f084107367eb1a95cd0e6ef3a379361f3e7c (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 575cb01..a627a64 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -383,12 +383,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;
}
@@ -408,8 +414,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;