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.
This commit is contained in:
Jon Szymaniak 2014-05-05 21:58:57 -04:00 committed by Dimitri Stolnikov
parent 00b579532c
commit c65d205d3b
1 changed files with 17 additions and 4 deletions

View File

@ -287,10 +287,23 @@ void bladerf_common::init(dict_t &dict, bladerf_module module)
throw std::runtime_error( oss.str() ); throw std::runtime_error( oss.str() );
} }
if ( dict.count("loopback") ) if ( module == BLADERF_MODULE_RX )
set_loopback_mode( dict["loopback"] ); {
else if ( dict.count("loopback") )
set_loopback_mode( "none" ); 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 */ /* Show some info about the device we've opened */