commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9567 - in gnuradio/branches/developers/jcorgan/bert:


From: jcorgan
Subject: [Commit-gnuradio] r9567 - in gnuradio/branches/developers/jcorgan/bert: gnuradio-core/src/lib/general gnuradio-examples/python/digital-bert
Date: Sat, 13 Sep 2008 15:21:51 -0600 (MDT)

Author: jcorgan
Date: 2008-09-13 15:21:49 -0600 (Sat, 13 Sep 2008)
New Revision: 9567

Added:
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.cc
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.h
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.i
Modified:
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/Makefile.am
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/general.i
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_rx.py
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/receive_path.py
Log:
Work in progress, added density probe for measuring BER

Modified: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/Makefile.am
 2008-09-13 19:50:01 UTC (rev 9566)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/Makefile.am
 2008-09-13 21:21:49 UTC (rev 9567)
@@ -166,7 +166,8 @@
        gr_unpack_k_bits_bb.cc          \
        gr_descrambler_bb.cc            \
        gr_scrambler_bb.cc              \
-       gr_probe_mpsk_snr_c.cc
+       gr_probe_mpsk_snr_c.cc          \
+       gr_probe_density_b.cc
 
 libgeneral_qa_la_SOURCES =             \
        qa_general.cc                   \
@@ -326,7 +327,8 @@
        gr_unpack_k_bits_bb.h           \
        gr_descrambler_bb.h             \
        gr_scrambler_bb.h               \
-       gr_probe_mpsk_snr_c.h
+       gr_probe_mpsk_snr_c.h           \
+       gr_probe_density_b.h
 
 noinst_HEADERS =                       \
        qa_general.h                    \
@@ -456,7 +458,8 @@
        gri_agc2_ff.i                   \
        gr_descrambler_bb.i             \
        gr_scrambler_bb.i               \
-       gr_probe_mpsk_snr_c.i
+       gr_probe_mpsk_snr_c.i           \
+       gr_probe_density_b.i
 
 
 CLEANFILES = $(BUILT_SOURCES) *.pyc

Modified: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/general.i
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/general.i
   2008-09-13 19:50:01 UTC (rev 9566)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/general.i
   2008-09-13 21:21:49 UTC (rev 9567)
@@ -132,6 +132,7 @@
 #include <gr_descrambler_bb.h>
 #include <gr_scrambler_bb.h>
 #include <gr_probe_mpsk_snr_c.h>
+#include <gr_probe_density_b.h>
 %}
 
 %include "gr_nop.i"
@@ -244,3 +245,4 @@
 %include "gr_descrambler_bb.i"
 %include "gr_scrambler_bb.i"
 %include "gr_probe_mpsk_snr_c.i"
+%include "gr_probe_density_b.i"

Added: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.cc
                               (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.cc
       2008-09-13 21:21:49 UTC (rev 9567)
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * 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,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gr_probe_density_b.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <iostream>
+
+gr_probe_density_b_sptr 
+gr_make_probe_density_b(double alpha)
+{
+  return gr_probe_density_b_sptr(new gr_probe_density_b(alpha));
+}
+
+gr_probe_density_b::gr_probe_density_b(double alpha)
+  : gr_sync_block("density_b",
+                 gr_make_io_signature(1, 1, sizeof(char)),
+                 gr_make_io_signature(0, 0, 0))
+{
+  set_alpha(alpha);
+  d_density = 1.0;
+}
+
+gr_probe_density_b::~gr_probe_density_b()
+{
+}
+
+int 
+gr_probe_density_b::work(int noutput_items,
+                        gr_vector_const_void_star &input_items,
+                        gr_vector_void_star &output_items)
+{
+  const char *in = (const char *)input_items[0];
+
+  for (int i = 0; i < noutput_items; i++)
+    d_density = d_alpha*(double)in[i] + d_beta*d_density;
+
+  return noutput_items;
+}
+
+void
+gr_probe_density_b::set_alpha(double alpha)
+{
+  d_alpha = alpha;
+  d_beta = 1.0-d_alpha;
+}
+

Added: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.h
                                (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.h
        2008-09-13 21:21:49 UTC (rev 9567)
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * 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,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef INCLUDED_GR_PROBE_DENSITY_B_H
+#define INCLUDED_GR_PROBE_DENSITY_B_H
+
+#include <gr_sync_block.h>
+
+class gr_probe_density_b;
+
+typedef boost::shared_ptr<gr_probe_density_b> gr_probe_density_b_sptr;
+
+gr_probe_density_b_sptr gr_make_probe_density_b(double alpha);
+
+class gr_probe_density_b : public gr_sync_block
+{
+private:
+  friend gr_probe_density_b_sptr gr_make_probe_density_b(double alpha);
+
+  double d_alpha;
+  double d_beta;
+  double d_density;
+
+  gr_probe_density_b(double alpha);
+
+public:
+  ~gr_probe_density_b();
+  
+  double density() const { return d_density; }
+
+  void set_alpha(double alpha);
+
+  int work(int noutput_items,
+          gr_vector_const_void_star &input_items,
+          gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_GR_PROBE_DENSITY_B_H */

Added: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.i
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.i
                                (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-core/src/lib/general/gr_probe_density_b.i
        2008-09-13 21:21:49 UTC (rev 9567)
@@ -0,0 +1,36 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,probe_density_b);
+
+gr_probe_density_b_sptr gr_make_probe_density_b(double alpha);
+
+class gr_probe_density_b : public gr_sync_block
+{
+public:
+  double density() const;
+
+  void set_alpha(double alpha);
+
+private:
+  gr_probe_density_b();
+};

Modified: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_rx.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_rx.py
     2008-09-13 19:50:01 UTC (rev 9566)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_rx.py
     2008-09-13 21:21:49 UTC (rev 9567)
@@ -25,7 +25,7 @@
 from gnuradio.eng_option import eng_option
 from receive_path import receive_path
 import gnuradio.gr.gr_threading as _threading
-import time
+import sys, time
 
 n2s = eng_notation.num_to_str
 
@@ -39,7 +39,8 @@
 
     def run(self):
         while not self.done:
-            print "MAG=%5.3f VAR=%5.3f SNR=%4.1fdB" % (tb.mag(), tb.var(), 
tb.snr())
+            print "Magnitude: %5.3f  Variance: %5.3f  Estimated SNR: %4.1f dB  
BER: %g" % (
+                tb.mag(), tb.var(), tb.snr(), tb.ber())
             try:
                 time.sleep(1.0)
             except KeyboardInterrupt:
@@ -94,6 +95,9 @@
         
     def var(self):
         return self._receiver.noise_variance()
+
+    def ber(self):
+        return self._receiver.ber()
             
 def get_options():
     parser = OptionParser(option_class=eng_option)
@@ -118,6 +122,10 @@
         parser.print_help()
         sys.exit(1)
        
+    if options.freq == None:
+        print "You must supply a frequency with -f or --freq"
+        sys.exit(1)
+
     return (options, args)
 
 

Modified: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/receive_path.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/receive_path.py
     2008-09-13 19:50:01 UTC (rev 9566)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/receive_path.py
     2008-09-13 21:21:49 UTC (rev 9567)
@@ -87,7 +87,7 @@
                                            mm_omega_limit) # Maximum timing 
offset
 
         # Add an SNR probe on the demodulated constellation
-        self._snr_probe = gr.probe_mpsk_snr_c()
+        self._snr_probe = gr.probe_mpsk_snr_c(1.0/symbol_rate)
         self.connect(self._mm, self._snr_probe)
         
         # Slice the resulting constellation into bits.
@@ -99,10 +99,10 @@
         self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit 
descrambler
 
         # This will be replaced with the density measurement block
-        self._sink = gr.null_sink(gr.sizeof_char)
+        self._ber = gr.probe_density_b(1/symbol_rate)
 
         self.connect(self, self._agc, self._rrc, self._costas, self._mm, 
-                     self._c2r, self._slicer, self._descrambler, self._sink)
+                     self._c2r, self._slicer, self._descrambler, self._ber)
 
     def snr(self):
         return self._snr_probe.snr()
@@ -112,3 +112,6 @@
         
     def noise_variance(self):
         return self._snr_probe.noise_variance()
+
+    def ber(self):
+        return (1.0-self._ber.density())/3.0





reply via email to

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