commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5461 - in gnuradio/trunk: gnuradio-core/src/lib/gener


From: jcorgan
Subject: [Commit-gnuradio] r5461 - in gnuradio/trunk: gnuradio-core/src/lib/general gnuradio-examples/python/digital
Date: Sat, 12 May 2007 17:50:46 -0600 (MDT)

Author: jcorgan
Date: 2007-05-12 17:50:46 -0600 (Sat, 12 May 2007)
New Revision: 5461

Added:
   gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc
   gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h
   gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.i
Modified:
   gnuradio/trunk/gnuradio-core/src/lib/general/Makefile.am
   gnuradio/trunk/gnuradio-core/src/lib/general/general.i
   gnuradio/trunk/gnuradio-examples/python/digital/receive_path.py
Log:
Added ability to log receive path power to file in digital examples.

Modified: gnuradio/trunk/gnuradio-core/src/lib/general/Makefile.am
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/Makefile.am    2007-05-11 
23:53:42 UTC (rev 5460)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/Makefile.am    2007-05-12 
23:50:46 UTC (rev 5461)
@@ -113,6 +113,7 @@
        gr_prefix.cc                    \
        gr_prefs.cc                     \
        gr_probe_avg_mag_sqrd_c.cc      \
+       gr_probe_avg_mag_sqrd_cf.cc     \
        gr_probe_avg_mag_sqrd_f.cc      \
        gr_probe_signal_f.cc            \
        gr_pwr_squelch_cc.cc            \
@@ -250,6 +251,7 @@
        gr_prefix.h                     \
        gr_prefs.h                      \
        gr_probe_avg_mag_sqrd_c.h       \
+       gr_probe_avg_mag_sqrd_cf.h      \
        gr_probe_avg_mag_sqrd_f.h       \
        gr_probe_signal_f.h             \
        gr_pwr_squelch_cc.h             \
@@ -388,6 +390,7 @@
        gr_prefix.i                     \
        gr_prefs.i                      \
        gr_probe_avg_mag_sqrd_c.i       \
+       gr_probe_avg_mag_sqrd_cf.i      \
        gr_probe_avg_mag_sqrd_f.i       \
        gr_probe_signal_f.i             \
        gr_pwr_squelch_cc.i             \

Modified: gnuradio/trunk/gnuradio-core/src/lib/general/general.i
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/general.i      2007-05-11 
23:53:42 UTC (rev 5460)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/general.i      2007-05-12 
23:50:46 UTC (rev 5461)
@@ -90,6 +90,7 @@
 #include <gr_pll_carriertracking_cc.h>
 #include <gr_pn_correlator_cc.h>
 #include <gr_probe_avg_mag_sqrd_c.h>
+#include <gr_probe_avg_mag_sqrd_cf.h>
 #include <gr_probe_avg_mag_sqrd_f.h>
 #include <gr_probe_signal_f.h>
 #include <gr_ofdm_correlator.h>
@@ -191,6 +192,7 @@
 %include "gr_pll_carriertracking_cc.i"
 %include "gr_pn_correlator_cc.i"
 %include "gr_probe_avg_mag_sqrd_c.i"
+%include "gr_probe_avg_mag_sqrd_cf.i"
 %include "gr_probe_avg_mag_sqrd_f.i"
 %include "gr_probe_signal_f.i"
 %include "gr_ofdm_correlator.i"

Copied: 
gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc (from 
rev 5460, 
gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.cc)
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc    
                        (rev 0)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc    
2007-05-12 23:50:46 UTC (rev 5461)
@@ -0,0 +1,86 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2007 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 2, 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,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <gr_probe_avg_mag_sqrd_cf.h>
+#include <gr_io_signature.h>
+#include <cmath>
+
+gr_probe_avg_mag_sqrd_cf_sptr
+gr_make_probe_avg_mag_sqrd_cf(double threshold_db, double alpha)
+{
+  return gr_probe_avg_mag_sqrd_cf_sptr(new 
gr_probe_avg_mag_sqrd_cf(threshold_db, alpha));
+}
+
+gr_probe_avg_mag_sqrd_cf::gr_probe_avg_mag_sqrd_cf (double threshold_db, 
double alpha)
+  : gr_sync_block ("probe_avg_mag_sqrd_cf",
+                  gr_make_io_signature(1, 1, sizeof(gr_complex)),
+                  gr_make_io_signature(1, 1, sizeof(float))),
+    d_iir(alpha), d_unmuted(false), d_level(0)
+{
+  set_threshold (threshold_db);
+}
+
+gr_probe_avg_mag_sqrd_cf::~gr_probe_avg_mag_sqrd_cf()
+{
+}
+
+
+int
+gr_probe_avg_mag_sqrd_cf::work(int noutput_items,
+                          gr_vector_const_void_star &input_items,
+                          gr_vector_void_star &output_items)
+{
+  const gr_complex *in = (const gr_complex *) input_items[0];
+  float *out = (float *) output_items[0];
+
+  for (int i = 0; i < noutput_items; i++){
+    out[i] = d_iir.prev_output();
+    double mag_sqrd = in[i].real()*in[i].real() + in[i].imag()*in[i].imag();
+    d_iir.filter(mag_sqrd);    // computed for side effect: prev_output()
+  }
+
+  d_unmuted = d_iir.prev_output() >= d_threshold;
+  d_level = d_iir.prev_output();
+  return noutput_items;
+}
+
+double
+gr_probe_avg_mag_sqrd_cf::threshold() const
+{
+  return 10 * std::log10(d_threshold);
+}
+
+void
+gr_probe_avg_mag_sqrd_cf::set_threshold(double decibels)
+{
+  // convert to absolute threshold (mag squared)
+  d_threshold = std::pow(10.0, decibels/10);
+}
+
+void
+gr_probe_avg_mag_sqrd_cf::set_alpha(double alpha)
+{
+  d_iir.set_taps(alpha);
+}

Copied: gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h 
(from rev 5460, 
gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h)
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h     
                        (rev 0)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h     
2007-05-12 23:50:46 UTC (rev 5461)
@@ -0,0 +1,76 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2006 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 2, 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,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef INCLUDED_GR_PROBE_AVG_MAG_SQRD_CF_H
+#define INCLUDED_GR_PROBE_AVG_MAG_SQRD_CF_H
+
+#include <gr_sync_block.h>
+#include <gr_single_pole_iir.h>
+
+class gr_probe_avg_mag_sqrd_cf;
+typedef boost::shared_ptr<gr_probe_avg_mag_sqrd_cf> 
gr_probe_avg_mag_sqrd_cf_sptr;
+
+gr_probe_avg_mag_sqrd_cf_sptr
+gr_make_probe_avg_mag_sqrd_cf (double threshold_db, double alpha = 0.0001);
+
+/*!
+ * \brief compute avg magnitude squared.
+ * \ingroup sink
+ *
+ * input: gr_complex
+ * output: gr_float
+ *
+ * Compute a running average of the magnitude squared of the the input.
+ * The level and indication as to whether the level exceeds threshold
+ * can be retrieved with the level and unmuted accessors.
+ *
+ */
+class gr_probe_avg_mag_sqrd_cf : public gr_sync_block
+{
+  double                                       d_threshold;
+  gr_single_pole_iir<double,double,double>     d_iir;
+  bool                                         d_unmuted;
+  double                                       d_level;
+
+  friend gr_probe_avg_mag_sqrd_cf_sptr
+  gr_make_probe_avg_mag_sqrd_cf (double threshold_db, double alpha);
+
+  gr_probe_avg_mag_sqrd_cf (double threshold_db, double alpha);
+
+public:
+  ~gr_probe_avg_mag_sqrd_cf ();
+
+  int work (int noutput_items,
+           gr_vector_const_void_star &input_items,
+           gr_vector_void_star &output_items);
+
+  // ACCESSORS
+  bool unmuted () const { return d_unmuted; }
+  double level () const { return d_level; }
+
+  double threshold() const;
+
+  // SETTERS
+  void set_alpha (double alpha);
+  void set_threshold (double decibels);
+};
+
+#endif /* INCLUDED_GR_PROBE_AVG_MAG_SQRD_CF_H */

Copied: gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.i 
(from rev 5460, 
gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.i)
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.i     
                        (rev 0)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.i     
2007-05-12 23:50:46 UTC (rev 5461)
@@ -0,0 +1,36 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005 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 2, 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,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,probe_avg_mag_sqrd_cf);
+
+gr_probe_avg_mag_sqrd_cf_sptr
+gr_make_probe_avg_mag_sqrd_cf (double threshold_db, double alpha = 0.0001);
+
+class gr_probe_avg_mag_sqrd_cf : public gr_sync_block
+{
+public:
+  bool unmuted () const { return d_unmuted; }
+  double level () const { return d_level; }
+  void set_alpha (double alpha);
+  void set_threshold (double decibels);
+  double threshold();
+};

Modified: gnuradio/trunk/gnuradio-examples/python/digital/receive_path.py
===================================================================
--- gnuradio/trunk/gnuradio-examples/python/digital/receive_path.py     
2007-05-11 23:53:42 UTC (rev 5460)
+++ gnuradio/trunk/gnuradio-examples/python/digital/receive_path.py     
2007-05-12 23:50:46 UTC (rev 5461)
@@ -105,9 +105,15 @@
         # Carrier Sensing Blocks
         alpha = 0.001
         thresh = 30   # in dB, will have to adjust
-        self.probe = gr.probe_avg_mag_sqrd_c(thresh,alpha)
-        fg.connect(self.chan_filt, self.probe)
 
+        if options.log_rx_power == True:
+            self.probe = gr.probe_avg_mag_sqrd_cf(thresh,alpha)
+            self.power_sink = gr.file_sink(gr.sizeof_float, "rxpower.dat")
+            fg.connect(self.chan_filt, self.probe, self.power_sink)
+        else:
+            self.probe = gr.probe_avg_mag_sqrd_c(thresh,alpha)
+            fg.connect(self.chan_filt, self.probe)
+
         # Display some information about the setup
         if self._verbose:
             self._print_verbage()
@@ -220,6 +226,8 @@
                           help="set fpga decimation rate to DECIM 
[default=%default]")
         expert.add_option("", "--log", action="store_true", default=False,
                           help="Log all parts of flow graph to files (CAUTION: 
lots of data)")
+        expert.add_option("", "--log-rx-power", action="store_true", 
default=False,
+                          help="Log receive signal power to file (CAUTION: 
lots of data)")
 
     # Make a static method to call before instantiation
     add_options = staticmethod(add_options)
@@ -238,7 +246,7 @@
         print "decim:           %3d"   % (self._decim)
         print "Rx Frequency:    %s"    % 
(eng_notation.num_to_str(self._rx_freq))
         # print "Rx Frequency:    %f"    % (self._rx_freq)
-
+            
 def add_freq_option(parser):
     """
     Hackery that has the -f / --freq option set both tx_freq and rx_freq





reply via email to

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