summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/python
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/python')
-rw-r--r--gnuradio-core/src/python/build_utils.py2
-rw-r--r--gnuradio-core/src/python/gnuradio/CMakeLists.txt41
-rw-r--r--gnuradio-core/src/python/gnuradio/Makefile.am2
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2/CMakeLists.txt26
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt54
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py75
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt52
-rw-r--r--gnuradio-core/src/python/gnuradio/gru/CMakeLists.txt (renamed from gnuradio-core/src/python/gnuradio/vocoder/Makefile.am)20
-rw-r--r--gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt38
-rw-r--r--gnuradio-core/src/python/gnuradio/modulation_utils2.py20
-rw-r--r--gnuradio-core/src/python/gnuradio/vocoder/.gitignore2
-rw-r--r--gnuradio-core/src/python/gnuradio/vocoder/__init__.py1
12 files changed, 266 insertions, 67 deletions
diff --git a/gnuradio-core/src/python/build_utils.py b/gnuradio-core/src/python/build_utils.py
index c7acf6bd0..90c7978f2 100644
--- a/gnuradio-core/src/python/build_utils.py
+++ b/gnuradio-core/src/python/build_utils.py
@@ -93,7 +93,7 @@ def output_makefile_fragment ():
return
# overwrite the source, which must be writable; this should have been
# checked for beforehand in the top-level Makefile.gen.gen .
- f = open_src ('Makefile.gen', 'w')
+ f = open (os.path.join (os.environ.get('gendir', os.environ.get('srcdir', '.')), 'Makefile.gen'), 'w')
f.write ('#\n# This file is machine generated. All edits will be overwritten\n#\n')
output_subfrag (f, 'h')
output_subfrag (f, 'i')
diff --git a/gnuradio-core/src/python/gnuradio/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/CMakeLists.txt
new file mode 100644
index 000000000..57bc91552
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/CMakeLists.txt
@@ -0,0 +1,41 @@
+# Copyright 2010-2011 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.
+
+INCLUDE(GrPython)
+
+ADD_SUBDIRECTORY(gr)
+ADD_SUBDIRECTORY(gru)
+ADD_SUBDIRECTORY(gruimpl)
+ADD_SUBDIRECTORY(blks2)
+ADD_SUBDIRECTORY(blks2impl)
+
+GR_PYTHON_INSTALL(FILES
+ __init__.py
+ eng_notation.py
+ eng_option.py
+ modulation_utils2.py
+ ofdm_packet_utils.py
+ gr_unittest.py
+ gr_xmlrunner.py
+ optfir.py
+ usrp_options.py
+ window.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio
+ COMPONENT "core_python"
+)
diff --git a/gnuradio-core/src/python/gnuradio/Makefile.am b/gnuradio-core/src/python/gnuradio/Makefile.am
index 30b5d02ab..289e37662 100644
--- a/gnuradio-core/src/python/gnuradio/Makefile.am
+++ b/gnuradio-core/src/python/gnuradio/Makefile.am
@@ -22,7 +22,7 @@
include $(top_srcdir)/Makefile.common
if PYTHON
-SUBDIRS = gr gru gruimpl blks2 blks2impl vocoder
+SUBDIRS = gr gru gruimpl blks2 blks2impl
grpython_PYTHON = \
__init__.py \
diff --git a/gnuradio-core/src/python/gnuradio/blks2/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/blks2/CMakeLists.txt
new file mode 100644
index 000000000..3e210100b
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/blks2/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Copyright 2010-2011 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.
+
+INCLUDE(GrPython)
+
+GR_PYTHON_INSTALL(
+ FILES __init__.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/blks2
+ COMPONENT "core_python"
+)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt
new file mode 100644
index 000000000..8b0baedd9
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt
@@ -0,0 +1,54 @@
+# Copyright 2010-2011 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.
+
+INCLUDE(GrPython)
+
+GR_PYTHON_INSTALL(FILES
+ __init__.py
+ am_demod.py
+ channel_model.py
+ filterbank.py
+ fm_demod.py
+ fm_emph.py
+ generic_usrp.py
+ logpwrfft.py
+ nbfm_rx.py
+ nbfm_tx.py
+ ofdm.py
+ ofdm_receiver.py
+ ofdm_sync_fixed.py
+ ofdm_sync_pn.py
+ ofdm_sync_pnac.py
+ ofdm_sync_ml.py
+ pfb_arb_resampler.py
+ pfb_channelizer.py
+ pfb_decimator.py
+ pfb_interpolator.py
+ psk.py
+ qam.py
+ rational_resampler.py
+ standard_squelch.py
+ stream_to_vector_decimator.py
+ wfm_rcv.py
+ wfm_rcv_fmdet.py
+ wfm_rcv_pll.py
+ wfm_tx.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/blks2impl
+ COMPONENT "core_python"
+)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
index 3b1cd12ac..2663f7cf8 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
@@ -21,26 +21,12 @@
#
import math
-from gnuradio import gr, ofdm_packet_utils, modulation_utils2
+from gnuradio import gr, ofdm_packet_utils
import gnuradio.gr.gr_threading as _threading
import psk, qam
from gnuradio.blks2impl.ofdm_receiver import ofdm_receiver
-def _add_common_options(normal, expert):
- """
- Adds OFDM-specific options to the Options Parser that are common
- both to the modulator and demodulator.
- """
- mods_list = ", ".join(modulation_utils2.type_1_constellations().keys())
- normal.add_option("-m", "--modulation", type="string", default="psk",
- help="set modulation type (" + mods_list + ") [default=%default]")
- expert.add_option("", "--fft-length", type="intx", default=512,
- help="set the number of FFT bins [default=%default]")
- expert.add_option("", "--occupied-tones", type="intx", default=200,
- help="set the number of occupied FFT bins [default=%default]")
- expert.add_option("", "--cp-length", type="intx", default=128,
- help="set the number of bits in the cyclic prefix [default=%default]")
# /////////////////////////////////////////////////////////////////////////////
# mod/demod with packets as i/o
@@ -75,8 +61,6 @@ class ofdm_mod(gr.hier_block2):
self._fft_length = options.fft_length
self._occupied_tones = options.occupied_tones
self._cp_length = options.cp_length
-
- arity = options.constellation_points
win = [] #[1 for i in range(self._fft_length)]
@@ -98,9 +82,19 @@ class ofdm_mod(gr.hier_block2):
symbol_length = options.fft_length + options.cp_length
- const = modulation_utils2.type_1_constellations()[self._modulation](arity).points()
-
- self._pkt_input = gr.ofdm_mapper_bcv(const, msgq_limit,
+ mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256}
+ arity = mods[self._modulation]
+
+ rot = 1
+ if self._modulation == "qpsk":
+ rot = (0.707+0.707j)
+
+ if(self._modulation.find("psk") >= 0):
+ rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity])
+ elif(self._modulation.find("qam") >= 0):
+ rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
+ #print rotated_const
+ self._pkt_input = gr.ofdm_mapper_bcv(rotated_const, msgq_limit,
options.occupied_tones, options.fft_length)
self.preambles = gr.ofdm_insert_preamble(self._fft_length, padded_preambles)
@@ -146,10 +140,14 @@ class ofdm_mod(gr.hier_block2):
"""
Adds OFDM-specific options to the Options Parser
"""
- _add_common_options(normal, expert)
- for mod in modulation_utils2.type_1_mods().values():
- mod.add_options(expert)
-
+ normal.add_option("-m", "--modulation", type="string", default="bpsk",
+ help="set modulation type (bpsk, qpsk, 8psk, qam{16,64}) [default=%default]")
+ expert.add_option("", "--fft-length", type="intx", default=512,
+ help="set the number of FFT bins [default=%default]")
+ expert.add_option("", "--occupied-tones", type="intx", default=200,
+ help="set the number of occupied FFT bins [default=%default]")
+ expert.add_option("", "--cp-length", type="intx", default=128,
+ help="set the number of bits in the cyclic prefix [default=%default]")
# Make a static method to call before instantiation
add_options = staticmethod(add_options)
@@ -198,9 +196,6 @@ class ofdm_demod(gr.hier_block2):
self._cp_length = options.cp_length
self._snr = options.snr
- arity = options.constellation_points
- print("con points is %s" % options.constellation_points)
-
# Use freq domain to get doubled-up known symbol for correlation in time domain
zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0))
ksfreq = known_symbols_4512_3[0:self._occupied_tones]
@@ -216,11 +211,22 @@ class ofdm_demod(gr.hier_block2):
self._occupied_tones, self._snr, preambles,
options.log)
- constell = modulation_utils2.type_1_constellations()[self._modulation](arity)
+ mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256}
+ arity = mods[self._modulation]
+
+ rot = 1
+ if self._modulation == "qpsk":
+ rot = (0.707+0.707j)
+
+ if(self._modulation.find("psk") >= 0):
+ rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity])
+ elif(self._modulation.find("qam") >= 0):
+ rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
+ #print rotated_const
phgain = 0.25
frgain = phgain*phgain / 4.0
- self.ofdm_demod = gr.ofdm_frame_sink2(constell.base(),
+ self.ofdm_demod = gr.ofdm_frame_sink(rotated_const, range(arity),
self._rcvd_pktq,
self._occupied_tones,
phgain, frgain)
@@ -247,9 +253,14 @@ class ofdm_demod(gr.hier_block2):
"""
Adds OFDM-specific options to the Options Parser
"""
- _add_common_options(normal, expert)
- for mod in modulation_utils2.type_1_mods().values():
- mod.add_options(expert)
+ normal.add_option("-m", "--modulation", type="string", default="bpsk",
+ help="set modulation type (bpsk or qpsk) [default=%default]")
+ expert.add_option("", "--fft-length", type="intx", default=512,
+ help="set the number of FFT bins [default=%default]")
+ expert.add_option("", "--occupied-tones", type="intx", default=200,
+ help="set the number of occupied FFT bins [default=%default]")
+ expert.add_option("", "--cp-length", type="intx", default=128,
+ help="set the number of bits in the cyclic prefix [default=%default]")
# Make a static method to call before instantiation
add_options = staticmethod(add_options)
diff --git a/gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt
new file mode 100644
index 000000000..bd7541a19
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt
@@ -0,0 +1,52 @@
+# Copyright 2010-2011 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.
+
+########################################################################
+INCLUDE(GrPython)
+
+GR_PYTHON_INSTALL(FILES
+ __init__.py
+ exceptions.py
+ gr_threading.py
+ gr_threading_23.py
+ gr_threading_24.py
+ hier_block2.py
+ prefs.py
+ top_block.py
+ pubsub.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/gr
+ COMPONENT "core_python"
+)
+
+########################################################################
+# Handle the unit tests
+########################################################################
+IF(ENABLE_TESTING)
+INCLUDE(GrTest)
+FILE(GLOB py_qa_test_files "qa_*.py")
+FOREACH(py_qa_test_file ${py_qa_test_files})
+ GET_FILENAME_COMPONENT(py_qa_test_name ${py_qa_test_file} NAME_WE)
+ SET(GR_TEST_PYTHON_DIRS
+ ${CMAKE_BINARY_DIR}/gnuradio-core/src/python
+ ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig
+ )
+ SET(GR_TEST_TARGET_DEPS gruel gnuradio-core)
+ GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${py_qa_test_file})
+ENDFOREACH(py_qa_test_file)
+ENDIF(ENABLE_TESTING)
diff --git a/gnuradio-core/src/python/gnuradio/vocoder/Makefile.am b/gnuradio-core/src/python/gnuradio/gru/CMakeLists.txt
index 69c140c10..55971ce5b 100644
--- a/gnuradio-core/src/python/gnuradio/vocoder/Makefile.am
+++ b/gnuradio-core/src/python/gnuradio/gru/CMakeLists.txt
@@ -1,26 +1,26 @@
+# Copyright 2010-2011 Free Software Foundation, Inc.
#
-# Copyright 2004,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 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.
-#
-include $(top_srcdir)/Makefile.common
+INCLUDE(GrPython)
-grvocoderpythondir = $(grpythondir)/vocoder
-grvocoderpython_PYTHON = \
- __init__.py
+GR_PYTHON_INSTALL(
+ FILES __init__.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/gru
+ COMPONENT "core_python"
+)
diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt
new file mode 100644
index 000000000..aa9338764
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt
@@ -0,0 +1,38 @@
+# Copyright 2010-2011 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.
+
+INCLUDE(GrPython)
+
+GR_PYTHON_INSTALL(FILES
+ __init__.py
+ freqz.py
+ gnuplot_freqz.py
+ hexint.py
+ listmisc.py
+ mathmisc.py
+ lmx2306.py
+ msgq_runner.py
+ os_read_exactly.py
+ sdr_1000.py
+ seq_with_cursor.py
+ socket_stuff.py
+ daemon.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/gruimpl
+ COMPONENT "core_python"
+)
diff --git a/gnuradio-core/src/python/gnuradio/modulation_utils2.py b/gnuradio-core/src/python/gnuradio/modulation_utils2.py
index f30055f4a..c5dba3e79 100644
--- a/gnuradio-core/src/python/gnuradio/modulation_utils2.py
+++ b/gnuradio-core/src/python/gnuradio/modulation_utils2.py
@@ -47,15 +47,6 @@ def type_1_demods():
def add_type_1_demod(name, demod_class):
_type_1_demodulators[name] = demod_class
-# Also record the constellation making functions of the modulations
-_type_1_constellations = {}
-
-def type_1_constellations():
- return _type_1_constellations
-
-def add_type_1_constellation(name, constellation):
- _type_1_constellations[name] = constellation
-
def extract_kwargs_from_options(function, excluded_args, options):
"""
@@ -88,14 +79,3 @@ def extract_kwargs_from_options(function, excluded_args, options):
if getattr(options, kw) is not None:
d[kw] = getattr(options, kw)
return d
-
-def extract_kwargs_from_options_for_class(cls, options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- d = extract_kwargs_from_options(
- cls.__init__, ('self',), options)
- for base in cls.__bases__:
- if hasattr(base, 'extract_kwargs_from_options'):
- d.update(base.extract_kwargs_from_options(options))
- return d
diff --git a/gnuradio-core/src/python/gnuradio/vocoder/.gitignore b/gnuradio-core/src/python/gnuradio/vocoder/.gitignore
deleted file mode 100644
index b336cc7ce..000000000
--- a/gnuradio-core/src/python/gnuradio/vocoder/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/Makefile
-/Makefile.in
diff --git a/gnuradio-core/src/python/gnuradio/vocoder/__init__.py b/gnuradio-core/src/python/gnuradio/vocoder/__init__.py
deleted file mode 100644
index a4917cf64..000000000
--- a/gnuradio-core/src/python/gnuradio/vocoder/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# make this a package