From e6701ca6215fd32f7d3d32ec7610008c5fbe56e2 Mon Sep 17 00:00:00 2001 From: Dimitri Stolnikov Date: Sat, 3 May 2014 18:15:22 +0200 Subject: [PATCH] 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. --- lib/uhd/uhd_sink_c.cc | 12 +++++++++-- lib/uhd/uhd_source_c.cc | 46 +++++++++++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/lib/uhd/uhd_sink_c.cc b/lib/uhd/uhd_sink_c.cc index d988926..edbdc6d 100644 --- a/lib/uhd/uhd_sink_c.cc +++ b/lib/uhd/uhd_sink_c.cc @@ -387,12 +387,20 @@ std::string uhd_sink_c::get_antenna( size_t chan ) void uhd_sink_c::set_dc_offset( const std::complex &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 &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 ) diff --git a/lib/uhd/uhd_source_c.cc b/lib/uhd/uhd_source_c.cc index 0fe31a4..8d6c0a7 100644 --- a/lib/uhd/uhd_source_c.cc +++ b/lib/uhd/uhd_source_c.cc @@ -385,35 +385,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_c::DCOffsetOff == mode ) { - _src->set_auto_dc_offset( false, chan ); - _src->set_dc_offset( std::complex(0.0, 0.0), chan ); /* uhd default */ - } else if ( osmosdr_source_c::DCOffsetManual == mode ) { - _src->set_auto_dc_offset( false, chan ); - } else if ( osmosdr_source_c::DCOffsetAutomatic == mode ) { - _src->set_auto_dc_offset( true, chan ); + try { + if ( osmosdr_source_c::DCOffsetOff == mode ) { + _src->set_auto_dc_offset( false, chan ); + _src->set_dc_offset( std::complex(0.0, 0.0), chan ); /* uhd default */ + } else if ( osmosdr_source_c::DCOffsetManual == mode ) { + _src->set_auto_dc_offset( false, chan ); + } else if ( osmosdr_source_c::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 &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_c::IQBalanceOff == mode ) { - _src->set_iq_balance( std::complex(0.0, 0.0), chan ); /* uhd default */ - } else if ( osmosdr_source_c::IQBalanceManual == mode ) { - /* nothing to do */ - } else if ( osmosdr_source_c::IQBalanceAutomatic == mode ) { - throw std::runtime_error("Automatic IQ imbalance correction not implemented"); + try { + if ( osmosdr_source_c::IQBalanceOff == mode ) { + _src->set_iq_balance( std::complex(0.0, 0.0), chan ); /* uhd default */ + } else if ( osmosdr_source_c::IQBalanceManual == mode ) { + /* nothing to do */ + } else if ( osmosdr_source_c::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 &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 )