diff options
author | Thomas Tsou <tom@tsou.cc> | 2013-04-08 19:05:50 -0400 |
---|---|---|
committer | Alexander Chemeris <Alexander.Chemeris@gmail.com> | 2013-06-24 01:46:34 +0400 |
commit | fbd6e1c98541d6ed5fa591755b3196c1594209c2 (patch) | |
tree | 31042e5d978f40abb69a6e2d84971c7dcdbedd26 /Transceiver52M/UHDDevice.cpp | |
parent | 03669856b74bd1e82a3986a5e05154fec88942ac (diff) |
Transceiver52M: Allow tolerance in UHD sample rate selection
We're performance floating point comparisons so allow a
10 Hz offset when UHD does not return an exact sample rate;
Signed-off-by: Thomas Tsou <tom@tsou.cc>
Diffstat (limited to 'Transceiver52M/UHDDevice.cpp')
-rw-r--r-- | Transceiver52M/UHDDevice.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp index 890fd20..101363d 100644 --- a/Transceiver52M/UHDDevice.cpp +++ b/Transceiver52M/UHDDevice.cpp @@ -406,6 +406,9 @@ int uhd_device::set_master_clk(double clk_rate) int uhd_device::set_rates(double rate) { + double offset_limit = 10.0; + double tx_offset, rx_offset; + // B100 is the only device where we set FPGA clocking if (dev_type == B100) { if (set_master_clk(B100_CLK_RT) < 0) @@ -417,14 +420,14 @@ int uhd_device::set_rates(double rate) usrp_dev->set_rx_rate(rate); actual_smpl_rt = usrp_dev->get_tx_rate(); - if (actual_smpl_rt != rate) { + tx_offset = actual_smpl_rt - rate; + rx_offset = usrp_dev->get_rx_rate() - rate; + if ((tx_offset > offset_limit) || (rx_offset > offset_limit)) { LOG(ALERT) << "Actual sample rate differs from desired rate"; + LOG(ALERT) << "Tx/Rx (" << actual_smpl_rt << "/" + << usrp_dev->get_rx_rate() << ")"; return -1; } - if (usrp_dev->get_rx_rate() != actual_smpl_rt) { - LOG(ALERT) << "Transmit and receive sample rates do not match"; - return -1.0; - } return 0; } |