aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri Stolnikov <horiz0n@gmx.net>2014-05-03 18:15:22 +0200
committerDimitri Stolnikov <horiz0n@gmx.net>2014-05-03 23:40:57 +0200
commit8ee05d31969ceefefb56f3ac078390f7ff6b6887 (patch)
tree034342c7776e0b78bf8e16232799b06f58836799
parentac95af24fa633e50b1c8ab88664c5d2663ea7b0b (diff)
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.
-rw-r--r--lib/uhd/uhd_sink_c.cc12
-rw-r--r--lib/uhd/uhd_source_c.cc46
2 files changed, 41 insertions, 17 deletions
diff --git a/lib/uhd/uhd_sink_c.cc b/lib/uhd/uhd_sink_c.cc
index c043e56..39abd0d 100644
--- a/lib/uhd/uhd_sink_c.cc
+++ b/lib/uhd/uhd_sink_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 )
diff --git a/lib/uhd/uhd_source_c.cc b/lib/uhd/uhd_source_c.cc
index 54e0d4b..c41f0d3 100644
--- a/lib/uhd/uhd_source_c.cc
+++ b/lib/uhd/uhd_source_c.cc
@@ -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 )