diff options
author | Johnathan Corgan | 2010-07-22 17:34:20 -0700 |
---|---|---|
committer | Johnathan Corgan | 2010-07-22 17:34:20 -0700 |
commit | 566363ff8077c92a0899513bd27165be8d70f41b (patch) | |
tree | 4ab35fb549b3d439e8b8c881273b54e827723b14 | |
parent | b055c7b35144093aa31830bf891c18a9751beb86 (diff) | |
parent | c3c4303b9fa4987369e9641ab4206724da74f3b2 (diff) | |
download | gnuradio-566363ff8077c92a0899513bd27165be8d70f41b.tar.gz gnuradio-566363ff8077c92a0899513bd27165be8d70f41b.tar.bz2 gnuradio-566363ff8077c92a0899513bd27165be8d70f41b.zip |
Merge remote branch 'jblum/uhd' into next
* jblum/uhd:
uhd: better error messages for tune and set sample rate
-rw-r--r-- | gr-uhd/lib/uhd_mimo_sink.cc | 6 | ||||
-rw-r--r-- | gr-uhd/lib/uhd_mimo_source.cc | 6 | ||||
-rw-r--r-- | gr-uhd/lib/uhd_simple_sink.cc | 6 | ||||
-rw-r--r-- | gr-uhd/lib/uhd_simple_source.cc | 6 | ||||
-rw-r--r-- | gr-uhd/lib/utils.cc | 25 | ||||
-rw-r--r-- | gr-uhd/lib/utils.h | 14 |
6 files changed, 51 insertions, 12 deletions
diff --git a/gr-uhd/lib/uhd_mimo_sink.cc b/gr-uhd/lib/uhd_mimo_sink.cc index 43ec04164..95174522a 100644 --- a/gr-uhd/lib/uhd_mimo_sink.cc +++ b/gr-uhd/lib/uhd_mimo_sink.cc @@ -55,7 +55,7 @@ public: void set_samp_rate_all(double rate){ _dev->set_tx_rate_all(rate); - do_samp_rate_error_message(rate, get_samp_rate_all()); + do_samp_rate_error_message(rate, get_samp_rate_all(), "TX"); } double get_samp_rate_all(void){ @@ -63,7 +63,9 @@ public: } uhd::tune_result_t set_center_freq(size_t chan, double freq){ - return _dev->set_tx_freq(chan, freq); + uhd::tune_result_t tr = _dev->set_tx_freq(chan, freq); + do_tune_freq_error_message(freq, _dev->get_tx_freq(chan), "TX"); + return tr; } uhd::freq_range_t get_freq_range(size_t chan){ diff --git a/gr-uhd/lib/uhd_mimo_source.cc b/gr-uhd/lib/uhd_mimo_source.cc index 28bd1e109..b620a56fc 100644 --- a/gr-uhd/lib/uhd_mimo_source.cc +++ b/gr-uhd/lib/uhd_mimo_source.cc @@ -55,7 +55,7 @@ public: void set_samp_rate_all(double rate){ _dev->set_rx_rate_all(rate); - do_samp_rate_error_message(rate, get_samp_rate_all()); + do_samp_rate_error_message(rate, get_samp_rate_all(), "RX"); } double get_samp_rate_all(void){ @@ -63,7 +63,9 @@ public: } uhd::tune_result_t set_center_freq(size_t chan, double freq){ - return _dev->set_rx_freq(chan, freq); + uhd::tune_result_t tr = _dev->set_rx_freq(chan, freq); + do_tune_freq_error_message(freq, _dev->get_rx_freq(chan), "RX"); + return tr; } uhd::freq_range_t get_freq_range(size_t chan){ diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index d4bb7d437..9df6c8e02 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -52,7 +52,7 @@ public: void set_samp_rate(double rate){ _dev->set_tx_rate(rate); - do_samp_rate_error_message(rate, get_samp_rate()); + do_samp_rate_error_message(rate, get_samp_rate(), "TX"); } double get_samp_rate(void){ @@ -60,7 +60,9 @@ public: } uhd::tune_result_t set_center_freq(double freq){ - return _dev->set_tx_freq(freq); + uhd::tune_result_t tr = _dev->set_tx_freq(freq); + do_tune_freq_error_message(freq, _dev->get_tx_freq(), "TX"); + return tr; } uhd::freq_range_t get_freq_range(void){ diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index c734e9244..846c0faeb 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -53,7 +53,7 @@ public: void set_samp_rate(double rate){ _dev->set_rx_rate(rate); - do_samp_rate_error_message(rate, get_samp_rate()); + do_samp_rate_error_message(rate, get_samp_rate(), "RX"); } double get_samp_rate(void){ @@ -61,7 +61,9 @@ public: } uhd::tune_result_t set_center_freq(double freq){ - return _dev->set_rx_freq(freq); + uhd::tune_result_t tr = _dev->set_rx_freq(freq); + do_tune_freq_error_message(freq, _dev->get_rx_freq(), "RX"); + return tr; } uhd::freq_range_t get_freq_range(void){ diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc index ddc36eb99..5d40c4fff 100644 --- a/gr-uhd/lib/utils.cc +++ b/gr-uhd/lib/utils.cc @@ -25,13 +25,32 @@ #include <iostream> #include <cmath> -void do_samp_rate_error_message(double target_rate, double actual_rate){ +void do_samp_rate_error_message( + double target_rate, + double actual_rate, + const std::string &xx +){ static const double max_allowed_error = 1.0; //Sps if (std::abs(target_rate - actual_rate) > max_allowed_error){ std::cerr << boost::format( - "The hardware does not support the requested sample rate:\n" + "Warning: The hardware does not support the requested %s sample rate:\n" " Target sample rate: %f MSps\n" " Actual sample rate: %f MSps\n" - ) % (target_rate/1e6) % (actual_rate/1e6) << std::endl; + ) % xx % (target_rate/1e6) % (actual_rate/1e6) << std::endl; + } +} + +void do_tune_freq_error_message( + double target_freq, + double actual_freq, + const std::string &xx +){ + static const double max_allowed_error = 1.0; //Hz + if (std::abs(target_freq - actual_freq) > max_allowed_error){ + std::cerr << boost::format( + "Warning: The hardware does not support the requested %s frequency:\n" + " Target frequency: %f MHz\n" + " Actual frequency: %f MHz\n" + ) % xx % (target_freq/1e6) % (actual_freq/1e6) << std::endl; } } diff --git a/gr-uhd/lib/utils.h b/gr-uhd/lib/utils.h index cf349e5aa..4a05476bd 100644 --- a/gr-uhd/lib/utils.h +++ b/gr-uhd/lib/utils.h @@ -23,6 +23,18 @@ #ifndef INCLUDED_NOINST_UTILS_H #define INCLUDED_NOINST_UTILS_H -void do_samp_rate_error_message(double target_rate, double actual_rate); +#include <string> + +void do_samp_rate_error_message( + double target_rate, + double actual_rate, + const std::string &xx +); + +void do_tune_freq_error_message( + double target_freq, + double actual_freq, + const std::string &xx +); #endif /* INCLUDED_NOINST_UTILS_H */ |