summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-digital/grc/digital_corr_est_cc.xml9
-rw-r--r--gr-digital/include/gnuradio/digital/corr_est_cc.h6
-rw-r--r--gr-digital/lib/corr_est_cc_impl.cc73
-rw-r--r--gr-digital/lib/corr_est_cc_impl.h13
4 files changed, 87 insertions, 14 deletions
diff --git a/gr-digital/grc/digital_corr_est_cc.xml b/gr-digital/grc/digital_corr_est_cc.xml
index d687cef67d..cb345e933f 100644
--- a/gr-digital/grc/digital_corr_est_cc.xml
+++ b/gr-digital/grc/digital_corr_est_cc.xml
@@ -4,35 +4,44 @@
<key>digital_corr_est_cc</key>
<import>from gnuradio import digital</import>
<make>digital.corr_est_cc($symbols, $sps, $mark_delay, $threshold)</make>
+ <callback>set_mark_delay($mark_delay)</callback>
+ <callback>set_theshold($threshold)</callback>
+
<param>
<name>Symbols</name>
<key>symbols</key>
<type>complex_vector</type>
</param>
+
<param>
<name>Samples per Symbol</name>
<key>sps</key>
<type>float</type>
</param>
+
<param>
<name>Tag marking delay</name>
<key>mark_delay</key>
<type>int</type>
</param>
+
<param>
<name>Threshold</name>
<key>threshold</key>
<value>0.9</value>
<type>float</type>
</param>
+
<sink>
<name>in</name>
<type>complex</type>
</sink>
+
<source>
<name>out</name>
<type>complex</type>
</source>
+
<source>
<name>corr</name>
<type>complex</type>
diff --git a/gr-digital/include/gnuradio/digital/corr_est_cc.h b/gr-digital/include/gnuradio/digital/corr_est_cc.h
index 0d432ba409..e8211cf60b 100644
--- a/gr-digital/include/gnuradio/digital/corr_est_cc.h
+++ b/gr-digital/include/gnuradio/digital/corr_est_cc.h
@@ -104,6 +104,12 @@ namespace gr {
virtual std::vector<gr_complex> symbols() const = 0;
virtual void set_symbols(const std::vector<gr_complex> &symbols) = 0;
+
+ virtual unsigned int mark_delay() const = 0;
+ virtual void set_mark_delay(unsigned int mark_delay) = 0;
+
+ virtual float threshold() const = 0;
+ virtual void set_threshold(float threshold) = 0;
};
} // namespace digital
diff --git a/gr-digital/lib/corr_est_cc_impl.cc b/gr-digital/lib/corr_est_cc_impl.cc
index 0d2470b678..ac753fbba5 100644
--- a/gr-digital/lib/corr_est_cc_impl.cc
+++ b/gr-digital/lib/corr_est_cc_impl.cc
@@ -62,16 +62,8 @@ namespace gr {
}
std::reverse(d_symbols.begin(), d_symbols.end());
- d_mark_delay = mark_delay >= d_symbols.size() ? d_symbols.size() - 1
- : mark_delay;
-
- // Compute a correlation threshold.
- // Compute the value of the discrete autocorrelation of the matched
- // filter with offset 0 (aka the autocorrelation peak).
- float corr = 0;
- for(size_t i = 0; i < d_symbols.size(); i++)
- corr += abs(d_symbols[i]*conj(d_symbols[i]));
- d_thresh = threshold*corr*corr;
+ set_mark_delay(mark_delay);
+ set_threshold(threshold);
// Correlation filter
d_filter = new kernel::fft_filter_ccc(1, d_symbols);
@@ -157,8 +149,65 @@ namespace gr {
declare_sample_delay(1, 0);
declare_sample_delay(0, d_symbols.size());
- d_mark_delay = d_mark_delay >= d_symbols.size() ? d_symbols.size()-1
- : d_mark_delay;
+ _set_mark_delay(d_stashed_mark_delay);
+ _set_threshold(d_stashed_threshold);
+ }
+
+ unsigned int
+ corr_est_cc_impl::mark_delay() const
+ {
+ return d_mark_delay;
+ }
+
+ void
+ corr_est_cc_impl::_set_mark_delay(unsigned int mark_delay)
+ {
+ d_stashed_mark_delay = mark_delay;
+
+ if(mark_delay >= d_symbols.size()) {
+ d_mark_delay = d_symbols.size()-1;
+ GR_LOG_WARN(d_logger, boost::format("set_mark_delay: asked for %1% but due "
+ "to the symbol size constraints, "
+ "mark delay set to %2%.") \
+ % mark_delay % d_mark_delay);
+ }
+ else {
+ d_mark_delay = mark_delay;
+ }
+ }
+
+ void
+ corr_est_cc_impl::set_mark_delay(unsigned int mark_delay)
+ {
+ gr::thread::scoped_lock lock(d_setlock);
+ _set_mark_delay(mark_delay);
+ }
+
+ float
+ corr_est_cc_impl::threshold() const
+ {
+ return d_thresh;
+ }
+
+ void
+ corr_est_cc_impl::_set_threshold(float threshold)
+ {
+ d_stashed_threshold = threshold;
+
+ // Compute a correlation threshold.
+ // Compute the value of the discrete autocorrelation of the matched
+ // filter with offset 0 (aka the autocorrelation peak).
+ float corr = 0;
+ for(size_t i = 0; i < d_symbols.size(); i++)
+ corr += abs(d_symbols[i]*conj(d_symbols[i]));
+ d_thresh = threshold*corr*corr;
+ }
+
+ void
+ corr_est_cc_impl::set_threshold(float threshold)
+ {
+ gr::thread::scoped_lock lock(d_setlock);
+ _set_threshold(threshold);
}
int
diff --git a/gr-digital/lib/corr_est_cc_impl.h b/gr-digital/lib/corr_est_cc_impl.h
index 83b5db60e1..6e8dd17083 100644
--- a/gr-digital/lib/corr_est_cc_impl.h
+++ b/gr-digital/lib/corr_est_cc_impl.h
@@ -37,13 +37,16 @@ namespace gr {
pmt::pmt_t d_src_id;
std::vector<gr_complex> d_symbols;
float d_sps;
- unsigned int d_mark_delay;
- float d_thresh;
+ unsigned int d_mark_delay, d_stashed_mark_delay;
+ float d_thresh, d_stashed_threshold;
kernel::fft_filter_ccc *d_filter;
gr_complex *d_corr;
float *d_corr_mag;
+ void _set_mark_delay(unsigned int mark_delay);
+ void _set_threshold(float threshold);
+
public:
corr_est_cc_impl(const std::vector<gr_complex> &symbols,
float sps, unsigned int mark_delay,
@@ -53,6 +56,12 @@ namespace gr {
std::vector<gr_complex> symbols() const;
void set_symbols(const std::vector<gr_complex> &symbols);
+ unsigned int mark_delay() const;
+ void set_mark_delay(unsigned int mark_delay);
+
+ float threshold() const;
+ void set_threshold(float threshold);
+
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);