summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--gnuradio-core/src/lib/general/gr_random_pdu.cc83
-rw-r--r--gnuradio-core/src/lib/general/gr_random_pdu.h64
-rw-r--r--gnuradio-core/src/lib/general/gr_random_pdu.i30
-rw-r--r--gr-atsc/src/lib/atsc.i1
-rw-r--r--gr-atsc/src/lib/atsc_bit_timing_loop.cc8
-rw-r--r--gr-atsc/src/lib/atsc_equalizer.h5
-rw-r--r--gr-atsc/src/lib/atsci_equalizer.h5
-rw-r--r--gr-atsc/src/lib/atsci_equalizer_lms.h3
-rw-r--r--gr-atsc/src/lib/atsci_sssr.cc8
-rw-r--r--gr-atsc/src/python/all_atsc.py140
-rw-r--r--grc/blocks/block_tree.xml1
-rw-r--r--grc/blocks/gr_random_pdu.xml35
13 files changed, 382 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 807b363f1..8f8adbb33 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,8 +41,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
# Set the version information here
set(VERSION_INFO_MAJOR_VERSION 3)
set(VERSION_INFO_API_COMPAT 6)
-set(VERSION_INFO_MINOR_VERSION 3)
-set(VERSION_INFO_MAINT_VERSION 0)
+set(VERSION_INFO_MINOR_VERSION 4)
+set(VERSION_INFO_MAINT_VERSION git)
include(GrVersion) #setup version info
# Append -O2 optimization flag for Debug builds
diff --git a/gnuradio-core/src/lib/general/gr_random_pdu.cc b/gnuradio-core/src/lib/general/gr_random_pdu.cc
new file mode 100644
index 000000000..9f692c72b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_random_pdu.cc
@@ -0,0 +1,83 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_random_pdu.h>
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+#include <string.h>
+#include <iostream>
+
+// public constructor that returns a shared_ptr
+
+gr_random_pdu_sptr
+gr_make_random_pdu (int items_min, int items_max)
+{
+ return gnuradio::get_initial_sptr(new gr_random_pdu(items_min, items_max));
+}
+
+gr_random_pdu::gr_random_pdu (int items_min, int items_max)
+ : gr_block("random_pdu",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(0, 0, 0)),
+ urange(items_min, items_max),
+ brange(0, 255),
+ rvar(rng, urange),
+ bvar(rng, brange)
+{
+ message_port_register_out(pmt::mp("pdus"));
+ message_port_register_in(pmt::mp("generate"));
+ set_msg_handler(pmt::mp("generate"), boost::bind(&gr_random_pdu::generate_pdu, this, _1));
+}
+
+bool gr_random_pdu::start(){
+ output_random();
+ return true;
+}
+
+void gr_random_pdu::output_random(){
+
+ // pick a random vector length
+ int len = rvar();
+
+ // fill it with random bytes
+ unsigned char vec[len];
+ for(int i=0; i<len; i++){
+ vec[i] = (unsigned char) bvar();
+ }
+
+ // send the vector
+ pmt::pmt_t vecpmt( pmt::pmt_make_blob( vec, len ) );
+ pmt::pmt_t pdu( pmt::pmt_cons( pmt::PMT_NIL, vecpmt ) );
+ message_port_pub( pmt::mp("pdus"), pdu );
+
+ std::cout << "sending new random vector of length " << len << "\n";
+}
+
diff --git a/gnuradio-core/src/lib/general/gr_random_pdu.h b/gnuradio-core/src/lib/general/gr_random_pdu.h
new file mode 100644
index 000000000..e6457d21b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_random_pdu.h
@@ -0,0 +1,64 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_RANDOM_PDU_H
+#define INCLUDED_GR_RANDOM_PDU_H
+
+#include <gr_core_api.h>
+#include <gr_block.h>
+#include <gr_message.h>
+#include <gr_msg_queue.h>
+
+#include <boost/random.hpp>
+#include <boost/generator_iterator.hpp>
+
+class gr_random_pdu;
+typedef boost::shared_ptr<gr_random_pdu> gr_random_pdu_sptr;
+
+GR_CORE_API gr_random_pdu_sptr gr_make_random_pdu (int mintime, int maxtime);
+
+/*!
+ * \brief Send message at defined interval
+ * \ingroup msg_blk
+ */
+class GR_CORE_API gr_random_pdu : public gr_block
+{
+ private:
+ friend GR_CORE_API gr_random_pdu_sptr
+ gr_make_random_pdu(int mintime, int maxtime);
+
+ void output_random();
+
+ boost::mt19937 rng;
+ boost::uniform_int<> urange;
+ boost::uniform_int<> brange;
+ boost::variate_generator< boost::mt19937, boost::uniform_int<> > rvar; // pdu length
+ boost::variate_generator< boost::mt19937, boost::uniform_int<> > bvar; // pdu contents
+
+ public:
+ gr_random_pdu (int, int);
+ bool start();
+ void generate_pdu(pmt::pmt_t msg){ output_random(); }
+ void generate_pdu(){ output_random(); }
+};
+
+#endif /* INCLUDED_GR_RANDOM_PDU_H */
diff --git a/gnuradio-core/src/lib/general/gr_random_pdu.i b/gnuradio-core/src/lib/general/gr_random_pdu.i
new file mode 100644
index 000000000..045a33060
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_random_pdu.i
@@ -0,0 +1,30 @@
+/* -*- 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 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,random_pdu);
+
+%{
+#include <gr_random_pdu.h>
+%}
+
+%include "gr_random_pdu.h"
+
diff --git a/gr-atsc/src/lib/atsc.i b/gr-atsc/src/lib/atsc.i
index 6e5662ae6..6b83a2315 100644
--- a/gr-atsc/src/lib/atsc.i
+++ b/gr-atsc/src/lib/atsc.i
@@ -225,6 +225,7 @@ class atsc_equalizer : public gr_sync_block
public:
void reset();
+ std::vector<double> taps();
};
// ----------------------------------------------------------------
diff --git a/gr-atsc/src/lib/atsc_bit_timing_loop.cc b/gr-atsc/src/lib/atsc_bit_timing_loop.cc
index 7abd907cc..dc43d28bc 100644
--- a/gr-atsc/src/lib/atsc_bit_timing_loop.cc
+++ b/gr-atsc/src/lib/atsc_bit_timing_loop.cc
@@ -44,7 +44,7 @@ atsc_make_bit_timing_loop()
atsc_bit_timing_loop::atsc_bit_timing_loop()
: gr_block("atsc_bit_timing_loop",
gr_make_io_signature(1, 1, sizeof(float)),
- gr_make_io_signature(2, 2, sizeof(float))),
+ gr_make_io_signature3(2, 3, sizeof(float), sizeof(float), sizeof(float))),
d_interp(ratio_of_rx_clock_to_symbol_freq), d_next_input(0),
d_rx_clock_to_symbol_freq (ratio_of_rx_clock_to_symbol_freq),
d_si(0)
@@ -82,6 +82,7 @@ atsc_bit_timing_loop::work (int noutput_items,
const float *in = (const float *) input_items[0];
float *out_sample = (float *) output_items[0];
atsc::syminfo *out_tag = (atsc::syminfo *) output_items[1];
+ float *out_timing_error = (float *) output_items[2];
assert(sizeof(float) == sizeof(atsc::syminfo));
@@ -110,12 +111,15 @@ atsc_bit_timing_loop::work (int noutput_items,
}
d_sssr.update (interp_sample, &seg_locked, &symbol_index, &timing_adjustment);
+ if (output_items.size() == 3) {
+ out_timing_error[k] = timing_adjustment;
+ }
out_sample[k] = interp_sample;
tag.valid = seg_locked;
tag.symbol_num = symbol_index;
out_tag[k] = tag;
}
-
+
return k;
}
diff --git a/gr-atsc/src/lib/atsc_equalizer.h b/gr-atsc/src/lib/atsc_equalizer.h
index 32b449b62..aca5e63b4 100644
--- a/gr-atsc/src/lib/atsc_equalizer.h
+++ b/gr-atsc/src/lib/atsc_equalizer.h
@@ -25,6 +25,7 @@
#include <atsc_api.h>
#include <gr_sync_block.h>
#include <atsci_equalizer.h>
+#include <vector>
class atsc_equalizer;
typedef boost::shared_ptr<atsc_equalizer> atsc_equalizer_sptr;
@@ -47,6 +48,10 @@ class ATSC_API atsc_equalizer : public gr_sync_block
public:
void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+ std::vector<double> taps() {
+ return d_equalizer->taps();
+ }
+
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
diff --git a/gr-atsc/src/lib/atsci_equalizer.h b/gr-atsc/src/lib/atsci_equalizer.h
index a0a1fc674..b0c243b51 100644
--- a/gr-atsc/src/lib/atsci_equalizer.h
+++ b/gr-atsc/src/lib/atsci_equalizer.h
@@ -25,6 +25,7 @@
#include <atsc_api.h>
#include <atsci_syminfo.h>
+#include <vector>
/*!
* \brief abstract base class for ATSC equalizer
@@ -54,6 +55,10 @@ public:
atsci_equalizer ();
virtual ~atsci_equalizer ();
+ virtual std::vector<double> taps () {
+ return std::vector<double>();
+ }
+
// MANIPULATORS
/*!
diff --git a/gr-atsc/src/lib/atsci_equalizer_lms.h b/gr-atsc/src/lib/atsci_equalizer_lms.h
index 68aa34ca5..eac72f75b 100644
--- a/gr-atsc/src/lib/atsci_equalizer_lms.h
+++ b/gr-atsc/src/lib/atsci_equalizer_lms.h
@@ -37,6 +37,9 @@ public:
virtual void reset ();
virtual int ntaps () const;
virtual int npretaps () const;
+ std::vector<double> taps () {
+ return d_taps;
+ }
protected:
FILE *trainingfile;
diff --git a/gr-atsc/src/lib/atsci_sssr.cc b/gr-atsc/src/lib/atsci_sssr.cc
index 48c0c51fb..56a0c6a00 100644
--- a/gr-atsc/src/lib/atsci_sssr.cc
+++ b/gr-atsc/src/lib/atsci_sssr.cc
@@ -29,6 +29,7 @@
#include <gr_math.h>
#include <stdio.h>
#include <boost/math/special_functions/sign.hpp>
+#include <iostream>
/*
* ----------------------------------------------------------------
@@ -142,7 +143,11 @@ atsci_sssr::update (sssr::sample_t sample_in, // input
double qo = d_quad_filter.update (sample_in);
d_quad_output[d_counter] = qo;
- int bit = boost::math::signbit (sample_in) ^ 1; // slice on sign: + => 1, - => 0
+ int bit = boost::math::signbit (sample_in);
+ if (bit != 0)
+ bit = 0;
+ else
+ bit = 1;
int corr_out = d_correlator.update (bit);
int weight = sipp (corr_out);
int corr_value = d_integrator.update (weight, d_counter);
@@ -153,6 +158,7 @@ atsci_sssr::update (sssr::sample_t sample_in, // input
int best_correlation_value;
best_correlation_index = d_integrator.find_max (&best_correlation_value);
d_seg_locked = best_correlation_value >= MIN_SEG_LOCK_CORRELATION_VALUE;
+ //std::cout << "best = " << best_correlation_value << " min is " << MIN_SEG_LOCK_CORRELATION_VALUE << std::endl;
d_timing_adjust = d_quad_output[best_correlation_index];
d_symbol_index = SYMBOL_INDEX_OFFSET - 1 - best_correlation_index;
diff --git a/gr-atsc/src/python/all_atsc.py b/gr-atsc/src/python/all_atsc.py
new file mode 100644
index 000000000..0137839bd
--- /dev/null
+++ b/gr-atsc/src/python/all_atsc.py
@@ -0,0 +1,140 @@
+#!/usr/bin/env /usr/bin/python
+#
+# Copyright 2004 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+# This module starts the atsc processing chain taking the captured
+# off-air signal created with:
+#
+# uhd_rx_cfile.py --samp-rate=6.4e6
+# -f <center of tv signal channel freq>
+# -g <appropriate gain for best signal / noise>
+# -s output shorts
+#
+# All this module does is multiply the sample rate by 3, from 6.4e6 to
+# 19.2e6 complex samples / sec, then lowpass filter with a cutoff of 3.2MHz
+# and a transition band width of .5MHz. Center of the tv channels is
+# then at 0 with edges at -3.2MHz and 3.2MHz.
+
+from gnuradio import gr, atsc
+import sys, os, math
+
+def graph (args):
+
+ nargs = len(args)
+ if nargs == 2:
+ infile = args[0]
+ outfile = args[1]
+ else:
+ raise ValueError('usage: interp.py input_file output_file\n')
+
+ tb = gr.top_block ()
+
+ # Convert to a from shorts to a stream of complex numbers.
+ srcf = gr.file_source (gr.sizeof_short,infile)
+ s2ss = gr.stream_to_streams(gr.sizeof_short,2)
+ s2f1 = gr.short_to_float()
+ s2f2 = gr.short_to_float()
+ src0 = gr.float_to_complex()
+ tb.connect(srcf, s2ss)
+ tb.connect((s2ss, 0), s2f1, (src0, 0))
+ tb.connect((s2ss, 1), s2f2, (src0, 1))
+
+ # Low pass filter it and increase sample rate by a factor of 3.
+ lp_coeffs = gr.firdes.low_pass ( 3, 19.2e6, 3.2e6, .5e6, gr.firdes.WIN_HAMMING )
+ lp = gr.interp_fir_filter_ccf ( 3, lp_coeffs )
+ tb.connect(src0, lp)
+
+ # Upconvert it.
+ duc_coeffs = gr.firdes.low_pass ( 1, 19.2e6, 9e6, 1e6, gr.firdes.WIN_HAMMING )
+ duc = gr.freq_xlating_fir_filter_ccf ( 1, duc_coeffs, 5.75e6, 19.2e6 )
+ # Discard the imaginary component.
+ c2f = gr.complex_to_float()
+ tb.connect(lp, duc, c2f)
+
+ # Frequency Phase Lock Loop
+ input_rate = 19.2e6
+ IF_freq = 5.75e6
+ # 1/2 as wide because we're designing lp filter
+ symbol_rate = atsc.ATSC_SYMBOL_RATE/2.
+ NTAPS = 279
+ tt = gr.firdes.root_raised_cosine (1.0, input_rate, symbol_rate, .115, NTAPS)
+ # heterodyne the low pass coefficients up to the specified bandpass
+ # center frequency. Note that when we do this, the filter bandwidth
+ # is effectively twice the low pass (2.69 * 2 = 5.38) and hence
+ # matches the diagram in the ATSC spec.
+ arg = 2. * math.pi * IF_freq / input_rate
+ t=[]
+ for i in range(len(tt)):
+ t += [tt[i] * 2. * math.cos(arg * i)]
+ rrc = gr.fir_filter_fff(1, t)
+
+ fpll = atsc.fpll()
+
+ pilot_freq = IF_freq - 3e6 + 0.31e6
+ lower_edge = 6e6 - 0.31e6
+ upper_edge = IF_freq - 3e6 + pilot_freq
+ transition_width = upper_edge - lower_edge
+ lp_coeffs = gr.firdes.low_pass (1.0,
+ input_rate,
+ (lower_edge + upper_edge) * 0.5,
+ transition_width,
+ gr.firdes.WIN_HAMMING);
+
+ lp_filter = gr.fir_filter_fff (1,lp_coeffs)
+
+ alpha = 1e-5
+ iir = gr.single_pole_iir_filter_ff(alpha)
+ remove_dc = gr.sub_ff()
+
+ tb.connect(c2f, fpll, lp_filter)
+ tb.connect(lp_filter, iir)
+ tb.connect(lp_filter, (remove_dc,0))
+ tb.connect(iir, (remove_dc,1))
+
+ # Bit Timing Loop, Field Sync Checker and Equalizer
+
+ btl = atsc.bit_timing_loop()
+ fsc = atsc.fs_checker()
+ eq = atsc.equalizer()
+ fsd = atsc.field_sync_demux()
+
+ tb.connect(remove_dc, btl)
+ tb.connect((btl, 0),(fsc, 0),(eq, 0),(fsd, 0))
+ tb.connect((btl, 1),(fsc, 1),(eq, 1),(fsd, 1))
+
+ # Viterbi
+
+ viterbi = atsc.viterbi_decoder()
+ deinter = atsc.deinterleaver()
+ rs_dec = atsc.rs_decoder()
+ derand = atsc.derandomizer()
+ depad = atsc.depad()
+ dst = gr.file_sink(gr.sizeof_char, outfile)
+ tb.connect(fsd, viterbi, deinter, rs_dec, derand, depad, dst)
+
+ dst2 = gr.file_sink(gr.sizeof_gr_complex, "atsc_complex.data")
+ tb.connect(src0, dst2)
+
+ tb.run ()
+
+if __name__ == '__main__':
+ graph (sys.argv[1:])
+
+
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index 183883959..dcd6c5448 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -45,6 +45,7 @@
<block>gr_tagged_stream_to_pdu</block>
<block>gr_tuntap_pdu</block>
<block>gr_socket_pdu</block>
+ <block>gr_random_pdu</block>
</cat>
<cat>
<name>Operators</name>
diff --git a/grc/blocks/gr_random_pdu.xml b/grc/blocks/gr_random_pdu.xml
new file mode 100644
index 000000000..ed5a79a92
--- /dev/null
+++ b/grc/blocks/gr_random_pdu.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## Random PDU
+###################################################
+ -->
+<block>
+ <name>Random PDU Generator</name>
+ <key>gr_random_pdu</key>
+ <import>from gnuradio import gr</import>
+ <import>from gruel import pmt</import>
+ <make>gr.random_pdu($minsize, $maxsize)</make>
+ <param>
+ <name>Min Bytes</name>
+ <key>minsize</key>
+ <value>50</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Max Bytes</name>
+ <key>maxsize</key>
+ <value>2000</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>generate</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+ <source>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </source>
+</block>