From fbd6e1c98541d6ed5fa591755b3196c1594209c2 Mon Sep 17 00:00:00 2001 From: Thomas Tsou Date: Mon, 8 Apr 2013 19:05:50 -0400 Subject: 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 --- Transceiver52M/UHDDevice.cpp | 13 ++++++++----- 1 file 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; } -- cgit v1.2.3