uhd: catch exceptions from dc offset & iq imbalance setters

since dc offset / iq imbalance is not implemented for recent USRPs this
might cause undesired behavior in GRC. As a workaround we do not pass
them to the caller but print them to the stderr.
wip-signat
Dimitri Stolnikov 9 years ago
parent ac95af24fa
commit 8ee05d3196
  1. 12
      lib/uhd/uhd_sink_c.cc
  2. 46
      lib/uhd/uhd_source_c.cc

@ -276,12 +276,20 @@ std::string uhd_sink_c::get_antenna( size_t chan )
void uhd_sink_c::set_dc_offset( const std::complex<double> &offset, size_t chan )
{
_snk->set_dc_offset( offset, chan );
try {
_snk->set_dc_offset( offset, chan );
} catch ( const std::exception &ex ) {
std::cerr << __FUNCTION__ << ": " << ex.what() << std::endl;
}
}
void uhd_sink_c::set_iq_balance( const std::complex<double> &balance, size_t chan )
{
_snk->set_iq_balance( balance, chan );
try {
_snk->set_iq_balance( balance, chan );
} catch ( const std::exception &ex ) {
std::cerr << __FUNCTION__ << ": " << ex.what() << std::endl;
}
}
double uhd_sink_c::set_bandwidth( double bandwidth, size_t chan )

@ -277,35 +277,51 @@ std::string uhd_source_c::get_antenna( size_t chan )
void uhd_source_c::set_dc_offset_mode( int mode, size_t chan )
{
if ( osmosdr::source::DCOffsetOff == mode ) {
_src->set_auto_dc_offset( false, chan );
_src->set_dc_offset( std::complex<double>(0.0, 0.0), chan ); /* uhd default */
} else if ( osmosdr::source::DCOffsetManual == mode ) {
_src->set_auto_dc_offset( false, chan );
} else if ( osmosdr::source::DCOffsetAutomatic == mode ) {
_src->set_auto_dc_offset( true, chan );
try {
if ( osmosdr::source::DCOffsetOff == mode ) {
_src->set_auto_dc_offset( false, chan );
_src->set_dc_offset( std::complex<double>(0.0, 0.0), chan ); /* uhd default */
} else if ( osmosdr::source::DCOffsetManual == mode ) {
_src->set_auto_dc_offset( false, chan );
} else if ( osmosdr::source::DCOffsetAutomatic == mode ) {
_src->set_auto_dc_offset( true, chan );
}
} catch ( const std::exception &ex ) {
std::cerr << __FUNCTION__ << ": " << ex.what() << std::endl;
}
}
void uhd_source_c::set_dc_offset( const std::complex<double> &offset, size_t chan )
{
_src->set_dc_offset( offset, chan );
try {
_src->set_dc_offset( offset, chan );
} catch ( const std::exception &ex ) {
std::cerr << __FUNCTION__ << ": " << ex.what() << std::endl;
}
}
void uhd_source_c::set_iq_balance_mode( int mode, size_t chan )
{
if ( osmosdr::source::IQBalanceOff == mode ) {
_src->set_iq_balance( std::complex<double>(0.0, 0.0), chan ); /* uhd default */
} else if ( osmosdr::source::IQBalanceManual == mode ) {
/* nothing to do */
} else if ( osmosdr::source::IQBalanceAutomatic == mode ) {
throw std::runtime_error("Automatic IQ imbalance correction not implemented");
try {
if ( osmosdr::source::IQBalanceOff == mode ) {
_src->set_iq_balance( std::complex<double>(0.0, 0.0), chan ); /* uhd default */
} else if ( osmosdr::source::IQBalanceManual == mode ) {
/* nothing to do */
} else if ( osmosdr::source::IQBalanceAutomatic == mode ) {
throw std::runtime_error("Automatic IQ imbalance correction not implemented");
}
} catch ( const std::exception &ex ) {
std::cerr << __FUNCTION__ << ": " << ex.what() << std::endl;
}
}
void uhd_source_c::set_iq_balance( const std::complex<double> &balance, size_t chan )
{
_src->set_iq_balance( balance, chan );
try {
_src->set_iq_balance( balance, chan );
} catch ( const std::exception &ex ) {
std::cerr << __FUNCTION__ << ": " << ex.what() << std::endl;
}
}
double uhd_source_c::set_bandwidth( double bandwidth, size_t chan )

Loading…
Cancel
Save