Transceiver52M: Set UHD rates before creating streamers
Recent versions of UHD require setting the sample rate before creating
streamers otherwise the following exception occurs.
Boost_105300; UHD_003.007.000-0-g7fef199d
terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::math::rounding_error> >'
what(): Error in function boost::math::round<d>(d): Value -nan can not be represented in the target integer type.
Signed-off-by: Thomas Tsou <tom@tsou.cc>
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index 3e1f0de..875fe47 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -642,18 +642,6 @@
if (extref)
usrp_dev->set_clock_source("external");
- // Create TX and RX streamers
- uhd::stream_args_t stream_args("sc16");
- for (size_t i = 0; i < chans; i++)
- stream_args.channels.push_back(i);
-
- 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 = tx_stream->get_max_num_samps();
- rx_spp = rx_stream->get_max_num_samps();
-
// Set rates
double _rx_rate;
double _tx_rate = select_rate(dev_type, sps);
@@ -667,6 +655,18 @@
if (set_rates(_tx_rate, _rx_rate) < 0)
return -1;
+ /* Create TX and RX streamers */
+ uhd::stream_args_t stream_args("sc16");
+ for (size_t i = 0; i < chans; i++)
+ stream_args.channels.push_back(i);
+
+ 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 = tx_stream->get_max_num_samps();
+ rx_spp = rx_stream->get_max_num_samps();
+
// Create receive buffer
size_t buf_len = SAMPLE_BUF_SZ / sizeof(uint32_t);
for (size_t i = 0; i < rx_buffers.size(); i++)