summaryrefslogtreecommitdiff
path: root/gr-digital
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital')
-rw-r--r--gr-digital/include/digital_probe_mpsk_snr_est_c.h28
-rw-r--r--gr-digital/lib/digital_probe_mpsk_snr_est_c.cc38
-rwxr-xr-xgr-digital/python/qa_mpsk_snr_est.py3
-rw-r--r--gr-digital/swig/digital_probe_mpsk_snr_est_c.i4
4 files changed, 62 insertions, 11 deletions
diff --git a/gr-digital/include/digital_probe_mpsk_snr_est_c.h b/gr-digital/include/digital_probe_mpsk_snr_est_c.h
index 2b03765db..a78e90412 100644
--- a/gr-digital/include/digital_probe_mpsk_snr_est_c.h
+++ b/gr-digital/include/digital_probe_mpsk_snr_est_c.h
@@ -30,7 +30,9 @@ class digital_probe_mpsk_snr_est_c;
typedef boost::shared_ptr<digital_probe_mpsk_snr_est_c> digital_probe_mpsk_snr_est_c_sptr;
DIGITAL_API digital_probe_mpsk_snr_est_c_sptr
-digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, double alpha);
+digital_make_probe_mpsk_snr_est_c(snr_est_type_t type,
+ int msg_nsamples=10000,
+ double alpha=0.001);
//! \brief A probe for computing SNR of a signal.
/*! \ingroup snr_blk
@@ -50,23 +52,33 @@ class DIGITAL_API digital_probe_mpsk_snr_est_c : public gr_sync_block
{
private:
snr_est_type_t d_type;
+ int d_nsamples, d_count;
double d_alpha;
digital_impl_mpsk_snr_est *d_snr_est;
+ //d_key is the message name, 'snr'
+ pmt::pmt_t d_key;
+
/*! Factory function returning shared pointer of this class
*
* Parameters:
*
- * \li \p type: the type of estimator to use \ref ref_snr_est_types
+ * \param type: the type of estimator to use \ref ref_snr_est_types
* "snr_est_type_t" for details about the available types.
- * \li \p alpha: the update rate of internal running average
+ * \param msg_nsamples: [not implemented yet] after this many
+ * samples, a message containing the SNR (key='snr') will be sent
+ * \param alpha: the update rate of internal running average
* calculations.
*/
friend DIGITAL_API digital_probe_mpsk_snr_est_c_sptr
- digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, double alpha);
+ digital_make_probe_mpsk_snr_est_c(snr_est_type_t type,
+ int msg_nsamples,
+ double alpha);
//! Private constructor
- digital_probe_mpsk_snr_est_c(snr_est_type_t type, double alpha);
+ digital_probe_mpsk_snr_est_c(snr_est_type_t type,
+ int msg_nsamples,
+ double alpha);
public:
@@ -82,12 +94,18 @@ public:
//! Return the type of estimator in use
snr_est_type_t type() const;
+ //! Return how many samples between SNR messages
+ int msg_nsample() const;
+
//! Get the running-average coefficient
double alpha() const;
//! Set type of estimator to use
void set_type(snr_est_type_t t);
+ //! Set the number of samples between SNR messages
+ void set_msg_nsample(int n);
+
//! Set the running-average coefficient
void set_alpha(double alpha);
};
diff --git a/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc b/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc
index 3d97ff899..5cdfea96d 100644
--- a/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc
+++ b/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc
@@ -30,14 +30,17 @@
digital_probe_mpsk_snr_est_c_sptr
digital_make_probe_mpsk_snr_est_c(snr_est_type_t type,
+ int msg_nsamples,
double alpha)
{
return gnuradio::get_initial_sptr(
- new digital_probe_mpsk_snr_est_c(type, alpha));
+ new digital_probe_mpsk_snr_est_c(type, msg_nsamples, alpha));
}
digital_probe_mpsk_snr_est_c::digital_probe_mpsk_snr_est_c(
- snr_est_type_t type, double alpha)
+ snr_est_type_t type,
+ int msg_nsamples,
+ double alpha)
: gr_sync_block ("probe_mpsk_snr_est_c",
gr_make_io_signature(1, 1, sizeof(gr_complex)),
gr_make_io_signature(0, 0, 0))
@@ -45,12 +48,16 @@ digital_probe_mpsk_snr_est_c::digital_probe_mpsk_snr_est_c(
d_snr_est = NULL;
d_type = type;
+ d_nsamples = msg_nsamples;
+ d_count = 0;
set_alpha(alpha);
set_type(type);
// at least 1 estimator has to look back
set_history(2);
+
+ d_key = pmt::pmt_string_to_symbol("snr");
}
digital_probe_mpsk_snr_est_c::~digital_probe_mpsk_snr_est_c()
@@ -83,6 +90,12 @@ digital_probe_mpsk_snr_est_c::type() const
return d_type;
}
+int
+digital_probe_mpsk_snr_est_c::msg_nsample() const
+{
+ return d_nsamples;
+}
+
double
digital_probe_mpsk_snr_est_c::alpha() const
{
@@ -116,9 +129,24 @@ digital_probe_mpsk_snr_est_c::set_type(snr_est_type_t t)
}
void
+digital_probe_mpsk_snr_est_c::set_msg_nsample(int n)
+{
+ if(n > 0) {
+ d_nsamples = n;
+ d_count = 0; // reset state
+ }
+ else
+ throw std::invalid_argument("digital_probe_mpsk_snr_est_c: msg_nsamples can't be <= 0\n");
+}
+
+void
digital_probe_mpsk_snr_est_c::set_alpha(double alpha)
{
- d_alpha = alpha;
- if(d_snr_est)
- d_snr_est->set_alpha(d_alpha);
+ if((alpha >= 0) && (alpha <= 1.0)) {
+ d_alpha = alpha;
+ if(d_snr_est)
+ d_snr_est->set_alpha(d_alpha);
+ }
+ else
+ throw std::invalid_argument("digital_probe_mpsk_snr_est_c: alpha must be in [0,1]\n");
}
diff --git a/gr-digital/python/qa_mpsk_snr_est.py b/gr-digital/python/qa_mpsk_snr_est.py
index e3abff908..d392567bf 100755
--- a/gr-digital/python/qa_mpsk_snr_est.py
+++ b/gr-digital/python/qa_mpsk_snr_est.py
@@ -106,8 +106,9 @@ class test_mpsk_snr_est (gr_unittest.TestCase):
src = gr.vector_source_c (src_data)
+ N = 10000
alpha = 0.001
- op = digital.probe_mpsk_snr_est_c (digital.SNR_EST_M2M4, alpha)
+ op = digital.probe_mpsk_snr_est_c (digital.SNR_EST_M2M4, N, alpha)
tb = gr.top_block ()
tb.connect (src, op)
diff --git a/gr-digital/swig/digital_probe_mpsk_snr_est_c.i b/gr-digital/swig/digital_probe_mpsk_snr_est_c.i
index fbe04cec2..93db4127a 100644
--- a/gr-digital/swig/digital_probe_mpsk_snr_est_c.i
+++ b/gr-digital/swig/digital_probe_mpsk_snr_est_c.i
@@ -24,18 +24,22 @@ GR_SWIG_BLOCK_MAGIC(digital,probe_mpsk_snr_est_c);
digital_probe_mpsk_snr_est_c_sptr
digital_make_probe_mpsk_snr_est_c(snr_est_type_t type,
+ int msg_nsamples=10000,
double alpha=0.001);
class digital_probe_mpsk_snr_est_c : public gr_sync_block
{
private:
void digital_probe_mpsk_snr_est_c(snr_est_type_t type,
+ int msg_nsamples,
double alpha);
public:
double snr();
snr_est_type_t type() const;
+ int msg_nsample() const;
double alpha() const;
void set_type(snr_est_type_t t);
+ void set_msg_nsample(int n);
void set_alpha(double alpha);
};