summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/lib/uhd_mimo_sink.cc6
-rw-r--r--gr-uhd/lib/uhd_mimo_source.cc6
-rw-r--r--gr-uhd/lib/uhd_simple_sink.cc6
-rw-r--r--gr-uhd/lib/uhd_simple_source.cc6
-rw-r--r--gr-uhd/lib/utils.cc25
-rw-r--r--gr-uhd/lib/utils.h14
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 */