From c65d205d3b7cc734f97284b66054e16c90886df2 Mon Sep 17 00:00:00 2001 From: Jon Szymaniak Date: Mon, 5 May 2014 21:58:57 -0400 Subject: [PATCH] bladerf: Accept 'loopback' parameter only on a source To alleviate some confusion (described below), the 'loopback' parameter may now only be applied to a bladeRF source. A warning will be printed if it is applied to a sink. This is intended to help users avoid the case where two different loopback options are applied to the same device. In this case, the loopback setting on whichever initializes last will be applied. This, coupled with the fact that not specifying a loopback defaults to loopback=none, yields rather unintuitive behavior. --- lib/bladerf/bladerf_common.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/bladerf/bladerf_common.cc b/lib/bladerf/bladerf_common.cc index 7fea7bb..7516020 100644 --- a/lib/bladerf/bladerf_common.cc +++ b/lib/bladerf/bladerf_common.cc @@ -287,10 +287,23 @@ void bladerf_common::init(dict_t &dict, bladerf_module module) throw std::runtime_error( oss.str() ); } - if ( dict.count("loopback") ) - set_loopback_mode( dict["loopback"] ); - else - set_loopback_mode( "none" ); + if ( module == BLADERF_MODULE_RX ) + { + if ( dict.count("loopback") ) + set_loopback_mode( dict["loopback"] ); + else + set_loopback_mode( "none" ); + } + else if ( module == BLADERF_MODULE_TX && dict.count("loopback") ) + { + std::cerr << _pfx + << "Warning: 'loopback' has been specified on a bladeRF sink, " + "and will have no effect. This parameter should be " + "specified on the associated bladeRF source." + << std::endl; + + + } /* Show some info about the device we've opened */