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.
This commit is contained in:
Dimitri Stolnikov 2014-05-03 18:15:22 +02:00
parent ac95af24fa
commit 8ee05d3196
2 changed files with 41 additions and 17 deletions

View File

@ -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 )
{
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 )
{
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 )

View File

@ -277,6 +277,7 @@ std::string uhd_source_c::get_antenna( size_t chan )
void uhd_source_c::set_dc_offset_mode( int mode, size_t 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 */
@ -285,15 +286,23 @@ void uhd_source_c::set_dc_offset_mode( int mode, size_t 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 )
{
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 )
{
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 ) {
@ -301,11 +310,18 @@ void uhd_source_c::set_iq_balance_mode( int mode, size_t chan )
} 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 )
{
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 )