summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-input/CMakeLists.txt55
-rw-r--r--gr-input/doc/CMakeLists.txt23
-rw-r--r--gr-input/doc/README.input2
-rw-r--r--gr-input/doc/input.dox29
-rw-r--r--gr-input/grc/CMakeLists.txt32
-rw-r--r--gr-input/grc/ramp_source.xml87
-rw-r--r--gr-input/grc/step_source.xml88
-rw-r--r--gr-input/python/CMakeLists.txt77
-rw-r--r--gr-input/python/__init__.py53
-rw-r--r--gr-input/python/gr_ramp_source.py46
-rw-r--r--gr-input/python/gr_step_source.py43
-rw-r--r--gr-input/python/ramp_hierblock.py19
-rw-r--r--gr-input/python/step_hierblock.py22
13 files changed, 576 insertions, 0 deletions
diff --git a/gr-input/CMakeLists.txt b/gr-input/CMakeLists.txt
new file mode 100644
index 000000000..50babee29
--- /dev/null
+++ b/gr-input/CMakeLists.txt
@@ -0,0 +1,55 @@
+# 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.
+
+########################################################################
+# Setup dependencies
+########################################################################
+#include(GrBoost)
+
+#find_package(SCIGENW3f)
+
+########################################################################
+# Register component
+########################################################################
+include(GrComponent)
+
+GR_REGISTER_COMPONENT("gr-input" ENABLE_GR_INPUT
+ ENABLE_GRUEL
+ ENABLE_VOLK
+ Boost_FOUND
+ ENABLE_GR_CORE
+)
+
+########################################################################
+# Begin conditional configuration
+########################################################################
+if(ENABLE_GR_INPUT)
+
+########################################################################
+# Add subdirectories
+########################################################################
+if(ENABLE_PYTHON)
+ add_subdirectory(python)
+ add_subdirectory(grc)
+endif(ENABLE_PYTHON)
+#add_subdirectory(examples)
+add_subdirectory(doc)
+
+
+endif(ENABLE_GR_INPUT)
diff --git a/gr-input/doc/CMakeLists.txt b/gr-input/doc/CMakeLists.txt
new file mode 100644
index 000000000..b10223aaf
--- /dev/null
+++ b/gr-input/doc/CMakeLists.txt
@@ -0,0 +1,23 @@
+# 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.
+
+install(
+ FILES README.input
+ DESTINATION ${GR_PKG_DOC_DIR}
+)
diff --git a/gr-input/doc/README.input b/gr-input/doc/README.input
new file mode 100644
index 000000000..1bd326897
--- /dev/null
+++ b/gr-input/doc/README.input
@@ -0,0 +1,2 @@
+Serial Python block
+
diff --git a/gr-input/doc/input.dox b/gr-input/doc/input.dox
new file mode 100644
index 000000000..8843d0560
--- /dev/null
+++ b/gr-input/doc/input.dox
@@ -0,0 +1,29 @@
+/*! \page page_fft FFT Signal Processing Blocks
+
+\section Introduction
+
+This is the gr-scigen package. It contains signal processing blocks to
+perform FFTs and FFT-related functionality.
+
+The Python namespace is in gnuradio.fft, which would be normally
+imported as:
+
+\code
+ from gnuradio import scigen
+\endcode
+
+See the Doxygen documentation for details about the blocks available
+in this package. A quick listing of the details can be found in Python
+after importing by using:
+
+\code
+ help(scigen)
+\endcode
+
+\section Dependencies
+
+The scigen blocks require the following dependencies.
+
+\li fftw3f (>= 3.0) http://www.fftw.org/download.html
+
+*/
diff --git a/gr-input/grc/CMakeLists.txt b/gr-input/grc/CMakeLists.txt
new file mode 100644
index 000000000..f89d28bcc
--- /dev/null
+++ b/gr-input/grc/CMakeLists.txt
@@ -0,0 +1,32 @@
+# 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.
+
+install(FILES
+ step_source.xml
+ DESTINATION ${GRC_BLOCKS_DIR}
+ COMPONENT "input_python"
+)
+
+install(FILES
+ ramp_source.xml
+ DESTINATION ${GRC_BLOCKS_DIR}
+ COMPONENT "input_python"
+)
+
+
diff --git a/gr-input/grc/ramp_source.xml b/gr-input/grc/ramp_source.xml
new file mode 100644
index 000000000..5cba29ae7
--- /dev/null
+++ b/gr-input/grc/ramp_source.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##
+CSIM Block:
+## all types, 1 output, 2 to inf inputs
+###################################################
+ -->
+<block>
+ <name>Ramp Input</name>
+ <key>ramp</key>
+ <category>Sources</category>
+
+ <import>from gnuradio.input import ramp_hierblock as ramp_hierblock</import>
+ <make>ramp_hierblock.HierBlock($S,$H_Off,$W_Off)
+ </make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option><name>F32_F32</name><key>f32_f32</key></option>
+ <option><name>S32_S32</name><key>s32_s32</key></option>
+ <option><name>S16_S16</name><key>s16_s16</key></option>
+ <option><name>S8_S8</name><key>s8_s8</key></option>
+ </param>
+ <param>
+ <name>Num Inputs</name>
+ <key>num_inputs</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+
+ <!--
+ Desimulation options
+ -->
+ <param>
+ <name>slope of ramp</name>
+ <key>S</key>
+ <value>1</value>
+ <type>real</type>
+ </param>
+
+ <param>
+ <name>height of offset</name>
+ <key>H_Off</key>
+ <value>0</value>
+ <type>real</type>
+ </param>
+
+ <param>
+ <name>width of offset</name>
+ <key>W_Off</key>
+ <value>0</value>
+ <type>real</type>
+ </param>
+
+ <!--
+ Check if number of inputs are greater than 0, and if vector length
+ is greater than 0.
+ -->
+ <check>$num_inputs &gt; 0</check>
+ <check>$vlen &gt; 0</check>
+
+ <source>
+ <name>out</name>
+ <type>$(str($type).split('_')[1])</type>
+ <vlen>$vlen</vlen>
+ </source>
+ <doc>
+
+Ramp Input block :
+
+Slope of ramp is the slope of ramp user wants to generate.
+Height of Offset is the height of step user wants to generate as initial signal.
+Width of Offset is the length upto which user wants to see the generated offset be.
+
+Default slope of ramp is 1 unit.
+Default height and width of offset is 1 unit.
+</doc>
+</block>
+
diff --git a/gr-input/grc/step_source.xml b/gr-input/grc/step_source.xml
new file mode 100644
index 000000000..599980030
--- /dev/null
+++ b/gr-input/grc/step_source.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##
+CSIM Block:
+## all types, 1 output, 2 to inf inputs
+###################################################
+ -->
+<block>
+ <name>Step Input</name>
+ <key>step_offset</key>
+ <category>Sources</category>
+
+ <import>from gnuradio.input import step_hierblock as step_hierblock</import>
+ <make>step_hierblock.HierBlock($S,$H_Off,$W_Off)
+ </make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option><name>F32_F32</name><key>f32_f32</key></option>
+ <option><name>S32_S32</name><key>s32_s32</key></option>
+ <option><name>S16_S16</name><key>s16_s16</key></option>
+ <option><name>S8_S8</name><key>s8_s8</key></option>
+ </param>
+ <param>
+ <name>Num Inputs</name>
+ <key>num_inputs</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+
+ <!--
+ Desimulation options
+ -->
+ <param>
+ <name>step size</name>
+ <key>S</key>
+ <value>1</value>
+ <type>real</type>
+ </param>
+
+ <param>
+ <name>height of offset</name>
+ <key>H_Off</key>
+ <value>0</value>
+ <type>real</type>
+ </param>
+
+ <param>
+ <name>width of offset</name>
+ <key>W_Off</key>
+ <value>0</value>
+ <type>real</type>
+ </param>
+
+
+ <!--
+ Check if number of inputs are greater than 0, and if vector length
+ is greater than 0.
+ -->
+ <check>$num_inputs &gt; 0</check>
+ <check>$vlen &gt; 0</check>
+
+ <source>
+ <name>out</name>
+ <type>$(str($type).split('_')[1])</type>
+ <vlen>$vlen</vlen>
+ </source>
+ <doc>
+
+Step Input block :
+
+Step size is the height of step user wants to generate.
+Height of Offset is the height of step user wants to generate as initial signal.
+Width of Offset is the length upto which user wants to see the generated offset before starting with the height equivalent to step size.
+
+Default step size is 1 unit.
+Default height and width of offset is 1 unit
+</doc>
+</block>
+
diff --git a/gr-input/python/CMakeLists.txt b/gr-input/python/CMakeLists.txt
new file mode 100644
index 000000000..992012646
--- /dev/null
+++ b/gr-input/python/CMakeLists.txt
@@ -0,0 +1,77 @@
+# 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.
+
+########################################################################
+include(GrPython)
+
+GR_PYTHON_INSTALL(
+ FILES
+ __init__.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/input
+ COMPONENT "input_python"
+)
+
+GR_PYTHON_INSTALL(
+ FILES
+ gr_ramp_source.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/input
+ COMPONENT "input_python"
+)
+
+GR_PYTHON_INSTALL(
+ FILES
+ gr_step_source.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/input
+ COMPONENT "input_python"
+)
+
+GR_PYTHON_INSTALL(
+ FILES
+ ramp_hierblock.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/input
+ COMPONENT "input_python"
+)
+
+GR_PYTHON_INSTALL(
+ FILES
+ step_hierblock.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/input
+ COMPONENT "input_python"
+)
+
+
+
+
+########################################################################
+# Handle the unit tests
+########################################################################
+if(ENABLE_TESTING)
+
+list(APPEND GR_TEST_PYTHON_DIRS
+ ${CMAKE_BINARY_DIR}/gr-input/python
+)
+list(APPEND GR_TEST_TARGET_DEPS gnuradio-input)
+
+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)
+ GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
+endforeach(py_qa_test_file)
+endif(ENABLE_TESTING)
diff --git a/gr-input/python/__init__.py b/gr-input/python/__init__.py
new file mode 100644
index 000000000..6e8ef1f55
--- /dev/null
+++ b/gr-input/python/__init__.py
@@ -0,0 +1,53 @@
+#
+# Copyright 2008,2009 Free Software Foundation, Inc.
+#
+# This application 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.
+#
+# This application 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+# The presence of this file turns this directory into a Python package
+
+'''
+This is the GNU Radio SCIGEN module. Place your Python package
+description here (python/__init__.py).
+'''
+
+# ----------------------------------------------------------------
+# Temporary workaround for ticket:181 (swig+python problem)
+import sys
+_RTLD_GLOBAL = 0
+try:
+ from dl import RTLD_GLOBAL as _RTLD_GLOBAL
+except ImportError:
+ try:
+ from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL
+ except ImportError:
+ pass
+
+if _RTLD_GLOBAL != 0:
+ _dlopenflags = sys.getdlopenflags()
+ sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL)
+# ----------------------------------------------------------------
+
+
+# import any pure python here
+import serial
+
+#
+
+# ----------------------------------------------------------------
+# Tail of workaround
+if _RTLD_GLOBAL != 0:
+ sys.setdlopenflags(_dlopenflags) # Restore original flags
+# ----------------------------------------------------------------
diff --git a/gr-input/python/gr_ramp_source.py b/gr-input/python/gr_ramp_source.py
new file mode 100644
index 000000000..687ffb957
--- /dev/null
+++ b/gr-input/python/gr_ramp_source.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+import gras
+import numpy
+# Serial is imported in __init__
+class ramp(gras.Block):
+
+
+ def __init__(self):
+ gras.Block.__init__(self,
+ name="ser",
+ in_sig=[numpy.float32],
+ out_sig=[numpy.float32])
+ self.i = 0
+ self.flag=True
+
+ def set_parameters(self, ramp_slope, height_Offset, width_Offset):
+ self.slope = ramp_slope
+ self.width = width_Offset
+ self.offset = height_Offset
+
+ def work(self, input_items, output_items):
+
+ out = output_items[0][0]
+ input_stream = input_items[0][0]
+
+ if self.flag:
+ for j in range(self.width):
+ out = self.offset
+ print "OUT", out
+
+ self.produce(0,1) # Produce from port 0 output_items
+ self.consume(0,1) # Consume from port 0 input_items
+
+ self.flag = False
+
+ else:
+
+ self.i = self.i + 1
+ out =self.offset + self.i*input_stream*self.slope
+
+ print "OUT", out
+
+ self.produce(0,1) # Produce from port 0 output_items
+ self.consume(0,1) # Consume from port 0 input_items
+
diff --git a/gr-input/python/gr_step_source.py b/gr-input/python/gr_step_source.py
new file mode 100644
index 000000000..904f89292
--- /dev/null
+++ b/gr-input/python/gr_step_source.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+
+import gras
+import numpy
+# Serial is imported in __init__
+class step(gras.Block):
+
+
+ def __init__(self):
+ gras.Block.__init__(self,
+ name="ser",
+ in_sig=[numpy.float32],
+ out_sig=[numpy.float32])
+ self.flag=True
+
+ def set_parameters(self, step_size, offset, width):
+ self.step_size = step_size
+ self.width = width
+ self.offset = offset
+
+ def work(self, input_items, output_items):
+
+ out = output_items[0][0:1]
+ input_stream = input_items[0][0]
+
+ if self.flag:
+ for i in range(self.width):
+ out[:1] = self.offset
+ print "OUT", out
+
+ self.produce(0,1) # Produce from port 0 output_items
+ self.consume(0,1) # Consume from port 0 input_items
+
+ self.flag = False
+
+ else:
+ out[:1] = self.offset + input_stream*self.step_size
+
+ print "OUT", out
+
+ self.produce(0,1) # Produce from port 0 output_items
+ self.consume(0,1) # Consume from port 0 input_items
+
diff --git a/gr-input/python/ramp_hierblock.py b/gr-input/python/ramp_hierblock.py
new file mode 100644
index 000000000..950615142
--- /dev/null
+++ b/gr-input/python/ramp_hierblock.py
@@ -0,0 +1,19 @@
+import gras
+import numpy
+from gnuradio import gr
+from gnuradio import blocks
+
+# Source block1 import
+import gr_ramp_source
+from gnuradio import blocks
+
+class HierBlock(gr.hier_block2):
+ def __init__(self,ramp_slope, height_Offset, width_Offset):
+ gr.hier_block2.__init__(self,"HierBlock",gr.io_signature(1,1,gr.sizeof_float), gr.io_signature(1,2,gr.sizeof_float))
+ #constant_block initialized
+ self.constant_block = gr.sig_source_f(0,gr.GR_CONST_WAVE,0,0,1)
+ #ramp_source block initialized
+ self.ramp_source=gr_ramp_source.ramp()
+ self.ramp_source.set_parameters(ramp_slope, height_Offset, width_Offset)
+ self.connect(self,(self.constant_block,0),(self.ramp_source,0),self)
+
diff --git a/gr-input/python/step_hierblock.py b/gr-input/python/step_hierblock.py
new file mode 100644
index 000000000..4243606d6
--- /dev/null
+++ b/gr-input/python/step_hierblock.py
@@ -0,0 +1,22 @@
+import gras
+import numpy
+from gnuradio import gr
+from gnuradio import blocks
+
+# Source block1 import
+import gr_step_source
+from gnuradio import blocks
+
+class HierBlock(gr.hier_block2):
+ def __init__(self, step_size, H_Off, W_Off):
+ gr.hier_block2.__init__(self, "HierBlock",
+ gr.io_signature(1,1,gr.sizeof_float),
+ gr.io_signature(1,2,gr.sizeof_float))
+
+ # constant_block initialized
+ self.constant_block = gr.sig_source_f(0, gr.GR_CONST_WAVE,0,0,1)
+ # step_source block initialized
+ self.step_source = gr_step_source.step()
+ self.step_source.set_parameters(step_size, H_Off, W_Off)
+ self.connect(self, (self.constant_block,0) , (self.step_source,0), self)
+