commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/02: digital: adding output message ports


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/02: digital: adding output message ports for MPSK SNR probe block. Can be used to feed back SNR information to other blocks.
Date: Fri, 29 Aug 2014 20:50:31 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch master
in repository gnuradio.

commit 01c392335044b4ed68110da797bd6571a341f301
Author: Tom Rondeau <address@hidden>
Date:   Fri Aug 29 16:21:03 2014 -0400

    digital: adding output message ports for MPSK SNR probe block. Can be used 
to feed back SNR information to other blocks.
---
 gr-digital/grc/digital_probe_mpsk_snr_est_c.xml    | 15 +++++++
 .../gnuradio/digital/probe_mpsk_snr_est_c.h        | 28 +++++++++---
 gr-digital/lib/probe_mpsk_snr_est_c_impl.cc        | 50 +++++++++++++++++++---
 gr-digital/lib/probe_mpsk_snr_est_c_impl.h         | 20 ++++++---
 4 files changed, 94 insertions(+), 19 deletions(-)

diff --git a/gr-digital/grc/digital_probe_mpsk_snr_est_c.xml 
b/gr-digital/grc/digital_probe_mpsk_snr_est_c.xml
index 62c5fad..e49f7e7 100644
--- a/gr-digital/grc/digital_probe_mpsk_snr_est_c.xml
+++ b/gr-digital/grc/digital_probe_mpsk_snr_est_c.xml
@@ -49,4 +49,19 @@
                <name>in</name>
                <type>complex</type>
        </sink>
+       <source>
+               <name>snr</name>
+               <type>message</type>
+                <optional>1</optional>
+       </source>
+       <source>
+               <name>signal</name>
+               <type>message</type>
+                <optional>1</optional>
+       </source>
+       <source>
+               <name>noise</name>
+               <type>message</type>
+                <optional>1</optional>
+       </source>
 </block>
diff --git a/gr-digital/include/gnuradio/digital/probe_mpsk_snr_est_c.h 
b/gr-digital/include/gnuradio/digital/probe_mpsk_snr_est_c.h
index f78c767..615f1a9 100644
--- a/gr-digital/include/gnuradio/digital/probe_mpsk_snr_est_c.h
+++ b/gr-digital/include/gnuradio/digital/probe_mpsk_snr_est_c.h
@@ -1,19 +1,19 @@
 /* -*- c++ -*- */
 /*
  * Copyright 2011,2012 Free Software Foundation, Inc.
- * 
+ *
  * This file is part of GNU Radio
- * 
+ *
  * GNU Radio is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3, or (at your option)
  * any later version.
- * 
+ *
  * GNU Radio is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with GNU Radio; see the file COPYING.  If not, write to
  * the Free Software Foundation, Inc., 51 Franklin Street,
@@ -31,10 +31,10 @@ namespace gr {
   namespace digital {
 
     /*!
-     * \brief A probe for computing SNR of a signal.
+     * \brief A probe for computing SNR of a PSK signal.
      * \ingroup measurement_tools_blk
      *
-     * \details 
+     * \details
      * This is a probe block (a sink) that can be used to monitor and
      * retrieve estimations of the signal SNR. This probe is designed
      * for use with M-PSK signals especially. The type of estimator is
@@ -45,6 +45,16 @@ namespace gr {
      * estimators are designed and proven theoretically under AWGN
      * conditions; some amount of error should be assumed and/or
      * estimated for real channel conditions.
+     *
+     * The block has three output message ports that will emit a
+     * message every msg_samples number of samples. These message
+     * ports are:
+     * \li snr: the current SNR estimate (in dB)
+     * \li signal: the current signal power estimate (in dBx)
+     * \li noise: the current noise power estimate (in dBx)
+     *
+     * Some calibration is required to convert dBx of the signal and
+     * noise power estimates to real measurements, such as dBm.
      */
     class DIGITAL_API probe_mpsk_snr_est_c : virtual public sync_block
     {
@@ -70,6 +80,12 @@ namespace gr {
       //! Return the estimated signal-to-noise ratio in decibels
       virtual double snr() = 0;
 
+      //! Return the estimated signal power in decibels
+      virtual double signal() = 0;
+
+      //! Return the estimated noise power in decibels
+      virtual double noise() = 0;
+
       //! Return the type of estimator in use
       virtual snr_est_type_t type() const = 0;
 
diff --git a/gr-digital/lib/probe_mpsk_snr_est_c_impl.cc 
b/gr-digital/lib/probe_mpsk_snr_est_c_impl.cc
index 6fa7c1b..a788f95 100644
--- a/gr-digital/lib/probe_mpsk_snr_est_c_impl.cc
+++ b/gr-digital/lib/probe_mpsk_snr_est_c_impl.cc
@@ -1,19 +1,19 @@
 /* -*- c++ -*- */
 /*
  * Copyright 2011,2012 Free Software Foundation, Inc.
- * 
+ *
  * This file is part of GNU Radio
- * 
+ *
  * GNU Radio is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3, or (at your option)
  * any later version.
- * 
+ *
  * GNU Radio is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with GNU Radio; see the file COPYING.  If not, write to
  * the Free Software Foundation, Inc., 51 Franklin Street,
@@ -59,7 +59,13 @@ namespace gr {
       // at least 1 estimator has to look back
       set_history(2);
 
-      d_key = pmt::string_to_symbol("snr");
+      d_snr_port = pmt::string_to_symbol("snr");
+      d_signal_port = pmt::string_to_symbol("signal");
+      d_noise_port = pmt::string_to_symbol("noise");
+
+      message_port_register_out(d_snr_port);
+      message_port_register_out(d_signal_port);
+      message_port_register_out(d_noise_port);
     }
 
     probe_mpsk_snr_est_c_impl::~probe_mpsk_snr_est_c_impl()
@@ -74,7 +80,18 @@ namespace gr {
                                    gr_vector_void_star &output_items)
     {
       const gr_complex *in = (const gr_complex*)input_items[0];
-      return d_snr_est->update(noutput_items, in);
+      int n = d_snr_est->update(noutput_items, in);
+
+      d_count += noutput_items;
+      while(d_count > d_nsamples) {
+       // Post a message with the latest SNR data
+       message_port_pub(d_snr_port, pmt::from_double(snr()));
+       message_port_pub(d_signal_port, pmt::from_double(signal()));
+       message_port_pub(d_noise_port, pmt::from_double(noise()));
+       d_count -= d_nsamples;
+      }
+
+      return n;
     }
 
     double
@@ -86,6 +103,25 @@ namespace gr {
        throw std::runtime_error("probe_mpsk_snr_est_c_impl:: No SNR estimator 
defined.\n");
     }
 
+    double
+    probe_mpsk_snr_est_c_impl::signal()
+    {
+      if(d_snr_est)
+       return d_snr_est->signal();
+      else
+       throw std::runtime_error("probe_mpsk_snr_est_c_impl:: No SNR estimator 
defined.\n");
+    }
+
+
+    double
+    probe_mpsk_snr_est_c_impl::noise()
+    {
+      if(d_snr_est)
+       return d_snr_est->noise();
+      else
+       throw std::runtime_error("probe_mpsk_snr_est_c_impl:: No SNR estimator 
defined.\n");
+    }
+
     snr_est_type_t
     probe_mpsk_snr_est_c_impl::type() const
     {
@@ -150,7 +186,7 @@ namespace gr {
          d_snr_est->set_alpha(d_alpha);
       }
       else
-       throw std::invalid_argument("probe_mpsk_snr_est_c_impl: alpha must be 
in [0,1]\n");    
+       throw std::invalid_argument("probe_mpsk_snr_est_c_impl: alpha must be 
in [0,1]\n");
     }
 
   } /* namespace digital */
diff --git a/gr-digital/lib/probe_mpsk_snr_est_c_impl.h 
b/gr-digital/lib/probe_mpsk_snr_est_c_impl.h
index 0663595..cd609a9 100644
--- a/gr-digital/lib/probe_mpsk_snr_est_c_impl.h
+++ b/gr-digital/lib/probe_mpsk_snr_est_c_impl.h
@@ -1,19 +1,19 @@
 /* -*- c++ -*- */
 /*
  * Copyright 2011,2012 Free Software Foundation, Inc.
- * 
+ *
  * This file is part of GNU Radio
- * 
+ *
  * GNU Radio is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3, or (at your option)
  * any later version.
- * 
+ *
  * GNU Radio is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with GNU Radio; see the file COPYING.  If not, write to
  * the Free Software Foundation, Inc., 51 Franklin Street,
@@ -36,8 +36,10 @@ namespace gr {
       double d_alpha;
       mpsk_snr_est *d_snr_est;
 
-      //d_key is the message name, 'snr'
-      pmt::pmt_t d_key;
+      // Message port names
+      pmt::pmt_t d_snr_port;
+      pmt::pmt_t d_signal_port;
+      pmt::pmt_t d_noise_port;
 
     public:
       probe_mpsk_snr_est_c_impl(snr_est_type_t type,
@@ -53,6 +55,12 @@ namespace gr {
       //! Return the estimated signal-to-noise ratio in decibels
       double snr();
 
+      //! Return the estimated signal power in decibels
+      double signal();
+
+      //! Return the estimated noise power in decibels
+      double noise();
+
       //! Return the type of estimator in use
       snr_est_type_t type() const;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]