From fda11abe6c3e58b80eac422dbcda3c1f55a6dbcc Mon Sep 17 00:00:00 2001 From: Thomas Tsou Date: Fri, 5 Aug 2011 12:26:51 -0700 Subject: [PATCH] uhd: verify setting of master clock rate If the master clock rate fails to set - this basically only happens when the wrong transceiver is choosen for the particular device - the error is fatal and the transceiver should exit. The clock rate setting was previously never verified. Signed-off-by: Thomas Tsou --- public-trunk/Transceiver/UHDDevice.cpp | 23 +++++++++++++++-------- public-trunk/Transceiver52M/UHDDevice.cpp | 23 +++++++++++++++-------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/public-trunk/Transceiver/UHDDevice.cpp b/public-trunk/Transceiver/UHDDevice.cpp index d8fa49e..d2f47fe 100644 --- a/public-trunk/Transceiver/UHDDevice.cpp +++ b/public-trunk/Transceiver/UHDDevice.cpp @@ -292,22 +292,32 @@ void uhd_device::set_ref_clk(bool ext_clk) double uhd_device::set_rates(double rate) { - double actual_rate; + double actual_rt, actual_clk_rt; + // Set master clock rate + usrp_dev->set_master_clock_rate(master_clk_rt); + actual_clk_rt = usrp_dev->get_master_clock_rate(); + + if (actual_clk_rt != master_clk_rt) { + LOG(ERROR) << "Failed to set master clock rate"; + return -1.0; + } + + // Set sample rates usrp_dev->set_tx_rate(rate); usrp_dev->set_rx_rate(rate); - actual_rate = usrp_dev->get_tx_rate(); + actual_rt = usrp_dev->get_tx_rate(); - if (actual_rate != rate) { + if (actual_rt != rate) { LOG(ERROR) << "Actual sample rate differs from desired rate"; return -1.0; } - if (usrp_dev->get_rx_rate() != actual_rate) { + if (usrp_dev->get_rx_rate() != actual_rt) { LOG(ERROR) << "Transmit and receive sample rates do not match"; return -1.0; } - return actual_rate; + return actual_rt; } double uhd_device::setTxGain(double db) @@ -345,9 +355,6 @@ bool uhd_device::open() return false; } - // Set master clock rate - usrp_dev->set_master_clock_rate(master_clk_rt); - // Number of samples per over-the-wire packet tx_spp = usrp_dev->get_device()->get_max_send_samps_per_packet(); rx_spp = usrp_dev->get_device()->get_max_recv_samps_per_packet(); diff --git a/public-trunk/Transceiver52M/UHDDevice.cpp b/public-trunk/Transceiver52M/UHDDevice.cpp index dc265cb..f319ba6 100644 --- a/public-trunk/Transceiver52M/UHDDevice.cpp +++ b/public-trunk/Transceiver52M/UHDDevice.cpp @@ -292,22 +292,32 @@ void uhd_device::set_ref_clk(bool ext_clk) double uhd_device::set_rates(double rate) { - double actual_rate; + double actual_rt, actual_clk_rt; + // Set master clock rate + usrp_dev->set_master_clock_rate(master_clk_rt); + actual_clk_rt = usrp_dev->get_master_clock_rate(); + + if (actual_clk_rt != master_clk_rt) { + LOG(ERROR) << "Failed to set master clock rate"; + return -1.0; + } + + // Set sample rates usrp_dev->set_tx_rate(rate); usrp_dev->set_rx_rate(rate); - actual_rate = usrp_dev->get_tx_rate(); + actual_rt = usrp_dev->get_tx_rate(); - if (actual_rate != rate) { + if (actual_rt != rate) { LOG(ERROR) << "Actual sample rate differs from desired rate"; return -1.0; } - if (usrp_dev->get_rx_rate() != actual_rate) { + if (usrp_dev->get_rx_rate() != actual_rt) { LOG(ERROR) << "Transmit and receive sample rates do not match"; return -1.0; } - return actual_rate; + return actual_rt; } double uhd_device::setTxGain(double db) @@ -345,9 +355,6 @@ bool uhd_device::open() return false; } - // Set master clock rate - usrp_dev->set_master_clock_rate(master_clk_rt); - // Number of samples per over-the-wire packet tx_spp = usrp_dev->get_device()->get_max_send_samps_per_packet(); rx_spp = usrp_dev->get_device()->get_max_recv_samps_per_packet();