From 2b48784c614e6ef2db5af0f06493359025eb5262 Mon Sep 17 00:00:00 2001 From: Thomas Tsou Date: Fri, 5 Apr 2013 15:11:35 -0400 Subject: Transceiver52M: Update to UHD streamer interface This patch is long overdue and can now be merged after better understanding of timestamp stability issues. UHD tick / timespec conversions were generally used with the streamer interface, though these calls are actually independent change sets. The combination would lead to internal rounding errors and a timing drift most notably on B100 running at GSM symbol rate multiples. There are no known issues, however, with the streamer code itself. The aforementioned issue was discovered in test code only, which was never merged to mainline. Signed-off-by: Thomas Tsou --- Transceiver52M/UHDDevice.cpp | 43 +++++++++++++++---------------------------- configure.ac | 2 +- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp index a6ac8e6..65bf345 100644 --- a/Transceiver52M/UHDDevice.cpp +++ b/Transceiver52M/UHDDevice.cpp @@ -210,6 +210,8 @@ public: private: uhd::usrp::multi_usrp::sptr usrp_dev; + uhd::tx_streamer::sptr tx_stream; + uhd::rx_streamer::sptr rx_stream; enum busType bus; double desired_smpl_rt, actual_smpl_rt; @@ -316,16 +318,8 @@ void uhd_device::init_gains() void uhd_device::set_ref_clk(bool ext_clk) { - uhd::clock_config_t clk_cfg; - - clk_cfg.pps_source = uhd::clock_config_t::PPS_SMA; - if (ext_clk) - clk_cfg.ref_source = uhd::clock_config_t::REF_SMA; - else - clk_cfg.ref_source = uhd::clock_config_t::REF_INT; - - usrp_dev->set_clock_config(clk_cfg); + usrp_dev->set_clock_source("external"); return; } @@ -477,10 +471,14 @@ bool uhd_device::open(const std::string &args) #ifdef EXTREF set_ref_clk(true); #endif + // Create TX and RX streamers + uhd::stream_args_t stream_args("sc16"); + tx_stream = usrp_dev->get_tx_stream(stream_args); + rx_stream = usrp_dev->get_rx_stream(stream_args); // 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(); + tx_spp = tx_stream->get_max_num_samps(); + rx_spp = rx_stream->get_max_num_samps(); // Set rates actual_smpl_rt = set_rates(desired_smpl_rt); @@ -514,14 +512,8 @@ bool uhd_device::flush_recv(size_t num_pkts) timeout = .01; for (size_t i = 0; i < num_pkts; i++) { - num_smpls = usrp_dev->get_device()->recv( - buff, - rx_spp, - md, - uhd::io_type_t::COMPLEX_INT16, - uhd::device::RECV_MODE_ONE_PACKET, - timeout); - + num_smpls = rx_stream->recv(buff, rx_spp, md, + timeout, true); if (!num_smpls) { switch (md.error_code) { case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT: @@ -673,13 +665,12 @@ int uhd_device::readSamples(short *buf, int len, bool *overrun, // Receive samples from the usrp until we have enough while (rx_smpl_buf->avail_smpls(timestamp) < len) { - size_t num_smpls = usrp_dev->get_device()->recv( + size_t num_smpls = rx_stream->recv( (void*)pkt_buf, rx_spp, metadata, - uhd::io_type_t::COMPLEX_INT16, - uhd::device::RECV_MODE_ONE_PACKET); - + 0.1, + true); rx_pkt_cnt++; // Check for errors @@ -757,11 +748,7 @@ int uhd_device::writeSamples(short *buf, int len, bool *underrun, } } - size_t num_smpls = usrp_dev->get_device()->send(buf, - len, - metadata, - uhd::io_type_t::COMPLEX_INT16, - uhd::device::SEND_MODE_FULL_BUFF); + size_t num_smpls = tx_stream->send(buf, len, metadata); if (num_smpls != (unsigned) len) { LOG(ALERT) << "UHD: Device send timed out"; diff --git a/configure.ac b/configure.ac index 03028c2..1c96f51 100644 --- a/configure.ac +++ b/configure.ac @@ -98,7 +98,7 @@ AS_IF([test "x$with_usrp1" = "xyes"], [ ]) AS_IF([test "x$with_uhd" = "xyes"],[ - PKG_CHECK_MODULES(UHD, uhd >= 003.002.000) + PKG_CHECK_MODULES(UHD, uhd >= 003.004.000) AC_DEFINE(USE_UHD, 1, Define to 1 if using UHD) ]) -- cgit v1.2.3