diff options
Diffstat (limited to 'gnuradio-core/src')
211 files changed, 1613 insertions, 16445 deletions
diff --git a/gnuradio-core/src/examples/CMakeLists.txt b/gnuradio-core/src/examples/CMakeLists.txt index 532c658083..b90a5542df 100644 --- a/gnuradio-core/src/examples/CMakeLists.txt +++ b/gnuradio-core/src/examples/CMakeLists.txt @@ -20,8 +20,3 @@ add_subdirectory(mp-sched) add_subdirectory(network) add_subdirectory(volk_benchmark) - -if(ENABLE_GR_CTRLPORT) -add_subdirectory(ctrlport) -endif(ENABLE_GR_CTRLPORT) - diff --git a/gnuradio-core/src/examples/ctrlport/CMakeLists.txt b/gnuradio-core/src/examples/ctrlport/CMakeLists.txt deleted file mode 100644 index 47ef4c225e..0000000000 --- a/gnuradio-core/src/examples/ctrlport/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# 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(PROGRAMS - DESTINATION ${GR_PKG_CTRLPORT_EXAMPLES_DIR} - COMPONENT "core_python" -) diff --git a/gnuradio-core/src/examples/ctrlport/comparing_resamplers.grc b/gnuradio-core/src/examples/ctrlport/comparing_resamplers.grc deleted file mode 100644 index 4ac4af247f..0000000000 --- a/gnuradio-core/src/examples/ctrlport/comparing_resamplers.grc +++ /dev/null @@ -1,390 +0,0 @@ -<?xml version='1.0' encoding='ASCII'?> -<flow_graph> - <timestamp>Fri Mar 15 11:01:13 2013</timestamp> - <block> - <key>blocks_throttle</key> - <param> - <key>id</key> - <value>blocks_throttle_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>samples_per_second</key> - <value>samp_rate</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(191, 125)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_ctrlport_probe2_c</key> - <param> - <key>id</key> - <value>probe_arc_resamp</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>name</key> - <value>arb_resampler</value> - </param> - <param> - <key>desc</key> - <value>PFB Arbitrary Resampler</value> - </param> - <param> - <key>len</key> - <value>1024</value> - </param> - <param> - <key>_coordinate</key> - <value>(9, 296)</value> - </param> - <param> - <key>_rotation</key> - <value>180</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>resamp_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>1.25</value> - </param> - <param> - <key>_coordinate</key> - <value>(272, 9)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>pfb_arb_resampler_xxx</key> - <param> - <key>id</key> - <value>pfb_arb_resampler_xxx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>ccf</value> - </param> - <param> - <key>rrate</key> - <value>resamp_rate</value> - </param> - <param> - <key>taps</key> - <value></value> - </param> - <param> - <key>nfilts</key> - <value>32</value> - </param> - <param> - <key>atten</key> - <value>60</value> - </param> - <param> - <key>_coordinate</key> - <value>(305, 280)</value> - </param> - <param> - <key>_rotation</key> - <value>180</value> - </param> - </block> - <block> - <key>gr_ctrlport_probe2_c</key> - <param> - <key>id</key> - <value>probe_frac_interp</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>name</key> - <value>fractional_interp</value> - </param> - <param> - <key>desc</key> - <value>Fractional Interpolator</value> - </param> - <param> - <key>len</key> - <value>1024</value> - </param> - <param> - <key>_coordinate</key> - <value>(10, 204)</value> - </param> - <param> - <key>_rotation</key> - <value>180</value> - </param> - </block> - <block> - <key>fractional_interpolator_xx</key> - <param> - <key>id</key> - <value>fractional_interpolator_xx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>phase_shift</key> - <value>0</value> - </param> - <param> - <key>interp_ratio</key> - <value>1.0/resamp_rate</value> - </param> - <param> - <key>_coordinate</key> - <value>(354, 212)</value> - </param> - <param> - <key>_rotation</key> - <value>180</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>samp_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>30e6</value> - </param> - <param> - <key>_coordinate</key> - <value>(181, 10)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>analog_sig_source_x</key> - <param> - <key>id</key> - <value>analog_sig_source_x_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>samp_rate</key> - <value>samp_rate</value> - </param> - <param> - <key>waveform</key> - <value>analog.GR_COS_WAVE</value> - </param> - <param> - <key>freq</key> - <value>samp_rate/10</value> - </param> - <param> - <key>amp</key> - <value>1</value> - </param> - <param> - <key>offset</key> - <value>0</value> - </param> - <param> - <key>_coordinate</key> - <value>(11, 93)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>channels_channel_model</key> - <param> - <key>id</key> - <value>channels_channel_model_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>noise_voltage</key> - <value>0.1</value> - </param> - <param> - <key>freq_offset</key> - <value>0.0</value> - </param> - <param> - <key>epsilon</key> - <value>1.0</value> - </param> - <param> - <key>taps</key> - <value>[1,]</value> - </param> - <param> - <key>seed</key> - <value>0</value> - </param> - <param> - <key>_coordinate</key> - <value>(382, 93)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>options</key> - <param> - <key>id</key> - <value>comparing_resamplers</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>title</key> - <value></value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> - </param> - <param> - <key>window_size</key> - <value>570,390</value> - </param> - <param> - <key>generate_options</key> - <value>no_gui</value> - </param> - <param> - <key>category</key> - <value>Custom</value> - </param> - <param> - <key>run_options</key> - <value>prompt</value> - </param> - <param> - <key>run</key> - <value>True</value> - </param> - <param> - <key>max_nouts</key> - <value>0</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(10, 10)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <connection> - <source_block_id>analog_sig_source_x_0</source_block_id> - <sink_block_id>blocks_throttle_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_throttle_0</source_block_id> - <sink_block_id>channels_channel_model_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>channels_channel_model_0</source_block_id> - <sink_block_id>pfb_arb_resampler_xxx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>channels_channel_model_0</source_block_id> - <sink_block_id>fractional_interpolator_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>pfb_arb_resampler_xxx_0</source_block_id> - <sink_block_id>probe_arc_resamp</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>fractional_interpolator_xx_0</source_block_id> - <sink_block_id>probe_frac_interp</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> -</flow_graph> diff --git a/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc b/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc deleted file mode 100644 index 31914412bc..0000000000 --- a/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc +++ /dev/null @@ -1,850 +0,0 @@ -<?xml version='1.0' encoding='ASCII'?> -<flow_graph> - <timestamp>Fri Mar 15 17:32:55 2013</timestamp> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>sps</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>2</value> - </param> - <param> - <key>_coordinate</key> - <value>(105, 126)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>samp_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>300000</value> - </param> - <param> - <key>_coordinate</key> - <value>(14, 124)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>import</key> - <param> - <key>id</key> - <value>import_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>import</key> - <value>import random, math, cmath</value> - </param> - <param> - <key>_coordinate</key> - <value>(14, 77)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>ctrlport_monitor</key> - <param> - <key>id</key> - <value>ctrlport_monitor_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>en</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(175, 10)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_vector_source_x</key> - <param> - <key>id</key> - <value>gr_vector_source_x_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>byte</value> - </param> - <param> - <key>vector</key> - <value>0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50</value> - </param> - <param> - <key>repeat</key> - <value>True</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(190, 71)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>blocks_packed_to_unpacked_xx</key> - <param> - <key>id</key> - <value>blocks_packed_to_unpacked_xx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>byte</value> - </param> - <param> - <key>bits_per_chunk</key> - <value>8</value> - </param> - <param> - <key>endianness</key> - <value>gr.GR_MSB_FIRST</value> - </param> - <param> - <key>num_ports</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(419, 10)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>blocks_throttle</key> - <param> - <key>id</key> - <value>blocks_throttle_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>byte</value> - </param> - <param> - <key>samples_per_second</key> - <value>samp_rate</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(436, 97)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>digital_psk_mod</key> - <param> - <key>id</key> - <value>digital_psk_mod_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>constellation_points</key> - <value>4</value> - </param> - <param> - <key>mod_code</key> - <value>"gray"</value> - </param> - <param> - <key>differential</key> - <value>True</value> - </param> - <param> - <key>samples_per_symbol</key> - <value>sps</value> - </param> - <param> - <key>excess_bw</key> - <value>0.35</value> - </param> - <param> - <key>verbose</key> - <value>False</value> - </param> - <param> - <key>log</key> - <value>False</value> - </param> - <param> - <key>_coordinate</key> - <value>(627, 65)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>digital_pfb_clock_sync_xxx</key> - <param> - <key>id</key> - <value>digital_pfb_clock_sync_xxx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>ccf</value> - </param> - <param> - <key>sps</key> - <value>sps</value> - </param> - <param> - <key>loop_bw</key> - <value>2*3.14/100.0</value> - </param> - <param> - <key>taps</key> - <value>firdes.root_raised_cosine(nfilts, nfilts,1.0/sps, 0.35, int(22*sps*nfilts))</value> - </param> - <param> - <key>filter_size</key> - <value>nfilts</value> - </param> - <param> - <key>init_phase</key> - <value>nfilts/2</value> - </param> - <param> - <key>max_dev</key> - <value>1.5</value> - </param> - <param> - <key>osps</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(339, 195)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>nfilts</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>32</value> - </param> - <param> - <key>_coordinate</key> - <value>(74, 390)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>amps</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>[1]</value> - </param> - <param> - <key>_coordinate</key> - <value>(7, 390)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>graymap</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>[[3,1,0,2]]</value> - </param> - <param> - <key>_coordinate</key> - <value>(7, 326)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>qtgui_const_sink_x</key> - <param> - <key>id</key> - <value>qtgui_const_sink_x_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>name</key> - <value>QT GUI Plot</value> - </param> - <param> - <key>size</key> - <value>1024</value> - </param> - <param> - <key>ymin</key> - <value>-2</value> - </param> - <param> - <key>ymax</key> - <value>2</value> - </param> - <param> - <key>xmin</key> - <value>-2</value> - </param> - <param> - <key>xmax</key> - <value>2</value> - </param> - <param> - <key>nconnections</key> - <value>2</value> - </param> - <param> - <key>update_time</key> - <value>0.10</value> - </param> - <param> - <key>gui_hint</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(752, 196)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>channels_channel_model</key> - <param> - <key>id</key> - <value>channels_channel_model_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>noise_voltage</key> - <value>noise</value> - </param> - <param> - <key>freq_offset</key> - <value>0.0</value> - </param> - <param> - <key>epsilon</key> - <value>1.0</value> - </param> - <param> - <key>taps</key> - <value>cmath.exp(1j*phase)</value> - </param> - <param> - <key>seed</key> - <value>0</value> - </param> - <param> - <key>_coordinate</key> - <value>(68, 211)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_ctrlport_probe2_c</key> - <param> - <key>id</key> - <value>received_probe2</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>name</key> - <value>received</value> - </param> - <param> - <key>desc</key> - <value>Constellation Points</value> - </param> - <param> - <key>len</key> - <value>1024</value> - </param> - <param> - <key>_coordinate</key> - <value>(195, 519)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_qtgui_range</key> - <param> - <key>id</key> - <value>phase</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Phase</value> - </param> - <param> - <key>value</key> - <value>0.5</value> - </param> - <param> - <key>start</key> - <value>0</value> - </param> - <param> - <key>stop</key> - <value>2</value> - </param> - <param> - <key>step</key> - <value>0.01</value> - </param> - <param> - <key>widget</key> - <value>counter_slider</value> - </param> - <param> - <key>orient</key> - <value>Qt.Horizontal</value> - </param> - <param> - <key>min_len</key> - <value>200</value> - </param> - <param> - <key>gui_hint</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(266, 344)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_ctrlport_probe2_c</key> - <param> - <key>id</key> - <value>time_probe2</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>name</key> - <value>time locked</value> - </param> - <param> - <key>desc</key> - <value>Constellation Points</value> - </param> - <param> - <key>len</key> - <value>1024</value> - </param> - <param> - <key>_coordinate</key> - <value>(447, 440)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_qtgui_range</key> - <param> - <key>id</key> - <value>noise</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Noise</value> - </param> - <param> - <key>value</key> - <value>0.050</value> - </param> - <param> - <key>start</key> - <value>0.0001</value> - </param> - <param> - <key>stop</key> - <value>2</value> - </param> - <param> - <key>step</key> - <value>0.01</value> - </param> - <param> - <key>widget</key> - <value>counter_slider</value> - </param> - <param> - <key>orient</key> - <value>Qt.Horizontal</value> - </param> - <param> - <key>min_len</key> - <value>200</value> - </param> - <param> - <key>gui_hint</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(7, 455)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>digital_costas_loop_cc</key> - <param> - <key>id</key> - <value>digital_costas_loop_cc_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>w</key> - <value>6.28/100.0</value> - </param> - <param> - <key>order</key> - <value>4</value> - </param> - <param> - <key>_coordinate</key> - <value>(610, 279)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_null_sink</key> - <param> - <key>id</key> - <value>gr_null_sink_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(859, 279)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_ctrlport_probe2_c</key> - <param> - <key>id</key> - <value>phase_probe2</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>name</key> - <value>phase locked</value> - </param> - <param> - <key>desc</key> - <value>Constellation Points</value> - </param> - <param> - <key>len</key> - <value>1024</value> - </param> - <param> - <key>_coordinate</key> - <value>(681, 379)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>options</key> - <param> - <key>id</key> - <value>pfb_sync_test_qt</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>title</key> - <value></value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> - </param> - <param> - <key>window_size</key> - <value>1280,1024</value> - </param> - <param> - <key>generate_options</key> - <value>qt_gui</value> - </param> - <param> - <key>category</key> - <value>Custom</value> - </param> - <param> - <key>run_options</key> - <value>prompt</value> - </param> - <param> - <key>run</key> - <value>True</value> - </param> - <param> - <key>max_nouts</key> - <value>0</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(10, 10)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <connection> - <source_block_id>blocks_throttle_0</source_block_id> - <sink_block_id>digital_psk_mod_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> - <sink_block_id>qtgui_const_sink_x_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_costas_loop_cc_0</source_block_id> - <sink_block_id>qtgui_const_sink_x_0</sink_block_id> - <source_key>0</source_key> - <sink_key>1</sink_key> - </connection> - <connection> - <source_block_id>digital_costas_loop_cc_0</source_block_id> - <sink_block_id>gr_null_sink_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>channels_channel_model_0</source_block_id> - <sink_block_id>digital_pfb_clock_sync_xxx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_psk_mod_0</source_block_id> - <sink_block_id>channels_channel_model_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_costas_loop_cc_0</source_block_id> - <sink_block_id>phase_probe2</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_packed_to_unpacked_xx_0</source_block_id> - <sink_block_id>blocks_throttle_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>gr_vector_source_x_0</source_block_id> - <sink_block_id>blocks_packed_to_unpacked_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>channels_channel_model_0</source_block_id> - <sink_block_id>received_probe2</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> - <sink_block_id>time_probe2</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> - <sink_block_id>digital_costas_loop_cc_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> -</flow_graph> diff --git a/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc b/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc deleted file mode 100644 index 5b0bfeb793..0000000000 --- a/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc +++ /dev/null @@ -1,668 +0,0 @@ -<?xml version='1.0' encoding='ASCII'?> -<flow_graph> - <timestamp>Thu Feb 21 19:08:39 2013</timestamp> - <block> - <key>options</key> - <param> - <key>id</key> - <value>pfb_sync_test</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>title</key> - <value></value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> - </param> - <param> - <key>window_size</key> - <value>1280, 1024</value> - </param> - <param> - <key>generate_options</key> - <value>wx_gui</value> - </param> - <param> - <key>category</key> - <value>Custom</value> - </param> - <param> - <key>run_options</key> - <value>prompt</value> - </param> - <param> - <key>run</key> - <value>True</value> - </param> - <param> - <key>max_nouts</key> - <value>0</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(10, 10)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>import</key> - <param> - <key>id</key> - <value>import_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>import</key> - <value>import random, math, cmath</value> - </param> - <param> - <key>_coordinate</key> - <value>(14, 77)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>samp_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>300000</value> - </param> - <param> - <key>_coordinate</key> - <value>(14, 124)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>graymap</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>[[3,1,0,2]]</value> - </param> - <param> - <key>_coordinate</key> - <value>(32, 387)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>amps</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>[1]</value> - </param> - <param> - <key>_coordinate</key> - <value>(32, 451)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>nfilts</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>32</value> - </param> - <param> - <key>_coordinate</key> - <value>(99, 451)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>digital_costas_loop_cc</key> - <param> - <key>id</key> - <value>digital_costas_loop_cc_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>w</key> - <value>6.28/100.0</value> - </param> - <param> - <key>order</key> - <value>4</value> - </param> - <param> - <key>_coordinate</key> - <value>(626, 223)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>sps</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>2</value> - </param> - <param> - <key>_coordinate</key> - <value>(105, 126)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_null_sink</key> - <param> - <key>id</key> - <value>gr_null_sink_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(964, 200)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_slider</key> - <param> - <key>id</key> - <value>noise</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value></value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>min</key> - <value>0.00000001</value> - </param> - <param> - <key>max</key> - <value>2</value> - </param> - <param> - <key>num_steps</key> - <value>100</value> - </param> - <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> - </param> - <param> - <key>converver</key> - <value>float_converter</value> - </param> - <param> - <key>grid_pos</key> - <value></value> - </param> - <param> - <key>notebook</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(281, 406)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_slider</key> - <param> - <key>id</key> - <value>phase</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value></value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>0</value> - </param> - <param> - <key>max</key> - <value>2</value> - </param> - <param> - <key>num_steps</key> - <value>100</value> - </param> - <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> - </param> - <param> - <key>converver</key> - <value>float_converter</value> - </param> - <param> - <key>grid_pos</key> - <value></value> - </param> - <param> - <key>notebook</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(167, 405)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>digital_pfb_clock_sync_xxx</key> - <param> - <key>id</key> - <value>digital_pfb_clock_sync_xxx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>ccf</value> - </param> - <param> - <key>sps</key> - <value>sps</value> - </param> - <param> - <key>loop_bw</key> - <value>2*3.14/100.0</value> - </param> - <param> - <key>taps</key> - <value>firdes.root_raised_cosine(nfilts, nfilts,1.0/sps, 0.35, int(22*sps*nfilts))</value> - </param> - <param> - <key>filter_size</key> - <value>nfilts</value> - </param> - <param> - <key>init_phase</key> - <value>nfilts/2</value> - </param> - <param> - <key>max_dev</key> - <value>1.5</value> - </param> - <param> - <key>osps</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(322, 231)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>digital_psk_mod</key> - <param> - <key>id</key> - <value>digital_psk_mod_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>constellation_points</key> - <value>4</value> - </param> - <param> - <key>mod_code</key> - <value>"gray"</value> - </param> - <param> - <key>differential</key> - <value>True</value> - </param> - <param> - <key>samples_per_symbol</key> - <value>sps</value> - </param> - <param> - <key>excess_bw</key> - <value>0.35</value> - </param> - <param> - <key>verbose</key> - <value>False</value> - </param> - <param> - <key>log</key> - <value>False</value> - </param> - <param> - <key>_coordinate</key> - <value>(846, 32)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>channels_channel_model</key> - <param> - <key>id</key> - <value>channels_channel_model_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>noise_voltage</key> - <value>noise</value> - </param> - <param> - <key>freq_offset</key> - <value>0.0</value> - </param> - <param> - <key>epsilon</key> - <value>1.0</value> - </param> - <param> - <key>taps</key> - <value>cmath.exp(1j*phase)</value> - </param> - <param> - <key>seed</key> - <value>0</value> - </param> - <param> - <key>_coordinate</key> - <value>(73, 247)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>ctrlport_monitor</key> - <param> - <key>id</key> - <value>ctrlport_monitor_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>en</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(228, 5)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>blocks_file_source</key> - <param> - <key>id</key> - <value>blocks_file_source_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>file</key> - <value>/dev/urandom</value> - </param> - <param> - <key>type</key> - <value>byte</value> - </param> - <param> - <key>repeat</key> - <value>True</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(229, 56)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>blocks_throttle</key> - <param> - <key>id</key> - <value>blocks_throttle_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>byte</value> - </param> - <param> - <key>samples_per_second</key> - <value>samp_rate</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(623, 64)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>blocks_packed_to_unpacked_xx</key> - <param> - <key>id</key> - <value>blocks_packed_to_unpacked_xx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>byte</value> - </param> - <param> - <key>bits_per_chunk</key> - <value>8</value> - </param> - <param> - <key>endianness</key> - <value>gr.GR_MSB_FIRST</value> - </param> - <param> - <key>num_ports</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(415, 56)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <connection> - <source_block_id>blocks_throttle_0</source_block_id> - <sink_block_id>digital_psk_mod_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> - <sink_block_id>digital_costas_loop_cc_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_costas_loop_cc_0</source_block_id> - <sink_block_id>gr_null_sink_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>channels_channel_model_0</source_block_id> - <sink_block_id>digital_pfb_clock_sync_xxx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_psk_mod_0</source_block_id> - <sink_block_id>channels_channel_model_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_file_source_0</source_block_id> - <sink_block_id>blocks_packed_to_unpacked_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_packed_to_unpacked_xx_0</source_block_id> - <sink_block_id>blocks_throttle_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> -</flow_graph> diff --git a/gnuradio-core/src/examples/mp-sched/affinity_set.py b/gnuradio-core/src/examples/mp-sched/affinity_set.py index 8b032acd83..eee88cd34e 100755 --- a/gnuradio-core/src/examples/mp-sched/affinity_set.py +++ b/gnuradio-core/src/examples/mp-sched/affinity_set.py @@ -7,6 +7,7 @@ from gnuradio import eng_notation from gnuradio import gr from gnuradio import blocks +from gnuradio import filter from gnuradio.eng_option import eng_option from gnuradio.filter import firdes from optparse import OptionParser @@ -27,21 +28,21 @@ class affinity_set(gr.top_block): ################################################## vec_len = 1 self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*vec_len, samp_rate) - self.gr_null_source_0 = gr.null_source(gr.sizeof_gr_complex*vec_len) - self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex*vec_len) - self.gr_filt_0 = gr.fir_filter_ccc(1, 40000*[0.2+0.3j,]) - self.gr_filt_1 = gr.fir_filter_ccc(1, 40000*[0.2+0.3j,]) + self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*vec_len) + self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*vec_len) + self.filter_filt_0 = filter.fir_filter_ccc(1, 40000*[0.2+0.3j,]) + self.filter_filt_1 = filter.fir_filter_ccc(1, 40000*[0.2+0.3j,]) - self.gr_filt_0.set_processor_affinity([0,]) - self.gr_filt_1.set_processor_affinity([0,1]) + self.filter_filt_0.set_processor_affinity([0,]) + self.filter_filt_1.set_processor_affinity([0,1]) ################################################## # Connections ################################################## - self.connect((self.gr_null_source_0, 0), (self.blocks_throttle_0, 0)) + self.connect((self.blocks_null_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.gr_filt_0, 0)) - self.connect((self.gr_filt_0, 0), (self.gr_filt_1, 0)) - self.connect((self.gr_filt_1, 0), (self.gr_null_sink_0, 0)) + self.connect((self.filter_filt_0, 0), (self.gr_filt_1, 0)) + self.connect((self.filter_filt_1, 0), (self.blocks_null_sink_0, 0)) # QT sink close method reimplementation diff --git a/gnuradio-core/src/examples/mp-sched/synthetic.py b/gnuradio-core/src/examples/mp-sched/synthetic.py index 5ce1b5eb89..6f0bb85da8 100755 --- a/gnuradio-core/src/examples/mp-sched/synthetic.py +++ b/gnuradio-core/src/examples/mp-sched/synthetic.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,6 +20,7 @@ # from gnuradio import gr, gru, eng_notation, blks2 +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os @@ -28,8 +29,8 @@ import os class pipeline(gr.hier_block2): def __init__(self, nstages, ntaps=256): """ - Create a pipeline of nstages of gr.fir_filter_fff's connected in serial - terminating in a gr.null_sink. + Create a pipeline of nstages of filter.fir_filter_fff's connected in serial + terminating in a blocks.null_sink. """ gr.hier_block2.__init__(self, "pipeline", gr.io_signature(1, 1, gr.sizeof_float), @@ -37,11 +38,11 @@ class pipeline(gr.hier_block2): taps = ntaps*[1.0/ntaps] upstream = self for i in range(nstages): - op = gr.fir_filter_fff(1, taps) + op = filter.fir_filter_fff(1, taps) self.connect(upstream, op) upstream = op - self.connect(upstream, gr.null_sink(gr.sizeof_float)) + self.connect(upstream, blocks.null_sink(gr.sizeof_float)) class top(gr.top_block): @@ -75,8 +76,8 @@ class top(gr.top_block): # Something vaguely like floating point ops self.flop = 2 * ntaps * options.npipelines * options.nstages * options.nsamples - src = gr.null_source(gr.sizeof_float) - head = gr.head(gr.sizeof_float, int(options.nsamples)) + src = blocks.null_source(gr.sizeof_float) + head = blocks.head(gr.sizeof_float, int(options.nsamples)) self.connect(src, head) for n in range(options.npipelines): diff --git a/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py b/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py index 2f638e26ec..7cf3210b0e 100755 --- a/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py +++ b/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py @@ -68,7 +68,7 @@ class wfm_rx_block (gr.top_block): 0.1, # passband ripple 60) # stopband attenuation #print len(chan_filt_coeffs) - chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) + chan_filt = filter.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) #self.guts = analog.wfm_rcv (demod_rate, audio_decimation) diff --git a/gnuradio-core/src/examples/network/vector_source.py b/gnuradio-core/src/examples/network/vector_source.py index b960a6d96a..568425fd50 100755 --- a/gnuradio-core/src/examples/network/vector_source.py +++ b/gnuradio-core/src/examples/network/vector_source.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2010 Free Software Foundation, Inc. +# Copyright 2006,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,7 +29,7 @@ class vector_source(gr.top_block): def __init__(self, host, port, pkt_size, eof): gr.top_block.__init__(self, "vector_source") data = [i*0.01 for i in range(1000)] - vec = gr.vector_source_f(data, True) + vec = blocks.vector_source_f(data, True) udp = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) self.connect(vec, udp) diff --git a/gnuradio-core/src/examples/volk_benchmark/volk_test_funcs.py b/gnuradio-core/src/examples/volk_benchmark/volk_test_funcs.py index 0ce25fcc6a..0f2c84100a 100644 --- a/gnuradio-core/src/examples/volk_benchmark/volk_test_funcs.py +++ b/gnuradio-core/src/examples/volk_benchmark/volk_test_funcs.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from gnuradio import gr +from gnuradio import blocks import math, sys, os, time try: @@ -119,13 +120,13 @@ class helper(gr.top_block): self.op = op self.srcs = [] self.snks = [] - self.head = gr.head(isizeof, N) + self.head = blocks.head(isizeof, N) for n in xrange(nsrcs): - self.srcs.append(gr.null_source(isizeof)) + self.srcs.append(blocks.null_source(isizeof)) for n in xrange(nsnks): - self.snks.append(gr.null_sink(osizeof)) + self.snks.append(blocks.null_sink(osizeof)) self.connect(self.srcs[0], self.head, (self.op,0)) diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt index 72b9f9bdeb..c72be94db5 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -27,10 +27,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/ConfigChecks.cmake) ######################################################################## GR_INCLUDE_SUBDIRECTORY(missing) GR_INCLUDE_SUBDIRECTORY(runtime) -GR_INCLUDE_SUBDIRECTORY(filter) GR_INCLUDE_SUBDIRECTORY(general) -GR_INCLUDE_SUBDIRECTORY(gengen) -GR_INCLUDE_SUBDIRECTORY(io) list(APPEND gnuradio_core_sources bug_work_around_6.cc) list(APPEND test_gnuradio_core_sources bug_work_around_6.cc) diff --git a/gnuradio-core/src/lib/filter/CMakeLists.txt b/gnuradio-core/src/lib/filter/CMakeLists.txt deleted file mode 100644 index a185b06bd5..0000000000 --- a/gnuradio-core/src/lib/filter/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# 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. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## - -######################################################################## -# Append gnuradio-core library sources -######################################################################## -list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.c -) - -######################################################################## -# Install runtime headers -######################################################################## -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/gr_rotator.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) diff --git a/gnuradio-core/src/lib/filter/gr_rotator.h b/gnuradio-core/src/lib/filter/gr_rotator.h deleted file mode 100644 index 77946dd397..0000000000 --- a/gnuradio-core/src/lib/filter/gr_rotator.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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. - */ - -#ifndef _GR_ROTATOR_H_ -#define _GR_ROTATOR_H_ - -#include <gr_core_api.h> -#include <gr_complex.h> - -class /*GR_CORE_API*/ gr_rotator { - gr_complex d_phase; - gr_complex d_phase_incr; - unsigned int d_counter; - - public: - gr_rotator () : d_phase (1), d_phase_incr (1), d_counter(0) { } - - void set_phase (gr_complex phase) { d_phase = phase / abs(phase); } - void set_phase_incr (gr_complex incr) { d_phase_incr = incr / abs(incr); } - - gr_complex rotate (gr_complex in){ - d_counter++; - - gr_complex z = in * d_phase; // rotate in by phase - d_phase *= d_phase_incr; // incr our phase (complex mult == add phases) - - if ((d_counter % 512) == 0) - d_phase /= abs(d_phase); // Normalize to ensure multiplication is rotation - - return z; - } - -}; - -#endif /* _GR_ROTATOR_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_rotator.cc b/gnuradio-core/src/lib/filter/qa_rotator.cc deleted file mode 100644 index b722f32c43..0000000000 --- a/gnuradio-core/src/lib/filter/qa_rotator.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,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 <gruel/attributes.h> -#include <cppunit/TestAssert.h> -#include <qa_rotator.h> -#include <analog/rotator.h> -#include <stdio.h> -#include <cmath> -#include <gr_expj.h> - -namespace gr { - namespace analog { - - // error vector magnitude - __GR_ATTR_UNUSED static float - error_vector_mag(gr_complex a, gr_complex b) - { - return abs(a-b); - } - - void - qa_rotator::t1() - { - static const unsigned int N = 100000; - - rotator r; - - double phase_incr = 2*M_PI / 1003; - double phase = 0; - - // Old code: We increment then return the rotated value, thus we - // need to start one tick back - // r.set_phase(gr_complex(1,0) * conj(gr_expj(phase_incr))); - - r.set_phase(gr_complex(1,0)); - r.set_phase_incr(gr_expj(phase_incr)); - - for(unsigned i = 0; i < N; i++) { - gr_complex expected = gr_expj(phase); - gr_complex actual = r.rotate(gr_complex(1, 0)); - -#if 0 - float evm = error_vector_mag(expected, actual); - printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n", - i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm); -#endif - - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); - - phase += phase_incr; - if(phase >= 2*M_PI) - phase -= 2*M_PI; - } - } - - } /* namespace analog */ -} /* namespace gr */ diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index e3dc18520b..d85039fe60 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -22,6 +22,26 @@ ######################################################################## ######################################################################## +# Handle the generated sine table +######################################################################## +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_sine_table.py + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/gen_sine_table.py > + ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h +) + +include(AddFileDependencies) +ADD_FILE_DEPENDENCIES(${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc + ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h +) + +add_custom_target(general_generated DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h +) + +######################################################################## # Handle the generated constants ######################################################################## execute_process(COMMAND ${PYTHON_EXECUTABLE} -c @@ -50,9 +70,11 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_BINARY_DIR}/gr_constants.cc) list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_fast_atan2f.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.c ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.cc ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.c ) @@ -63,7 +85,11 @@ list(APPEND gnuradio_core_sources list(APPEND test_gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/qa_general.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_circular_file.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt_nco.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt_vco.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_math.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_sincos.cc ) ######################################################################## @@ -73,15 +99,20 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_core_api.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_expj.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_nco.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_vco.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_math.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_nco.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_test_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vco.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_15_1_0.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_32k.h ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.h ${CMAKE_CURRENT_SOURCE_DIR}/random.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio @@ -105,39 +136,11 @@ endif(ENABLE_PYTHON) ######################################################################## set(gr_core_general_triple_threats complex_vec_test - gr_align_on_samplenumbers_ss gr_block_gateway - gr_check_counting_s - gr_check_lfsr_32k_s - gr_copy - gr_endian_swap - gr_fake_channel_coder_pp gr_feval - gr_head - gr_iqcomp_cc - gr_kludge_copy - gr_lfsr_32k_source_s - gr_nop - gr_null_sink - gr_null_source - gr_pa_2x2_phase_combiner gr_prefs - gr_skiphead gr_test - gr_vector_map - gr_annotator_alltoall - gr_annotator_1to1 - gr_annotator_raw -) - -if(ENABLE_GR_CTRLPORT) -ADD_DEFINITIONS(-DGR_CTRLPORT) -list(APPEND gr_core_general_triple_threats - gr_ctrlport_probe_c - gr_ctrlport_probe2_c ) -endif(ENABLE_GR_CTRLPORT) - foreach(file_tt ${gr_core_general_triple_threats}) list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.cc) @@ -146,3 +149,11 @@ foreach(file_tt ${gr_core_general_triple_threats}) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig") endif(ENABLE_PYTHON) endforeach(file_tt ${gr_core_general_triple_threats}) + +CHECK_CXX_SOURCE_COMPILES(" + #define _GNU_SOURCE + #include <math.h> + int main(){double x, sin, cos; sincos(x, &sin, &cos); return 0;} + " HAVE_SINCOS +) +GR_ADD_COND_DEF(HAVE_SINCOS) diff --git a/gnuradio-core/src/lib/general/README b/gnuradio-core/src/lib/general/README deleted file mode 100644 index 5fa18d7f64..0000000000 --- a/gnuradio-core/src/lib/general/README +++ /dev/null @@ -1,98 +0,0 @@ -Files beginning with Gr* define classes that inherit from VrSigProc. -These are high level signal processing modules that can be glued -together in your signal processing chain. - -All the others are either lower level routines which implement the -functionality of the Gr* modules, but are easier to test (fewer -dependencies), or they are general purpose. - -gr_fir_???.{h,cc}, where ??? are in F, S or C are low level Finite -Impulse Response Filters. These turn out to be where the bulk of the -cycles are burned in many applications. The ??? suffix specifies the -input type, output type and tap type of the arguments. We've -implemented the most frequently used ones. - -[Once upon a time this stuff was done with templates -(gr_fir<iType,oType,tapType>), but this turned out to be a headache. -The code appeared to trigger a bug in GCC where we were getting -multiple definitions of unrelated stuff when we started subclassing -partially specialized templates. It was also not obvious as to to -what combinations of iType, oType and tapType actually worked. We're -now explicit, and the world is a safer place to live...] - -The top level routines for FIR filtering are: - - GrFIRfilterFFF : Float input, Float output, Float taps - -- general purpose - - GrFIRfilterCCF : Complex input, Complex output, Float taps - -- applying real filter to a complex signal - - GrFIRfilterFCC : Float input, Complex output, Complex taps - -- applying complex filter to float input - - GrFIRfilterSCC : Short input, Complex output, Complex taps - -- applying complex filter to short input. Quantizes complex - coefficients to 16 bits and uses MMX or SSE2 as appropriate - - -The combination of down conversion (frequency translation) and channel -selection (filtering) is performed with: - - GrFreqXlatingFIRfilterSFC : Short input, Float taps, Complex baseband output - -- quantizes complex coefficents to 16 bits and uses MMX or - SSE2 (128-bit MMX) as appropriate [optimization to be done]. - - GrFreqXlatingFIRfilterFFC : Float input, Float taps, Complex baseband output - -- 3dnow or SSE as appropriate. - - -[ The stuff described from here down is used to implement the routines - above. This info is only relevant to those who are hacking the internals ] - - -A bit of indirection is involved in selecting the fastest -implementation for any given platform. The lower level classes -gr_fir_FFF.h, gr_fir_CCF, gr_fir_FCC and gr_fir_SCC have i/o -signatures similar to the high level clases above. These -should be considered the abstract base classes that you -work with. Note that they are not actually abstract (they've got a -default implementation; this might be considered a bug), but they -should not be directly instantiated by user code. - -Instead of directly instantiating a gr_fir_FFF, for example, your code -should actually: - - #include <gr_fir_util.h> - - // let the system pick the best implementation for you - gr_fir_FFF *filter = gr_fir_util::create_gr_fir_FFF (my_taps); - -Clear? The same for all the other gr_fir_XXX's. - - - -Performance hacking can be done by subclassing the appropriate -base class. For example, on the x86 platform, there are two -additional classes derived from gr_fir_FFF, gr_fir_FFF_sse and -gr_fir_FFF_3dnow. These classes are then made available to the rest -of the system by virtue of being added to gr_fir_sysconfig_x86.cc, -along with any guards (CPUID checks) needed to ensure that only -compatible code is executed on the current hardware. - - -TO DO ------- - -* Move all the machine specific code to a subdirectory, then have -configure symlink to the right directory. This will allow us to build on -any platform without choking. There is generic code for all routines, -only the machine dependent speedup will be lacking. - -* Add an interface to gr_fir_util that will return a vector of all -valid constructors with descriptive names for each i/o signature. -This will allow the test code and benchmarking code to be blissfully -ignorant of what platform they're running on. The actual building of -the vectors should be done bottom up through the gr_fir_sysconfig -hierarchy. - diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index bcf4392bb4..68b963702c 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -22,69 +22,20 @@ %{ -#include <gr_nop.h> -#include <gr_null_sink.h> -#include <gr_null_source.h> -#include <gr_head.h> -#include <gr_skiphead.h> -#include <gr_check_counting_s.h> -#include <gr_lfsr_32k_source_s.h> -#include <gr_check_lfsr_32k_s.h> -#include <gr_align_on_samplenumbers_ss.h> -//#include <gr_endianness.h> -#include <gr_endian_swap.h> -#include <gr_fake_channel_coder_pp.h> -#include <gr_pa_2x2_phase_combiner.h> -#include <gr_kludge_copy.h> #include <gr_prefs.h> #include <gr_constants.h> #include <gr_test_types.h> #include <gr_test.h> #include <gr_feval.h> -#include <gr_copy.h> #include <complex_vec_test.h> -#include <gr_annotator_alltoall.h> -#include <gr_annotator_1to1.h> -#include <gr_annotator_raw.h> -#include <gr_vector_map.h> +#include <gr_endianness.h> %} -%include "gr_nop.i" -%include "gr_null_sink.i" -%include "gr_null_source.i" -%include "gr_head.i" -%include "gr_skiphead.i" -%include "gr_check_counting_s.i" -%include "gr_lfsr_32k_source_s.i" -%include "gr_check_lfsr_32k_s.i" -%include "gr_align_on_samplenumbers_ss.i" -//%include "gr_endianness.i" -%include "gr_endian_swap.i" -%include "gr_fake_channel_coder_pp.i" -%include "gr_pa_2x2_phase_combiner.i" -%include "gr_kludge_copy.i" %include "gr_prefs.i" %include "gr_constants.i" %include "gr_test_types.h" %include "gr_test.i" %include "gr_feval.i" -%include "gr_copy.i" %include "complex_vec_test.i" -%include "gr_annotator_alltoall.i" -%include "gr_annotator_1to1.i" -%include "gr_annotator_raw.i" -%include "gr_vector_map.i" %include "gr_block_gateway.i" - - -#ifdef GR_CTRLPORT - -%{ -#include <gr_ctrlport_probe_c.h> -#include <gr_ctrlport_probe2_c.h> -%} - -%include "gr_ctrlport_probe_c.i" -%include "gr_ctrlport_probe2_c.i" - -#endif /* GR_CTRLPORT */ +%include "gr_endianness.h" diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i deleted file mode 100644 index c3f67e0d47..0000000000 --- a/gnuradio-core/src/lib/general/general_generated.i +++ /dev/null @@ -1,26 +0,0 @@ -// -// This file is machine generated. All edits will be overwritten -// -%{ -#include <gr_vector_sink_b.h> -#include <gr_vector_sink_c.h> -#include <gr_vector_sink_f.h> -#include <gr_vector_sink_i.h> -#include <gr_vector_sink_s.h> -#include <gr_vector_source_b.h> -#include <gr_vector_source_c.h> -#include <gr_vector_source_f.h> -#include <gr_vector_source_i.h> -#include <gr_vector_source_s.h> -%} - -%include <gr_vector_sink_b.i> -%include <gr_vector_sink_c.i> -%include <gr_vector_sink_f.i> -%include <gr_vector_sink_i.i> -%include <gr_vector_sink_s.i> -%include <gr_vector_source_b.i> -%include <gr_vector_source_c.i> -%include <gr_vector_source_f.i> -%include <gr_vector_source_i.i> -%include <gr_vector_source_s.i> diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc deleted file mode 100644 index 4728533964..0000000000 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc +++ /dev/null @@ -1,464 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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_align_on_samplenumbers_ss.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <stdexcept> -#include <string.h> -#include <cstdio> - -//define ALIGN_ADVANCED_IMPLEMENTATION to have an alternative implementation of the align algoritm which exactly follows the align_interval spec. -//It is more resource intensive, less tested and probably not needed -//define ALIGN_ADVANCED_IMPLEMENTATION - -//define DEBUG_TOCONSUME to see debug messages about the synchronisation part of this block -//define DEBUG_TOCONSUME -#ifdef DEBUG_TOCONSUME -#define tcPrintf if(dprint) printf -#else -#define tcPrintf //printf -#endif - -#define ePrintf printf - -gr_align_on_samplenumbers_ss_sptr -gr_make_align_on_samplenumbers_ss (int nchan, int align_interval) -{ - return gnuradio::get_initial_sptr(new gr_align_on_samplenumbers_ss (nchan,align_interval)); -} - -gr_align_on_samplenumbers_ss::gr_align_on_samplenumbers_ss (int nchan,int align_interval) - : gr_block ("align_on_samplenumbers_ss", - gr_make_io_signature (2, -1, sizeof (short)), //2, -1 - gr_make_io_signature (2, -1, sizeof (short))), //2,-1 - d_align_interval (align_interval), - d_nchan(nchan), - d_ninputs(0) -{ - if (d_align_interval<0) - set_output_multiple (d_nchan*2); - else - { - set_output_multiple (d_align_interval*d_nchan*2); - } - -} - -gr_align_on_samplenumbers_ss::~gr_align_on_samplenumbers_ss() -{ - -} -void -gr_align_on_samplenumbers_ss::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - //assert (0 == noutput_items % d_align_interval); - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) - ninput_items_required[i] = std::max(noutput_items*d_nchan*2+ history() - 1,1024*d_nchan*2+ history() - 1);//TODO include the diffs found in determine input_items_required -} - -bool -gr_align_on_samplenumbers_ss::check_topology (int ninputs, int noutputs) -{ - bool result=true; - if(noutputs!=ninputs) - { - result=false; - ePrintf("gr_align_on_samplenumbers_ss: ERROR noutputs %i != ninputs %i\n",noutputs,ninputs); - } - if(d_nchan<2) - { - result=false; - ePrintf("gr_align_on_samplenumbers_ss: ERROR nchan %i<2 \n",d_nchan); - } - if((int)d_ninputs!=ninputs) - { - //Only resize and reset the status if there really changed something - //Don't reset the status if the user just called stop() and start(), although maybe we should. - d_state.resize(ninputs); - d_ninputs=ninputs; - for(unsigned int i=0;i<d_ninputs;i++) - { - d_state[i].sync_found=false; - d_state[i].sync_end_found=false; - } - d_in_presync=false; - } - return result; -} - -#ifdef ALIGN_ADVANCED_IMPLEMENTATION -int -gr_align_on_samplenumbers_ss::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ -#ifdef DEBUG_TOCONSUME - static int dcount=0; - bool dprint=false; - dcount++; - if(dcount>200) - { - dcount=0; - dprint=true; - } -#endif - const size_t item_size = output_signature()->sizeof_stream_item (0); - const unsigned ninputs = input_items.size(); - const unsigned noutputs = output_items.size(); - - int align_interval=d_align_interval*2*d_nchan; - if(d_align_interval<0) - { - //align once per noutput_items - align_interval=noutput_items; - align_interval=align_interval/(2*d_nchan); - align_interval=align_interval*(2*d_nchan); - } - - int min_ninput_items=noutput_items;//numeric_limits<int>::max(); - int noutput_items_produced=0; - for(unsigned int i=0;i<ninputs;i++) - { - d_state[i].ninput_items=ninput_items[i]; - d_state[i].ninput_items_used=0; - min_ninput_items=std::min(ninput_items[i],min_ninput_items); - } - for(int j=0;j<noutput_items-align_interval+1;j+=align_interval) - { - int common_end; - if(min_ninput_items>=align_interval) - common_end=align_interval; - else - { - common_end=min_ninput_items/(d_nchan*2); - common_end=common_end*(d_nchan*2); - } - if (common_end<=0) break; - - bool all_diffs_zero=true; - //bool sync_found=false; - int diff_comp_end_max=0; - for(unsigned int i=0;i<ninputs;i++) - { - unsigned short * uin=&(((unsigned short*)input_items[i])[d_state[i].ninput_items_used]); - unsigned int x_high16bits = uin[0]; - unsigned int x_low16bits = uin[1]; - d_state[i].ucounter_begin = x_high16bits<<16 | x_low16bits; - d_state[i].diff=d_state[0].ucounter_begin-d_state[i].ucounter_begin;//Result is a signed value,Will wrap around on 32 bit boundary - int common_last=std::max(common_end-d_nchan*2,0); - x_high16bits = uin[d_nchan*2]; - x_low16bits = uin[d_nchan*2+1]; - unsigned int ucounter_begin2 = x_high16bits<<16 | x_low16bits; -#ifdef DEBUG_TOCONSUME - if((d_state[i].ucounter_begin+1)!=(ucounter_begin2)) - if(ucounter_begin2==0) - ePrintf("SYNC counters are 0\n"); - else - ePrintf("Error: counter not continuous.\n ucounter_begin[%i]=%i +1 != ucounter_begin2=%i\n",i,d_state[i].ucounter_begin,ucounter_begin2); -#endif - x_high16bits = uin[common_last]; - x_low16bits = uin[common_last+1]; - d_state[i].ucounter_end = x_high16bits<<16 | x_low16bits; - d_state[i].diff_end=d_state[0].ucounter_end-d_state[i].ucounter_end;//Result is a signed value,Will wrap around on 32 bit boundary - d_state[i].diff_comp_end=d_state[i].ucounter_end-d_state[0].ucounter_end; - diff_comp_end_max=std::max(d_state[i].diff_comp_end,diff_comp_end_max); -#ifdef DEBUG_TOCONSUME - if(d_state[i].diff>256000000 || d_state[i].diff_end>256000000 || d_state[i].diff_comp_end>256000000) - { - tcPrintf("diff[%i]=%i diff_end=%i diff_comp_end=%i\n",i,d_state[i].diff,d_state[i].diff_end,d_state[i].diff_comp_end); - } -#endif - all_diffs_zero=all_diffs_zero && (0==d_state[i].diff_end); - if(d_state[i].ucounter_end<d_state[i].ucounter_begin+(unsigned)(common_last/(d_nchan*2))) //(unsigned)(common_last/(d_nchan*2))) - { - //printf("sync 1 ");// found ucounter_end[%i]=%i ucounter_begin[%i]=%i \n",i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); - //sync_found=true;//sync_found or 32 bit counter wraparound (0xffffffff -> 0x00000000) - if(!d_in_presync) - { -#ifdef DEBUG_TOCONSUME - printf("presync START with %i\n",i); -#endif - for(unsigned int k=0;k<ninputs;k++) - { - d_state[k].sync_found=false; - d_state[i].sync_end_found=false; - } - d_in_presync=true; - d_state[i].sync_found=true; - } else - { - //d_in_presync=true; -#ifdef DEBUG_TOCONSUME - if(d_state[i].sync_found) - printf("presync CONTINUE with %i\n",i); - else - printf("presync NEXT with %i\n",i); -#endif - d_state[i].sync_found=true; - d_state[i].sync_end_found=false; - } - } else - { - if(d_in_presync && d_state[i].sync_found) - { - d_state[i].sync_end_found=true; - bool all_syncs_found=true; - for(unsigned int k=0;k<ninputs;k++) - all_syncs_found=all_syncs_found && d_state[k].sync_end_found; - d_in_presync=!all_syncs_found; - if(!d_in_presync) - { - for(unsigned int k=0;k<ninputs;k++) - { - d_state[k].sync_found=false; - d_state[i].sync_end_found=false; - } -#ifdef DEBUG_TOCONSUME - printf("presync END\n"); -#endif - } - } - } - } - if(d_in_presync || all_diffs_zero) - { - for(unsigned int i=0;i<ninputs;i++) - { - memcpy(&(((unsigned short*)output_items[i])[j]),&(((const unsigned short*)input_items[i])[d_state[i].ninput_items_used]),common_end*item_size); - //consume(i,common_end); - d_state[i].ninput_items-=common_end; - d_state[i].ninput_items_used+=common_end; - min_ninput_items=std::min(d_state[i].ninput_items,min_ninput_items); -#ifdef DEBUG_TOCONSUME - if(common_end<256) - tcPrintf("common_end %i\n",common_end); -#endif - } - //min_ninput_items-=common_end; - noutput_items_produced+=common_end; - //return common_end; - } else - { - //printf("sync 2"); - for(unsigned int i=0;i<ninputs;i++) - { - int toconsume=std::min((d_state[i].diff_end+diff_comp_end_max)*d_nchan*2,d_state[i].ninput_items); - toconsume=toconsume/(d_nchan*2); - toconsume=toconsume*(d_nchan*2); - d_state[i].ninput_items-=toconsume; - d_state[i].ninput_items_used+=toconsume; - min_ninput_items=std::min(d_state[i].ninput_items,min_ninput_items); -#ifdef DEBUG_TOCONSUME - static int toconsume_counter=0; - toconsume_counter++; - //if(toconsume_counter>10) - { - tcPrintf("toconsume=%i diff_end[%i]*d_nchan*2=%i diff_comp_end_max*d_nchan*2=%i ninput_items[%i]=%i\n",toconsume,i,d_state[i].diff_end*d_nchan*2,diff_comp_end_max*d_nchan*2,i,ninput_items[i]); - toconsume_counter=0; - } -#endif - //printf("toconsume[%i]=%i\n",i,toconsume); - //consume(i,toconsume);//skip the difference in samplenumber items - } - //return 0; - } - } - for(unsigned int i=0;i<ninputs;i++) - consume(i,d_state[i].ninput_items_used); -#ifdef DEBUG_TOCONSUME - if(noutput_items_produced<256) - tcPrintf("noutput_items_produced %i\n",noutput_items_produced); -#endif - return noutput_items_produced; -} - - -#else /*ALIGN_ADVANCED_IMPLEMENTATION*/ -int -gr_align_on_samplenumbers_ss::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ -#ifdef DEBUG_TOCONSUME - static int dcount=0; - bool dprint=false; - dcount++; - if(dcount>2000) - { - dcount=0; - dprint=true; - } -#endif - const size_t item_size = output_signature()->sizeof_stream_item (0); - const unsigned ninputs = input_items.size(); - - int common_end=noutput_items; - //int diff_min=INT_MAX; - //int diff_max=INT_MIN; - for(unsigned int i=0;i<ninputs;i++) - { - unsigned short * uin=(unsigned short*)input_items[i]; - unsigned int x_high16bits = uin[0]; - unsigned int x_low16bits = uin[1]; - d_state[i].ucounter_begin = x_high16bits<<16 | x_low16bits; - d_state[i].diff=d_state[0].ucounter_end-d_state[i].ucounter_end;//Result is a signed value,Will wrap around on 32 bit boundary - x_high16bits = uin[d_nchan*2]; - x_low16bits = uin[d_nchan*2+1]; - unsigned int ucounter_begin2 = x_high16bits<<16 | x_low16bits; - if((d_state[i].ucounter_begin+1)!=(ucounter_begin2)){ - if(ucounter_begin2==0) - { -#ifdef DEBUG_TOCONSUME - ePrintf("SYNC counters are 0\n"); -#endif - } - else - { - ePrintf("Error: counter not continuous.\n ucounter_begin[%i]=%i +1 != ucounter_begin2=%i\n",i,d_state[i].ucounter_begin,ucounter_begin2); - } - } - - //diff_comp[i]=ucounter[i]-ucounter[0]; - //diff_min=std::min(diff[i],diff_min); - //diff_max=std::max(diff[i],diff_max); - common_end=std::max(std::min(ninput_items[i],common_end),0); - } - common_end=common_end/(d_nchan*2); - common_end=common_end*(d_nchan*2); -#ifdef DEBUG_TOCONSUME - if(common_end<d_nchan*2) - { - printf(" common_end %i\n",common_end); - for(int j=0;j<ninputs;j++) - printf("ninput_items[%i]=%i\n",j,ninput_items[j]); - } -#endif - bool all_diffs_zero=true; - bool sync_found=false; - int diff_comp_end_max=0; - for(unsigned int i=0;i<ninputs;i++) - { - unsigned short * uin=(unsigned short*)input_items[i]; - int common_last=common_end-(d_nchan*2); - unsigned int x_high16bits = uin[common_last]; - unsigned int x_low16bits = uin[common_last+1]; - d_state[i].ucounter_end = x_high16bits<<16 | x_low16bits; - d_state[i].diff_end=d_state[0].ucounter_end-d_state[i].ucounter_end;//Result is a signed value,Will wrap around on 32 bit boundary - d_state[i].diff_comp_end=d_state[i].ucounter_end-d_state[0].ucounter_end; - //diff_end_min=std::min(diff_end[i],diff_end_min); - //diff_end_max=std::max(diff_end[i],diff_end_max); - diff_comp_end_max=std::max(d_state[i].diff_comp_end,diff_comp_end_max); -#ifdef DEBUG_TOCONSUME - if(d_state[i].diff_end!=d_state[i].diff) - { - //samples_lost_or_syncstart=true; - printf("Us%i %i %i ",i,d_state[i].diff_end,d_state[i].diff); - } -#endif - all_diffs_zero=all_diffs_zero && (0==d_state[i].diff_end); - if((d_state[i].ucounter_end<d_state[i].ucounter_begin+(unsigned)(common_last/(d_nchan*2))) || (0==d_state[i].ucounter_end) || (0==d_state[i].ucounter_begin)) //(unsigned)(common_last/(d_nchan*2))) - { - sync_found=true;//sync_found or 32 bit counter wraparound (0xffffffff -> 0x00000000) -#ifdef DEBUG_TOCONSUME - tcPrintf("SYNC diff_end[%i]=%i ucounter_end[%i]=%i ucounter_begin[%i]=%i \n",i,d_state[i].diff_end,i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); - tcPrintf("ucounter_end=%i < %i = ucounter_begin+(unsigned)(common_last/(d_nchan*2) \n",d_state[i].ucounter_end,d_state[i].ucounter_begin+(unsigned)(common_last/(d_nchan*2))); - - printf("ucounter_end[%i]=%i ucounter_begin[%i]=%i\n",i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); - int expected_sync_position=common_last - d_state[i].ucounter_end*(d_nchan*2); - if(0==uin[expected_sync_position] && 0==uin[expected_sync_position+1]) - { - printf("sync found on input %i at position %i \n",i,expected_sync_position); - //sync_start[i]=expected_sync_position; - } else - { - printf("sync found on input %i position unclear, expected at %i value there %i\n",i,expected_sync_position,uin[expected_sync_position]<<16 | uin[expected_sync_position+1]); - //sync_start[i]=-1; - } - } else - { - tcPrintf("NOsync diff_end[%i]=%i ucounter_end[%i]=%i ucounter_begin[%i]=%i \n",i,d_state[i].diff_end,i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); -#endif - } - } - bool problem=false; - for(unsigned int i=0;i<ninputs;i++) - if((d_state[i].diff_end+diff_comp_end_max) >0x4000000) - { - problem=true; - ePrintf("Warning: counter diff greater as 64 Million\n"); - ePrintf(" You might want to swap master and slave.\n"); - ePrintf(" i=%i,d_state[i].diff_end+diff_comp_end_max=%i,d_state[i].diff_end=%i,diff_comp_end_max=%i,ucounter[i]=%i,ucounter[0]=%i\n", - i,d_state[i].diff_end+diff_comp_end_max,d_state[i].diff_end,diff_comp_end_max,d_state[i].ucounter_end,d_state[0].ucounter_end); - //ePrintf(" toconsume=%i\n",toconsume); - } - if(sync_found || all_diffs_zero || problem) - { -#ifdef DEBUG_TOCONSUME - if(all_diffs_zero) tcPrintf("ZERO\n"); - if(sync_found) tcPrintf("SYNC\n"); -#endif - for(unsigned int i=0;i<ninputs;i++) - { - memcpy(output_items[i],input_items[i],common_end*item_size); - consume(i,common_end); -#ifdef DEBUG_TOCONSUME - if(common_end<256) - tcPrintf("common_end %i\n",common_end); -#endif - } - return common_end; - } else - { - //int minconsume=0;//common_end/(2*d_nchan*2); - //min_consume=min_consume*d_nchan*2; - for(unsigned int i=0;i<ninputs;i++) - { - int toconsume=std::min((d_state[i].diff_end+diff_comp_end_max)*d_nchan*2,ninput_items[i]); - toconsume=toconsume/(d_nchan*2); - toconsume=toconsume*(d_nchan*2); -#ifdef DEBUG_TOCONSUME - //printf("dcount %i\n",dcount); - static int toconsume_counter=0; - toconsume_counter++; - //if(toconsume_counter>10) - { - tcPrintf("toconsume=%i diff_end[[%i]*d_nchan*2=%i diff_comp_end_max)*d_nchan*2=%i ninput_items[%i]=%i\n", - toconsume,i,d_state[i].diff_end*d_nchan*2,diff_comp_end_max*d_nchan*2,i,ninput_items[i]); - toconsume_counter=0; - } -#endif - consume(i,toconsume);//skip the difference in samplenumber items - //printf("toconsume%i %i diff_comp_end_max %i diff_end[[%i] %i\n",i,toconsume,diff_comp_end_max,i,d_state[i].diff_end); - } - return 0; - } - return -1;//Should never come here -} -#endif /*ALIGN_ADVANCED_IMPLEMENTATION*/ diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h deleted file mode 100644 index 1b71a3f4bc..0000000000 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- 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. - */ - -#ifndef INCLUDED_GR_ALIGN_ON_SAMPLE_NUMBERS_SS_H -#define INCLUDED_GR_ALIGN_ON_SAMPLE_NUMBERS_SS_H - -#include <gr_core_api.h> -#include <gr_block.h> - -/*! - * \brief align several complex short (interleaved short) input channels with corresponding unsigned 32 bit sample_counters (provided as interleaved 16 bit values) - * \ingroup misc - * \param number of complex_short input channels (including the 32 bit counting channel) - * \param align_interval is after how much samples (minimally) the sample-alignement is refreshed. Default is 128. - * A bigger value means less processing power but also requests more buffer space, which has a maximum. - * Decrease the align_interval if you get an error like: - * "sched: <gr_block align_on_samplenumbers_ss (0)> is requesting more input data than we can provide. - * ninput_items_required = 32768 - * max_possible_items_available = 16383 - * If this is a filter, consider reducing the number of taps." - * \ingroup block - * Pay attention on how you connect this block. - * It expects a minimum of 2 usrp_source_s with nchan number of channels and FPGA_MODE_COUNTING_32BIT enabled. - * This means that the first complex_short channel on every input is an interleaved 32 bit counter. - * The samples are aligned by dropping samples untill the samplenumbers match. - */ -class gr_align_on_samplenumbers_ss; -typedef boost::shared_ptr<gr_align_on_samplenumbers_ss> gr_align_on_samplenumbers_ss_sptr; - -GR_CORE_API gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan=2, int align_interval=128); - - - - -class GR_CORE_API gr_align_on_samplenumbers_ss : public gr_block -{ - int d_align_interval; - int d_sample_counter; - int d_nchan; - bool d_in_presync; - unsigned int d_ninputs; - class GR_CORE_API align_state { - public: - unsigned int ucounter_end; - unsigned int ucounter_begin; - int diff; - int diff_comp; - int diff_end; - int diff_comp_end; - bool sync_found; - bool sync_end_found; - int ninput_items; - int ninput_items_used; - }; - std::vector<align_state> d_state; - - friend GR_CORE_API gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan,int align_interval); - gr_align_on_samplenumbers_ss (int nchan,int align_interval); - - public: - ~gr_align_on_samplenumbers_ss(); - bool check_topology (int ninputs, int noutputs); - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_ALIGN_ON_SAMPLE_NUMBERS_SS_H */ diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i deleted file mode 100644 index 471f743010..0000000000 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- 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,align_on_samplenumbers_ss); - -gr_align_on_samplenumbers_ss_sptr -gr_make_align_on_samplenumbers_ss(int nchan=2, int align_interval=128) throw (std::exception); - -class gr_align_on_samplenumbers_ss : public gr_block -{ - public: - ~gr_align_on_samplenumbers_ss (); - private: - gr_align_on_samplenumbers_ss (int nchan,int align_interval); -}; diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc deleted file mode 100644 index 1178bdc34f..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_annotator_1to1.h> -#include <gr_io_signature.h> -#include <string.h> -#include <iostream> -#include <iomanip> - -gr_annotator_1to1_sptr -gr_make_annotator_1to1 (int when, size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr (new gr_annotator_1to1 - (when, sizeof_stream_item)); -} - -gr_annotator_1to1::gr_annotator_1to1 (int when, size_t sizeof_stream_item) - : gr_sync_block ("annotator_1to1", - gr_make_io_signature (1, -1, sizeof_stream_item), - gr_make_io_signature (1, -1, sizeof_stream_item)), - d_itemsize(sizeof_stream_item), d_when((uint64_t)when) -{ - set_tag_propagation_policy(TPP_ONE_TO_ONE); - - d_tag_counter = 0; - set_relative_rate(1.0); -} - -gr_annotator_1to1::~gr_annotator_1to1 () -{ -} - -int -gr_annotator_1to1::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float*)input_items[0]; - float *out = (float*)output_items[0]; - - std::stringstream str; - str << name() << unique_id(); - - uint64_t abs_N = 0; - int ninputs = input_items.size(); - for(int i = 0; i < ninputs; i++) { - abs_N = nitems_read(i); - - std::vector<gr_tag_t> all_tags; - get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items); - - std::vector<gr_tag_t>::iterator itr; - for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { - d_stored_tags.push_back(*itr); - } - } - - // Storing the current noutput_items as the value to the "noutput_items" key - pmt::pmt_t srcid = pmt::string_to_symbol(str.str()); - pmt::pmt_t key = pmt::string_to_symbol("seq"); - - // Work does nothing to the data stream; just copy all inputs to outputs - // Adds a new tag when the number of items read is a multiple of d_when - abs_N = nitems_read(0); - int noutputs = output_items.size(); - for(int j = 0; j < noutput_items; j++) { - // the min() is a hack to make sure this doesn't segfault if there are a - // different number of ins and outs. This is specifically designed to test - // the 1-to-1 propagation policy. - for(int i = 0; i < std::min(noutputs, ninputs); i++) { - if(abs_N % d_when == 0) { - pmt::pmt_t value = pmt::from_uint64(d_tag_counter++); - add_item_tag(i, abs_N, key, value, srcid); - } - - in = (const float*)input_items[i]; - out = (float*)output_items[i]; - out[j] = in[j]; - } - abs_N++; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.h b/gnuradio-core/src/lib/general/gr_annotator_1to1.h deleted file mode 100644 index 57e5720141..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_ANNOTATOR_1TO1_H -#define INCLUDED_GR_ANNOTATOR_1TO1_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_annotator_1to1; -typedef boost::shared_ptr<gr_annotator_1to1> gr_annotator_1to1_sptr; - -// public constructor -GR_CORE_API gr_annotator_1to1_sptr -gr_make_annotator_1to1 (int when, size_t sizeof_stream_item); - -/*! - * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY. - * - * This block creates tags to be sent downstream every 10,000 items it sees. The - * tags contain the name and ID of the instantiated block, use "seq" as a key, - * and have a counter that increments by 1 for every tag produced that is used - * as the tag's value. The tags are propagated using the 1-to-1 policy. - * - * It also stores a copy of all tags it sees flow past it. These tags can be - * recalled externally with the data() member. - * - * This block is only meant for testing and showing how to use the tags. - */ -class GR_CORE_API gr_annotator_1to1 : public gr_sync_block -{ - public: - ~gr_annotator_1to1 (); - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - std::vector<gr_tag_t> data() const - { - return d_stored_tags; - } - -protected: - gr_annotator_1to1 (int when, size_t sizeof_stream_item); - - private: - size_t d_itemsize; - uint64_t d_when; - uint64_t d_tag_counter; - std::vector<gr_tag_t> d_stored_tags; - - friend GR_CORE_API gr_annotator_1to1_sptr - gr_make_annotator_1to1 (int when, size_t sizeof_stream_item); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.i b/gnuradio-core/src/lib/general/gr_annotator_1to1.i deleted file mode 100644 index 2637b8d277..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.i +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,annotator_1to1); - -%include <gr_annotator_1to1.h> diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc deleted file mode 100644 index d8b7e2db7e..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_annotator_alltoall.h> -#include <gr_io_signature.h> -#include <string.h> -#include <iostream> -#include <iomanip> - -gr_annotator_alltoall_sptr -gr_make_annotator_alltoall (int when, size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr (new gr_annotator_alltoall - (when, sizeof_stream_item)); -} - -gr_annotator_alltoall::gr_annotator_alltoall (int when, - size_t sizeof_stream_item) - : gr_sync_block ("annotator_alltoall", - gr_make_io_signature (1, -1, sizeof_stream_item), - gr_make_io_signature (1, -1, sizeof_stream_item)), - d_itemsize(sizeof_stream_item), d_when((uint64_t)when) -{ - set_tag_propagation_policy(TPP_ALL_TO_ALL); - - d_tag_counter = 0; -} - -gr_annotator_alltoall::~gr_annotator_alltoall () -{ -} - -int -gr_annotator_alltoall::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - std::stringstream str; - str << name() << unique_id(); - - uint64_t abs_N = 0, end_N; - int ninputs = input_items.size(); - for(int i = 0; i < ninputs; i++) { - abs_N = nitems_read(i); - end_N = abs_N + (uint64_t)(noutput_items); - - std::vector<gr_tag_t> all_tags; - get_tags_in_range(all_tags, i, abs_N, end_N); - - std::vector<gr_tag_t>::iterator itr; - for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { - d_stored_tags.push_back(*itr); - } - } - - // Source ID and key for any tag that might get applied from this block - pmt::pmt_t srcid = pmt::string_to_symbol(str.str()); - pmt::pmt_t key = pmt::string_to_symbol("seq"); - - // Work does nothing to the data stream; just copy all inputs to outputs - // Adds a new tag when the number of items read is a multiple of d_when - abs_N = nitems_written(0); - int noutputs = output_items.size(); - - for(int j = 0; j < noutput_items; j++) { - for(int i = 0; i < noutputs; i++) { - if(abs_N % d_when == 0) { - pmt::pmt_t value = pmt::from_uint64(d_tag_counter++); - add_item_tag(i, abs_N, key, value, srcid); - } - - // Sum all of the inputs together for each output. Just 'cause. - out = (float*)output_items[i]; - out[j] = 0; - for(int ins = 0; ins < ninputs; ins++) { - in = (const float*)input_items[ins]; - out[j] += in[j]; - } - } - abs_N++; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h deleted file mode 100644 index deb5874a49..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_ANNOTATOR_ALLTOALL_H -#define INCLUDED_GR_ANNOTATOR_ALLTOALL_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_annotator_alltoall; -typedef boost::shared_ptr<gr_annotator_alltoall> gr_annotator_alltoall_sptr; - -// public constructor -GR_CORE_API gr_annotator_alltoall_sptr -gr_make_annotator_alltoall (int when, size_t sizeof_stream_item); - -/*! - * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY. - * - * This block creates tags to be sent downstream every 10,000 items it sees. The - * tags contain the name and ID of the instantiated block, use "seq" as a key, - * and have a counter that increments by 1 for every tag produced that is used - * as the tag's value. The tags are propagated using the all-to-all policy. - * - * It also stores a copy of all tags it sees flow past it. These tags can be - * recalled externally with the data() member. - * - * This block is only meant for testing and showing how to use the tags. - */ -class GR_CORE_API gr_annotator_alltoall : public gr_sync_block -{ - public: - ~gr_annotator_alltoall (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - std::vector<gr_tag_t> data() const - { - return d_stored_tags; - } - -protected: - gr_annotator_alltoall (int when, size_t sizeof_stream_item); - - private: - size_t d_itemsize; - uint64_t d_when; - uint64_t d_tag_counter; - std::vector<gr_tag_t> d_stored_tags; - - friend GR_CORE_API gr_annotator_alltoall_sptr - gr_make_annotator_alltoall (int when, size_t sizeof_stream_item); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i deleted file mode 100644 index 35190a3d1b..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,annotator_alltoall); - -%include <gr_annotator_alltoall.h> diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.cc b/gnuradio-core/src/lib/general/gr_annotator_raw.cc deleted file mode 100644 index c3aecdd938..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_annotator_raw.h> -#include <gr_io_signature.h> -#include <string.h> -#include <iostream> -#include <iomanip> -#include <stdexcept> - -using namespace pmt; - -gr_annotator_raw_sptr -gr_make_annotator_raw(size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr(new gr_annotator_raw - (sizeof_stream_item)); -} - -gr_annotator_raw::gr_annotator_raw(size_t sizeof_stream_item) - : gr_sync_block("annotator_raw", - gr_make_io_signature(1, 1, sizeof_stream_item), - gr_make_io_signature(1, 1, sizeof_stream_item)), - d_itemsize(sizeof_stream_item) -{ - set_tag_propagation_policy(TPP_ONE_TO_ONE); - set_relative_rate(1.0); -} - -void gr_annotator_raw::add_tag(uint64_t offset, pmt_t key, pmt_t val) -{ - gruel::scoped_lock l(d_mutex); - - gr_tag_t tag; - tag.srcid = pmt::intern(name()); - tag.key = key; - tag.value = val; - tag.offset = offset; - - // add our new tag - d_queued_tags.push_back(tag); - // make sure our tags are in offset order - std::sort(d_queued_tags.begin(), d_queued_tags.end(), - gr_tag_t::offset_compare); - // make sure we are not adding an item in the past! - if(tag.offset > nitems_read(0)) { - throw std::runtime_error("gr_annotator_raw::add_tag: item added too far in the past\n."); - } -} - -gr_annotator_raw::~gr_annotator_raw() -{ -} - -int -gr_annotator_raw::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gruel::scoped_lock l(d_mutex); - - const char *in = (const char*)input_items[0]; - char *out = (char*)output_items[0]; - - uint64_t start_N = nitems_read(0); - uint64_t end_N = start_N + (uint64_t)(noutput_items); - - // locate queued tags that fall in this range and insert them when appropriate - std::vector<gr_tag_t>::iterator i = d_queued_tags.begin(); - while( i != d_queued_tags.end() ) { - if( (*i).offset >= start_N && (*i).offset < end_N) { - add_item_tag(0, (*i).offset,(*i).key, (*i).value, (*i).srcid); - i = d_queued_tags.erase(i); - } - else { - break; - } - } - - // copy data across - memcpy(out, in, noutput_items*d_itemsize); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.h b/gnuradio-core/src/lib/general/gr_annotator_raw.h deleted file mode 100644 index 02d0619081..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_ANNOTATOR_RAW_H -#define INCLUDED_GR_ANNOTATOR_RAW_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_tags.h> -#include <gruel/thread.h> - -class gr_annotator_raw; -typedef boost::shared_ptr<gr_annotator_raw> gr_annotator_raw_sptr; - -// public constructor -GR_CORE_API gr_annotator_raw_sptr -gr_make_annotator_raw(size_t sizeof_stream_item); - -/*! - * \brief raw stream annotator testing block. - * - * This block creates arbitrary tags to be sent downstream - * blocks to be sent are set manually via accessor methods and are sent only once. - * - * This block is intended for testing of tag related blocks - */ -class GR_CORE_API gr_annotator_raw : public gr_sync_block -{ - public: - ~gr_annotator_raw(); - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - // insert a tag to be added - void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val); - -protected: - gr_annotator_raw(size_t sizeof_stream_item); - - private: - size_t d_itemsize; - std::vector<gr_tag_t> d_queued_tags; - gruel::mutex d_mutex; - - friend GR_CORE_API gr_annotator_raw_sptr - gr_make_annotator_raw(size_t sizeof_stream_item); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.i b/gnuradio-core/src/lib/general/gr_annotator_raw.i deleted file mode 100644 index 4a58fe7c79..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.i +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,annotator_raw); - -%include <gr_tags.i> -%include <gr_annotator_raw.h> diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.cc b/gnuradio-core/src/lib/general/gr_check_counting_s.cc deleted file mode 100644 index c3288f4813..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.cc +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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_check_counting_s.h> -#include <gr_io_signature.h> -#include <stdlib.h> -#include <stdio.h> - -gr_check_counting_s_sptr -gr_make_check_counting_s (bool do_32bit) -{ - return gnuradio::get_initial_sptr(new gr_check_counting_s (do_32bit)); -} - -gr_check_counting_s::gr_check_counting_s (bool do_32bit) - : gr_sync_block ("gr_check_counting", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (0, 0, 0)), - d_state(SEARCHING), d_history (0), d_current_count (0), d_current_count_32bit(0), - d_total_errors (0), d_total_shorts (0), - d_do_32bit(do_32bit) -{ - enter_SEARCHING (); -} - -int -gr_check_counting_s::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - unsigned short *in = (unsigned short *) input_items[0]; - if(d_do_32bit) - return check_32bit(noutput_items,in); - else - return check_16bit(noutput_items,in); -} - -int -gr_check_counting_s::check_16bit (int noutput_items, - unsigned short * in) -{ - for (int i = 0; i < noutput_items; i++){ - unsigned short x = in[i]; - - switch (d_state){ - - case SEARCHING: - if (x == d_current_count){ - right (); - log_error (d_current_count, x); - d_current_count = d_current_count + 1; - if (right_three_times ()) - enter_LOCKED (); - } - else { - wrong (); - log_error (d_current_count, x); - d_current_count = x + 1; - } - break; - - case LOCKED: - if (x == d_current_count){ - right (); - d_current_count = d_current_count + 1; - } - else { - wrong (); - log_error (d_current_count, x); - d_current_count = d_current_count + 1; - if (wrong_three_times ()) - enter_SEARCHING (); - } - break; - - default: - abort (); - } - - d_total_shorts++; - } - - return noutput_items; -} - -int -gr_check_counting_s::check_32bit (int noutput_items, - unsigned short * in) -{ - - for (int i = 0; i < noutput_items-1; i+=2){ - unsigned int x_high16bits = in[i]; - unsigned int x_low16bits = in[i+1]; - unsigned int x = x_high16bits<<16 | x_low16bits; - - switch (d_state){ - - case SEARCHING: - if (x == d_current_count_32bit){ - right (); - log_error_32bit (d_current_count_32bit, x); - d_current_count_32bit = d_current_count_32bit + 1; - if (right_three_times ()) - enter_LOCKED (); - } - else { - wrong (); - log_error_32bit (d_current_count_32bit, x); - d_current_count_32bit = x + 1; - } - break; - - case LOCKED: - if (x == d_current_count_32bit){ - right (); - d_current_count_32bit = d_current_count_32bit + 1; - } - else { - wrong (); - log_error_32bit (d_current_count_32bit, x); - d_current_count_32bit = d_current_count_32bit + 1; - if (wrong_three_times ()) - enter_SEARCHING (); - } - break; - - default: - abort (); - } - - d_total_shorts++; - } - - return noutput_items; -} - -void -gr_check_counting_s::enter_SEARCHING () -{ - d_state = SEARCHING; - fprintf (stdout, "gr_check_counting: enter_SEARCHING at offset %8ld (0x%08lx)\n", - d_total_shorts, d_total_shorts); -} - -void -gr_check_counting_s::enter_LOCKED () -{ - d_state = LOCKED; - fprintf (stdout, "gr_check_counting: enter_LOCKED at offset %8ld (0x%08lx)\n", - d_total_shorts, d_total_shorts); -} - -void -gr_check_counting_s::log_error (unsigned short expected, unsigned short actual) -{ - fprintf (stdout, -"gr_check_counting: expected %5d (0x%04x) got %5d (0x%04x) offset %8ld (0x%08lx)\n", - expected, expected, actual, actual, d_total_shorts, d_total_shorts); -} - -void -gr_check_counting_s::log_error_32bit (unsigned int expected, unsigned int actual) -{ - fprintf (stdout, -"gr_check_counting: expected %10d (0x%08x) got %10d (0x%08x) offset %8ld (0x%08lx)\n", - expected, expected, actual, actual, d_total_shorts, d_total_shorts); -} diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.h b/gnuradio-core/src/lib/general/gr_check_counting_s.h deleted file mode 100644 index 996fa3259f..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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_CHECK_COUNTING_S_H -#define INCLUDED_GR_CHECK_COUNTING_S_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_check_counting_s; -typedef boost::shared_ptr<gr_check_counting_s> gr_check_counting_s_sptr; - -GR_CORE_API gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=false); - -/*! - * \brief sink that checks if its input stream consists of a counting sequence. - * \param do_32bit expect an interleaved 32 bit counter in stead of 16 bit counter (default false) - * \ingroup sink_blk - * - * This sink is typically used to test the USRP "Counting Mode" or "Counting mode 32 bit". - */ -class GR_CORE_API gr_check_counting_s : public gr_sync_block -{ - friend GR_CORE_API gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit); - - enum state { - SEARCHING, // searching for synchronization - LOCKED // is locked - }; - - state d_state; - unsigned int d_history; // bitmask of decisions - unsigned short d_current_count; - unsigned int d_current_count_32bit; - - long d_total_errors; - long d_total_shorts; - bool d_do_32bit; - - gr_check_counting_s (bool do_32bit); - - void enter_SEARCHING (); - void enter_LOCKED (); - - void right (){ - d_history = (d_history << 1) | 0x1; - } - - void wrong (){ - d_history = (d_history << 1) | 0x0; - d_total_errors++; - } - - bool right_three_times () { return (d_history & 0x7) == 0x7; } - bool wrong_three_times () { return (d_history & 0x7) == 0x0; } - - void log_error (unsigned short expected, unsigned short actual); - void log_error_32bit (unsigned int expected, unsigned int actual); - - int check_32bit (int noutput_items, unsigned short * in); - int check_16bit (int noutput_items, unsigned short * in); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_CHECK_COUNTING_S_H */ diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.i b/gnuradio-core/src/lib/general/gr_check_counting_s.i deleted file mode 100644 index 0275dad9db..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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,check_counting_s) - -gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=false); - -class gr_check_counting_s : public gr_sync_block -{ - private: - gr_check_counting_s (bool do_32bit); -}; diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc deleted file mode 100644 index 088b8c38ae..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc +++ /dev/null @@ -1,169 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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_check_lfsr_32k_s.h> -#include <gr_io_signature.h> -#include <stdlib.h> -#include <stdio.h> - -gr_check_lfsr_32k_s_sptr -gr_make_check_lfsr_32k_s () -{ - return gnuradio::get_initial_sptr(new gr_check_lfsr_32k_s ()); -} - -gr_check_lfsr_32k_s::gr_check_lfsr_32k_s () - : gr_sync_block ("gr_check_lfsr_32k", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (0, 0, 0)), - d_state(SEARCHING), d_history (0), d_ntotal (0), d_nright (0), - d_runlength (0), d_index(0) -{ - gri_lfsr_32k lfsr; - - for (int i = 0; i < BUFSIZE; i++) - d_buffer[i] = lfsr.next_short (); - - enter_SEARCHING (); -} - -int -gr_check_lfsr_32k_s::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - unsigned short *in = (unsigned short *) input_items[0]; - - for (int i = 0; i < noutput_items; i++){ - unsigned short x = in[i]; - unsigned short expected; - - switch (d_state){ - - case MATCH0: - if (x == d_buffer[0]) - enter_MATCH1 (); - break; - - case MATCH1: - if (x == d_buffer[1]) - enter_MATCH2 (); - else - enter_MATCH0 (); - break; - - case MATCH2: - if (x == d_buffer[2]) - enter_LOCKED (); - else - enter_MATCH0 (); - break; - - case LOCKED: - expected = d_buffer[d_index]; - d_index = d_index + 1; - if (d_index >= BUFSIZE) - d_index = 0; - - if (x == expected) - right (); - else { - wrong (); - log_error (expected, x); - if (wrong_three_times ()) - enter_SEARCHING (); - } - break; - - default: - abort (); - } - - d_ntotal++; - } - - return noutput_items; -} - -void -gr_check_lfsr_32k_s::enter_SEARCHING () -{ - d_state = SEARCHING; - wrong (); // reset history - wrong (); - wrong (); - - d_runlength = 0; - d_index = 0; // reset LFSR to beginning - - if (0) - fprintf (stdout, "gr_check_lfsr_32k: enter_SEARCHING at offset %8ld (0x%08lx)\n", - d_ntotal, d_ntotal); - - enter_MATCH0 (); -} - -void -gr_check_lfsr_32k_s::enter_MATCH0 () -{ - d_state = MATCH0; -} - -void -gr_check_lfsr_32k_s::enter_MATCH1 () -{ - d_state = MATCH1; -} - -void -gr_check_lfsr_32k_s::enter_MATCH2 () -{ - d_state = MATCH2; -} - -void -gr_check_lfsr_32k_s::enter_LOCKED () -{ - d_state = LOCKED; - right (); // setup history - right (); - right (); - - d_index = 3; // already matched first 3 items - - if (0) - fprintf (stdout, "gr_check_lfsr_32k: enter_LOCKED at offset %8ld (0x%08lx)\n", - d_ntotal, d_ntotal); -} - -void -gr_check_lfsr_32k_s::log_error (unsigned short expected, unsigned short actual) -{ - if (0) - fprintf (stdout, - "gr_check_lfsr_32k: expected %5d (0x%04x) got %5d (0x%04x) offset %8ld (0x%08lx)\n", - expected, expected, actual, actual, d_ntotal, d_ntotal); -} diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h deleted file mode 100644 index 2f980b427b..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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_CHECK_LFSR_32K_S_H -#define INCLUDED_GR_CHECK_LFSR_32K_S_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_lfsr_32k.h> - - -class gr_check_lfsr_32k_s; -typedef boost::shared_ptr<gr_check_lfsr_32k_s> gr_check_lfsr_32k_s_sptr; - -GR_CORE_API gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); - -/*! - * \brief sink that checks if its input stream consists of a lfsr_32k sequence. - * \ingroup sink_blk - * - * This sink is typically used along with gr_lfsr_32k_source_s to test - * the USRP using its digital loopback mode. - */ -class GR_CORE_API gr_check_lfsr_32k_s : public gr_sync_block -{ - friend GR_CORE_API gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); - - enum state { - SEARCHING, // searching for synchronization - MATCH0, - MATCH1, - MATCH2, - LOCKED // is locked - }; - - state d_state; - unsigned int d_history; // bitmask of decisions - - long d_ntotal; // total number of shorts - long d_nright; // # of correct shorts - long d_runlength; // # of correct shorts in a row - - static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned - int d_index; - unsigned short d_buffer[BUFSIZE]; - - - gr_check_lfsr_32k_s (); - - void enter_SEARCHING (); - void enter_MATCH0 (); - void enter_MATCH1 (); - void enter_MATCH2 (); - void enter_LOCKED (); - - void right (){ - d_history = (d_history << 1) | 0x1; - d_nright++; - d_runlength++; - } - - void wrong (){ - d_history = (d_history << 1) | 0x0; - d_runlength = 0; - } - - bool right_three_times () { return (d_history & 0x7) == 0x7; } - bool wrong_three_times () { return (d_history & 0x7) == 0x0; } - - void log_error (unsigned short expected, unsigned short actual); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - long ntotal () const { return d_ntotal; } - long nright () const { return d_nright; } - long runlength () const { return d_runlength; } - -}; - - -#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_H */ diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.i b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.i deleted file mode 100644 index 34d4a0b0c1..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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,check_lfsr_32k_s) - -gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); - -class gr_check_lfsr_32k_s : public gr_sync_block -{ - private: - gr_check_lfsr_32k_s (); - -public: - long ntotal () const; - long nright () const; - long runlength () const; -}; diff --git a/gnuradio-core/src/lib/general/gr_copy.cc b/gnuradio-core/src/lib/general/gr_copy.cc deleted file mode 100644 index 0a6f721f94..0000000000 --- a/gnuradio-core/src/lib/general/gr_copy.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 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_copy.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_copy_sptr -gr_make_copy(size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_copy(itemsize)); -} - -gr_copy::gr_copy(size_t itemsize) - : gr_block ("copy", - gr_make_io_signature (1, 1, itemsize), - gr_make_io_signature (1, 1, itemsize)), - d_itemsize(itemsize), - d_enabled(true) -{ -} - -bool -gr_copy::check_topology(int ninputs, int noutputs) -{ - return ninputs == noutputs; -} - -int -gr_copy::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const uint8_t *in = (const uint8_t *) input_items[0]; - uint8_t *out = (uint8_t *) output_items[0]; - - int n = std::min<int>(ninput_items[0], noutput_items); - int j = 0; - - if (d_enabled) { - memcpy(out, in, n*d_itemsize); - j = n; - } - - consume_each(n); - return j; -} diff --git a/gnuradio-core/src/lib/general/gr_copy.h b/gnuradio-core/src/lib/general/gr_copy.h deleted file mode 100644 index b0769fa2b1..0000000000 --- a/gnuradio-core/src/lib/general/gr_copy.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 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_COPY_H -#define INCLUDED_GR_COPY_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_copy; -typedef boost::shared_ptr<gr_copy> gr_copy_sptr; - -GR_CORE_API gr_copy_sptr gr_make_copy(size_t itemsize); - -/*! - * \brief output[i] = input[i] - * \ingroup misc_blk - * - * When enabled (default), this block copies its input to its output. - * When disabled, this block drops its input on the floor. - * - */ -class GR_CORE_API gr_copy : public gr_block -{ - size_t d_itemsize; - bool d_enabled; - - friend GR_CORE_API gr_copy_sptr gr_make_copy(size_t itemsize); - gr_copy(size_t itemsize); - - public: - - bool check_topology(int ninputs, int noutputs); - - void set_enabled(bool enable) { d_enabled = enable; } - bool enabled() const { return d_enabled;} - - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_copy.i b/gnuradio-core/src/lib/general/gr_copy.i deleted file mode 100644 index 12ddce6aaf..0000000000 --- a/gnuradio-core/src/lib/general/gr_copy.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 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,copy) - -gr_copy_sptr gr_make_copy(size_t itemsize); - -class gr_copy : public gr_block -{ - private: - gr_copy(size_t itemsize); - -public: - - void set_enabled(bool enabled); - bool enabled(); -}; diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc deleted file mode 100644 index ca6667a214..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- 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_ctrlport_probe2_c.h> -#include <gr_io_signature.h> - -gr_ctrlport_probe2_c_sptr -gr_make_ctrlport_probe2_c(const std::string &id, - const std::string &desc, int len) -{ - return gnuradio::get_initial_sptr - (new gr_ctrlport_probe2_c(id, desc, len)); -} - -gr_ctrlport_probe2_c::gr_ctrlport_probe2_c(const std::string &id, - const std::string &desc, int len) - : gr_sync_block("probe2_c", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(0, 0, 0)), - d_id(id), d_desc(desc), d_len(len) -{ - set_length(len); -} - -gr_ctrlport_probe2_c::~gr_ctrlport_probe2_c() -{ -} - -void -gr_ctrlport_probe2_c::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - // make sure all inputs have noutput_items available - unsigned ninputs = ninput_items_required.size(); - for(unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = d_len; -} - -// boost::shared_mutex mutex_buffer; -// mutable boost::mutex mutex_notify; -// boost::condition_variable condition_buffer_ready; -std::vector<gr_complex> -gr_ctrlport_probe2_c::get() -{ - mutex_buffer.lock(); - d_buffer.clear(); - mutex_buffer.unlock(); - - // wait for condition - boost::mutex::scoped_lock lock(mutex_notify); - condition_buffer_ready.wait(lock); - - mutex_buffer.lock(); - std::vector<gr_complex> buf_copy = d_buffer; - assert(buf_copy.size() == d_len); - mutex_buffer.unlock(); - - return buf_copy; -} - -void -gr_ctrlport_probe2_c::set_length(int len) -{ - if(len > 8191) { - std::cerr << "probe2_c: length " << len - << " exceeds maximum buffer size of 8191" << std::endl; - len = 8191; - } - - d_len = len; - d_buffer.reserve(d_len); -} - -int -gr_ctrlport_probe2_c::length() const -{ - return (int)d_len; -} - -int -gr_ctrlport_probe2_c::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]; - - // copy samples to get buffer if we need samples - mutex_buffer.lock(); - if(d_buffer.size() < d_len) { - // copy smaller of remaining buffer space and num inputs to work() - int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items ); - - // TODO: convert this to a copy operator for speed... - for(int i = 0; i < num_copy; i++) { - d_buffer.push_back(in[i]); - } - - // notify the waiting get() if we fill up the buffer - if(d_buffer.size() == d_len) { - condition_buffer_ready.notify_one(); - } - } - mutex_buffer.unlock(); - - return noutput_items; -} - -void -gr_ctrlport_probe2_c::setup_rpc() -{ -#ifdef GR_CTRLPORT - int len = static_cast<int>(d_len); - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_get<gr_ctrlport_probe2_c, std::vector<std::complex<float> > >( - alias(), d_id.c_str(), &gr_ctrlport_probe2_c::get, - pmt::make_c32vector(0,-2), - pmt::make_c32vector(0,2), - pmt::make_c32vector(0,0), - "volts", d_desc.c_str(), RPC_PRIVLVL_MIN, - DISPXY | DISPOPTSCATTER))); - - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_get<gr_ctrlport_probe2_c, int>( - alias(), "length", &gr_ctrlport_probe2_c::length, - pmt::mp(1), pmt::mp(10*len), pmt::mp(len), - "samples", "get vector length", RPC_PRIVLVL_MIN, DISPNULL))); - - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_set<gr_ctrlport_probe2_c, int>( - alias(), "length", &gr_ctrlport_probe2_c::set_length, - pmt::mp(1), pmt::mp(10*len), pmt::mp(len), - "samples", "set vector length", RPC_PRIVLVL_MIN, DISPNULL))); -#endif /* GR_CTRLPORT */ -} diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.h b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.h deleted file mode 100644 index 0920c0f4e8..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- 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_CTRLPORT_PROBE2_C_H -#define INCLUDED_CTRLPORT_PROBE2_C_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <rpcregisterhelpers.h> -#include <boost/thread/shared_mutex.hpp> - -class gr_ctrlport_probe2_c; -typedef boost::shared_ptr<gr_ctrlport_probe2_c> gr_ctrlport_probe2_c_sptr; - -GR_CORE_API gr_ctrlport_probe2_c_sptr -gr_make_ctrlport_probe2_c(const std::string &id, const std::string &desc, int len); - -class GR_CORE_API gr_ctrlport_probe2_c : public gr_sync_block -{ - private: - friend GR_CORE_API gr_ctrlport_probe2_c_sptr gr_make_ctrlport_probe2_c - (const std::string &id, const std::string &desc, int len); - - gr_ctrlport_probe2_c(const std::string &id, const std::string &desc, int len); - - std::string d_id; - std::string d_desc; - size_t d_len; - boost::shared_mutex mutex_buffer; - mutable boost::mutex mutex_notify; - boost::condition_variable condition_buffer_ready; - - std::vector<gr_complex> d_buffer; - - public: - ~gr_ctrlport_probe2_c(); - - void setup_rpc(); - - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - - std::vector<gr_complex> get(); - - void set_length(int len); - int length() const; - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_CTRLPORT_PROBE2_C_H */ - diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.i b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.i deleted file mode 100644 index 18858595ea..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,ctrlport_probe2_c) - -gr_ctrlport_probe2_c_sptr -gr_make_ctrlport_probe2_c(const std::string &id, const std::string &desc, int len); - -class gr_ctrlport_probe2_c : public gr_sync_block -{ -public: - ~gr_ctrlport_probe2_c(); - std::vector<gr_complex> get(); - void set_length(int len); - int length() const; -}; - diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc deleted file mode 100644 index 253d4c380e..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- 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_ctrlport_probe_c.h> -#include <gr_io_signature.h> - -gr_ctrlport_probe_c_sptr -gr_make_ctrlport_probe_c(const std::string &id, - const std::string &desc) -{ - return gnuradio::get_initial_sptr - (new gr_ctrlport_probe_c(id, desc)); -} - - -gr_ctrlport_probe_c::gr_ctrlport_probe_c(const std::string &id, - const std::string &desc) - : gr_sync_block("probe_c", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(0, 0, 0)), - d_id(id), d_desc(desc), d_ptr(NULL), d_ptrLen(0) -{ -} - -gr_ctrlport_probe_c::~gr_ctrlport_probe_c() -{ -} - -std::vector<gr_complex> -gr_ctrlport_probe_c::get() -{ - if(d_ptr != NULL && d_ptrLen > 0) { - ptrlock.lock(); - std::vector<gr_complex> vec(d_ptr, d_ptr+d_ptrLen); - ptrlock.unlock(); - return vec; - } - else { - std::vector<gr_complex> vec; - return vec; - } -} - -int -gr_ctrlport_probe_c::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]; - - // keep reference to symbols - ptrlock.lock(); - d_ptr = in; - d_ptrLen = noutput_items; - ptrlock.unlock(); - - return noutput_items; -} - -void -gr_ctrlport_probe_c::setup_rpc() -{ -#ifdef GR_CTRLPORT - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_get<gr_ctrlport_probe_c, std::vector<std::complex<float> > >( - alias(), d_id.c_str(), &gr_ctrlport_probe_c::get, - pmt::make_c32vector(0,-2), - pmt::make_c32vector(0,2), - pmt::make_c32vector(0,0), - "volts", d_desc.c_str(), RPC_PRIVLVL_MIN, - DISPXY | DISPOPTSCATTER))); -#endif /* GR_CTRLPORT */ -} diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.h b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.h deleted file mode 100644 index 27666ab597..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- 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_CTRLPORT_PROBE_C_H -#define INCLUDED_CTRLPORT_PROBE_C_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <rpcregisterhelpers.h> -#include <boost/thread/shared_mutex.hpp> - -class gr_ctrlport_probe_c; -typedef boost::shared_ptr<gr_ctrlport_probe_c> gr_ctrlport_probe_c_sptr; - -GR_CORE_API gr_ctrlport_probe_c_sptr -gr_make_ctrlport_probe_c(const std::string &id, const std::string &desc); - -class GR_CORE_API gr_ctrlport_probe_c : public gr_sync_block -{ - private: - friend GR_CORE_API gr_ctrlport_probe_c_sptr gr_make_ctrlport_probe_c - (const std::string &id, const std::string &desc); - - gr_ctrlport_probe_c(const std::string &id, const std::string &desc); - - boost::shared_mutex ptrlock; - - std::string d_id; - std::string d_desc; - const gr_complex* d_ptr; - size_t d_ptrLen; - - public: - ~gr_ctrlport_probe_c(); - - void setup_rpc(); - - std::vector<gr_complex> get(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_CTRLPORT_GR_CTRLPORT_PROBE_C_H */ - diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.i b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.i deleted file mode 100644 index cd4c521cb0..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,ctrlport_probe_c) - -gr_ctrlport_probe_c_sptr -gr_make_ctrlport_probe_c(const std::string &id, const std::string &desc); - -class gr_ctrlport_probe_c : public gr_sync_block -{ -public: - ~gr_ctrlport_probe_c(); - std::vector<gr_complex> get(); -}; - diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.cc b/gnuradio-core/src/lib/general/gr_endian_swap.cc deleted file mode 100644 index 8bea0ca30d..0000000000 --- a/gnuradio-core/src/lib/general/gr_endian_swap.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,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_endian_swap.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_endian_swap_sptr -gr_make_endian_swap (size_t item_size_bytes) -{ - return gnuradio::get_initial_sptr(new gr_endian_swap (item_size_bytes)); -} - -gr_endian_swap::gr_endian_swap (size_t item_size_bytes) - : gr_sync_block ("gr_endian_swap", - gr_make_io_signature (1, 1, item_size_bytes), - gr_make_io_signature (1, 1, item_size_bytes)) -{ - const int alignment_multiple = volk_get_alignment(); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_endian_swap::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]; - char *out = (char *) output_items[0]; - - int nbytes( output_signature()->sizeof_stream_item(0) ); - if(is_unaligned()) { - switch(nbytes){ - case 1: - memcpy(out,in,noutput_items); - break; - case 2: - memcpy(out,in,2*noutput_items); - volk_16u_byteswap_u((uint16_t*)out,noutput_items); - break; - case 4: - memcpy(out,in,4*noutput_items); - volk_32u_byteswap_u((uint32_t*)out,noutput_items); - break; - case 8: - memcpy(out,in,8*noutput_items); - volk_64u_byteswap_u((uint64_t*)out,noutput_items); - break; - default: - throw std::runtime_error("itemsize is not valid for gr_endian_swap!"); - } - } else { - switch(nbytes){ - case 1: - memcpy(out,in,noutput_items); - break; - case 2: - memcpy(out,in,2*noutput_items); - volk_16u_byteswap_a((uint16_t*)out,noutput_items); - break; - case 4: - memcpy(out,in,4*noutput_items); - volk_32u_byteswap_a((uint32_t*)out,noutput_items); - break; - case 8: - memcpy(out,in,8*noutput_items); - volk_64u_byteswap_a((uint64_t*)out,noutput_items); - break; - default: - throw std::runtime_error("itemsize is not valid for gr_endian_swap!"); - } - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.h b/gnuradio-core/src/lib/general/gr_endian_swap.h deleted file mode 100644 index 0baa3f3389..0000000000 --- a/gnuradio-core/src/lib/general/gr_endian_swap.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,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_ENDIAN_SWAP_H -#define INCLUDED_GR_ENDIAN_SWAP_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_endian_swap; -typedef boost::shared_ptr<gr_endian_swap> gr_endian_swap_sptr; - -GR_CORE_API gr_endian_swap_sptr -gr_make_endian_swap (size_t item_size_bytes=1); - -/*! - * \brief Convert stream of items into thier byte swapped version - * - * \param item_size_bytes number of bytes per item, 1=no-op,2=uint16_t,4=uint32_t,8=uint64_t - */ - -class GR_CORE_API gr_endian_swap : public gr_sync_block -{ - private: - friend GR_CORE_API gr_endian_swap_sptr - gr_make_endian_swap (size_t item_size_bytes); - gr_endian_swap (size_t item_size_bytes); - - size_t item_size_bytes; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_ENDIAN_SWAP_H */ diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.i b/gnuradio-core/src/lib/general/gr_endian_swap.i deleted file mode 100644 index 6058b9de77..0000000000 --- a/gnuradio-core/src/lib/general/gr_endian_swap.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,endian_swap) - -gr_endian_swap_sptr -gr_make_endian_swap (size_t bytes_per_item=1); - -class gr_endian_swap : public gr_sync_block -{ -public: -}; diff --git a/gnuradio-core/src/lib/gengen/gr_endianness.h b/gnuradio-core/src/lib/general/gr_endianness.h index c4ecb1383e..c4ecb1383e 100644 --- a/gnuradio-core/src/lib/gengen/gr_endianness.h +++ b/gnuradio-core/src/lib/general/gr_endianness.h diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc deleted file mode 100644 index c1c3883c56..0000000000 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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_fake_channel_coder_pp.h> -#include <gr_io_signature.h> -#include <string.h> -#include <stdexcept> -#include <string.h> - -static const int PAD_VAL = 0xAA; - -gr_fake_channel_encoder_pp_sptr -gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen) -{ - return gnuradio::get_initial_sptr(new gr_fake_channel_encoder_pp(input_vlen, - output_vlen)); -} - -gr_fake_channel_encoder_pp::gr_fake_channel_encoder_pp(int input_vlen, int output_vlen) - : gr_sync_block("fake_channel_encoder_pp", - gr_make_io_signature(1, 1, input_vlen * sizeof(unsigned char)), - gr_make_io_signature(1, 1, output_vlen * sizeof(unsigned char))), - d_input_vlen(input_vlen), d_output_vlen(output_vlen) -{ - if (input_vlen <= 0 || output_vlen <= 0 || input_vlen > output_vlen) - throw std::invalid_argument("gr_fake_channel_encoder_pp"); -} - -gr_fake_channel_encoder_pp::~gr_fake_channel_encoder_pp() -{ -} - -int -gr_fake_channel_encoder_pp::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - int npad = d_output_vlen - d_input_vlen; - - for (int i = 0; i < noutput_items; i++){ - memcpy(out, in, d_input_vlen); - memset(out + d_input_vlen, PAD_VAL, npad); - in += d_input_vlen; - out += d_output_vlen; - } - - return noutput_items; -} - -// ------------------------------------------------------------------------ - -gr_fake_channel_decoder_pp_sptr -gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen) -{ - return gnuradio::get_initial_sptr(new gr_fake_channel_decoder_pp(input_vlen, - output_vlen)); -} - -gr_fake_channel_decoder_pp::gr_fake_channel_decoder_pp(int input_vlen, int output_vlen) - : gr_sync_block("fake_channel_decoder_pp", - gr_make_io_signature(1, 1, input_vlen * sizeof(unsigned char)), - gr_make_io_signature(1, 1, output_vlen * sizeof(unsigned char))), - d_input_vlen(input_vlen), d_output_vlen(output_vlen) -{ - if (input_vlen <= 0 || output_vlen <= 0 || output_vlen > input_vlen) - throw std::invalid_argument("gr_fake_channel_decoder_pp"); -} - -gr_fake_channel_decoder_pp::~gr_fake_channel_decoder_pp() -{ -} - -int -gr_fake_channel_decoder_pp::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - memcpy(out, in, d_output_vlen); - in += d_input_vlen; - out += d_output_vlen; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h deleted file mode 100644 index 45808752d3..0000000000 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- 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. - */ - -#ifndef INCLUDED_GR_FAKE_CHANNEL_CODER_PP_H -#define INCLUDED_GR_FAKE_CHANNEL_CODER_PP_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_fake_channel_encoder_pp; -typedef boost::shared_ptr<gr_fake_channel_encoder_pp> gr_fake_channel_encoder_pp_sptr; - -GR_CORE_API gr_fake_channel_encoder_pp_sptr -gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen); - -/*! - * \brief pad packet with alternating 1,0 pattern. - * \ingroup coding_blk - * - * input: stream of byte vectors; output: stream of byte vectors - */ -class GR_CORE_API gr_fake_channel_encoder_pp : public gr_sync_block -{ - int d_input_vlen; - int d_output_vlen; - - gr_fake_channel_encoder_pp(int input_vlen, int output_vlen); - - friend GR_CORE_API gr_fake_channel_encoder_pp_sptr - gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_encoder_pp(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -// ------------------------------------------------------------------------ - -class gr_fake_channel_decoder_pp; -typedef boost::shared_ptr<gr_fake_channel_decoder_pp> gr_fake_channel_decoder_pp_sptr; - -GR_CORE_API gr_fake_channel_decoder_pp_sptr -gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen); - -/*! - * \brief remove fake padding from packet - * \ingroup coding_blk - * - * input: stream of byte vectors; output: stream of byte vectors - */ -class GR_CORE_API gr_fake_channel_decoder_pp : public gr_sync_block -{ - int d_input_vlen; - int d_output_vlen; - - gr_fake_channel_decoder_pp(int input_vlen, int output_vlen); - - friend GR_CORE_API gr_fake_channel_decoder_pp_sptr - gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_decoder_pp(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FAKE_CHANNEL_CODER_PP_H */ diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.i b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.i deleted file mode 100644 index 123c84e473..0000000000 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.i +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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,fake_channel_encoder_pp) - -gr_fake_channel_encoder_pp_sptr -gr_make_fake_channel_encoder_pp(int input_vlen, - int output_vlen - ) throw(std::invalid_argument); - -class gr_fake_channel_encoder_pp : public gr_sync_block -{ - gr_fake_channel_encoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_encoder_pp(); -}; - -// ------------------------------------------------------------------------ - -GR_SWIG_BLOCK_MAGIC(gr,fake_channel_decoder_pp) - -gr_fake_channel_decoder_pp_sptr -gr_make_fake_channel_decoder_pp(int input_vlen, - int output_vlen - ) throw(std::invalid_argument); - -class gr_fake_channel_decoder_pp : public gr_sync_block -{ - gr_fake_channel_decoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_decoder_pp(); -}; diff --git a/gnuradio-core/src/lib/io/sdr_1000.i b/gnuradio-core/src/lib/general/gr_fxpt.cc index c9b1ef5609..2ea8520e6b 100644 --- a/gnuradio-core/src/lib/io/sdr_1000.i +++ b/gnuradio-core/src/lib/general/gr_fxpt.cc @@ -20,17 +20,16 @@ * Boston, MA 02110-1301, USA. */ -const int L_EXT = 0; -const int L_BAND = 1; -const int L_DDS0 = 2; -const int L_DDS1 = 3; +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -class sdr_1000_base { -public: +#include <gr_fxpt.h> - sdr_1000_base (int which_pp); - ~sdr_1000_base (); - - void reset (); - void write_latch (int which, int value, int mask); +const float gr_fxpt::s_sine_table[1 << NBITS][2] = { +#include "sine_table.h" }; + +const float gr_fxpt::PI = 3.14159265358979323846; +const float gr_fxpt::TWO_TO_THE_31 = 2147483648.0; + diff --git a/gnuradio-core/src/lib/general/gr_fxpt.h b/gnuradio-core/src/lib/general/gr_fxpt.h new file mode 100644 index 0000000000..9de6c0c18a --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_fxpt.h @@ -0,0 +1,104 @@ +/* -*- c++ -*- */ +/* + * 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 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_FXPT_H +#define INCLUDED_GR_FXPT_H + +#include <gr_core_api.h> +#include <gr_types.h> + +/*! + * \brief fixed point sine and cosine and friends. + * \ingroup misc + * + * fixed pt radians + * --------- -------- + * -2**31 -pi + * 0 0 + * 2**31-1 pi - epsilon + * + */ +class GR_CORE_API gr_fxpt +{ + static const int WORDBITS = 32; + static const int NBITS = 10; + static const float s_sine_table[1 << NBITS][2]; + static const float PI; + static const float TWO_TO_THE_31; +public: + + static gr_int32 + float_to_fixed (float x) + { + // Fold x into -PI to PI. + int d = (int)floor(x/2/PI+0.5); + x -= d*2*PI; + // And convert to an integer. + return (gr_int32) ((float) x * TWO_TO_THE_31 / PI); + } + + static float + fixed_to_float (gr_int32 x) + { + return x * (PI / TWO_TO_THE_31); + } + + /*! + * \brief Given a fixed point angle x, return float sine (x) + */ + static float + sin (gr_int32 x) + { + gr_uint32 ux = x; + int index = ux >> (WORDBITS - NBITS); + return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; + } + + /* + * \brief Given a fixed point angle x, return float cosine (x) + */ + static float + cos (gr_int32 x) + { + gr_uint32 ux = x + 0x40000000; + int index = ux >> (WORDBITS - NBITS); + return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; + } + + /* + * \brief Given a fixedpoint angle x, return float cos(x) and sin (x) + */ + static void sincos(gr_int32 x, float *s, float *c) + { + gr_uint32 ux = x; + int sin_index = ux >> (WORDBITS - NBITS); + *s = s_sine_table[sin_index][0] * (ux >> 1) + s_sine_table[sin_index][1]; + + ux = x + 0x40000000; + int cos_index = ux >> (WORDBITS - NBITS); + *c = s_sine_table[cos_index][0] * (ux >> 1) + s_sine_table[cos_index][1]; + + return; + } + +}; + +#endif /* INCLUDED_GR_FXPT_H */ diff --git a/gnuradio-core/src/lib/general/gr_fxpt_nco.h b/gnuradio-core/src/lib/general/gr_fxpt_nco.h new file mode 100644 index 0000000000..9defa083da --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_fxpt_nco.h @@ -0,0 +1,153 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,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 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_FXPT_NCO_H +#define INCLUDED_GR_FXPT_NCO_H + +#include <gr_core_api.h> +#include <gr_fxpt.h> +#include <gr_complex.h> + +/*! + * \brief Numerically Controlled Oscillator (NCO) + * \ingroup misc + */ +class /*GR_CORE_API*/ gr_fxpt_nco { + gr_uint32 d_phase; + gr_int32 d_phase_inc; + +public: + gr_fxpt_nco () : d_phase (0), d_phase_inc (0) {} + + ~gr_fxpt_nco () {} + + // radians + void set_phase (float angle) { + d_phase = gr_fxpt::float_to_fixed (angle); + } + + void adjust_phase (float delta_phase) { + d_phase += gr_fxpt::float_to_fixed (delta_phase); + } + + // angle_rate is in radians / step + void set_freq (float angle_rate){ + d_phase_inc = gr_fxpt::float_to_fixed (angle_rate); + } + + // angle_rate is a delta in radians / step + void adjust_freq (float delta_angle_rate) + { + d_phase_inc += gr_fxpt::float_to_fixed (delta_angle_rate); + } + + // increment current phase angle + + void step () + { + d_phase += d_phase_inc; + } + + void step (int n) + { + d_phase += d_phase_inc * n; + } + + // units are radians / step + float get_phase () const { return gr_fxpt::fixed_to_float (d_phase); } + float get_freq () const { return gr_fxpt::fixed_to_float (d_phase_inc); } + + // compute sin and cos for current phase angle + void sincos (float *sinx, float *cosx) const + { + *sinx = gr_fxpt::sin (d_phase); + *cosx = gr_fxpt::cos (d_phase); + } + + // compute cos and sin for a block of phase angles + void sincos (gr_complex *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = gr_complex(gr_fxpt::cos (d_phase) * ampl, gr_fxpt::sin (d_phase) * ampl); + step (); + } + } + + // compute sin for a block of phase angles + void sin (float *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (float)(gr_fxpt::sin (d_phase) * ampl); + step (); + } + } + + // compute cos for a block of phase angles + void cos (float *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (float)(gr_fxpt::cos (d_phase) * ampl); + step (); + } + } + + // compute sin for a block of phase angles + void sin (short *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (short)(gr_fxpt::sin (d_phase) * ampl); + step (); + } + } + + // compute cos for a block of phase angles + void cos (short *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (short)(gr_fxpt::cos (d_phase) * ampl); + step (); + } + } + + // compute sin for a block of phase angles + void sin (int *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (int)(gr_fxpt::sin (d_phase) * ampl); + step (); + } + } + + // compute cos for a block of phase angles + void cos (int *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (int)(gr_fxpt::cos (d_phase) * ampl); + step (); + } + } + + // compute cos or sin for current phase angle + float cos () const { return gr_fxpt::cos (d_phase); } + float sin () const { return gr_fxpt::sin (d_phase); } +}; + +#endif /* INCLUDED_GR_FXPT_NCO_H */ diff --git a/gnuradio-core/src/lib/general/gr_fxpt_vco.h b/gnuradio-core/src/lib/general/gr_fxpt_vco.h new file mode 100644 index 0000000000..13be2526bd --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_fxpt_vco.h @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004,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. + */ +#ifndef INCLUDED_GR_FXPT_VCO_H +#define INCLUDED_GR_FXPT_VCO_H + +#include <gr_core_api.h> +#include <gr_fxpt.h> +#include <gr_complex.h> + +/*! + * \brief Voltage Controlled Oscillator (VCO) + * \ingroup misc + */ +class /*GR_CORE_API*/ gr_fxpt_vco { + gr_int32 d_phase; + +public: + gr_fxpt_vco () : d_phase (0) {} + + ~gr_fxpt_vco () {} + + // radians + void set_phase (float angle) { + d_phase = gr_fxpt::float_to_fixed (angle); + } + + void adjust_phase (float delta_phase) { + d_phase += gr_fxpt::float_to_fixed (delta_phase); + } + + float get_phase () const { return gr_fxpt::fixed_to_float (d_phase); } + + // compute sin and cos for current phase angle + void sincos (float *sinx, float *cosx) const + { + *sinx = gr_fxpt::sin (d_phase); + *cosx = gr_fxpt::cos (d_phase); + } + + // compute a block at a time + void cos (float *output, const float *input, int noutput_items, float k, float ampl = 1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (float)(gr_fxpt::cos (d_phase) * ampl); + adjust_phase(input[i] * k); + } + } + + // compute cos or sin for current phase angle + float cos () const { return gr_fxpt::cos (d_phase); } + float sin () const { return gr_fxpt::sin (d_phase); } +}; + +#endif /* INCLUDED_GR_FXPT_VCO_H */ diff --git a/gnuradio-core/src/lib/general/gr_head.cc b/gnuradio-core/src/lib/general/gr_head.cc deleted file mode 100644 index 1726888113..0000000000 --- a/gnuradio-core/src/lib/general/gr_head.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009 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_head.h> -#include <gr_io_signature.h> -#include <string.h> -#include <iostream> - -gr_head::gr_head (size_t sizeof_stream_item, unsigned long long nitems) - : gr_sync_block ("head", - gr_make_io_signature (1, 1, sizeof_stream_item), - gr_make_io_signature (1, 1, sizeof_stream_item)), - d_nitems (nitems), d_ncopied_items (0) -{ -} - -gr_head_sptr -gr_make_head (size_t sizeof_stream_item, unsigned long long nitems) -{ - return gnuradio::get_initial_sptr(new gr_head (sizeof_stream_item, nitems)); -} - -int -gr_head::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - if (d_ncopied_items >= d_nitems) - return -1; // Done! - - unsigned n = std::min (d_nitems - d_ncopied_items, (unsigned long long) noutput_items); - - if (n == 0) - return 0; - - memcpy (output_items[0], input_items[0], n * input_signature()->sizeof_stream_item (0)); - d_ncopied_items += n; - - return n; -} diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h deleted file mode 100644 index 48415892dd..0000000000 --- a/gnuradio-core/src/lib/general/gr_head.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009,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_HEAD_H -#define INCLUDED_GR_HEAD_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <stddef.h> // size_t - -class gr_head; -typedef boost::shared_ptr<gr_head> gr_head_sptr; - -/*! - * \brief copies the first N items to the output then signals done - * \ingroup slicedice_blk - * - * Useful for building test cases - */ - -class GR_CORE_API gr_head : public gr_sync_block -{ - friend GR_CORE_API gr_head_sptr gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); - gr_head (size_t sizeof_stream_item, unsigned long long nitems); - - unsigned long long d_nitems; - unsigned long long d_ncopied_items; - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void reset() { d_ncopied_items = 0; } - void set_length(int nitems) { d_nitems = nitems; } -}; - -GR_CORE_API gr_head_sptr -gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); - - -#endif /* INCLUDED_GR_HEAD_H */ diff --git a/gnuradio-core/src/lib/general/gr_head.i b/gnuradio-core/src/lib/general/gr_head.i deleted file mode 100644 index 11f3331d47..0000000000 --- a/gnuradio-core/src/lib/general/gr_head.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009,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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,head); - -gr_head_sptr gr_make_head(size_t sizeof_stream_item, unsigned long long nitems); - -class gr_head : public gr_block { - gr_head(); -public: - void reset(); - void set_length(int nitems); -}; - diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc b/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc deleted file mode 100644 index 599b25b728..0000000000 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 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_iqcomp_cc.h> -#include <gr_io_signature.h> - -gr_iqcomp_cc_sptr -gr_make_iqcomp_cc (float mu) -{ - return gnuradio::get_initial_sptr(new gr_iqcomp_cc (mu)); -} - -gr_iqcomp_cc::gr_iqcomp_cc (float mu) - : gr_sync_block ("iqcomp_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_mu (mu) -{ - d_wi=0.0; - d_wq=0.0; -} - -int -gr_iqcomp_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (gr_complex *) input_items[0]; - // gr_complex *optr = (gr_complex *) output_items[0]; - - for(int i = 0 ; i < noutput_items ; i++) { - float i_out = iptr[i].real() - iptr[i].imag() * d_wq; - float q_out = iptr[i].imag() - iptr[i].real() * d_wi; - d_wi += d_mu * q_out * iptr[i].real(); - d_wq += d_mu * i_out * iptr[i].imag(); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.h b/gnuradio-core/src/lib/general/gr_iqcomp_cc.h deleted file mode 100644 index 2f5a44ebfb..0000000000 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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_IQCOMP_CC_H -#define INCLUDED_GR_IQCOMP_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_iqcomp_cc; -typedef boost::shared_ptr<gr_iqcomp_cc> gr_iqcomp_cc_sptr; - -GR_CORE_API gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); - -/*! - * \brief - * \ingroup misc_blk - */ -class GR_CORE_API gr_iqcomp_cc : public gr_sync_block -{ - friend GR_CORE_API gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); - - float d_mu, d_wi, d_wq; - gr_iqcomp_cc (float mu); - - public: - float mu () const { return d_mu; } - void set_mu (float mu) { d_mu = mu; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.i b/gnuradio-core/src/lib/general/gr_iqcomp_cc.i deleted file mode 100644 index 5cca59dd5d..0000000000 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- 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,iqcomp_cc) - -gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); - -class gr_iqcomp_cc : public gr_sync_block -{ - private: - gr_iqcomp_cc (float mu); - - public: - float mu () const { return d_mu; } - void set_mu (float mu) { d_mu = mu; } -}; diff --git a/gnuradio-core/src/lib/general/gr_kludge_copy.cc b/gnuradio-core/src/lib/general/gr_kludge_copy.cc deleted file mode 100644 index f6a8d8af68..0000000000 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 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_kludge_copy.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_kludge_copy_sptr -gr_make_kludge_copy(size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_kludge_copy(itemsize)); -} - -gr_kludge_copy::gr_kludge_copy(size_t itemsize) - : gr_sync_block ("kludge_copy", - gr_make_io_signature (1, -1, itemsize), - gr_make_io_signature (1, -1, itemsize)), - d_itemsize(itemsize) -{ -} - -bool -gr_kludge_copy::check_topology(int ninputs, int noutputs) -{ - return ninputs == noutputs; -} - -int -gr_kludge_copy::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float **in = (const float **) &input_items[0]; - float **out = (float **) &output_items[0]; - - int ninputs = input_items.size(); - for (int i = 0; i < ninputs; i++){ - memcpy(out[i], in[i], noutput_items * d_itemsize); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_kludge_copy.h b/gnuradio-core/src/lib/general/gr_kludge_copy.h deleted file mode 100644 index 0bcf144699..0000000000 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 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_KLUDGE_COPY_H -#define INCLUDED_GR_KLUDGE_COPY_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_kludge_copy; -typedef boost::shared_ptr<gr_kludge_copy> gr_kludge_copy_sptr; - -GR_CORE_API gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); - -/*! - * \brief output[i] = input[i] - * \ingroup misc_blk - * - * This is a short term kludge to work around a problem with the hierarchical block impl. - */ -class GR_CORE_API gr_kludge_copy : public gr_sync_block -{ - size_t d_itemsize; - - friend GR_CORE_API gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); - gr_kludge_copy(size_t itemsize); - - public: - - bool check_topology(int ninputs, int noutputs); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_kludge_copy.i b/gnuradio-core/src/lib/general/gr_kludge_copy.i deleted file mode 100644 index 7ff2b57365..0000000000 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 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,kludge_copy) - -gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); - -class gr_kludge_copy : public gr_sync_block -{ - private: - gr_kludge_copy(size_t itemsize); -}; diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc deleted file mode 100644 index c9a8742486..0000000000 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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_lfsr_32k_source_s.h> -#include <gr_io_signature.h> -#include <stdexcept> - - -gr_lfsr_32k_source_s_sptr -gr_make_lfsr_32k_source_s () -{ - return gnuradio::get_initial_sptr(new gr_lfsr_32k_source_s ()); -} - - -gr_lfsr_32k_source_s::gr_lfsr_32k_source_s () - : gr_sync_block ("lfsr_32k_source_s", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (short))), - d_index (0) -{ - gri_lfsr_32k lfsr; - - for (int i = 0; i < BUFSIZE; i++) - d_buffer[i] = lfsr.next_short (); -} - -int -gr_lfsr_32k_source_s::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - short *out = (short *) output_items[0]; - short *buf = d_buffer; - int index = d_index; - - for (int i = 0; i < noutput_items; i++){ - out[i] = buf[index]; - // index = (index + 1) & (BUFSIZE - 1); - index = index + 1; - if (index >= BUFSIZE) - index = 0; - } - - d_index = index; - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h deleted file mode 100644 index db107652ad..0000000000 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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_LFSR_32K_SOURCE_S_H -#define INCLUDED_GR_LFSR_32K_SOURCE_S_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_lfsr_32k.h> - -class gr_lfsr_32k_source_s; -typedef boost::shared_ptr<gr_lfsr_32k_source_s> gr_lfsr_32k_source_s_sptr; - -GR_CORE_API gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); - -/*! - * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts) - * \ingroup source_blk - * - * This source is typically used along with gr_check_lfsr_32k_s to test - * the USRP using its digital loopback mode. - */ -class GR_CORE_API gr_lfsr_32k_source_s : public gr_sync_block -{ - friend GR_CORE_API gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); - - - static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned - int d_index; - short d_buffer[BUFSIZE]; - - gr_lfsr_32k_source_s (); - - public: - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.i b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.i deleted file mode 100644 index c2dc1c61b7..0000000000 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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,lfsr_32k_source_s); - -gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); - -class gr_lfsr_32k_source_s : public gr_sync_block -{ - private: - gr_lfsr_32k_source_s (); -}; diff --git a/gnuradio-core/src/lib/general/gr_nco.h b/gnuradio-core/src/lib/general/gr_nco.h new file mode 100644 index 0000000000..fb51106aab --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_nco.h @@ -0,0 +1,198 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002 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 _GR_NCO_H_ +#define _GR_NCO_H_ + + +#include <vector> +#include <gr_sincos.h> +#include <cmath> +#include <gr_complex.h> + +/*! + * \brief base class template for Numerically Controlled Oscillator (NCO) + * \ingroup misc + */ + + +//FIXME Eventually generalize this to fixed point + +template<class o_type, class i_type> +class gr_nco { +public: + gr_nco () : phase (0), phase_inc(0) {} + + virtual ~gr_nco () {} + + // radians + void set_phase (double angle) { + phase = angle; + } + + void adjust_phase (double delta_phase) { + phase += delta_phase; + } + + + // angle_rate is in radians / step + void set_freq (double angle_rate){ + phase_inc = angle_rate; + } + + // angle_rate is a delta in radians / step + void adjust_freq (double delta_angle_rate) + { + phase_inc += delta_angle_rate; + } + + // increment current phase angle + + void step () + { + phase += phase_inc; + if (fabs (phase) > M_PI){ + + while (phase > M_PI) + phase -= 2*M_PI; + + while (phase < -M_PI) + phase += 2*M_PI; + } + } + + void step (int n) + { + phase += phase_inc * n; + if (fabs (phase) > M_PI){ + + while (phase > M_PI) + phase -= 2*M_PI; + + while (phase < -M_PI) + phase += 2*M_PI; + } + } + + // units are radians / step + double get_phase () const { return phase; } + double get_freq () const { return phase_inc; } + + // compute sin and cos for current phase angle + void sincos (float *sinx, float *cosx) const; + + // compute cos or sin for current phase angle + float cos () const { return std::cos (phase); } + float sin () const { return std::sin (phase); } + + // compute a block at a time + void sin (float *output, int noutput_items, double ampl = 1.0); + void cos (float *output, int noutput_items, double ampl = 1.0); + void sincos (gr_complex *output, int noutput_items, double ampl = 1.0); + void sin (short *output, int noutput_items, double ampl = 1.0); + void cos (short *output, int noutput_items, double ampl = 1.0); + void sin (int *output, int noutput_items, double ampl = 1.0); + void cos (int *output, int noutput_items, double ampl = 1.0); + +protected: + double phase; + double phase_inc; +}; + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::sincos (float *sinx, float *cosx) const +{ + gr_sincosf (phase, sinx, cosx); +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::sin (float *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (float)(sin () * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::cos (float *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (float)(cos () * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::sin (short *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (short)(sin() * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::cos (short *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (short)(cos () * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::sin (int *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (int)(sin () * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::cos (int *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (int)(cos () * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::sincos (gr_complex *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + float cosx, sinx; + sincos (&sinx, &cosx); + output[i] = gr_complex(cosx * ampl, sinx * ampl); + step (); + } +} +#endif /* _NCO_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_nop.cc b/gnuradio-core/src/lib/general/gr_nop.cc deleted file mode 100644 index 164f3ba8dd..0000000000 --- a/gnuradio-core/src/lib/general/gr_nop.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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_nop.h> -#include <gr_io_signature.h> -#include <boost/bind.hpp> - -#ifdef GR_CTRLPORT -#include <rpcregisterhelpers.h> -#endif - -gr_nop_sptr -gr_make_nop (size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr (new gr_nop (sizeof_stream_item)); -} - -gr_nop::gr_nop (size_t sizeof_stream_item) - : gr_block ("nop", - gr_make_io_signature (0, -1, sizeof_stream_item), - gr_make_io_signature (0, -1, sizeof_stream_item)), - d_nmsgs_recvd(0), d_ctrlport_test(0) -{ - // Arrange to have count_received_msgs called when messages are received. - message_port_register_in(pmt::mp("port")); - set_msg_handler(pmt::mp("port"), boost::bind(&gr_nop::count_received_msgs, this, _1)); -} - -// Trivial message handler that just counts them. -// (N.B., This feature is used in qa_set_msg_handler) -void -gr_nop::count_received_msgs(pmt::pmt_t msg) -{ - d_nmsgs_recvd++; -} - -int -gr_nop::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // eat any input that's available - for (unsigned i = 0; i < ninput_items.size (); i++) - consume (i, ninput_items[i]); - - return noutput_items; -} - -void -gr_nop::setup_rpc() -{ -#ifdef GR_CTRLPORT - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_get<gr_nop, int>( - alias(), "test", - &gr_nop::ctrlport_test, - pmt::mp(-256), pmt::mp(255), pmt::mp(0), - "", "Simple testing variable", - RPC_PRIVLVL_MIN, DISPNULL))); - - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_set<gr_nop, int>( - alias(), "test", - &gr_nop::set_ctrlport_test, - pmt::mp(-256), pmt::mp(255), pmt::mp(0), - "", "Simple testing variable", - RPC_PRIVLVL_MIN, DISPNULL))); -#endif /* GR_CTRLPORT */ -} diff --git a/gnuradio-core/src/lib/general/gr_nop.h b/gnuradio-core/src/lib/general/gr_nop.h deleted file mode 100644 index 5f1cb13a02..0000000000 --- a/gnuradio-core/src/lib/general/gr_nop.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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_NOP_H -#define INCLUDED_GR_NOP_H - -#include <gr_core_api.h> -#include <gr_block.h> -#include <stddef.h> // size_t - -class gr_nop; -typedef boost::shared_ptr<gr_nop> gr_nop_sptr; - -GR_CORE_API gr_nop_sptr -gr_make_nop (size_t sizeof_stream_item); - -/*! - * \brief Does nothing. Used for testing only. - * \ingroup misc_blk - */ -class GR_CORE_API gr_nop : public gr_block -{ - friend GR_CORE_API gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); - gr_nop (size_t sizeof_stream_item); - - std::vector<boost::any> d_rpc_vars; - void setup_rpc(); - -protected: - int d_nmsgs_recvd; - int d_ctrlport_test; - - // Method that just counts any received messages. - void count_received_msgs(pmt::pmt_t msg); - - public: - virtual int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - int nmsgs_received() const { return d_nmsgs_recvd; } - - int ctrlport_test() { return d_ctrlport_test; } - void set_ctrlport_test(int x) { d_ctrlport_test = x; } -}; - -#endif /* INCLUDED_GR_NOP_H */ diff --git a/gnuradio-core/src/lib/general/gr_nop.i b/gnuradio-core/src/lib/general/gr_nop.i deleted file mode 100644 index 73ffa93630..0000000000 --- a/gnuradio-core/src/lib/general/gr_nop.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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,nop) - -gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); - -class gr_nop : public gr_block { -public: - int ctrlport_test(); - void set_ctrlport_test(int x); -private: - gr_nop (size_t sizeof_stream_item); -}; - diff --git a/gnuradio-core/src/lib/general/gr_null_sink.cc b/gnuradio-core/src/lib/general/gr_null_sink.cc deleted file mode 100644 index 1836655024..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_sink.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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_null_sink.h> -#include <gr_io_signature.h> - -gr_null_sink::gr_null_sink (size_t sizeof_stream_item) - : gr_sync_block ("null_sink", - gr_make_io_signature (1, 1, sizeof_stream_item), - gr_make_io_signature (0, 0, 0)) -{ -} - -gr_null_sink_sptr -gr_make_null_sink (size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr (new gr_null_sink (sizeof_stream_item)); -} - -int -gr_null_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_null_sink.h b/gnuradio-core/src/lib/general/gr_null_sink.h deleted file mode 100644 index 7374293295..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_sink.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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_NULL_SINK_H -#define INCLUDED_GR_NULL_SINK_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <stddef.h> // size_t - -class gr_null_sink; -typedef boost::shared_ptr<gr_null_sink> gr_null_sink_sptr; - -GR_CORE_API gr_null_sink_sptr -gr_make_null_sink (size_t sizeof_stream_item); - -/*! - * \brief Bit bucket - * \ingroup sink_blk - */ -class GR_CORE_API gr_null_sink : public gr_sync_block -{ - friend GR_CORE_API gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); - gr_null_sink (size_t sizeof_stream_item); - - public: - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif /* INCLUDED_GR_NULL_SINK_H */ diff --git a/gnuradio-core/src/lib/general/gr_null_sink.i b/gnuradio-core/src/lib/general/gr_null_sink.i deleted file mode 100644 index 80411f9b74..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_sink.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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,null_sink) - -gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); - -class gr_null_sink : public gr_sync_block { -private: - gr_null_sink (size_t sizeof_stream_item); -}; - diff --git a/gnuradio-core/src/lib/general/gr_null_source.cc b/gnuradio-core/src/lib/general/gr_null_source.cc deleted file mode 100644 index 1ad5c351d6..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_source.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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_null_source.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_null_source::gr_null_source (size_t sizeof_stream_item) - : gr_sync_block ("null_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof_stream_item)) -{ -} - -gr_null_source_sptr -gr_make_null_source (size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr (new gr_null_source (sizeof_stream_item)); -} - -int -gr_null_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - void *optr = (void *) output_items[0]; - memset (optr, 0, noutput_items * output_signature()->sizeof_stream_item (0)); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_null_source.h b/gnuradio-core/src/lib/general/gr_null_source.h deleted file mode 100644 index 1c64e8bd98..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_source.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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_NULL_SOURCE_H -#define INCLUDED_GR_NULL_SOURCE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_null_source; -typedef boost::shared_ptr<gr_null_source> gr_null_source_sptr; - -GR_CORE_API gr_null_source_sptr -gr_make_null_source (size_t sizeof_stream_item); - -/*! - * \brief A source of zeros. - * \ingroup source_blk - */ -class GR_CORE_API gr_null_source : public gr_sync_block -{ - friend GR_CORE_API gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item); - - gr_null_source (size_t sizeof_stream_item); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif /* INCLUDED_GR_NULL_SOURCE_H */ diff --git a/gnuradio-core/src/lib/general/gr_null_source.i b/gnuradio-core/src/lib/general/gr_null_source.i deleted file mode 100644 index 120a59999c..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_source.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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,null_source) - -gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item); - -class gr_null_source : public gr_sync_block { -private: - gr_null_source (size_t sizeof_stream_item); -}; - diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc deleted file mode 100644 index 2b718e5ce2..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 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_ofdm_bpsk_demapper.h> -#include <gr_io_signature.h> - -gr_ofdm_bpsk_demapper_sptr -gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_bpsk_demapper (occupied_carriers)); -} - -gr_ofdm_bpsk_demapper::gr_ofdm_bpsk_demapper (unsigned occupied_carriers) - : gr_block ("ofdm_bpsk_demapper", - gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers), - gr_make_io_signature (1, 1, sizeof(unsigned char))), - d_occupied_carriers(occupied_carriers), - d_byte_offset(0), d_partial_byte(0) -{ -} - -gr_ofdm_bpsk_demapper::~gr_ofdm_bpsk_demapper(void) -{ -} - -unsigned char gr_ofdm_bpsk_demapper::slicer(gr_complex x) -{ - return (unsigned char)(x.real() > 0 ? 1 : 0); -} - -void -gr_ofdm_bpsk_demapper::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = 1; -} - -int -gr_ofdm_bpsk_demapper::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *)input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - unsigned int i=0, bytes_produced=0; - - while(i < d_occupied_carriers) { - - while((d_byte_offset < 8) && (i < d_occupied_carriers)) { - //fprintf(stderr, "%f+j%f\n", in[i].real(), in[i].imag()); - d_partial_byte |= slicer(in[i++]) << (d_byte_offset++); - } - - if(d_byte_offset == 8) { - out[bytes_produced++] = d_partial_byte; - d_byte_offset = 0; - d_partial_byte = 0; - } - } - -#if 0 -printf("demod out: "); - for(i = 0; i < bytes_produced; i++) { - printf("%4x", out[i]); - } - printf(" \tlen: %d\n", i); -#endif - - consume_each(1); - return bytes_produced; -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h deleted file mode 100644 index d69d427edb..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 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_OFDM_BPSK_DEMAPPER_H -#define INCLUDED_GR_OFDM_BPSK_DEMAPPER_H - - -#include <gr_core_api.h> -#include <gr_block.h> -#include <vector> - -class gr_ofdm_bpsk_demapper; -typedef boost::shared_ptr<gr_ofdm_bpsk_demapper> gr_ofdm_bpsk_demapper_sptr; - -GR_CORE_API gr_ofdm_bpsk_demapper_sptr -gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - -/*! - * \brief take a vector of complex constellation points in from an FFT - * and demodulate to a stream of bits. Simple BPSK version. - * \ingroup ofdm_blk - */ -class GR_CORE_API gr_ofdm_bpsk_demapper : public gr_block -{ - friend GR_CORE_API gr_ofdm_bpsk_demapper_sptr - gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - protected: - gr_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - private: - unsigned char slicer(gr_complex x); - - unsigned int d_occupied_carriers; - unsigned int d_byte_offset; - unsigned char d_partial_byte; - - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - - public: - ~gr_ofdm_bpsk_demapper(void); - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i deleted file mode 100644 index e58a4e40c5..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,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 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 <vector> - -GR_SWIG_BLOCK_MAGIC(gr,ofdm_bpsk_demapper) - -gr_ofdm_bpsk_demapper_sptr -gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); - -class gr_ofdm_bpsk_demapper : public gr_sync_decimator -{ - protected: - gr_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - public: - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.cc b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.cc deleted file mode 100644 index eb12327565..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.cc +++ /dev/null @@ -1,374 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_ofdm_frame_sink2.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <gr_math.h> -#include <math.h> -#include <cstdio> -#include <stdexcept> -#include <iostream> -#include <string.h> -#include <gr_constellation.h> - -#define VERBOSE 0 - -inline void -gr_ofdm_frame_sink2::enter_search() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_search\n"); - - d_state = STATE_SYNC_SEARCH; - -} - -inline void -gr_ofdm_frame_sink2::enter_have_sync() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_sync\n"); - - d_state = STATE_HAVE_SYNC; - - // clear state of demapper - d_byte_offset = 0; - d_partial_byte = 0; - - d_header = 0; - d_headerbytelen_cnt = 0; - - // Resetting PLL - d_freq = 0.0; - d_phase = 0.0; - fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); -} - -inline void -gr_ofdm_frame_sink2::enter_have_header() -{ - d_state = STATE_HAVE_HEADER; - - // header consists of two 16-bit shorts in network byte order - // payload length is lower 12 bits - // whitener offset is upper 4 bits - d_packetlen = (d_header >> 16) & 0x0fff; - d_packet_whitener_offset = (d_header >> 28) & 0x000f; - d_packetlen_cnt = 0; - - if (VERBOSE) - fprintf(stderr, "@ enter_have_header (payload_len = %d) (offset = %d)\n", - d_packetlen, d_packet_whitener_offset); -} - - -unsigned int gr_ofdm_frame_sink2::demapper(const gr_complex *in, - unsigned char *out) -{ - unsigned int i=0, bytes_produced=0; - gr_complex carrier; - - carrier=gr_expj(d_phase); - - gr_complex accum_error = 0.0; - //while(i < d_occupied_carriers) { - while(i < d_subcarrier_map.size()) { - if(d_nresid > 0) { - d_partial_byte |= d_resid; - d_byte_offset += d_nresid; - d_nresid = 0; - d_resid = 0; - } - - //while((d_byte_offset < 8) && (i < d_occupied_carriers)) { - while((d_byte_offset < 8) && (i < d_subcarrier_map.size())) { - //gr_complex sigrot = in[i]*carrier*d_dfe[i]; - gr_complex sigrot = in[d_subcarrier_map[i]]*carrier*d_dfe[i]; - - if(d_derotated_output != NULL){ - d_derotated_output[i] = sigrot; - } - - unsigned char bits = d_constell->decision_maker(&sigrot); - - gr_complex closest_sym = d_constell->points()[bits]; - - accum_error += sigrot * conj(closest_sym); - - // FIX THE FOLLOWING STATEMENT - if (norm(sigrot)> 0.001) d_dfe[i] += d_eq_gain*(closest_sym/sigrot-d_dfe[i]); - - i++; - - if((8 - d_byte_offset) >= d_nbits) { - d_partial_byte |= bits << (d_byte_offset); - d_byte_offset += d_nbits; - } - else { - d_nresid = d_nbits-(8-d_byte_offset); - int mask = ((1<<(8-d_byte_offset))-1); - d_partial_byte |= (bits & mask) << d_byte_offset; - d_resid = bits >> (8-d_byte_offset); - d_byte_offset += (d_nbits - d_nresid); - } - //printf("demod symbol: %.4f + j%.4f bits: %x partial_byte: %x byte_offset: %d resid: %x nresid: %d\n", - // in[i-1].real(), in[i-1].imag(), bits, d_partial_byte, d_byte_offset, d_resid, d_nresid); - } - - if(d_byte_offset == 8) { - //printf("demod byte: %x \n\n", d_partial_byte); - out[bytes_produced++] = d_partial_byte; - d_byte_offset = 0; - d_partial_byte = 0; - } - } - //std::cerr << "accum_error " << accum_error << std::endl; - - float angle = arg(accum_error); - - d_freq = d_freq - d_freq_gain*angle; - d_phase = d_phase + d_freq - d_phase_gain*angle; - if (d_phase >= 2*M_PI) d_phase -= 2*M_PI; - if (d_phase <0) d_phase += 2*M_PI; - - //if(VERBOSE) - // std::cerr << angle << "\t" << d_freq << "\t" << d_phase << "\t" << std::endl; - - return bytes_produced; -} - - -gr_ofdm_frame_sink2_sptr -gr_make_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, - float phase_gain, float freq_gain) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_frame_sink2(constell, - target_queue, occupied_carriers, - phase_gain, freq_gain)); -} - - -gr_ofdm_frame_sink2::gr_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, - float phase_gain, float freq_gain) - : gr_sync_block ("ofdm_frame_sink2", - gr_make_io_signature2 (2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char)), - gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers)), - d_constell(constell), - d_target_queue(target_queue), d_occupied_carriers(occupied_carriers), - d_byte_offset(0), d_partial_byte(0), - d_resid(0), d_nresid(0),d_phase(0),d_freq(0),d_phase_gain(phase_gain),d_freq_gain(freq_gain), - d_eq_gain(0.05) -{ - if (d_constell->dimensionality() != 1) - throw std::runtime_error ("This receiver only works with constellations of dimension 1."); - - std::string carriers = "FE7F"; - - // A bit hacky to fill out carriers to occupied_carriers length - int diff = (d_occupied_carriers - 4*carriers.length()); - while(diff > 7) { - carriers.insert(0, "f"); - carriers.insert(carriers.length(), "f"); - diff -= 8; - } - - // if there's extras left to be processed - // divide remaining to put on either side of current map - // all of this is done to stick with the concept of a carrier map string that - // can be later passed by the user, even though it'd be cleaner to just do this - // on the carrier map itself - int diff_left=0; - int diff_right=0; - - // dictionary to convert from integers to ascii hex representation - char abc[16] = {'0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - if(diff > 0) { - char c[2] = {0,0}; - - diff_left = (int)ceil((float)diff/2.0f); // number of carriers to put on the left side - c[0] = abc[(1 << diff_left) - 1]; // convert to bits and move to ASCI integer - carriers.insert(0, c); - - diff_right = diff - diff_left; // number of carriers to put on the right side - c[0] = abc[0xF^((1 << diff_right) - 1)]; // convert to bits and move to ASCI integer - carriers.insert(carriers.length(), c); - } - - // It seemed like such a good idea at the time... - // because we are only dealing with the occupied_carriers - // at this point, the diff_left in the following compensates - // for any offset from the 0th carrier introduced - unsigned int i,j,k; - for(i = 0; i < (d_occupied_carriers/4)+diff_left; i++) { - char c = carriers[i]; - for(j = 0; j < 4; j++) { - k = (strtol(&c, NULL, 16) >> (3-j)) & 0x1; - if(k) { - d_subcarrier_map.push_back(4*i + j - diff_left); - } - } - } - - // make sure we stay in the limit currently imposed by the occupied_carriers - if(d_subcarrier_map.size() > d_occupied_carriers) { - throw std::invalid_argument("gr_ofdm_mapper_bcv: subcarriers allocated exceeds size of occupied carriers"); - } - - d_bytes_out = new unsigned char[d_occupied_carriers]; - d_dfe.resize(occupied_carriers); - fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); - - d_nbits = d_constell->bits_per_symbol(); - - enter_search(); -} - -gr_ofdm_frame_sink2::~gr_ofdm_frame_sink2 () -{ - delete [] d_bytes_out; -} - - -int -gr_ofdm_frame_sink2::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]; - const char *sig = (const char *) input_items[1]; - unsigned int j = 0; - unsigned int bytes=0; - - // If the output is connected, send it the derotated symbols - if(output_items.size() >= 1) - d_derotated_output = (gr_complex *)output_items[0]; - else - d_derotated_output = NULL; - - if (VERBOSE) - fprintf(stderr,">>> Entering state machine\n"); - - switch(d_state) { - - case STATE_SYNC_SEARCH: // Look for flag indicating beginning of pkt - if (VERBOSE) - fprintf(stderr,"SYNC Search, noutput=%d\n", noutput_items); - - if (sig[0]) { // Found it, set up for header decode - enter_have_sync(); - } - break; - - case STATE_HAVE_SYNC: - // only demod after getting the preamble signal; otherwise, the - // equalizer taps will screw with the PLL performance - bytes = demapper(&in[0], d_bytes_out); - - if (VERBOSE) { - if(sig[0]) - printf("ERROR -- Found SYNC in HAVE_SYNC\n"); - fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", - d_headerbytelen_cnt, d_header); - } - - j = 0; - while(j < bytes) { - d_header = (d_header << 8) | (d_bytes_out[j] & 0xFF); - j++; - - if (++d_headerbytelen_cnt == HEADERBYTELEN) { - - if (VERBOSE) - fprintf(stderr, "got header: 0x%08x\n", d_header); - - // we have a full header, check to see if it has been received properly - if (header_ok()){ - enter_have_header(); - - if (VERBOSE) - printf("\nPacket Length: %d\n", d_packetlen); - - while((j < bytes) && (d_packetlen_cnt < d_packetlen)) { - d_packet[d_packetlen_cnt++] = d_bytes_out[j++]; - } - - if(d_packetlen_cnt == d_packetlen) { - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - } - } - else { - enter_search(); // bad header - } - } - } - break; - - case STATE_HAVE_HEADER: - bytes = demapper(&in[0], d_bytes_out); - - if (VERBOSE) { - if(sig[0]) - printf("ERROR -- Found SYNC in HAVE_HEADER at %d, length of %d\n", d_packetlen_cnt, d_packetlen); - fprintf(stderr,"Packet Build\n"); - } - - j = 0; - while(j < bytes) { - d_packet[d_packetlen_cnt++] = d_bytes_out[j++]; - - if (d_packetlen_cnt == d_packetlen){ // packet is filled - // build a message - // NOTE: passing header field as arg1 is not scalable - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen_cnt); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - break; - } - } - break; - - default: - assert(0); - - } // switch - - return 1; -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h deleted file mode 100644 index a743e8c5a5..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,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. - */ - -#ifndef INCLUDED_GR_OFDM_FRAME_SINK2_H -#define INCLUDED_GR_OFDM_FRAME_SINK2_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> -#include <gr_constellation.h> - -class gr_ofdm_frame_sink2; -typedef boost::shared_ptr<gr_ofdm_frame_sink2> gr_ofdm_frame_sink2_sptr; - -GR_CORE_API gr_ofdm_frame_sink2_sptr -gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain=0.25, float freq_gain=0.25*0.25/4.0); - -/*! - * \brief Takes an OFDM symbol in, demaps it into bits of 0's and 1's, packs - * them into packets, and sends to to a message queue sink. - * \ingroup sink_blk - * \ingroup ofdm_blk - * - * NOTE: The mod input parameter simply chooses a pre-defined demapper/slicer. Eventually, - * we want to be able to pass in a reference to an object to do the demapping and slicing - * for a given modulation type. - */ -class GR_CORE_API gr_ofdm_frame_sink2 : public gr_sync_block -{ - friend GR_CORE_API gr_ofdm_frame_sink2_sptr - gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - private: - enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; - - static const int MAX_PKT_LEN = 4096; - static const int HEADERBYTELEN = 4; - - gr_msg_queue_sptr d_target_queue; // where to send the packet when received - state_t d_state; - unsigned int d_header; // header bits - int d_headerbytelen_cnt; // how many so far - - unsigned char *d_bytes_out; // hold the current bytes produced by the demapper - - unsigned int d_occupied_carriers; - unsigned int d_byte_offset; - unsigned int d_partial_byte; - - unsigned char d_packet[MAX_PKT_LEN]; // assembled payload - int d_packetlen; // length of packet - int d_packet_whitener_offset; // offset into whitener string to use - int d_packetlen_cnt; // how many so far - - gr_complex * d_derotated_output; // Pointer to output stream to send deroated symbols out - - gr_constellation_sptr d_constell; - std::vector<gr_complex> d_dfe; - unsigned int d_nbits; - - unsigned char d_resid; - unsigned int d_nresid; - float d_phase; - float d_freq; - float d_phase_gain; - float d_freq_gain; - float d_eq_gain; - - std::vector<int> d_subcarrier_map; - - protected: - gr_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - void enter_search(); - void enter_have_sync(); - void enter_have_header(); - - bool header_ok() - { - // confirm that two copies of header info are identical - return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; - } - - unsigned char slicer(const gr_complex x); - unsigned int demapper(const gr_complex *in, - unsigned char *out); - - public: - ~gr_ofdm_frame_sink2(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_OFDM_FRAME_SINK2_H */ diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i deleted file mode 100644 index 8c04d1e160..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,ofdm_frame_sink2); - -gr_ofdm_frame_sink2_sptr -gr_make_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain=0.25, float freq_gain=0.25*0.25/4); - -class gr_ofdm_frame_sink2 : public gr_sync_block -{ - protected: - gr_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - public: - ~gr_ofdm_frame_sink2(); -}; diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc deleted file mode 100644 index 3187536726..0000000000 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 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_pa_2x2_phase_combiner.h> -#include <gr_io_signature.h> - -gr_pa_2x2_phase_combiner_sptr -gr_make_pa_2x2_phase_combiner() -{ - return gnuradio::get_initial_sptr(new gr_pa_2x2_phase_combiner()); -} - -gr_pa_2x2_phase_combiner::gr_pa_2x2_phase_combiner () - : gr_sync_block ("pa_2x2_phase_combiner", - gr_make_io_signature (1, 1, NM * sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (float))) -{ - set_theta(0); -} - -void -gr_pa_2x2_phase_combiner::set_theta(float theta) -{ - d_theta = theta; - gr_complex j = gr_complex(0,1); - d_phase[0] = exp(j * (float) (M_PI * (sin(theta) + cos(theta)))); - d_phase[1] = exp(j * (float) (M_PI * cos(theta))); - d_phase[2] = exp(j * (float) (M_PI * sin(theta))); - d_phase[3] = exp(j * (float) 0.0); -} - -int -gr_pa_2x2_phase_combiner::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]; - gr_complex *out = (gr_complex *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - gr_complex acc = 0; - acc += in[0] * d_phase[0]; - acc += in[1] * d_phase[1]; - acc += in[2] * d_phase[2]; - acc += in[3] * d_phase[3]; - out[i] = acc; - in += 4; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h deleted file mode 100644 index d430d154fc..0000000000 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 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_PA_2X2_PHASE_COMBINER_H -#define INCLUDED_GR_PA_2X2_PHASE_COMBINER_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_pa_2x2_phase_combiner; -typedef boost::shared_ptr<gr_pa_2x2_phase_combiner> gr_pa_2x2_phase_combiner_sptr; - -GR_CORE_API gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner (); - -/*! - * \brief pa_2x2 phase combiner - * \ingroup misc_blk - * - * Anntenas are arranged like this: - * - * 2 3 - * 0 1 - * - * dx and dy are lambda/2. - */ -class GR_CORE_API gr_pa_2x2_phase_combiner : public gr_sync_block -{ - static const int NM = 4; - - float d_theta; - gr_complex d_phase[NM]; - - gr_pa_2x2_phase_combiner (); - friend GR_CORE_API gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner(); - - public: - float theta() const { return d_theta; } - void set_theta(float theta); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_PA_2X2_PHASE_COMBINER_H */ diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.i b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.i deleted file mode 100644 index 2cd373a5e4..0000000000 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 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,pa_2x2_phase_combiner) - -gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner(); - -class gr_pa_2x2_phase_combiner : public gr_sync_block -{ - gr_pa_2x2_phase_combiner(); - - public: - float theta() const; - void set_theta(float theta); -}; diff --git a/gnuradio-core/src/lib/filter/gr_sincos.c b/gnuradio-core/src/lib/general/gr_sincos.c index a8d01b0da4..a8d01b0da4 100644 --- a/gnuradio-core/src/lib/filter/gr_sincos.c +++ b/gnuradio-core/src/lib/general/gr_sincos.c diff --git a/gnuradio-core/src/lib/filter/gr_sincos.h b/gnuradio-core/src/lib/general/gr_sincos.h index 516f43437a..516f43437a 100644 --- a/gnuradio-core/src/lib/filter/gr_sincos.h +++ b/gnuradio-core/src/lib/general/gr_sincos.h diff --git a/gnuradio-core/src/lib/general/gr_skiphead.cc b/gnuradio-core/src/lib/general/gr_skiphead.cc deleted file mode 100644 index c93478597b..0000000000 --- a/gnuradio-core/src/lib/general/gr_skiphead.cc +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2007,2010 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_skiphead.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_skiphead::gr_skiphead (size_t itemsize, uint64_t nitems_to_skip) - : gr_block ("skiphead", - gr_make_io_signature(1, 1, itemsize), - gr_make_io_signature(1, 1, itemsize)), - d_nitems_to_skip(nitems_to_skip), d_nitems(0) -{ -} - -gr_skiphead_sptr -gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip) -{ - return gnuradio::get_initial_sptr(new gr_skiphead (itemsize, nitems_to_skip)); -} - -void -gr_skiphead::set_nitems_to_skip(uint64_t nitems_to_skip) -{ - d_nitems_to_skip = nitems_to_skip; - reset(); -} - -uint64_t -gr_skiphead::nitems_to_skip() const -{ - return d_nitems_to_skip; -} - -uint64_t -gr_skiphead::nitems_skiped() const -{ - return d_nitems; -} - -void -gr_skiphead::reset() -{ - d_nitems = 0; -} - -int -gr_skiphead::general_work(int noutput_items, - gr_vector_int &ninput_items_, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - - int ninput_items = std::min(ninput_items_[0], noutput_items); - int ii = 0; // input index - - while (ii < ninput_items){ - - uint64_t ni_total = ii + d_nitems; // total items processed so far - if (ni_total < d_nitems_to_skip){ // need to skip some more - - int n_to_skip = (int) std::min(d_nitems_to_skip - ni_total, - (uint64_t)(ninput_items - ii)); - ii += n_to_skip; - } - - else { // nothing left to skip. copy away - - int n_to_copy = ninput_items - ii; - if (n_to_copy > 0){ - size_t itemsize = output_signature()->sizeof_stream_item(0); - memcpy(out, in + (ii*itemsize), n_to_copy*itemsize); - } - - d_nitems += ninput_items; - consume_each(ninput_items); - return n_to_copy; - } - } - - d_nitems += ninput_items; - consume_each(ninput_items); - return 0; -} diff --git a/gnuradio-core/src/lib/general/gr_skiphead.h b/gnuradio-core/src/lib/general/gr_skiphead.h deleted file mode 100644 index 710530ff4c..0000000000 --- a/gnuradio-core/src/lib/general/gr_skiphead.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- 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. - */ - -#ifndef INCLUDED_GR_SKIPHEAD_H -#define INCLUDED_GR_SKIPHEAD_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <stddef.h> // size_t - -class gr_skiphead; -typedef boost::shared_ptr<gr_skiphead> gr_skiphead_sptr; - -GR_CORE_API gr_skiphead_sptr -gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); - - -/*! - * \brief skips the first N items, from then on copies items to the output - * \ingroup slicedice_blk - * - * Useful for building test cases and sources which have metadata or junk at the start - */ - -class GR_CORE_API gr_skiphead : public gr_block -{ - friend GR_CORE_API gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); - gr_skiphead (size_t itemsize, uint64_t nitems_to_skip); - - uint64_t d_nitems_to_skip; - uint64_t d_nitems; // total items seen - - public: - - /*! - * \brief Sets number of items to skip; resets current skip count to 0. - */ - void set_nitems_to_skip(uint64_t nitems_to_skip); - - /*! - * \brief Gets the number of items to skip. - */ - uint64_t nitems_to_skip() const; - - /*! - * \brief Gets the number of items already skipped. - */ - uint64_t nitems_skiped() const; - - /*! - * \brief Resets number of items skipped to 0. - */ - void reset(); - - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_SKIPHEAD_H */ diff --git a/gnuradio-core/src/lib/general/gr_skiphead.i b/gnuradio-core/src/lib/general/gr_skiphead.i deleted file mode 100644 index 8ab23a77a6..0000000000 --- a/gnuradio-core/src/lib/general/gr_skiphead.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2007,2010 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,skiphead); - -gr_skiphead_sptr gr_make_skiphead(size_t itemsize, - uint64_t nitems_to_skip); - -class gr_skiphead : public gr_block -{ -public: - void set_nitems_to_skip(uint64_t nitems_to_skip); - uint64_t nitems_to_skip() const; - uint64_t nitems_skiped() const; - void reset(); -}; diff --git a/gnuradio-core/src/lib/general/gr_vco.h b/gnuradio-core/src/lib/general/gr_vco.h new file mode 100644 index 0000000000..3ceaf15dd4 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_vco.h @@ -0,0 +1,94 @@ +/* -*- 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. + */ +#ifndef _GR_VCO_H_ +#define _GR_VCO_H_ + + +#include <vector> +#include <gr_sincos.h> +#include <cmath> +#include <gr_complex.h> + +/*! + * \brief base class template for Voltage Controlled Oscillator (VCO) + * \ingroup misc + */ + +//FIXME Eventually generalize this to fixed point + +template<class o_type, class i_type> +class gr_vco { +public: + gr_vco () : d_phase (0) {} + + virtual ~gr_vco () {} + + // radians + void set_phase (double angle) { + d_phase = angle; + } + + void adjust_phase (double delta_phase) { + d_phase += delta_phase; + if (fabs (d_phase) > M_PI){ + + while (d_phase > M_PI) + d_phase -= 2*M_PI; + + while (d_phase < -M_PI) + d_phase += 2*M_PI; + } + } + + double get_phase () const { return d_phase; } + + // compute sin and cos for current phase angle + void sincos (float *sinx, float *cosx) const; + + // compute cos or sin for current phase angle + float cos () const { return std::cos (d_phase); } + float sin () const { return std::sin (d_phase); } + + // compute a block at a time + void cos (float *output, const float *input, int noutput_items, double k, double ampl = 1.0); + +protected: + double d_phase; +}; + +template<class o_type, class i_type> +void +gr_vco<o_type,i_type>::sincos (float *sinx, float *cosx) const +{ + gr_sincosf (d_phase, sinx, cosx); +} + +template<class o_type, class i_type> +void +gr_vco<o_type,i_type>::cos (float *output, const float *input, int noutput_items, double k, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = cos() * ampl; + adjust_phase(input[i] * k); + } +} +#endif /* _GR_VCO_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_vector_map.cc b/gnuradio-core/src/lib/general/gr_vector_map.cc deleted file mode 100644 index 2a13efb06d..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_map.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- 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_vector_map.h> -#include <gr_io_signature.h> -#include <string.h> - -std::vector<int> -get_in_sizeofs(size_t item_size, std::vector<size_t> in_vlens) -{ - std::vector<int> in_sizeofs; - for(unsigned int i = 0; i < in_vlens.size(); i++) { - in_sizeofs.push_back(in_vlens[i]*item_size); - } - return in_sizeofs; -} - -std::vector<int> -get_out_sizeofs(size_t item_size, - std::vector< std::vector< std::vector<size_t> > > mapping) -{ - std::vector<int> out_sizeofs; - for(unsigned int i = 0; i < mapping.size(); i++) { - out_sizeofs.push_back(mapping[i].size()*item_size); - } - return out_sizeofs; -} - -gr_vector_map_sptr -gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping) -{ - return gnuradio::get_initial_sptr(new gr_vector_map(item_size, - in_vlens, - mapping)); -} - -gr_vector_map::gr_vector_map(size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping) - : gr_sync_block("vector_map", - gr_make_io_signaturev(in_vlens.size(), in_vlens.size(), - get_in_sizeofs(item_size, in_vlens)), - gr_make_io_signaturev(mapping.size(), mapping.size(), - get_out_sizeofs(item_size, mapping))), - d_item_size(item_size), d_in_vlens(in_vlens) -{ - set_mapping(mapping); -} - -void -gr_vector_map::set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping) { - // Make sure the contents of the mapping vectors are possible. - for(unsigned int i=0; i<mapping.size(); i++) { - for(unsigned int j=0; j<mapping[i].size(); j++) { - if(mapping[i][j].size() != 2) { - throw std::runtime_error("Mapping must be of the form (out_mapping_stream1, out_mapping_stream2, ...), where out_mapping_stream1 is of the form (mapping_element1, mapping_element2, ...), where mapping_element1 is of the form (input_stream, input_element). This error is raised because a mapping_element vector does not contain exactly 2 items."); - } - unsigned int s = mapping[i][j][0]; - unsigned int index = mapping[i][j][1]; - if(s >= d_in_vlens.size()) { - throw std::runtime_error("Stream numbers in mapping must be less than the number of input streams."); - } - if((index < 0) || (index >= d_in_vlens[s])) { - throw std::runtime_error ("Indices in mapping must be greater than 0 and less than the input vector lengths."); - } - } - } - gruel::scoped_lock guard(d_mutex); - d_mapping = mapping; -} - -int -gr_vector_map::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char **inv = (const char **) &input_items[0]; - char **outv = (char **) &output_items[0]; - - for(unsigned int n = 0; n < (unsigned int)(noutput_items); n++) { - for(unsigned int i = 0; i < d_mapping.size(); i++) { - unsigned int out_vlen = d_mapping[i].size(); - for(unsigned int j = 0; j < out_vlen; j++) { - unsigned int s = d_mapping[i][j][0]; - unsigned int k = d_mapping[i][j][1]; - memcpy(outv[i] + out_vlen*d_item_size*n + - d_item_size*j, inv[s] + d_in_vlens[s]*d_item_size*n + - k*d_item_size, d_item_size); - } - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_vector_map.h b/gnuradio-core/src/lib/general/gr_vector_map.h deleted file mode 100644 index f5492b1e3a..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_map.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- 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_VECTOR_MAP_H -#define INCLUDED_GR_VECTOR_MAP_H - -#include <vector> -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> -#include <gruel/thread.h> - -class gr_vector_map; -typedef boost::shared_ptr<gr_vector_map> gr_vector_map_sptr; - -GR_CORE_API gr_vector_map_sptr -gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping); - -/*! - * \brief Maps elements from a set of input vectors to a set of output vectors. - * - * If in[i] is the input vector in the i'th stream then the output - * vector in the j'th stream is: - * - * out[j][k] = in[mapping[j][k][0]][mapping[j][k][1]] - * - * That is mapping is of the form (out_stream1_mapping, - * out_stream2_mapping, ...) and out_stream1_mapping is of the form - * (element1_mapping, element2_mapping, ...) and element1_mapping is - * of the form (in_stream, in_element). - * - * \param item_size (integer) size of vector elements - * - * \param in_vlens (vector of integers) number of elements in each - * input vector - * - * \param mapping (vector of vectors of vectors of integers) how to - * map elements from input to output vectors - * - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_vector_map : public gr_sync_block -{ - friend GR_CORE_API gr_vector_map_sptr - gr_make_vector_map(size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping); - size_t d_item_size; - std::vector<size_t> d_in_vlens; - std::vector< std::vector< std::vector<size_t> > > d_mapping; - gruel::mutex d_mutex; // mutex to protect set/work access - - protected: - gr_vector_map(size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping); - - public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping); -}; - -#endif /* INCLUDED_GR_VECTOR_MAP_H */ diff --git a/gnuradio-core/src/lib/general/gr_vector_map.i b/gnuradio-core/src/lib/general/gr_vector_map.i deleted file mode 100644 index e9fa3f27e5..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_map.i +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr, vector_map); - -%template() std::vector<size_t>; -%template() std::vector< std::vector< std::vector<size_t> > >; - -%include "gr_vector_map.h" diff --git a/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h b/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h deleted file mode 100644 index 578739f7ef..0000000000 --- a/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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_GRI_LFSR_15_1_0_H -#define INCLUDED_GRI_LFSR_15_1_0_H - -#include <gr_core_api.h> - -/*! - * \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1 - * \ingroup misc - * - * Generates a maximal length pseudo-random sequence of length 2^15 - 1 bits. - */ - -class GR_CORE_API gri_lfsr_15_1_0 { - unsigned long d_sr; // shift register - - public: - - gri_lfsr_15_1_0 () { reset (); } - - void reset () { d_sr = 0x7fff; } - - int next_bit (){ - d_sr = ((((d_sr >> 1) ^ d_sr) & 0x1) << 14) | (d_sr >> 1); - return d_sr & 0x1; - } - - int next_byte (){ - int v = 0; - for (int i = 0; i < 8; i++){ - v >>= 1; - if (next_bit ()) - v |= 0x80; - } - return v; - } -}; - -#endif /* INCLUDED_GRI_LFSR_15_1_0_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_lfsr_32k.h b/gnuradio-core/src/lib/general/gri_lfsr_32k.h deleted file mode 100644 index e84512b9a6..0000000000 --- a/gnuradio-core/src/lib/general/gri_lfsr_32k.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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_GRI_LFSR_32k_H -#define INCLUDED_GRI_LFSR_32k_H - -#include <gr_core_api.h> -#include <gri_lfsr_15_1_0.h> - -/*! - * \brief generate pseudo-random sequence of length 32768 bits. - * \ingroup misc - * - * This is based on gri_lfsr_15_1_0 with an extra 0 added at the end - * of the sequence. - */ - -class GR_CORE_API gri_lfsr_32k { - gri_lfsr_15_1_0 d_lfsr; - unsigned int d_count; - - public: - gri_lfsr_32k () { reset (); } - - void reset (){ - d_lfsr.reset (); - d_count = 0; - } - - int next_bit (){ - if (d_count == 32767){ - d_count = 0; - return 0; - } - d_count++; - return d_lfsr.next_bit (); - } - - int next_byte (){ - int v = 0; - for (int i = 0; i < 8; i++){ - v >>= 1; - if (next_bit ()) - v |= 0x80; - } - return v; - } - - int next_short (){ - int v = 0; - for (int i = 0; i < 16; i++){ - v >>= 1; - if (next_bit ()) - v |= 0x8000; - } - return v; - } - -}; - -#endif /* INCLUDED_GRI_LFSR_32k_H */ diff --git a/gnuradio-core/src/lib/general/qa_general.cc b/gnuradio-core/src/lib/general/qa_general.cc index e2328c2cb2..121551b050 100644 --- a/gnuradio-core/src/lib/general/qa_general.cc +++ b/gnuradio-core/src/lib/general/qa_general.cc @@ -27,7 +27,11 @@ #include <qa_general.h> #include <qa_gr_circular_file.h> +#include <qa_gr_fxpt.h> +#include <qa_gr_fxpt_nco.h> +#include <qa_gr_fxpt_vco.h> #include <qa_gr_math.h> +#include <qa_sincos.h> CppUnit::TestSuite * qa_general::suite () @@ -35,7 +39,11 @@ qa_general::suite () CppUnit::TestSuite *s = new CppUnit::TestSuite ("general"); s->addTest (qa_gr_circular_file::suite ()); + s->addTest (qa_gr_fxpt::suite ()); + s->addTest (qa_gr_fxpt_nco::suite ()); + s->addTest (qa_gr_fxpt_vco::suite ()); s->addTest (qa_gr_math::suite ()); + s->addTest(gr::analog::qa_sincos::suite()); return s; } diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt.cc new file mode 100644 index 0000000000..7eac0d8964 --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt.cc @@ -0,0 +1,103 @@ +/* -*- c++ -*- */ +/* + * 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 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 <qa_gr_fxpt.h> +#include <gr_fxpt.h> +#include <cppunit/TestAssert.h> +#include <iostream> +#include <stdio.h> +#include <unistd.h> +#include <math.h> + +static const float SIN_COS_TOLERANCE = 1e-5; + +void +qa_gr_fxpt::t0 () +{ + CPPUNIT_ASSERT_DOUBLES_EQUAL (M_PI/2, gr_fxpt::fixed_to_float (0x40000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, gr_fxpt::fixed_to_float (0x00000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (-M_PI, gr_fxpt::fixed_to_float (0x80000000), SIN_COS_TOLERANCE); + + if (0){ + /* + * These are disabled because of some precision issues. + * + * Different compilers seem to have different opinions on whether + * the calulations are done single or double (or extended) + * precision. Any of the answers are fine for our real purpose, but + * sometimes the answer is off by a few bits at the bottom. + * Hence, the disabled check. + */ + CPPUNIT_ASSERT_EQUAL ((gr_int32) 0x40000000, gr_fxpt::float_to_fixed (M_PI/2)); + CPPUNIT_ASSERT_EQUAL ((gr_int32) 0, gr_fxpt::float_to_fixed (0)); + CPPUNIT_ASSERT_EQUAL ((gr_int32) 0x80000000, gr_fxpt::float_to_fixed (-M_PI)); + } +} + +void +qa_gr_fxpt::t1 () +{ + + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x00000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0.707106781, gr_fxpt::sin (0x20000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 1, gr_fxpt::sin (0x40000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0.707106781, gr_fxpt::sin (0x60000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x7fffffff), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x80000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x80000001), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (-1, gr_fxpt::sin (-0x40000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (-0.707106781, gr_fxpt::sin (-0x20000000), SIN_COS_TOLERANCE); + + + for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ + float expected = sin (p); + float actual = gr_fxpt::sin (gr_fxpt::float_to_fixed (p)); + CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, SIN_COS_TOLERANCE); + } +} + +void +qa_gr_fxpt::t2 () +{ + for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ + float expected = cos (p); + float actual = gr_fxpt::cos (gr_fxpt::float_to_fixed (p)); + CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, SIN_COS_TOLERANCE); + } +} + +void +qa_gr_fxpt::t3 () +{ + for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ + float expected_sin = sin (p); + float expected_cos = cos (p); + float actual_sin; + float actual_cos; + gr_fxpt::sincos (gr_fxpt::float_to_fixed (p), &actual_sin, &actual_cos); + CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_sin, actual_sin, SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_cos, actual_cos, SIN_COS_TOLERANCE); + } +} diff --git a/gnuradio-core/src/lib/runtime/qa_gr_block.h b/gnuradio-core/src/lib/general/qa_gr_fxpt.h index 14c7c40d1f..72211563e7 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_block.h +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt.h @@ -19,17 +19,16 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ +#ifndef INCLUDED_QA_GR_FXPT_H +#define INCLUDED_QA_GR_FXPT_H -#ifndef INCLUDED_QA_GR_BLOCK_H -#define INCLUDED_QA_GR_BLOCK_H #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <stdexcept> -class qa_gr_block : public CppUnit::TestCase { +class qa_gr_fxpt : public CppUnit::TestCase { - CPPUNIT_TEST_SUITE (qa_gr_block); + CPPUNIT_TEST_SUITE (qa_gr_fxpt); CPPUNIT_TEST (t0); CPPUNIT_TEST (t1); CPPUNIT_TEST (t2); @@ -44,5 +43,6 @@ class qa_gr_block : public CppUnit::TestCase { }; +#endif /* INCLUDED_QA_GR_FXPT_H */ + -#endif /* INCLUDED_QA_GR_BLOCK_H */ diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc new file mode 100644 index 0000000000..6f208eac80 --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc @@ -0,0 +1,119 @@ +/* -*- c++ -*- */ +/* + * 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 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 <qa_gr_fxpt_nco.h> +#include <gr_fxpt_nco.h> +#include <gr_nco.h> +#include <cppunit/TestAssert.h> +#include <iostream> +#include <stdio.h> +#include <unistd.h> +#include <math.h> + +static const float SIN_COS_TOLERANCE = 1e-5; + +//static const float SIN_COS_FREQ = 5003; +static const float SIN_COS_FREQ = 4096; + +static const int SIN_COS_BLOCK_SIZE = 100000; + +static double max_d(double a, double b) +{ + return fabs(a) > fabs(b) ? a : b; +} + +void +qa_gr_fxpt_nco::t0 () +{ + gr_nco<float,float> ref_nco; + gr_fxpt_nco new_nco; + double max_error = 0, max_phase_error = 0; + + ref_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); + new_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); + + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + float ref_sin = ref_nco.sin (); + float new_sin = new_nco.sin (); + //printf ("i = %6d\n", i); + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_sin, new_sin, SIN_COS_TOLERANCE); + + max_error = max_d (max_error, ref_sin-new_sin); + + float ref_cos = ref_nco.cos (); + float new_cos = new_nco.cos (); + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_cos, new_cos, SIN_COS_TOLERANCE); + + max_error = max_d (max_error, ref_cos-new_cos); + + ref_nco.step (); + new_nco.step (); + + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); + + max_phase_error = max_d (max_phase_error, ref_nco.get_phase()-new_nco.get_phase()); + } + // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); +} + +void +qa_gr_fxpt_nco::t1 () +{ + gr_nco<float,float> ref_nco; + gr_fxpt_nco new_nco; + gr_complex ref_block[SIN_COS_BLOCK_SIZE]; + gr_complex new_block[SIN_COS_BLOCK_SIZE]; + double max_error = 0; + + ref_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); + new_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); + + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); + + ref_nco.sincos ((gr_complex*)ref_block, SIN_COS_BLOCK_SIZE); + new_nco.sincos ((gr_complex*)new_block, SIN_COS_BLOCK_SIZE); + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].real(), new_block[i].real(), SIN_COS_TOLERANCE); + max_error = max_d (max_error, ref_block[i].real()-new_block[i].real()); + + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].imag(), new_block[i].imag(), SIN_COS_TOLERANCE); + max_error = max_d (max_error, ref_block[i].imag()-new_block[i].imag()); + } + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); + // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); +} + +void +qa_gr_fxpt_nco::t2 () +{ +} + +void +qa_gr_fxpt_nco::t3 () +{ +} diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.h b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h index 039d345cdf..8998922bbb 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.h +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2004 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,23 +19,20 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ +#ifndef INCLUDED_QA_GR_FXPT_NCO_H +#define INCLUDED_QA_GR_FXPT_NCO_H -#ifndef INCLUDED_QA_BLOCK_TAGS_H -#define INCLUDED_QA_BLOCK_TAGS_H #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <stdexcept> -class qa_block_tags : public CppUnit::TestCase { +class qa_gr_fxpt_nco : public CppUnit::TestCase { - CPPUNIT_TEST_SUITE (qa_block_tags); + CPPUNIT_TEST_SUITE (qa_gr_fxpt_nco); CPPUNIT_TEST (t0); CPPUNIT_TEST (t1); CPPUNIT_TEST (t2); CPPUNIT_TEST (t3); - CPPUNIT_TEST (t4); - //CPPUNIT_TEST (t5); CPPUNIT_TEST_SUITE_END (); private: @@ -43,10 +40,9 @@ class qa_block_tags : public CppUnit::TestCase { void t1 (); void t2 (); void t3 (); - void t4 (); - //void t5 (); }; +#endif /* INCLUDED_QA_GR_FXPT_NCO_H */ + -#endif /* INCLUDED_QA_BLOCK_TAGS_H */ diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc new file mode 100644 index 0000000000..5b6993a30c --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc @@ -0,0 +1,110 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <qa_gr_fxpt_vco.h> +#include <gr_fxpt_vco.h> +#include <gr_vco.h> +#include <cppunit/TestAssert.h> +#include <iostream> +#include <stdio.h> +#include <unistd.h> +#include <math.h> + +static const float SIN_COS_TOLERANCE = 1e-5; + +static const float SIN_COS_K = 0.42; +static const float SIN_COS_AMPL = 0.8; + +static const int SIN_COS_BLOCK_SIZE = 100000; + +static double max_d(double a, double b) +{ + return fabs(a) > fabs(b) ? a : b; +} + +void +qa_gr_fxpt_vco::t0 () +{ + gr_vco<float,float> ref_vco; + gr_fxpt_vco new_vco; + double max_error = 0, max_phase_error = 0; + float input[SIN_COS_BLOCK_SIZE]; + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + input[i] = sin(double(i)); + } + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + float ref_cos = ref_vco.cos (); + float new_cos = new_vco.cos (); + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_cos, new_cos, SIN_COS_TOLERANCE); + + max_error = max_d (max_error, ref_cos-new_cos); + + ref_vco.adjust_phase (input[i]); + new_vco.adjust_phase (input[i]); + + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); + + max_phase_error = max_d (max_phase_error, ref_vco.get_phase()-new_vco.get_phase()); + } + // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); +} + + +void +qa_gr_fxpt_vco::t1 () +{ + gr_vco<float,float> ref_vco; + gr_fxpt_vco new_vco; + float ref_block[SIN_COS_BLOCK_SIZE]; + float new_block[SIN_COS_BLOCK_SIZE]; + float input[SIN_COS_BLOCK_SIZE]; + double max_error = 0; + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + input[i] = sin(double(i)); + } + + ref_vco.cos (ref_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); + new_vco.cos (new_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i], new_block[i], SIN_COS_TOLERANCE); + max_error = max_d (max_error, ref_block[i]-new_block[i]); + } + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); + // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, ref_vco.get_phase()-new_vco.get_phase()); +} + +void +qa_gr_fxpt_vco::t2 () +{ +} + +void +qa_gr_fxpt_vco::t3 () +{ +} diff --git a/gnuradio-core/src/lib/runtime/qa_set_msg_handler.h b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h index 60277a12cc..fab8022e36 100644 --- a/gnuradio-core/src/lib/runtime/qa_set_msg_handler.h +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2011 Free Software Foundation, Inc. + * Copyright 2004,2005 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,25 +19,30 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ +#ifndef INCLUDED_QA_GR_FXPT_VCO_H +#define INCLUDED_QA_GR_FXPT_VCO_H -#ifndef INCLUDED_QA_SET_MSG_HANDLER_H -#define INCLUDED_QA_SET_MSG_HANDLER_H #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <stdexcept> -class qa_set_msg_handler : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_set_msg_handler); +class qa_gr_fxpt_vco : public CppUnit::TestCase { - CPPUNIT_TEST(t0); + CPPUNIT_TEST_SUITE (qa_gr_fxpt_vco); + CPPUNIT_TEST (t0); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST (t3); + CPPUNIT_TEST_SUITE_END (); - CPPUNIT_TEST_SUITE_END(); + private: + void t0 (); + void t1 (); + void t2 (); + void t3 (); -private: - - void t0(); }; -#endif /* INCLUDED_QA_SET_MSG_HANDLER_H */ +#endif /* INCLUDED_QA_GR_FXPT_VCO_H */ + + diff --git a/gnuradio-core/src/lib/general/qa_sincos.cc b/gnuradio-core/src/lib/general/qa_sincos.cc new file mode 100644 index 0000000000..0066ff6b92 --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_sincos.cc @@ -0,0 +1,75 @@ +/* -*- 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 <qa_sincos.h> +#include <gr_sincos.h> +#include <gruel/attributes.h> +#include <cppunit/TestAssert.h> +#include <cmath> + +namespace gr { + namespace analog { + + void + qa_sincos::t1() + { + static const unsigned int N = 1000; + double c_sin, c_cos; + double gr_sin, gr_cos; + + for(unsigned i = 0; i < N; i++) { + double x = i/100.0; + c_sin = sin(x); + c_cos = cos(x); + + gr_sincos(x, &gr_sin, &gr_cos); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(c_sin, gr_sin, 0.0001); + CPPUNIT_ASSERT_DOUBLES_EQUAL(c_cos, gr_cos, 0.0001); + } + } + + void + qa_sincos::t2() + { + static const unsigned int N = 1000; + float c_sin, c_cos; + float gr_sin, gr_cos; + + for(unsigned i = 0; i < N; i++) { + float x = i/100.0; + c_sin = sinf(x); + c_cos = cosf(x); + + gr_sincosf(x, &gr_sin, &gr_cos); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(c_sin, gr_sin, 0.0001); + CPPUNIT_ASSERT_DOUBLES_EQUAL(c_cos, gr_cos, 0.0001); + } + } + + } /* namespace analog */ +} /* namespace gr */ diff --git a/gnuradio-core/src/lib/filter/qa_rotator.h b/gnuradio-core/src/lib/general/qa_sincos.h index a22e41ec26..f18e879dd8 100644 --- a/gnuradio-core/src/lib/filter/qa_rotator.h +++ b/gnuradio-core/src/lib/general/qa_sincos.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008,2012 Free Software Foundation, Inc. + * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#ifndef _QA_ANALOG_ROTATOR_H_ -#define _QA_ANALOG_ROTATOR_H_ +#ifndef _QA_ANALOG_SINCOS_H_ +#define _QA_ANALOG_SINCOS_H_ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> @@ -29,17 +29,19 @@ namespace gr { namespace analog { - class qa_rotator : public CppUnit::TestCase + class qa_sincos : public CppUnit::TestCase { - CPPUNIT_TEST_SUITE(qa_rotator); + CPPUNIT_TEST_SUITE(qa_sincos); CPPUNIT_TEST(t1); + CPPUNIT_TEST(t2); CPPUNIT_TEST_SUITE_END(); private: void t1(); + void t2(); }; } /* namespace analog */ } /* namespace gr */ -#endif /* _QA_ANALOG_ROTATOR_H_ */ +#endif /* _QA_ANALOG_SINCOS_H_ */ diff --git a/gnuradio-core/src/lib/gengen/CMakeLists.txt b/gnuradio-core/src/lib/gengen/CMakeLists.txt deleted file mode 100644 index 45834ced5f..0000000000 --- a/gnuradio-core/src/lib/gengen/CMakeLists.txt +++ /dev/null @@ -1,143 +0,0 @@ -# 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. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## -include(GrPython) - -######################################################################## -# generate the python helper script which calls into the build utils -######################################################################## -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " -#!${PYTHON_EXECUTABLE} - -import sys, os, re -sys.path.append('${GR_CORE_PYTHONPATH}') -os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' -os.chdir('${CMAKE_CURRENT_BINARY_DIR}') - -if __name__ == '__main__': - import build_utils - root, inp = sys.argv[1:3] - for sig in sys.argv[3:]: - name = re.sub ('X+', sig, root) - d = build_utils.standard_dict(name, sig) - build_utils.expand_template(d, inp) - -") - -######################################################################## -# generation helper macro to generate various files from template -######################################################################## -macro(expand_h_cc_i root) - - foreach(ext h cc i) - #make a list of all the generated files - unset(expanded_files_${ext}) - foreach(sig ${ARGN}) - string(REGEX REPLACE "X+" ${sig} name ${root}) - list(APPEND expanded_files_${ext} ${CMAKE_CURRENT_BINARY_DIR}/${name}.${ext}) - endforeach(sig) - - #create a command to generate the files - add_custom_command( - OUTPUT ${expanded_files_${ext}} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.${ext}.t - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} - ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py - ${root} ${root}.${ext}.t ${ARGN} - ) - endforeach(ext) - - #make source files depends on headers to force generation - set_source_files_properties(${expanded_files_cc} - PROPERTIES OBJECT_DEPENDS "${expanded_files_h}" - ) - - #install rules for the generated cc, h, and i files - list(APPEND generated_gengen_sources ${expanded_files_cc}) - list(APPEND generated_gengen_includes ${expanded_files_h}) - list(APPEND generated_gengen_swigs ${expanded_files_i}) - -endmacro(expand_h_cc_i) - -######################################################################## -# Invoke macro to generate various sources -######################################################################## -expand_h_cc_i(gr_vector_source_X b s i f c) -expand_h_cc_i(gr_vector_insert_X b) -expand_h_cc_i(gr_vector_sink_X b s i f c) - -add_custom_target(gengen_generated DEPENDS - ${generated_gengen_includes} - ${generated_gengen_swigs} -) - -######################################################################## -# Create the master gengen swig include files -######################################################################## -set(generated_index ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i.in) -file(WRITE ${generated_index} " -// -// This file is machine generated. All edits will be overwritten -// -") - -file(APPEND ${generated_index} "%{\n") -foreach(swig_file ${generated_gengen_swigs}) - get_filename_component(name ${swig_file} NAME_WE) - file(APPEND ${generated_index} "#include<${name}.h>\n") -endforeach(swig_file) -file(APPEND ${generated_index} "%}\n") - -foreach(swig_file ${generated_gengen_swigs}) - get_filename_component(name ${swig_file} NAME) - file(APPEND ${generated_index} "%include<${name}>\n") -endforeach(swig_file) - -execute_process( - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${generated_index} ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i -) - -######################################################################## -# Handle the generated sources + a few non-generated ones -######################################################################## -list(APPEND gnuradio_core_sources - ${generated_gengen_sources} -) - -install(FILES - ${generated_gengen_includes} - ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) - -if(ENABLE_PYTHON) - install(FILES - ${generated_gengen_swigs} - ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.i - ${CMAKE_CURRENT_SOURCE_DIR}/gengen.i - ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "core_swig" - ) -endif(ENABLE_PYTHON) diff --git a/gnuradio-core/src/lib/gengen/generate_all.py b/gnuradio-core/src/lib/gengen/generate_all.py deleted file mode 100755 index 6b0f20f058..0000000000 --- a/gnuradio-core/src/lib/gengen/generate_all.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env 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 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. -# - -from build_utils import output_glue - -import generate_common - -def generate_all (): - generate_common.generate () - output_glue ('gengen') - - -if __name__ == '__main__': - generate_all () diff --git a/gnuradio-core/src/lib/gengen/generate_common.py b/gnuradio-core/src/lib/gengen/generate_common.py deleted file mode 100755 index 68913f9a75..0000000000 --- a/gnuradio-core/src/lib/gengen/generate_common.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2006,2007,2008,2009 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. -# - -from build_utils import expand_template, standard_dict -from build_utils_codes import * - -import re - - -# sources and sinks -ss_signatures = ['s', 'i', 'f', 'c'] - -ss_roots = [ - 'gr_vector_source_X', - 'gr_vector_sink_X', - ] - -# regular blocks -reg_signatures = ['ss', 'ii', 'ff', 'cc'] - - -def expand_h_cc_i (root, sig): - # root looks like 'gr_vector_sink_X' - name = re.sub ('X+', sig, root) - d = standard_dict (name, sig) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - - -def generate (): - expand_h_cc_i ('gr_vector_sink_X', 'b') - expand_h_cc_i ('gr_vector_source_X', 'b') - for r in ss_roots: - for s in ss_signatures: - expand_h_cc_i (r, s) - -if __name__ == '__main__': - generate () - - diff --git a/gnuradio-core/src/lib/gengen/gengen.i b/gnuradio-core/src/lib/gengen/gengen.i deleted file mode 100644 index 7d8c27fe68..0000000000 --- a/gnuradio-core/src/lib/gengen/gengen.i +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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 "gr_endianness.h" -%} - -%include "gr_endianness.i" - -%include "gengen_generated.i" diff --git a/gnuradio-core/src/lib/gengen/gr_endianness.i b/gnuradio-core/src/lib/gengen/gr_endianness.i deleted file mode 100644 index 572b7a42fb..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_endianness.i +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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 <gr_endianness.h> diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t deleted file mode 100644 index 20968afe22..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@NAME@.h> -#include <algorithm> -#include <gr_io_signature.h> -#include <stdexcept> - -#include <stdio.h> - -@NAME@::@NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset) - : gr_block("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof(@TYPE@)), - gr_make_io_signature (1, 1, sizeof(@TYPE@))), - d_data(data), - d_offset(offset), - d_periodicity(periodicity) -{ - //printf("INITIAL: periodicity = %d, offset = %d\n", periodicity, offset); - // some sanity checks - assert(offset < periodicity); - assert(offset >= 0); - assert((size_t)periodicity > data.size()); -} - -int -@NAME@::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @TYPE@ *out = (@TYPE@ *)output_items[0]; - const @TYPE@ *in = (const @TYPE@ *)input_items[0]; - - int ii(0), oo(0); - - while((oo < noutput_items) && (ii < ninput_items[0])) { - - //printf("oo = %d, ii = %d, d_offset = %d, noutput_items = %d, ninput_items[0] = %d", oo, ii, d_offset, noutput_items, ninput_items[0]); - //printf(", d_periodicity = %d\n", d_periodicity); - - if(d_offset >= ((int)d_data.size())) { // if we are in the copy region - int max_copy = std::min( std::min( noutput_items - oo, ninput_items[0] - ii ), d_periodicity - d_offset ); - //printf("copy %d from input\n", max_copy); - memcpy( &out[oo], &in[ii], sizeof(@TYPE@)*max_copy ); - //printf(" * memcpy returned.\n"); - ii += max_copy; - oo += max_copy; - d_offset = (d_offset + max_copy)%d_periodicity; - - } - else { // if we are in the insertion region - int max_copy = std::min( noutput_items - oo, ((int)d_data.size()) - d_offset ); - //printf("copy %d from d_data[%d] to out[%d]\n", max_copy, d_offset, oo); - memcpy( &out[oo], &d_data[d_offset], sizeof(@TYPE@)*max_copy ); - //printf(" * memcpy returned.\n"); - oo += max_copy; - d_offset = (d_offset + max_copy)%d_periodicity; - //printf(" ## (inelse) oo = %d, d_offset = %d\n", oo, d_offset); - } - - //printf(" # exit else, on to next loop.\n"); - } - //printf(" # got out of loop\n"); - - //printf("consume = %d, produce = %d\n", ii, oo); - consume_each(ii); - return oo; -} - -@NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset) -{ - return gnuradio::get_initial_sptr(new @NAME@ (data, periodicity, offset)); -} - diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t deleted file mode 100644 index 26f851700d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_block.h> - -class GR_CORE_API @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -/*! - * \brief source of @TYPE@'s that gets its data from a vector - * \ingroup source_blk - */ - -class @NAME@ : public gr_block { - friend GR_CORE_API @NAME@_sptr - gr_make_@BASE_NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset); - - std::vector<@TYPE@> d_data; - int d_offset; - int d_periodicity; - - @NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset); - - public: - void rewind() {d_offset=0;} - virtual int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - void set_data(const std::vector<@TYPE@> &data){ d_data = data; rewind(); } -}; - -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset=0); - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t deleted file mode 100644 index f3341eec4f..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset = 0) - throw(std::invalid_argument); - -class @NAME@ : public gr_block { - public: - void rewind(); - void set_data(const std::vector<@TYPE@> &data); - private: - @NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset = 0); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t deleted file mode 100644 index 2b8207c027..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 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. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@NAME@.h> -#include <algorithm> -#include <gr_io_signature.h> -#include <iostream> - - -@NAME@::@NAME@ (int vlen) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@TYPE@) * vlen), - gr_make_io_signature (0, 0, 0)), - d_vlen(vlen) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @TYPE@ *iptr = (@TYPE@ *) input_items[0]; - for (int i = 0; i < noutput_items * d_vlen; i++) - d_data.push_back (iptr[i]); - std::vector<gr_tag_t> tags; - get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items); - d_tags.insert(d_tags.end(), tags.begin(), tags.end()); - return noutput_items; -} - - -@NAME@_sptr -gr_make_@BASE_NAME@ (int vlen) -{ - return gnuradio::get_initial_sptr(new @NAME@ (vlen)); -} - -std::vector<@TYPE@> -@NAME@::data () const -{ - return d_data; -} - -std::vector<gr_tag_t> -@NAME@::tags () const -{ - return d_tags; -} diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t deleted file mode 100644 index b7de1d101c..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2009 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (int vlen = 1); - - -/*! - * \brief @TYPE@ sink that writes to a vector - * \ingroup sink_blk - */ - -class GR_CORE_API @NAME@ : public gr_sync_block { - friend GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (int vlen); - std::vector<@TYPE@> d_data; - std::vector<gr_tag_t> d_tags; - int d_vlen; - @NAME@ (int vlen); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void reset() {d_data.clear();} - void clear() {reset(); } // deprecated - std::vector<@TYPE@> data () const; - std::vector<gr_tag_t> tags () const; -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t deleted file mode 100644 index ee0ebf378b..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2009 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. - */ - -// @WARNING@ - - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int vlen = 1); - -class @NAME@ : public gr_sync_block { - private: - @NAME@ (int vlen); - - public: - void clear(); // deprecated - void reset(); - std::vector<@TYPE@> data () const; - std::vector<gr_tag_t> tags () const; -}; - diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t deleted file mode 100644 index 19272ee24b..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 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. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@NAME@.h> -#include <algorithm> -#include <gr_io_signature.h> -#include <stdexcept> - -@NAME@::@NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (@TYPE@) * vlen)), - d_data (data), - d_repeat (repeat), - d_offset (0), - d_vlen (vlen), - d_tags (tags), - d_tagpos (0) -{ - if (tags.size() == 0) { - d_settags = 0; - } else { - d_settags = 1; - set_output_multiple(data.size() / vlen); - } - if ((data.size() % vlen) != 0) - throw std::invalid_argument("data length must be a multiple of vlen"); -} - -void -@NAME@::set_data (const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags){ - d_data = data; - d_tags = tags; - rewind(); - if (tags.size() == 0) { - d_settags = false; - } else { - d_settags = true; - } -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @TYPE@ *optr = (@TYPE@ *) output_items[0]; - - if (d_repeat){ - unsigned int size = d_data.size (); - unsigned int offset = d_offset; - if (size == 0) - return -1; - - if (d_settags) { - int n_outputitems_per_vector = d_data.size() / d_vlen; - for (int i = 0; i < noutput_items; i += n_outputitems_per_vector) { - // FIXME do proper vector copy - memcpy((void *) optr, (const void *) &d_data[0], size * sizeof (@TYPE@)); - optr += size; - for (unsigned t = 0; t < d_tags.size(); t++) { - add_item_tag(0, nitems_written(0)+i+d_tags[t].offset, d_tags[t].key, d_tags[t].value); - } - } - } else { - for (int i = 0; i < noutput_items*d_vlen; i++){ - optr[i] = d_data[offset++]; - if (offset >= size) { - offset = 0; - } - } - } - - - d_offset = offset; - return noutput_items; - } else { - if (d_offset >= d_data.size ()) - return -1; // Done! - - unsigned n = std::min ((unsigned) d_data.size () - d_offset, - (unsigned) noutput_items*d_vlen); - for (unsigned i = 0; i < n; i++) { - optr[i] = d_data[d_offset + i]; - } - for (unsigned t = 0; t < d_tags.size(); t++) { - if ((d_tags[t].offset >= d_offset) && (d_tags[t].offset < d_offset+n)) - add_item_tag(0, d_tags[t].offset, d_tags[t].key, d_tags[t].value); - } - d_offset += n; - return n/d_vlen; - } -} - -@NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags) -{ - return gnuradio::get_initial_sptr(new @NAME@ (data, repeat, vlen, tags)); -} - diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t deleted file mode 100644 index 041cc47a45..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class GR_CORE_API @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -/*! - * \brief source of @TYPE@'s that gets its data from a vector - * \ingroup source_blk - */ - -class @NAME@ : public gr_sync_block { - friend GR_CORE_API @NAME@_sptr - gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags); - - std::vector<@TYPE@> d_data; - bool d_repeat; - unsigned int d_offset; - int d_vlen; - bool d_settags; - std::vector<gr_tag_t> d_tags; - unsigned int d_tagpos; - - @NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags); - - public: - void rewind() {d_offset=0;} - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - void set_data(const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); -}; - -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t deleted file mode 100644 index 1f1479f947..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1, const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>()) - throw(std::invalid_argument); - -class @NAME@ : public gr_sync_block { - public: - void rewind(); - void set_data(const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); - private: - @NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags); -}; diff --git a/gnuradio-core/src/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt deleted file mode 100644 index 7aeea798cd..0000000000 --- a/gnuradio-core/src/lib/io/CMakeLists.txt +++ /dev/null @@ -1,94 +0,0 @@ -# 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. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## - -######################################################################## -# Append gnuradio-core library sources -######################################################################## -list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink_f.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_guts.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_f.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_x.cc - ${CMAKE_CURRENT_SOURCE_DIR}/i2c.cc - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bitbang.cc - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio.cc - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio_pp.cc - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4702.cc - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4937.cc - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.cc - ${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.cc -) - -######################################################################## -# Install runtime headers -######################################################################## -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink_f.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_guts.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_f.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_x.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_trigger_mode.h - ${CMAKE_CURRENT_SOURCE_DIR}/i2c.h - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bitbang.h - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio.h - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio_pp.h - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4702.h - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4937.h - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_eval_board_defs.h - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.h - ${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) - -######################################################################## -# Install swig headers -######################################################################## -if(ENABLE_PYTHON) -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/io.i - ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink.i - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "core_swig" -) -endif(ENABLE_PYTHON) - -######################################################################## -# Handle triple-threat files that have cc, h, and i -######################################################################## -set(gr_core_io_triple_threats - microtune_xxxx_eval_board - microtune_4702_eval_board - microtune_4937_eval_board - ppio - sdr_1000 -) - -foreach(file_tt ${gr_core_io_triple_threats}) - list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.cc) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel") - if(ENABLE_PYTHON) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig") - endif(ENABLE_PYTHON) -endforeach(file_tt ${gr_core_io_triple_threats}) diff --git a/gnuradio-core/src/lib/io/gr_histo_sink.i b/gnuradio-core/src/lib/io/gr_histo_sink.i deleted file mode 100644 index 14079e1907..0000000000 --- a/gnuradio-core/src/lib/io/gr_histo_sink.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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,histo_sink_f) - -gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); - -class gr_histo_sink_f : public gr_sync_block -{ -public: - ~gr_histo_sink_f (void); - - unsigned int get_frame_size(void); - unsigned int get_num_bins(void); - - void set_frame_size(unsigned int frame_size); - void set_num_bins(unsigned int num_bins); - -}; diff --git a/gnuradio-core/src/lib/io/gr_histo_sink_f.cc b/gnuradio-core/src/lib/io/gr_histo_sink_f.cc deleted file mode 100644 index fc0c12ce64..0000000000 --- a/gnuradio-core/src/lib/io/gr_histo_sink_f.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_histo_sink_f.h> -#include <gr_io_signature.h> -#include <boost/math/special_functions/round.hpp> - -static float get_clean_num(float num){ - if (num == 0) return 0; - /* extract sign and exponent from num */ - int sign = (num < 0) ? -1 : 1; num = fabs(num); - float exponent = floor(log10(num)); - /* search for closest number with base 1, 2, 5, 10 */ - float closest_num = 10*pow(10, exponent); - if (fabs(num - 1*pow(10, exponent)) < fabs(num - closest_num)) - closest_num = 1*pow(10, exponent); - if (fabs(num - 2*pow(10, exponent)) < fabs(num - closest_num)) - closest_num = 2*pow(10, exponent); - if (fabs(num - 5*pow(10, exponent)) < fabs(num - closest_num)) - closest_num = 5*pow(10, exponent); - return sign*closest_num; -} - -gr_histo_sink_f_sptr -gr_make_histo_sink_f (gr_msg_queue_sptr msgq) -{ - return gnuradio::get_initial_sptr(new gr_histo_sink_f (msgq)); -} - -gr_histo_sink_f::gr_histo_sink_f (gr_msg_queue_sptr msgq) - : gr_sync_block ("histo_sink_f", gr_make_io_signature (1, 1, sizeof (float)), gr_make_io_signature (0, 0, 0)), - d_msgq (msgq), d_num_bins(11), d_frame_size(1000), d_sample_count(0), d_bins(NULL), d_samps(NULL) -{ - //allocate arrays and clear - set_num_bins(d_num_bins); - set_frame_size(d_frame_size); -} - -gr_histo_sink_f::~gr_histo_sink_f (void) -{ - delete [] d_samps; - delete [] d_bins; -} - -int -gr_histo_sink_f::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - for (unsigned int i = 0; i < (unsigned int)noutput_items; i++){ - d_samps[d_sample_count] = in[i]; - d_sample_count++; - /* processed a frame? */ - if (d_sample_count == d_frame_size){ - send_frame(); - clear(); - } - } - return noutput_items; -} - -void -gr_histo_sink_f::send_frame(void){ - /* output queue full, drop the data */ - if (d_msgq->full_p()) return; - /* find the minimum and maximum */ - float minimum = d_samps[0]; - float maximum = d_samps[0]; - for (unsigned int i = 0; i < d_frame_size; i++){ - if (d_samps[i] < minimum) minimum = d_samps[i]; - if (d_samps[i] > maximum) maximum = d_samps[i]; - } - minimum = get_clean_num(minimum); - maximum = get_clean_num(maximum); - if (minimum == maximum || minimum > maximum) return; //useless data or screw up? - /* load the bins */ - int index; - float bin_width = (maximum - minimum)/(d_num_bins-1); - for (unsigned int i = 0; i < d_sample_count; i++){ - index = boost::math::iround((d_samps[i] - minimum)/bin_width); - /* ensure the index range in case a small floating point error is involed */ - if (index < 0) index = 0; - if (index >= (int)d_num_bins) index = d_num_bins-1; - d_bins[index]++; - } - /* Build a message to hold the output records */ - gr_message_sptr msg = gr_make_message(0, minimum, maximum, d_num_bins*sizeof(float)); - float *out = (float *)msg->msg(); // get pointer to raw message buffer - /* normalize the bins and put into message */ - for (unsigned int i = 0; i < d_num_bins; i++){ - out[i] = ((float)d_bins[i])/d_frame_size; - } - /* send the message */ - d_msgq->handle(msg); -} - -void -gr_histo_sink_f::clear(void){ - d_sample_count = 0; - /* zero the bins */ - for (unsigned int i = 0; i < d_num_bins; i++){ - d_bins[i] = 0; - } -} - -/************************************************** - * Getters - **************************************************/ -unsigned int -gr_histo_sink_f::get_frame_size(void){ - return d_frame_size; -} - -unsigned int -gr_histo_sink_f::get_num_bins(void){ - return d_num_bins; -} - -/************************************************** - * Setters - **************************************************/ -void -gr_histo_sink_f::set_frame_size(unsigned int frame_size){ - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - d_frame_size = frame_size; - /* allocate a new sample array */ - delete [] d_samps; - d_samps = new float[d_frame_size]; - clear(); -} - -void -gr_histo_sink_f::set_num_bins(unsigned int num_bins){ - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - d_num_bins = num_bins; - /* allocate a new bin array */ - delete [] d_bins; - d_bins = new unsigned int[d_num_bins]; - clear(); -} diff --git a/gnuradio-core/src/lib/io/gr_histo_sink_f.h b/gnuradio-core/src/lib/io/gr_histo_sink_f.h deleted file mode 100644 index 934066ba20..0000000000 --- a/gnuradio-core/src/lib/io/gr_histo_sink_f.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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_HISTO_SINK_F_H -#define INCLUDED_GR_HISTO_SINK_F_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> -#include <gruel/thread.h> - -class gr_histo_sink_f; -typedef boost::shared_ptr<gr_histo_sink_f> gr_histo_sink_f_sptr; - -GR_CORE_API gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); - -/*! - * \brief Histogram module. - * \ingroup sink_blk - */ -class GR_CORE_API gr_histo_sink_f : public gr_sync_block -{ -private: - gr_msg_queue_sptr d_msgq; - unsigned int d_num_bins; - unsigned int d_frame_size; - unsigned int d_sample_count; - unsigned int *d_bins; - float *d_samps; - gruel::mutex d_mutex; - - friend GR_CORE_API gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); - gr_histo_sink_f (gr_msg_queue_sptr msgq); - void send_frame(void); - void clear(void); - -public: - ~gr_histo_sink_f (void); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - unsigned int get_frame_size(void); - unsigned int get_num_bins(void); - - void set_frame_size(unsigned int frame_size); - void set_num_bins(unsigned int num_bins); - -}; - -#endif /* INCLUDED_GR_HISTO_SINK_F_H */ diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.cc b/gnuradio-core/src/lib/io/gr_oscope_guts.cc deleted file mode 100644 index a5ea3002a9..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_guts.cc +++ /dev/null @@ -1,437 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_oscope_guts.h> -#include <stdexcept> -#include <stdio.h> -#include <algorithm> -#include <unistd.h> -#include <math.h> -#include <assert.h> - -/* - * Bad performance if it's large, and flaky triggering if it's too small - */ -static const int OUTPUT_RECORD_SIZE = 1024; // Must be power of 2 - -/* - * For (slow-updated) STRIPCHART triggering, we make the record size larger, since we - * potentially want to be able to "see" hours of data. This works as long as the - * update rates to a STRIPCHART are low, which they generally are--that's rather what - * a stripchart is all about! - */ -static const int SCHART_MULT = 8; - - -static inline int -wrap_bi (int buffer_index, int mx) // wrap buffer index -{ - return buffer_index & (mx - 1); -} - -static inline int -incr_bi (int buffer_index, int mx) // increment buffer index -{ - return wrap_bi (buffer_index + 1, mx); -} - -static inline int -decr_bi (int buffer_index, int mx) // decrement buffer index -{ - return wrap_bi (buffer_index - 1, mx); -} - -gr_oscope_guts::gr_oscope_guts (double sample_rate, gr_msg_queue_sptr msgq) - : d_nchannels (1), - d_msgq (msgq), - d_trigger_mode (gr_TRIG_MODE_AUTO), - d_trigger_slope (gr_TRIG_SLOPE_POS), - d_trigger_channel (0), - d_sample_rate (sample_rate), - d_update_rate (20), - d_trigger_level (0), - d_obi (0), - d_state (HOLD_OFF), - d_decimator_count (0), - d_decimator_count_init (1), - d_hold_off_count (0), - d_hold_off_count_init (OUTPUT_RECORD_SIZE/2-1), - d_pre_trigger_count (0), - d_post_trigger_count (0), - d_post_trigger_count_init (OUTPUT_RECORD_SIZE/2) -{ - for (int i = 0; i < MAX_CHANNELS; i++) - d_buffer[i] = 0; - - for (int i = 0; i < MAX_CHANNELS; i++){ - d_buffer[i] = new float [OUTPUT_RECORD_SIZE*SCHART_MULT]; - for (int j = 0; j < OUTPUT_RECORD_SIZE*SCHART_MULT; j++) - d_buffer[i][j] = 0.0; - } - - // be sure buffer is full before first write - enter_hold_off (); - update_rate_or_decimation_changed (); -} - -gr_oscope_guts::~gr_oscope_guts () -{ - for (int i = 0; i < MAX_CHANNELS; i++) - delete [] d_buffer[i]; -} - -// MANIPULATORS - -// \p channel_data points to nchannels float values. These are the values -// for each channel at this sample time. - -void -gr_oscope_guts::process_sample (const float *channel_data) -{ - d_decimator_count--; - if (d_decimator_count > 0) - return; - - d_decimator_count = d_decimator_count_init; - - if (d_trigger_mode != gr_TRIG_MODE_STRIPCHART) - { - for (int i = 0; i < d_nchannels; i++) - d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer - - switch (d_state){ - case HOLD_OFF: - d_hold_off_count--; - if (d_hold_off_count <= 0) - enter_look_for_trigger (); - break; - - case LOOK_FOR_TRIGGER: - if (found_trigger ()) - enter_post_trigger (); - break; - - case POST_TRIGGER: - d_post_trigger_count--; - if (d_post_trigger_count <= 0){ - write_output_records (); - enter_hold_off (); - } - break; - - default: - assert (0); - } - - d_obi = incr_bi (d_obi, OUTPUT_RECORD_SIZE); - } - else - { - for (int i = 0; i < d_nchannels; i++) - { - for (int j = (OUTPUT_RECORD_SIZE*SCHART_MULT)-1; j > 0; j--) - { - d_buffer[i][j] = d_buffer[i][j-1]; - } - d_buffer[i][0] = channel_data[i]; - } - d_trigger_off = 0; - write_output_records(); - } -} - -/* - * Functions called on state entry - */ - -void -gr_oscope_guts::enter_hold_off () -{ - d_state = HOLD_OFF; - d_hold_off_count = d_hold_off_count_init; -} - -void -gr_oscope_guts::enter_look_for_trigger () -{ - d_pre_trigger_count = 0; - d_state = LOOK_FOR_TRIGGER; -} - -void -gr_oscope_guts::enter_post_trigger () -{ - d_state = POST_TRIGGER; - d_post_trigger_count = d_post_trigger_count_init; - //ensure that the trigger offset is no more than than half a sample - if (d_trigger_off > .5) d_trigger_off -= 1; - else d_post_trigger_count--; -} - -// ---------------------------------------------------------------- -// returns true if trigger found - -bool -gr_oscope_guts::found_trigger () -{ - int mx = d_trigger_mode == gr_TRIG_MODE_STRIPCHART ? OUTPUT_RECORD_SIZE*SCHART_MULT : - OUTPUT_RECORD_SIZE; - - float prev_sample = d_buffer[d_trigger_channel][decr_bi(d_obi, mx)]; - float new_sample = d_buffer[d_trigger_channel][d_obi]; - - switch (d_trigger_mode){ - - case gr_TRIG_MODE_AUTO: //too many samples without a trigger - d_pre_trigger_count++; - if (d_pre_trigger_count > OUTPUT_RECORD_SIZE/2) return true; - - case gr_TRIG_MODE_NORM: //look for trigger - switch (d_trigger_slope){ - - case gr_TRIG_SLOPE_POS: //trigger point in pos slope? - if (new_sample < d_trigger_level || prev_sample >= d_trigger_level) return false; - break; - - case gr_TRIG_SLOPE_NEG: //trigger point in neg slope? - if (new_sample > d_trigger_level || prev_sample <= d_trigger_level) return false; - break; - } - - //calculate the trigger offset in % sample - d_trigger_off = (d_trigger_level - prev_sample)/(new_sample - prev_sample); - return true; - - case gr_TRIG_MODE_FREE: //free run mode, always trigger - d_trigger_off = 0; - return true; - - default: - assert (0); - return false; - } -} - -// ---------------------------------------------------------------- -// write output records (duh!) - -void -gr_oscope_guts::write_output_records () -{ - int mx; - - mx = d_trigger_mode == gr_TRIG_MODE_STRIPCHART ? - OUTPUT_RECORD_SIZE*SCHART_MULT : OUTPUT_RECORD_SIZE; - - // if the output queue if full, drop the data like its hot. - if (d_msgq->full_p()) - return; - // Build a message to hold the output records - gr_message_sptr msg = - gr_make_message(0, // msg type - d_nchannels, // arg1 for other side - mx, // arg2 for other side - ((d_nchannels * mx) + 1) * sizeof(float)); // sizeof payload - - float *out = (float *)msg->msg(); // get pointer to raw message buffer - - for (int ch = 0; ch < d_nchannels; ch++){ - // note that d_obi + 1 points at the oldest sample in the buffer - for (int i = 0; i < mx; i++){ - out[i] = d_buffer[ch][wrap_bi(d_obi + 1 + i, mx)]; - } - out += mx; - } - //Set the last sample as the trigger offset: - // The non gl scope sink will not look at this last sample. - // The gl scope sink will use this last sample as an offset. - out[0] = d_trigger_off; - d_msgq->handle(msg); // send the msg -} - -// ---------------------------------------------------------------- - -bool -gr_oscope_guts::set_update_rate (double update_rate) -{ - d_update_rate = std::min (std::max (1./10., update_rate), d_sample_rate); - update_rate_or_decimation_changed (); - return true; -} - -bool -gr_oscope_guts::set_decimation_count (int decimator_count) -{ - decimator_count = std::max (1, decimator_count); - d_decimator_count_init = decimator_count; - update_rate_or_decimation_changed (); - return true; -} - -bool -gr_oscope_guts::set_sample_rate(double sample_rate) -{ - d_sample_rate = sample_rate; - return set_update_rate(update_rate()); -} - - -void -gr_oscope_guts::update_rate_or_decimation_changed () -{ - d_hold_off_count_init = - (int) rint (d_sample_rate / d_update_rate / d_decimator_count_init); -} - -bool -gr_oscope_guts::set_trigger_channel (int channel) -{ - if (channel >= 0 && channel < d_nchannels){ - d_trigger_channel = channel; - trigger_changed (); - return true; - } - - return false; -} - -bool -gr_oscope_guts::set_trigger_mode (gr_trigger_mode mode) -{ - d_trigger_mode = mode; - trigger_changed (); - return true; -} - -bool -gr_oscope_guts::set_trigger_slope (gr_trigger_slope slope) -{ - d_trigger_slope = slope; - trigger_changed (); - return true; -} - -bool -gr_oscope_guts::set_trigger_level (double trigger_level) -{ - d_trigger_level = trigger_level; - trigger_changed (); - return true; -} - -bool -gr_oscope_guts::set_trigger_level_auto () -{ - // find the level 1/2 way between the min and the max - - float min_v = d_buffer[d_trigger_channel][0]; - float max_v = d_buffer[d_trigger_channel][0]; - - for (int i = 1; i < OUTPUT_RECORD_SIZE; i++){ - min_v = std::min (min_v, d_buffer[d_trigger_channel][i]); - max_v = std::max (max_v, d_buffer[d_trigger_channel][i]); - } - return set_trigger_level((min_v + max_v) * 0.5); -} - -bool -gr_oscope_guts::set_num_channels(int nchannels) -{ - if (nchannels > 0 && nchannels <= MAX_CHANNELS){ - d_nchannels = nchannels; - return true; - } - return false; -} - - -void -gr_oscope_guts::trigger_changed () -{ - enter_look_for_trigger (); -} - -// ACCESSORS - -int -gr_oscope_guts::num_channels () const -{ - return d_nchannels; -} - -double -gr_oscope_guts::sample_rate () const -{ - return d_sample_rate; -} - -double -gr_oscope_guts::update_rate () const -{ - return d_update_rate; -} - -int -gr_oscope_guts::get_decimation_count () const -{ - return d_decimator_count_init; -} - -int -gr_oscope_guts::get_trigger_channel () const -{ - return d_trigger_channel; -} - -gr_trigger_mode -gr_oscope_guts::get_trigger_mode () const -{ - return d_trigger_mode; -} - -gr_trigger_slope -gr_oscope_guts::get_trigger_slope () const -{ - return d_trigger_slope; -} - -double -gr_oscope_guts::get_trigger_level () const -{ - return d_trigger_level; -} - -int -gr_oscope_guts::get_samples_per_output_record () const -{ - int mx; - - mx = OUTPUT_RECORD_SIZE; - if (d_trigger_mode == gr_TRIG_MODE_STRIPCHART) - { - mx = OUTPUT_RECORD_SIZE*SCHART_MULT; - } - return mx; -} diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.h b/gnuradio-core/src/lib/io/gr_oscope_guts.h deleted file mode 100644 index bc9513c7e7..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_guts.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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. - */ - - -#ifndef INCLUDED_GR_OSCOPE_GUTS_H -#define INCLUDED_GR_OSCOPE_GUTS_H - -#include <gr_core_api.h> -#include <gr_trigger_mode.h> -#include <gr_msg_queue.h> - -/*! - * \brief guts of oscilloscope trigger and buffer module - * - * This module processes sets of samples provided the \p process_sample - * method. When appropriate given the updateRate, sampleRate and - * trigger conditions, process_sample will periodically write output - * records of captured data to output_fd. For each trigger event, - * nchannels records will be written. Each record consists of - * get_samples_per_output_record binary floats. The trigger instant - * occurs at the 1/2 way point in the buffer. Thus, output records - * consist of 50% pre-trigger data and 50% post-trigger data. - */ - -class GR_CORE_API gr_oscope_guts { -public: - static const int MAX_CHANNELS = 8; -private: - enum scope_state { HOLD_OFF, LOOK_FOR_TRIGGER, POST_TRIGGER }; - - int d_nchannels; // how many channels - gr_msg_queue_sptr d_msgq; // message queue we stuff output records into - gr_trigger_mode d_trigger_mode; - gr_trigger_slope d_trigger_slope; - int d_trigger_channel; // which channel to watch for trigger condition - double d_sample_rate; // input sample rate in Hz - double d_update_rate; // approx freq to produce an output record (Hz) - double d_trigger_level; - - int d_obi; // output buffer index - float *d_buffer[MAX_CHANNELS]; - - scope_state d_state; - int d_decimator_count; - int d_decimator_count_init; - int d_hold_off_count; - int d_hold_off_count_init; - int d_pre_trigger_count; - int d_post_trigger_count; - int d_post_trigger_count_init; - float d_trigger_off; //%sample trigger is off - - // NOT IMPLEMENTED - gr_oscope_guts (const gr_oscope_guts &rhs); // no copy constructor - gr_oscope_guts &operator= (const gr_oscope_guts &rhs); // no assignment operator - - void trigger_changed (); - void update_rate_or_decimation_changed (); - bool found_trigger (); // returns true if found - void write_output_records (); - - void enter_hold_off (); // called on state entry - void enter_look_for_trigger (); - void enter_post_trigger (); - -public: - // CREATORS - gr_oscope_guts (double sample_rate, gr_msg_queue_sptr msgq); - ~gr_oscope_guts (); - - // MANIPULATORS - - /*! - * \p channel_data points to nchannels float values. These are the values - * for each channel at this sample time. - */ - void process_sample (const float *channel_data); - - bool set_update_rate (double update_rate); - bool set_decimation_count (int decimation_count); - bool set_trigger_channel (int channel); - bool set_trigger_mode (gr_trigger_mode mode); - bool set_trigger_slope (gr_trigger_slope slope); - bool set_trigger_level (double trigger_level); - bool set_trigger_level_auto (); // set to 50% level - bool set_sample_rate(double sample_rate); - bool set_num_channels(int nchannels); - - - // ACCESSORS - int num_channels () const; - double sample_rate () const; - double update_rate () const; - int get_decimation_count () const; - int get_trigger_channel () const; - gr_trigger_mode get_trigger_mode () const; - gr_trigger_slope get_trigger_slope () const; - double get_trigger_level () const; - - // # of samples written to each output record. - int get_samples_per_output_record () const; -}; - -#endif /* INCLUDED_GR_OSCOPE_GUTS_H */ diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink.i b/gnuradio-core/src/lib/io/gr_oscope_sink.i deleted file mode 100644 index 3d7072ed45..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink.i +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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 gr_trigger_mode.h - -// GR_SWIG_BLOCK_MAGIC(gr,oscope_sink_x) - -%ignore gr_oscope_sink_x; -class gr_oscope_sink_x : public gr_sync_block -{ - protected: - gr_oscope_sink_x (const std::string name, - gr_io_signature_sptr input_sig, - double sample_rate); - - public: - ~gr_oscope_sink_x (); - - bool set_update_rate (double update_rate); - bool set_decimation_count (int decimation_count); - bool set_trigger_channel (int channel); - bool set_trigger_mode (gr_trigger_mode mode); - bool set_trigger_slope (gr_trigger_slope slope); - bool set_trigger_level (double trigger_level); - bool set_trigger_level_auto (); // set to 50% level - bool set_sample_rate(double sample_rate); - - // ACCESSORS - int num_channels () const; - double sample_rate () const; - double update_rate () const; - int get_decimation_count () const; - int get_trigger_channel () const; - gr_trigger_mode get_trigger_mode () const; - gr_trigger_slope get_trigger_slope () const; - double get_trigger_level () const; - - // # of samples written to each output record. - int get_samples_per_output_record () const; -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(gr,oscope_sink_f) - -gr_oscope_sink_f_sptr -gr_make_oscope_sink_f (double sample_rate, gr_msg_queue_sptr msgq); - -class gr_oscope_sink_f : public gr_oscope_sink_x -{ -private: - gr_oscope_sink_f (double sample_rate, gr_msg_queue_sptr msgq); - -public: - ~gr_oscope_sink_f (); -}; - -// ---------------------------------------------------------------- diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc b/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc deleted file mode 100644 index 493a25e81e..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004,2005,2010 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_oscope_sink_f.h> -#include <gr_io_signature.h> -#include <gr_oscope_guts.h> - - -gr_oscope_sink_f_sptr -gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq) -{ - return gnuradio::get_initial_sptr(new gr_oscope_sink_f (sampling_rate, msgq)); -} - - -gr_oscope_sink_f::gr_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq) - : gr_oscope_sink_x ("oscope_sink_f", - gr_make_io_signature (1, gr_oscope_guts::MAX_CHANNELS, sizeof (float)), - sampling_rate), - d_msgq(msgq) -{ - d_guts = new gr_oscope_guts (d_sampling_rate, d_msgq); -} - - -bool -gr_oscope_sink_f::check_topology (int ninputs, int noutputs) -{ - return d_guts->set_num_channels(ninputs); -} - - -gr_oscope_sink_f::~gr_oscope_sink_f () -{ -} - -int -gr_oscope_sink_f::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int ni = input_items.size (); - float tmp[gr_oscope_guts::MAX_CHANNELS]; - - for (int i = 0; i < noutput_items; i++){ - - // FIXME for now, copy the data. Fix later if reqd - for (int ch = 0; ch < ni; ch++) - tmp[ch] = ((const float *) input_items[ch])[i]; - - d_guts->process_sample (tmp); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_f.h b/gnuradio-core/src/lib/io/gr_oscope_sink_f.h deleted file mode 100644 index 8d434d2bc4..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_f.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004,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. - */ - -#ifndef INCLUDED_GR_OSCOPE_SINK_F_H -#define INCLUDED_GR_OSCOPE_SINK_F_H - -#include <gr_core_api.h> -#include <gr_oscope_sink_x.h> -#include <gr_msg_queue.h> - -class gr_oscope_sink_f; -typedef boost::shared_ptr<gr_oscope_sink_x> gr_oscope_sink_f_sptr; - -GR_CORE_API gr_oscope_sink_f_sptr gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); - - -/*! - * \brief Building block for python oscilloscope module. - * \ingroup sink_blk - * - * Accepts multiple float streams. - */ -class GR_CORE_API gr_oscope_sink_f : public gr_oscope_sink_x -{ -private: - friend GR_CORE_API gr_oscope_sink_f_sptr - gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); - - gr_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); - - gr_msg_queue_sptr d_msgq; - - public: - ~gr_oscope_sink_f (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool check_topology (int ninputs, int noutputs); -}; - -#endif /* INCLUDED_GR_OSCOPE_SINK_F_H */ - diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc b/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc deleted file mode 100644 index 9580dbf6a3..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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 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_oscope_sink_x.h> -#include <gr_io_signature.h> -#include <gr_oscope_guts.h> - - -gr_oscope_sink_x::gr_oscope_sink_x (const std::string name, - gr_io_signature_sptr input_sig, - double sampling_rate) - : gr_sync_block (name, input_sig, gr_make_io_signature (0, 0, 0)), - d_sampling_rate (sampling_rate), d_guts (0) -{ -} - -gr_oscope_sink_x::~gr_oscope_sink_x () -{ - delete d_guts; -} - -// ---------------------------------------------------------------- - -bool -gr_oscope_sink_x::set_update_rate (double update_rate) -{ - return d_guts->set_update_rate (update_rate); -} - -bool -gr_oscope_sink_x::set_decimation_count (int decimation_count) -{ - return d_guts->set_decimation_count (decimation_count); -} - -bool -gr_oscope_sink_x::set_trigger_channel (int channel) -{ - return d_guts->set_trigger_channel (channel); -} - -bool -gr_oscope_sink_x::set_trigger_mode (gr_trigger_mode mode) -{ - return d_guts->set_trigger_mode (mode); -} - -bool -gr_oscope_sink_x::set_trigger_slope (gr_trigger_slope slope) -{ - return d_guts->set_trigger_slope (slope); -} - -bool -gr_oscope_sink_x::set_trigger_level (double trigger_level) -{ - return d_guts->set_trigger_level (trigger_level); -} - - -bool -gr_oscope_sink_x::set_trigger_level_auto () -{ - return d_guts->set_trigger_level_auto (); -} - -bool -gr_oscope_sink_x::set_sample_rate (double sample_rate) -{ - return d_guts->set_sample_rate (sample_rate); -} - -bool -gr_oscope_sink_x::set_num_channels (int nchannels) -{ - return d_guts->set_num_channels (nchannels); -} - -// ACCESSORS - -int -gr_oscope_sink_x::num_channels () const -{ - return d_guts->num_channels (); -} - -double -gr_oscope_sink_x::sample_rate () const -{ - return d_guts->sample_rate (); -} - -double -gr_oscope_sink_x::update_rate () const -{ - return d_guts->update_rate (); -} - -int -gr_oscope_sink_x::get_decimation_count () const -{ - return d_guts->get_decimation_count (); -} - -int -gr_oscope_sink_x::get_trigger_channel () const -{ - return d_guts->get_trigger_channel (); -} - -gr_trigger_mode -gr_oscope_sink_x::get_trigger_mode () const -{ - return d_guts->get_trigger_mode (); -} - -gr_trigger_slope -gr_oscope_sink_x::get_trigger_slope () const -{ - return d_guts->get_trigger_slope (); -} - -double -gr_oscope_sink_x::get_trigger_level () const -{ - return d_guts->get_trigger_level (); -} - -int -gr_oscope_sink_x::get_samples_per_output_record () const -{ - return d_guts->get_samples_per_output_record (); -} diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_x.h b/gnuradio-core/src/lib/io/gr_oscope_sink_x.h deleted file mode 100644 index 153d0937ab..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_x.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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 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_OSCOPE_SINK_X_H -#define INCLUDED_GR_OSCOPE_SINK_X_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_trigger_mode.h> - -class gr_oscope_guts; - -/*! - * \brief Abstract class for python oscilloscope module. - * \ingroup sink_blk - * - * Don't instantiate this. Use gr_oscope_sink_f or gr_oscope_sink_c instead. - */ -class GR_CORE_API gr_oscope_sink_x : public gr_sync_block -{ -protected: - double d_sampling_rate; - gr_oscope_guts *d_guts; - - gr_oscope_sink_x (const std::string name, - gr_io_signature_sptr input_sig, - double sampling_rate); - -public: - ~gr_oscope_sink_x (); - - bool set_update_rate (double update_rate); - bool set_decimation_count (int decimation_count); - bool set_trigger_channel (int channel); - bool set_trigger_mode (gr_trigger_mode mode); - bool set_trigger_slope (gr_trigger_slope slope); - bool set_trigger_level (double trigger_level); - bool set_trigger_level_auto (); // set to 50% level - bool set_sample_rate(double sample_rate); - bool set_num_channels (int nchannels); - - - // ACCESSORS - int num_channels () const; - double sample_rate () const; - double update_rate () const; - int get_decimation_count () const; - int get_trigger_channel () const; - gr_trigger_mode get_trigger_mode () const; - gr_trigger_slope get_trigger_slope () const; - double get_trigger_level () const; - - // # of samples written to each output record. - int get_samples_per_output_record () const; - -}; - -#endif /* INCLUDED_GR_OSCOPE_SINK_X_H */ diff --git a/gnuradio-core/src/lib/io/gr_trigger_mode.h b/gnuradio-core/src/lib/io/gr_trigger_mode.h deleted file mode 100644 index be131686b4..0000000000 --- a/gnuradio-core/src/lib/io/gr_trigger_mode.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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 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_TRIGGER_MODE_H -#define INCLUDED_GR_TRIGGER_MODE_H - -enum gr_trigger_mode { - gr_TRIG_MODE_FREE, - gr_TRIG_MODE_AUTO, - gr_TRIG_MODE_NORM, - gr_TRIG_MODE_STRIPCHART, -}; - -enum gr_trigger_slope { - gr_TRIG_SLOPE_POS, - gr_TRIG_SLOPE_NEG, -}; - -#endif /* INCLUDED_GR_TRIGGER_MODE_H */ diff --git a/gnuradio-core/src/lib/io/i2c.cc b/gnuradio-core/src/lib/io/i2c.cc deleted file mode 100644 index 02dd47b53e..0000000000 --- a/gnuradio-core/src/lib/io/i2c.cc +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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 "i2c.h" - -i2c::~i2c () -{ - // NOP -} diff --git a/gnuradio-core/src/lib/io/i2c.h b/gnuradio-core/src/lib/io/i2c.h deleted file mode 100644 index 6b7f25a293..0000000000 --- a/gnuradio-core/src/lib/io/i2c.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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_I2C_H -#define INCLUDED_I2C_H - -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> - -class i2c; -typedef boost::shared_ptr<i2c> i2c_sptr; - -/*! - * \brief abstract class for controlling i2c bus - */ -class GR_CORE_API i2c { - public: - - i2c () {} - virtual ~i2c (); - - //! \returns true iff successful - virtual bool write (int addr, const unsigned char *buf, int nbytes) = 0; - - //! \returns number of bytes read or -1 if error - virtual int read (int addr, unsigned char *buf, int max_bytes) = 0; -}; - -#endif /* INCLUDED_I2C_H */ - diff --git a/gnuradio-core/src/lib/io/i2c_bbio.cc b/gnuradio-core/src/lib/io/i2c_bbio.cc deleted file mode 100644 index ddd00290d0..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bbio.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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 "i2c_bbio.h" - -i2c_bbio::~i2c_bbio () -{ - // NOP -} - diff --git a/gnuradio-core/src/lib/io/i2c_bbio.h b/gnuradio-core/src/lib/io/i2c_bbio.h deleted file mode 100644 index 6bf47b9cd0..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bbio.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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_I2C_BBIO_H -#define INCLUDED_I2C_BBIO_H - -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> - -class i2c_bbio; -typedef boost::shared_ptr<i2c_bbio> i2c_bbio_sptr; - - -/*! - * \brief abstract class that implements bit banging i/o for i2c bus. - * \ingroup base - */ -class GR_CORE_API i2c_bbio { - public: - - i2c_bbio () {} - virtual ~i2c_bbio (); - - virtual void set_scl (bool state) = 0; - virtual void set_sda (bool state) = 0; - virtual bool get_sda () = 0; - - virtual void lock () = 0; - virtual void unlock () = 0; -}; - -#endif /* INCLUDED_I2C_BBIO_H */ diff --git a/gnuradio-core/src/lib/io/i2c_bbio_pp.cc b/gnuradio-core/src/lib/io/i2c_bbio_pp.cc deleted file mode 100644 index 382bb6b378..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bbio_pp.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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 "i2c_bbio_pp.h" -#include "microtune_eval_board_defs.h" - -i2c_bbio_pp::i2c_bbio_pp (ppio_sptr pp) -{ - d_pp = pp; - d_pp->lock (); - d_pp->write_control (d_pp->read_control () & ~UT_CP_MUST_BE_ZERO); // output, no interrupts - d_pp->unlock (); -} - -i2c_bbio_sptr -make_i2c_bbio_pp (ppio_sptr pp) -{ - return i2c_bbio_sptr (new i2c_bbio_pp (pp)); -} - -void -i2c_bbio_pp::set_scl (bool state) -{ - int r = d_pp->read_control(); - - if (!state){ // active low - d_pp->write_control (r | UT_CP_TUNER_SCL); - } - else { - d_pp->write_control (r & ~UT_CP_TUNER_SCL); - } - d_pp->read_control (); // use for 1us delay - d_pp->read_control (); // use for 1us delay -} - -void -i2c_bbio_pp::set_sda (bool state) -{ - int r = d_pp->read_data (); - - if (!state){ // active low - d_pp->write_data (r | UT_DP_TUNER_SDA_OUT); - } - else { - d_pp->write_data (r & ~UT_DP_TUNER_SDA_OUT); - } - d_pp->read_data (); // use for 1us delay - d_pp->read_data (); // use for 1us delay -} - -bool -i2c_bbio_pp::get_sda () -{ - int r = d_pp->read_status (); - return (r & UT_SP_TUNER_SDA_IN) == 0; // eval board has an inverter on it -} - -void -i2c_bbio_pp::lock () -{ - d_pp->lock (); -} - -void -i2c_bbio_pp::unlock () -{ - d_pp->unlock (); -} diff --git a/gnuradio-core/src/lib/io/i2c_bbio_pp.h b/gnuradio-core/src/lib/io/i2c_bbio_pp.h deleted file mode 100644 index 2391bc1fc0..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bbio_pp.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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_I2C_BBIO_PP_H -#define INCLUDED_I2C_BBIO_PP_H - -#include <gr_core_api.h> -#include "i2c_bbio.h" -#include "ppio.h" - -/*! - * \brief concrete class that bit bangs eval board i2c bus using parallel port - * - * \ingroup base - * This class talks to the i2c bus on the microtune eval board using - * the parallel port. This works for both the 4937 and 4702 boards. - */ -class GR_CORE_API i2c_bbio_pp : public i2c_bbio { - friend GR_CORE_API i2c_bbio_sptr make_i2c_bbio_pp (ppio_sptr pp); - i2c_bbio_pp (ppio_sptr pp); - - public: - - virtual void set_scl (bool state); - virtual void set_sda (bool state); - virtual bool get_sda (); - - virtual void lock (); - virtual void unlock (); - - private: - ppio_sptr d_pp; -}; - -GR_CORE_API i2c_bbio_sptr make_i2c_bbio_pp (ppio_sptr pp); - - -#endif /* INCLUDED_I2C_BBIO_PP_H */ diff --git a/gnuradio-core/src/lib/io/i2c_bitbang.cc b/gnuradio-core/src/lib/io/i2c_bitbang.cc deleted file mode 100644 index eb801c68f5..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bitbang.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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 "i2c_bitbang.h" - -i2c_bitbang::i2c_bitbang (i2c_bbio_sptr io) -{ - d_io = io; - d_io->lock (); - - stop (); // get bus in known state - - d_io->unlock (); -} - -i2c_sptr -make_i2c_bitbang (i2c_bbio_sptr io) -{ - return i2c_sptr (new i2c_bitbang (io)); -} - - -// start: -// entry: SCL = 1, SDA = 1 -// exit: SCL = 0, SDA = 0 - -void -i2c_bitbang::start () -{ - set_sda (1); - set_scl (1); - set_sda (0); // SDA high -> low while SCL high - set_scl (0); -} - - -// stop: -// entry: SCL = X, SDA = X -// exit: SCL = 1, SDA = 1 - -void -i2c_bitbang::stop () -{ - set_scl (0); - set_sda (0); - set_scl (1); - set_sda (1); // SDA low -> high while SCL high -} - - -// write_bit: -// entry: SCL = 0, SDA = X -// exit: SCL = 0, SDA = X - -void -i2c_bitbang::write_bit (bool bit) -{ - set_sda (bit); - set_scl (1); - set_scl (0); -} - - -// write_byte: -// entry: SCL = 0, SDA = X -// exit: SCL = 0, SDA = 1 - -bool -i2c_bitbang::write_byte (char t) -{ - int i; - bool ack_bit; - - for (i = 0; i < 8; i++){ - write_bit (t & 0x80); - t <<= 1; - } - - // clock #9. This is the ACK bit. - - set_sda (1); // tristate SDA - set_scl (1); - ack_bit = get_sda (); // slave should pull SDA line low - set_scl (0); - - return ack_bit == 0; -} - - -// write: the high level entry point... -// entry: SCL = 1, SDA = 1 -// exit: SCL = 1, SDA = 1 - -bool -i2c_bitbang::write (int addr, const unsigned char *buf, int nbytes) -{ - bool ok = true; - - d_io->lock (); - start (); - ok = write_byte ((addr << 1) | 0); // addr plus "read opcode" - - for (int i = 0; i < nbytes; i++) - ok &= write_byte (buf[i]); - - stop (); - d_io->unlock (); - return ok; -} - - -// read: the high level entry point... -// entry: SCL = 1, SDA = 1 -// exit: SCL = 1, SDA = 1 - -int -i2c_bitbang::read (int addr, unsigned char *buf, int max_bytes) -{ - d_io->lock (); - - // FIXME - - d_io->unlock (); - return -1; -} diff --git a/gnuradio-core/src/lib/io/i2c_bitbang.h b/gnuradio-core/src/lib/io/i2c_bitbang.h deleted file mode 100644 index 1d6fe5044e..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bitbang.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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_I2C_BITBANG_H -#define INCLUDED_I2C_BITBANG_H - -#include <gr_core_api.h> -#include <i2c.h> -#include <i2c_bbio.h> - -/*! - * \brief class for controlling i2c bus - * \ingroup base - */ -class GR_CORE_API i2c_bitbang : public i2c { - friend GR_CORE_API i2c_sptr make_i2c_bitbang (i2c_bbio_sptr io); - i2c_bitbang (i2c_bbio_sptr io); - - public: - ~i2c_bitbang () {} - - //! \returns true iff successful - bool write (int addr, const unsigned char *buf, int nbytes); - - //! \returns number of bytes read or -1 if error - int read (int addr, unsigned char *buf, int max_bytes); - - -private: - void start (); - void stop (); - void write_bit (bool bit); - bool write_byte (char byte); - - void set_sda (bool bit) { d_io->set_sda (bit); } - void set_scl (bool bit) { d_io->set_scl (bit); } - bool get_sda () { return d_io->get_sda (); } - - i2c_bbio_sptr d_io; -}; - -GR_CORE_API i2c_sptr make_i2c_bitbang (i2c_bbio_sptr io); - -#endif /* INCLUDED_I2C_BITBANG_H */ - - diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i deleted file mode 100644 index 6cd3e06f47..0000000000 --- a/gnuradio-core/src/lib/io/io.i +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -%{ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_histo_sink_f.h> -#include <microtune_4702_eval_board.h> -#include <microtune_4937_eval_board.h> -#include <sdr_1000.h> -#include <gr_oscope_sink_x.h> -#include <gr_oscope_sink_f.h> -#include <ppio.h> -%} - -%include "gr_histo_sink.i" -%include "microtune_xxxx_eval_board.i" -%include "microtune_4702_eval_board.i" -%include "microtune_4937_eval_board.i" -%include "sdr_1000.i" -%include "gr_oscope_sink.i" -%include "ppio.i" - - diff --git a/gnuradio-core/src/lib/io/microtune_4702.cc b/gnuradio-core/src/lib/io/microtune_4702.cc deleted file mode 100644 index 3ec072d51b..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4702.cc +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- c++-*- */ -/* - * Copyright 2001,2003,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 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 "microtune_4702.h" -#include <stdlib.h> -#include <stdio.h> -#include "i2c.h" - -static const double FIRST_IF = 36.00e6; - -// The tuner internally has 3 bands: VHF Low, VHF High & UHF. -// These are the recommened boundaries -static const double VHF_High_takeover = 174e6; -static const double UHF_takeover = 470e6; - -static int PLL_I2C_ADDR = 0x60; - -static unsigned char -control_byte_1 (bool prescaler, int reference_divisor) -{ - int c = 0x80; - //Note: Last two divider bits (bits 2 and 3 of this byte) determined later - if (prescaler) - c |= 0x10; - - switch (reference_divisor){ - case 2: - c |= 0x00; break; - case 4: - c |= 0x01; break; - case 8: - c |= 0x02; break; - case 16: - c |= 0x03; break; - case 32: - c |= 0x04; break; - case 64: - c |= 0x05; break; - case 128: - c |= 0x06; break; - case 256: - c |= 0x07; break; - case 24: - c |= 0x08; break; - case 5: - c |= 0x09; break; - case 10: - c |= 0x0A; break; - case 20: - c |= 0x0B; break; - case 40: - c |= 0x0C; break; - case 80: - c |= 0x0D; break; - case 160: - c |= 0x0E; break; - case 320: - c |= 0x0F; break; - default: - abort (); - } - return c; -} - -static unsigned char -control_byte_2 (double target_freq) -{ - int c; - - if (target_freq < VHF_High_takeover) // VHF low - c = 0x8E; - - else if (target_freq < UHF_takeover){ // VHF high - c = 0x05; - if (target_freq < 390e6) - c |= 0x40; - else - c |= 0x80; - } - else { // UHF - c = 0x03; - if (target_freq < 750e6) - c |= 0x80; - else - c |= 0xC0; - } - - return c; -} - - -microtune_4702::microtune_4702 (i2c_sptr i2c, int i2c_addr) -{ - d_i2c = i2c; - d_i2c_addr = i2c_addr; - d_reference_divider = 320; - d_prescaler = false; -} - -microtune_4702::~microtune_4702 () -{ - // nop -} - -/*! - * \brief select RF frequency to be tuned to output frequency. - * \p target_freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ -bool -microtune_4702::set_RF_freq (double target_freq, double *p_actual_freq) -{ - unsigned char buf[4]; - - double target_f_osc = target_freq + FIRST_IF; - - double f_ref = 4e6 / d_reference_divider; - - //int divisor = (int) ((target_f_osc + (f_ref * 4)) / (f_ref * 8)); - - long int divisor = (long int) (target_f_osc / f_ref); - double actual_freq = (f_ref * divisor) - FIRST_IF; - if (p_actual_freq != 0) - *p_actual_freq = actual_freq; - - if ((divisor & ~0x1ffff) != 0) // >17 bit divisor - return false; - - buf[0] = ((divisor & 0x07f00) >> 8) & 0xff; // DB1 - buf[1] = divisor & 0xff; // DB2 - buf[2] = control_byte_1 (d_prescaler, d_reference_divider); - buf[2] = buf[2] | (((divisor & 0x18000) >> 10) & 0xff); - buf[3] = control_byte_2 (target_freq); - - printf ("%x\n", PLL_I2C_ADDR); -//#if 0 - printf ("set_RF_freq: target: %g MHz actual: %g MHz %02x %02x %02x %02x\n", - target_freq/1e6, actual_freq/1e6, buf[0], buf[1], buf[2], buf[3]); -//#endif - - return d_i2c->write (d_i2c_addr, buf, sizeof (buf)); -} - -/*! - * \returns true iff PLL is locked - */ -bool -microtune_4702::pll_locked_p () -{ - // FIXME - return true; -} - -/*! - * \returns the output frequency of the tuner in Hz. - */ -double -microtune_4702::get_output_freq () -{ - return FIRST_IF; -} diff --git a/gnuradio-core/src/lib/io/microtune_4702.h b/gnuradio-core/src/lib/io/microtune_4702.h deleted file mode 100644 index ccc66db71e..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4702.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2003 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_MICROTUNE_4702_H -#define INCLUDED_MICROTUNE_4702_H - -#include <gr_core_api.h> -#include <microtune_xxxx.h> - -/*! - * \brief class for controlling microtune 4702 tuner module - * \ingroup hardware - */ - -class GR_CORE_API microtune_4702 : public microtune_xxxx { -public: - microtune_4702 (i2c_sptr i2c, int i2c_addr); - - virtual ~microtune_4702 (); - - /*! - * \brief select RF frequency to be tuned to output frequency. - * \p freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ - bool set_RF_freq (double freq, double *actual_freq); - - /*! - * \returns true iff PLL is locked - */ - bool pll_locked_p (); - - /*! - * \returns the output frequency of the tuner in Hz. - */ - double get_output_freq (); - - private: - - i2c_sptr d_i2c; - int d_i2c_addr; - int d_reference_divider; - bool d_prescaler; /* if set, higher charge pump current: - faster tuning, worse phase noise - for distance < 10kHz to the carrier */ -}; - -#endif /* INCLUDED_MICROTUNE_4702_H */ - diff --git a/gnuradio-core/src/lib/io/microtune_4702_eval_board.cc b/gnuradio-core/src/lib/io/microtune_4702_eval_board.cc deleted file mode 100644 index f6c68726b5..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4702_eval_board.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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 "microtune_4702_eval_board.h" -#include "microtune_eval_board_defs.h" -#include "ppio.h" -#include "microtune_4702.h" - -static const int TUNER_I2C_ADDR = 0x60; - -microtune_4702_eval_board::microtune_4702_eval_board (int which_pp) - : microtune_xxxx_eval_board (which_pp) -{ - d_tuner = new microtune_4702 (d_i2c, TUNER_I2C_ADDR); -} - -microtune_4702_eval_board::~microtune_4702_eval_board () -{ - // default is OK -} - -static const float RF_MIN_V = 1.0; // RF AGC control voltages -static const float RF_MAX_V = 4.0; -static const float IF_MIN_V = 2.0; // IF AGC control voltages -static const float IF_MAX_V = 4.0; - -static const float MIN_AGC = 0; // bottom of synthetic range -static const float MAX_AGC = 1000; // top of synthetic range - -static const float CUTOVER_POINT = 667; - - -// linear is in the range MIN_AGC to MAX_AGC - -static float -linear_to_RF_AGC_voltage (float linear) -{ - if (linear >= CUTOVER_POINT) - return RF_MAX_V; - - float slope = (RF_MAX_V - RF_MIN_V) / CUTOVER_POINT; - return RF_MIN_V + linear * slope; -} - -static float -linear_to_IF_AGC_voltage (float linear) -{ - if (linear < CUTOVER_POINT) - return IF_MIN_V; - - float slope = (IF_MAX_V - IF_MIN_V) / (MAX_AGC - CUTOVER_POINT); - return IF_MIN_V + (linear - CUTOVER_POINT) * slope; -} - -void -microtune_4702_eval_board::set_AGC (float v) -{ - if (v < MIN_AGC) - v = MIN_AGC; - - if (v > MAX_AGC) - v = MAX_AGC; - - float rf_agc_voltage = linear_to_RF_AGC_voltage (v); - float if_agc_voltage = linear_to_IF_AGC_voltage (v); - - set_RF_AGC_voltage (rf_agc_voltage); - set_IF_AGC_voltage (if_agc_voltage); -} diff --git a/gnuradio-core/src/lib/io/microtune_4702_eval_board.h b/gnuradio-core/src/lib/io/microtune_4702_eval_board.h deleted file mode 100644 index d866a4b943..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4702_eval_board.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2001,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 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_MICROTUNE_4702_EVAL_BOARD_H -#define INCLUDED_MICROTUNE_4702_EVAL_BOARD_H - -#include <gr_core_api.h> -#include "microtune_xxxx_eval_board.h" - -/*! - * \brief control microtune 4702 eval board - * \ingroup hardware - */ - -class GR_CORE_API microtune_4702_eval_board : public microtune_xxxx_eval_board { -public: - microtune_4702_eval_board (int which_pp = 0); - ~microtune_4702_eval_board (); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000); -}; - -#endif /* INCLUDED_MICROTUNE_4702_EVAL_BOARD_H */ diff --git a/gnuradio-core/src/lib/io/microtune_4702_eval_board.i b/gnuradio-core/src/lib/io/microtune_4702_eval_board.i deleted file mode 100644 index fc085a9756..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4702_eval_board.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2001,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 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. - */ - -class microtune_4702_eval_board : public microtune_xxxx_eval_board { -public: - microtune_4702_eval_board (int which_pp = 0); - ~microtune_4702_eval_board (); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000); -}; diff --git a/gnuradio-core/src/lib/io/microtune_4937.cc b/gnuradio-core/src/lib/io/microtune_4937.cc deleted file mode 100644 index 72ddd4bb62..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4937.cc +++ /dev/null @@ -1,146 +0,0 @@ -/* -*- c++-*- */ -/* - * Copyright 2001,2003 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 "microtune_4937.h" -#include <stdlib.h> -#include <stdio.h> -#include <i2c.h> - -static const double first_IF = 43.75e6; - -// The tuner internally has 3 bands: VHF Low, VHF High & UHF. -// These are the recommened boundaries -static const double VHF_High_takeover = 158e6; -static const double UHF_takeover = 464e6; - - -static unsigned char -control_byte_1 (bool fast_tuning_p, int reference_divisor) -{ - int c = 0x88; - - if (fast_tuning_p) - c |= 0x40; - - switch (reference_divisor){ - case 512: - c |= 0x3 << 1; break; - case 640: - c |= 0x0 << 1; break; - case 1024: - c |= 0x1 << 1; break; - default: - abort (); - } - return c; -} - -static unsigned char -control_byte_2 (double target_freq, bool shutdown_tx_PGA) -{ - int c; - - if (target_freq < VHF_High_takeover) // VHF low - c = 0xa0; - else if (target_freq < UHF_takeover) // VHF high - c = 0x90; - else // UHF - c = 0x30; - - if (shutdown_tx_PGA) - c |= 0x08; - - return c; -} - -microtune_4937::microtune_4937 (i2c_sptr i2c, int i2c_addr) -{ - d_i2c = i2c; - d_i2c_addr = i2c_addr; - d_reference_divider = 640; - d_fast_tuning_p = false; -} - -microtune_4937::~microtune_4937 () -{ - // nop -} - -/*! - * \brief select RF frequency to be tuned to output frequency. - * \p target_freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ -bool -microtune_4937::set_RF_freq (double target_freq, double *p_actual_freq) -{ - unsigned char buf[4]; - - double target_f_osc = target_freq + first_IF; - - double f_ref = 4e6 / d_reference_divider; - - // f_osc = f_ref * 8 * divisor - // divisor = f_osc / (f_ref * 8) - - int divisor = (int) ((target_f_osc + (f_ref * 4)) / (f_ref * 8)); - double actual_freq = (f_ref * 8 * divisor) - first_IF; - if (p_actual_freq != 0) - *p_actual_freq = actual_freq; - - if ((divisor & ~0x7fff) != 0) // 15 bit divisor - return false; - - buf[0] = (divisor >> 8) & 0xff; // DB1 - buf[1] = divisor & 0xff; // DB2 - buf[2] = control_byte_1 (d_fast_tuning_p, d_reference_divider); - buf[3] = control_byte_2 (target_freq, true); - -#if 0 - printf ("set_RF_freq: target: %g MHz actual: %g MHz %02x %02x %02x %02x\n", - target_freq/1e6, actual_freq/1e6, buf[0], buf[1], buf[2], buf[3]); -#endif - - return d_i2c->write (d_i2c_addr, buf, 4); -} - -/*! - * \returns true iff PLL is locked - */ -bool -microtune_4937::pll_locked_p () -{ - // FIXME - return true; -} - -/*! - * \returns the output frequency of the tuner in Hz. - */ -double -microtune_4937::get_output_freq () -{ - return 5.75e6; // 3x7702 -} diff --git a/gnuradio-core/src/lib/io/microtune_4937.h b/gnuradio-core/src/lib/io/microtune_4937.h deleted file mode 100644 index be8657c950..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4937.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2003 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_MICROTUNE_4937_H -#define INCLUDED_MICROTUNE_4937_H - -#include <gr_core_api.h> -#include <microtune_xxxx.h> - -/*! - * \brief class for controlling microtune 4937 tuner module - * \ingroup hardware - */ -class GR_CORE_API microtune_4937 : public microtune_xxxx { -public: - microtune_4937 (i2c_sptr i2c, int i2c_addr = 0x61); - virtual ~microtune_4937 (); - - /*! - * \brief select RF frequency to be tuned to output frequency. - * \p freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ - bool set_RF_freq (double freq, double *actual_freq); - - /*! - * \returns true iff PLL is locked - */ - bool pll_locked_p (); - - /*! - * \returns the output frequency (IF center freq) of the tuner in Hz. - */ - double get_output_freq (); - - private: - - i2c_sptr d_i2c; - int d_i2c_addr; - int d_reference_divider; - bool d_fast_tuning_p; /* if set, higher charge pump current: - faster tuning, worse phase noise - for distance < 10kHz to the carrier */ -}; - -#endif /* INCLUDED_MICROTUNE_4937_H */ diff --git a/gnuradio-core/src/lib/io/microtune_4937_eval_board.cc b/gnuradio-core/src/lib/io/microtune_4937_eval_board.cc deleted file mode 100644 index a25b8addfb..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4937_eval_board.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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 "microtune_4937_eval_board.h" -#include "microtune_eval_board_defs.h" -#include "ppio.h" -#include "microtune_4937.h" - -static const int TUNER_I2C_ADDR = 0x61; - -microtune_4937_eval_board::microtune_4937_eval_board (int which_pp) - : microtune_xxxx_eval_board (which_pp) -{ - d_tuner = new microtune_4937 (d_i2c, TUNER_I2C_ADDR); - - // disable upstream amplifier - d_ppio->lock (); - int t = d_ppio->read_data (); - t &= ~(UT_DP_TX_ENABLE | UT_DP_TX_SDA | UT_DP_TX_SCL); - t |= UT_DP_TX_AS; - d_ppio->write_data (t); - d_ppio->unlock (); -} - -microtune_4937_eval_board::~microtune_4937_eval_board () -{ - // Default action is OK -} - - -static const float RF_MIN_V = 1.5; // RF AGC control voltages -static const float RF_MAX_V = 4.0; -static const float IF_MIN_V = 2.0; // IF AGC control voltages -static const float IF_MAX_V = 4.0; - -static const float MIN_AGC = 0; // bottom of synthetic range -static const float MAX_AGC = 1000; // top of synthetic range - -static const float CUTOVER_POINT = 667; - - -// linear is in the range MIN_AGC to MAX_AGC - -static float -linear_to_RF_AGC_voltage (float linear) -{ - if (linear >= CUTOVER_POINT) - return RF_MAX_V; - - float slope = (RF_MAX_V - RF_MIN_V) / CUTOVER_POINT; - return RF_MIN_V + linear * slope; -} - -static float -linear_to_IF_AGC_voltage (float linear) -{ - if (linear < CUTOVER_POINT) - return IF_MIN_V; - - float slope = (IF_MAX_V - IF_MIN_V) / (MAX_AGC - CUTOVER_POINT); - return IF_MIN_V + (linear - CUTOVER_POINT) * slope; -} - -void -microtune_4937_eval_board::set_AGC (float v) -{ - if (v < MIN_AGC) - v = MIN_AGC; - - if (v > MAX_AGC) - v = MAX_AGC; - - float rf_agc_voltage = linear_to_RF_AGC_voltage (v); - float if_agc_voltage = linear_to_IF_AGC_voltage (v); - - set_RF_AGC_voltage (rf_agc_voltage); - set_IF_AGC_voltage (if_agc_voltage); -} diff --git a/gnuradio-core/src/lib/io/microtune_4937_eval_board.h b/gnuradio-core/src/lib/io/microtune_4937_eval_board.h deleted file mode 100644 index 3abd9084ef..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4937_eval_board.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2001,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 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_MICROTUNE_4937_EVAL_BOARD_H -#define INCLUDED_MICROTUNE_4937_EVAL_BOARD_H - -#include <gr_core_api.h> -#include "microtune_xxxx_eval_board.h" - -/*! - * \brief control microtune 4937 eval board - * \ingroup hardware - */ - -class GR_CORE_API microtune_4937_eval_board : public microtune_xxxx_eval_board { -public: - microtune_4937_eval_board (int which_pp = 0); - ~microtune_4937_eval_board (); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000); -}; - - -#endif /* INCLUDED_MICROTUNE_4937_EVAL_BOARD_H */ diff --git a/gnuradio-core/src/lib/io/microtune_4937_eval_board.i b/gnuradio-core/src/lib/io/microtune_4937_eval_board.i deleted file mode 100644 index e261416f78..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4937_eval_board.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2001,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 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. - */ - -class microtune_4937_eval_board : public microtune_xxxx_eval_board { -public: - microtune_4937_eval_board (int which_pp = 0); - ~microtune_4937_eval_board (); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000); -}; diff --git a/gnuradio-core/src/lib/io/microtune_eval_board.i b/gnuradio-core/src/lib/io/microtune_eval_board.i deleted file mode 100644 index f77ef47b4b..0000000000 --- a/gnuradio-core/src/lib/io/microtune_eval_board.i +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 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. - */ - -/* - * SWIG interface defs for Microtune 4937 and eval board with Eric's daughterboard - */ - -/*! - * \brief abstract class for controlling microtune 4937 tuner module - */ -class microtune_4937 { -public: - microtune_4937 (); - - virtual ~microtune_4937 (); - - // returns actual freq or 0 if error (easier interface for SWIG) - double set_RF_freq (double freq); - - /*! - * \returns true iff PLL is locked - */ - bool pll_locked_p (); - - /*! - * \returns the output frequency (IF center freq) of the tuner in Hz. - */ - double get_output_freq (); - - - private: - //! \returns true iff successful - virtual bool i2c_write (int addr, const unsigned char *buf, int nbytes) = 0; - - //! \returns number of bytes read or -1 if error - virtual int i2c_read (int addr, unsigned char *buf, int max_bytes) = 0; - - int d_reference_divider; - bool d_fast_tuning_p; /* if set, higher charge pump current: - faster tuning, worse phase noise - for distance < 10kHz to the carrier */ -}; - -/*! - * \brief concrete class for controlling microtune 4937 eval board attached to parallel port - */ -class microtune_eval_board : public microtune_4937 { -public: - microtune_eval_board (int which_pp = 0); - ~microtune_eval_board (); - - //! is the eval board present? - bool board_present_p (); - - /*! - * \brief set RF and IF AGC control voltages ([0, 5] volts) - */ - void set_RF_AGC_voltage (float volts); - void set_IF_AGC_voltage (float volts); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - void set_AGC (float value_0_1000); - -private: - //! \returns true iff successful - virtual bool i2c_write (int addr, const unsigned char *buf, int nbytes); - - //! \returns number of bytes read or -1 if error - virtual int i2c_read (int addr, unsigned char *buf, int max_bytes); -}; diff --git a/gnuradio-core/src/lib/io/microtune_eval_board_defs.h b/gnuradio-core/src/lib/io/microtune_eval_board_defs.h deleted file mode 100644 index 61c52364f3..0000000000 --- a/gnuradio-core/src/lib/io/microtune_eval_board_defs.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*-C-*- -******************************************************************************* -* -* File: microtune_eval_board_defs.h -* Description: defines for parallel port control of eval board -* -******************************************************************************* -*/ - -/* - * Copyright 2001 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 _MICROTUNE_EVAL_BOARD_DEFS_H_ -#define _MICROTUNE_EVAL_BOARD_DEFS_H_ - -/* - * The Microtune 4937DI5 cable modem tuner eval board is controlled - * by bit banging the PC parallel port. This file defines the relevant - * bits. - * - * The parallel port has an 8 bit data port (output), - * an 8 bit control port (output) and - * an 8 bit status port (input). - * - * Not all bits of the control and status ports may be arbitrarily used. - */ - - -// parallel port data port constants (output) - -static const int UT_DP_TX_SDA = 0x01; // upstream control bus -static const int UT_DP_TX_SCL = 0x02; // upstream control bus -static const int UT_DP_TX_AS = 0x04; // upstream control bus -static const int UT_DP_TX_ENABLE = 0x08; // upstream h/w enable -// bits 4,5,6 not used -static const int UT_DP_TUNER_SDA_OUT = 0x80; // tuner i2c bus data - -// parallel port control port constants (output) - -static const int UT_CP_TUNER_SCL = 0x08; // tuner i2c bus clock -static const int UT_CP_MUST_BE_ZERO = 0xf0; // must be zero - -// parallel port status port constants (input) - -// bits 0,1,2 not used -static const int UT_SP_TUNER_SCL_LOOP_BACK= 0x08; // inverted SCL loop back -static const int UT_SP_SHOULD_BE_ZERO = 0x10; // reads as zero -static const int UT_SP_SHOULD_BE_ONE = 0x20; // reads as one -// bit 6 not used -static const int UT_SP_TUNER_SDA_IN = 0x80; - - -#endif /* _MICROTUNE_EVAL_BOARD_DEFS_H_ */ diff --git a/gnuradio-core/src/lib/io/microtune_xxxx.cc b/gnuradio-core/src/lib/io/microtune_xxxx.cc deleted file mode 100644 index 3d55f534a0..0000000000 --- a/gnuradio-core/src/lib/io/microtune_xxxx.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++-*- */ -/* - * Copyright 2001,2003,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 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 "microtune_xxxx.h" - -microtune_xxxx::~microtune_xxxx () -{ - // nop -} - -double -microtune_xxxx::set_RF_freq (double target_freq) -{ - double actual_freq = 0.0; - - if (set_RF_freq (target_freq, &actual_freq)) - return actual_freq; - - return 0.0; -} - - diff --git a/gnuradio-core/src/lib/io/microtune_xxxx.h b/gnuradio-core/src/lib/io/microtune_xxxx.h deleted file mode 100644 index b2646d39f9..0000000000 --- a/gnuradio-core/src/lib/io/microtune_xxxx.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2003,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 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_MICROTUNE_XXXX_H -#define INCLUDED_MICROTUNE_XXXX_H - -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> - -class i2c; -typedef boost::shared_ptr<i2c> i2c_sptr; - -/*! - * \brief abstract class for controlling microtune {4937,4702} tuner modules - * \ingroup base - */ -class GR_CORE_API microtune_xxxx { -public: - microtune_xxxx () {} - virtual ~microtune_xxxx (); - - /*! - * \brief select RF frequency to be tuned to output frequency. - * \p freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ - virtual bool set_RF_freq (double freq, double *actual_freq) = 0; - - // returns actual freq or 0 if error (easier interface for SWIG) - double set_RF_freq (double freq); - - /*! - * \returns true iff PLL is locked - */ - virtual bool pll_locked_p () = 0; - - /*! - * \returns the output frequency (IF center freq) of the tuner in Hz. - */ - virtual double get_output_freq () = 0; - -}; - -#endif /* INCLUDED_MICROTUNE_XXXX_H */ diff --git a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.cc b/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.cc deleted file mode 100644 index 35600ff066..0000000000 --- a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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 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 "microtune_xxxx_eval_board.h" -#include "microtune_eval_board_defs.h" -#include "microtune_xxxx.h" -#include "ppio.h" -#include "i2c_bitbang.h" -#include "i2c_bbio_pp.h" -#include <cmath> - -static int AGC_DAC_I2C_ADDR = 0x2C; - -microtune_xxxx_eval_board::microtune_xxxx_eval_board (int which_pp) -{ - d_ppio = make_ppio (which_pp); - d_i2c = make_i2c_bitbang (make_i2c_bbio_pp (d_ppio)); - d_tuner = 0; -} - -microtune_xxxx_eval_board::~microtune_xxxx_eval_board () -{ - delete d_tuner; - d_tuner = 0; -} - - -//! is the eval board present? -bool -microtune_xxxx_eval_board::board_present_p () -{ - bool result = true; - d_ppio->lock (); - - int t = d_ppio->read_status (); - if ((t & UT_SP_SHOULD_BE_ZERO) != 0 - || (t & UT_SP_SHOULD_BE_ONE) != UT_SP_SHOULD_BE_ONE) - result = false; - - // could also see if SCL is looped back or not, but that seems like overkill - - d_ppio->unlock (); - return result; -} - -/* - * ---------------------------------------------------------------- - * AGC stuff - * - * We're using a MAX518 8-bit 5V dual dac for setting the AGC's - * ---------------------------------------------------------------- - */ -void -microtune_xxxx_eval_board::write_dac (int which, int value) -{ - unsigned char cmd[2]; - cmd[0] = which & 1; - cmd[1] = value; - d_i2c->write (AGC_DAC_I2C_ADDR, cmd, sizeof (cmd)); -} - -void -microtune_xxxx_eval_board::write_both_dacs (int value0, int value1) -{ - unsigned char cmd[4]; - cmd[0] = 0; - cmd[1] = value0; - cmd[2] = 1; - cmd[3] = value1; - d_i2c->write (AGC_DAC_I2C_ADDR, cmd, sizeof (cmd)); -} - -static int scale_volts (float volts) -{ - int n; - n = (int) rint (volts * (256 / 5.0)); - if (n < 0) - n = 0; - if (n > 255) - n = 255; - - return n; -} - -void -microtune_xxxx_eval_board::set_RF_AGC_voltage (float volts) -{ - write_dac (0, scale_volts (volts)); -} - -void -microtune_xxxx_eval_board::set_IF_AGC_voltage (float volts) -{ - write_dac (1, scale_volts (volts)); -} - -// delegate to tuner - -bool -microtune_xxxx_eval_board::set_RF_freq (double freq, double *actual_freq) -{ - return d_tuner->set_RF_freq (freq, actual_freq); -} - -double -microtune_xxxx_eval_board::set_RF_freq (double freq) -{ - return d_tuner->set_RF_freq (freq); -} - -bool -microtune_xxxx_eval_board::pll_locked_p () -{ - return d_tuner->pll_locked_p (); -} - -double -microtune_xxxx_eval_board::get_output_freq () -{ - return d_tuner->get_output_freq (); -} diff --git a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.h b/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.h deleted file mode 100644 index 7fd784ade3..0000000000 --- a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2001,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 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_MICROTUNE_XXXX_EVAL_BOARD_H -#define INCLUDED_MICROTUNE_XXXX_EVAL_BOARD_H - -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> - -class microtune_xxxx; - -class ppio; -typedef boost::shared_ptr<ppio> ppio_sptr; - -class i2c; -typedef boost::shared_ptr<i2c> i2c_sptr; - -/*! - * \brief abstract class for controlling microtune xxxx eval board - * \ingroup hardware - */ -class GR_CORE_API microtune_xxxx_eval_board { -public: - microtune_xxxx_eval_board (int which_pp = 0); - virtual ~microtune_xxxx_eval_board (); - - //! is the eval board present? - bool board_present_p (); - - /*! - * \brief set RF and IF AGC control voltages ([0, 5] volts) - */ - void set_RF_AGC_voltage (float volts); - void set_IF_AGC_voltage (float volts); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000) = 0; - - /*! - * \brief select RF frequency to be tuned to output frequency. - * \p freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ - bool set_RF_freq (double freq, double *actual_freq); - - // returns actual freq or 0 if error (easier interface for SWIG) - double set_RF_freq (double freq); - - /*! - * \returns true iff PLL is locked - */ - bool pll_locked_p (); - - /*! - * \returns the output frequency (IF center freq) of the tuner in Hz. - */ - double get_output_freq (); - - -private: - void write_dac (int which, int value); - void write_both_dacs (int val0, int val1); - -protected: - ppio_sptr d_ppio; - i2c_sptr d_i2c; - microtune_xxxx *d_tuner; -}; - -#endif /* INCLUDED_MICROTUNE_XXXX_EVAL_BOARD_H */ diff --git a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.i b/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.i deleted file mode 100644 index 8a8a597427..0000000000 --- a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.i +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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. - */ - -class microtune_xxxx_eval_board { -public: - microtune_xxxx_eval_board (int which_pp = 0); - virtual ~microtune_xxxx_eval_board (); - - //! is the eval board present? - bool board_present_p (); - - /*! - * \brief set RF and IF AGC control voltages ([0, 5] volts) - */ - void set_RF_AGC_voltage (float volts); - void set_IF_AGC_voltage (float volts); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000) = 0; - - // returns actual freq or 0 if error (easier interface for SWIG) - double set_RF_freq (double freq); - - /*! - * \returns true iff PLL is locked - */ - bool pll_locked_p (); - - /*! - * \returns the output frequency (IF center freq) of the tuner in Hz. - */ - double get_output_freq (); -}; diff --git a/gnuradio-core/src/lib/io/ppio.cc b/gnuradio-core/src/lib/io/ppio.cc deleted file mode 100644 index a5edc539ca..0000000000 --- a/gnuradio-core/src/lib/io/ppio.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 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 <ppio.h> -#include <ppio_ppdev.h> - -ppio::~ppio () -{ -} - -// Factory method. -// -// Right now, we've only got one subclass we like. If there were more, -// we'd instantiate the "right one" here. - -ppio_sptr -make_ppio (int which_pp) -{ - return make_ppio_ppdev (which_pp); -} diff --git a/gnuradio-core/src/lib/io/ppio.h b/gnuradio-core/src/lib/io/ppio.h deleted file mode 100644 index d99f7bf79a..0000000000 --- a/gnuradio-core/src/lib/io/ppio.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2003 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_PPIO_H -#define INCLUDED_PPIO_H - -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> - -class ppio; -typedef boost::shared_ptr<ppio> ppio_sptr; - - -/*! - * \brief abstract class that provides low level access to parallel port bits - * \ingroup hardware - */ - -class GR_CORE_API ppio { - public: - ppio () {} - virtual ~ppio (); - - virtual void write_data (unsigned char v) = 0; - virtual unsigned char read_data () = 0; - virtual void write_control (unsigned char v) = 0; - virtual unsigned char read_control () = 0; - virtual unsigned char read_status () = 0; - - virtual void lock () = 0; - virtual void unlock () = 0; -}; - -/*! - * \brief Factory method. - * - * Split out from class to make life easier for SWIG - */ - -GR_CORE_API ppio_sptr make_ppio (int which_pp); - - -#endif /* INCLUDED_PPIO_H */ - diff --git a/gnuradio-core/src/lib/io/ppio.i b/gnuradio-core/src/lib/io/ppio.i deleted file mode 100644 index 6b95dcf888..0000000000 --- a/gnuradio-core/src/lib/io/ppio.i +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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. - */ - -class ppio; -typedef boost::shared_ptr<ppio> ppio_sptr; - -%template(ppio_sptr) boost::shared_ptr<ppio>; - -/*! - * \brief abstract class that provides low level access to parallel port bits - */ - -class ppio { - public: - ppio () {} - virtual ~ppio (); - - virtual void write_data (unsigned char v) = 0; - virtual unsigned char read_data () = 0; - virtual void write_control (unsigned char v) = 0; - virtual unsigned char read_control () = 0; - virtual unsigned char read_status () = 0; - - virtual void lock () = 0; - virtual void unlock () = 0; -}; - - -ppio_sptr make_ppio (int which_pp); diff --git a/gnuradio-core/src/lib/io/ppio_ppdev.cc b/gnuradio-core/src/lib/io/ppio_ppdev.cc deleted file mode 100644 index f528459585..0000000000 --- a/gnuradio-core/src/lib/io/ppio_ppdev.cc +++ /dev/null @@ -1,321 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2003,2004,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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <ppio_ppdev.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdlib.h> -#include <iostream> -#include <errno.h> -#include <stdio.h> -#include <stdexcept> -#if defined(HAVE_LINUX_PPDEV_H) -#include <sys/ioctl.h> -#include <linux/ppdev.h> -#include <linux/parport.h> -#include <sstream> -#elif defined(HAVE_DEV_PPBUS_PPI_H) -#include <sys/ioctl.h> -#include <dev/ppbus/ppi.h> -#include <dev/ppbus/ppbconf.h> -#include <sstream> -#else -// #warn "ppio_ppdev is not functional on this platform" -#endif - -// These control port bits are active low. -// We toggle them so that this weirdness doesn't get get propagated -// through our interface. - -static int CP_ACTIVE_LOW_BITS = 0x0B; - -// These status port bits are active low. -// We toggle them so that this weirdness doesn't get get propagated -// through our interface. - -static int SP_ACTIVE_LOW_BITS = 0x80; - -#if defined(HAVE_LINUX_PPDEV_H) - -// The real Linux code... - -ppio_ppdev::ppio_ppdev (int which) -{ - std::ostringstream filename; - filename << "/dev/parport" << which; - const char *c_filename = filename.str().c_str(); - - if ((d_fd = open (c_filename, O_RDWR)) < 0){ - int my_errno = errno; - perror (c_filename); - if (my_errno == ENOENT){ - std::cerr << "Does the device file " << c_filename << " exist?\n"; - std::cerr << "If not, as root execute: \n"; - std::cerr << " # mknod " << c_filename << " c 99 0\n"; - std::cerr << " # chmod 666 " << c_filename << std::endl; - } - throw std::runtime_error ("open"); - } - - int mode = IEEE1284_MODE_COMPAT; - if (ioctl (d_fd, PPSETMODE, &mode) != 0){ - perror ("ppio_ppdev: PPSETMODE"); - close (d_fd); - throw std::runtime_error ("PPSETMODE"); - } -} - -ppio_ppdev::~ppio_ppdev () -{ - close (d_fd); -} - - -void -ppio_ppdev::write_data (unsigned char v) -{ - if (ioctl (d_fd, PPWDATA, &v) != 0){ - perror ("ppio_ppdev: PPWDATA"); - throw std::runtime_error ("PPWDATA"); - } -} - -unsigned char -ppio_ppdev::read_data () -{ - unsigned char v; - - if (ioctl (d_fd, PPRDATA, &v) != 0){ - perror ("ppio_ppdev: PPRDATA"); - throw std::runtime_error ("PPRDATA"); - } - return v; -} - -void -ppio_ppdev::write_control (unsigned char v) -{ - unsigned char ctrl = v ^ CP_ACTIVE_LOW_BITS; - if (ioctl (d_fd, PPWCONTROL, &ctrl) != 0){ - perror ("ppio_ppdev: PPWCONTROL"); - throw std::runtime_error ("PPWCONTROL"); - } -} - -unsigned char -ppio_ppdev::read_control () -{ - unsigned char ctrl; - if (ioctl (d_fd, PPRCONTROL, &ctrl) != 0){ - perror ("ppio_ppdev: PPRCONTROL"); - throw std::runtime_error ("PPRCONTROL"); - } - - return ctrl ^ CP_ACTIVE_LOW_BITS; -} - -unsigned char -ppio_ppdev::read_status () -{ - unsigned char status; - if (ioctl (d_fd, PPRSTATUS, &status) != 0){ - perror ("ppio_ppdev: PPRSTATUS"); - throw std::runtime_error ("PPRSTATUS"); - } - - return status ^ SP_ACTIVE_LOW_BITS; -} - -void -ppio_ppdev::lock () -{ - if (ioctl (d_fd, PPCLAIM) != 0){ - perror ("ppio_ppdev: PPCLAIM"); - throw std::runtime_error ("PPCLAIM"); - } -} - -void -ppio_ppdev::unlock () -{ - if (ioctl (d_fd, PPRELEASE) != 0){ - perror ("ppio_ppdev: PPRELEASE"); - throw std::runtime_error ("PPRELEASE"); - } -} - -#elif defined(HAVE_DEV_PPBUS_PPI_H) - -// The real FreeBSD code... (Could work on other BSDs as well) - -ppio_ppdev::ppio_ppdev (int which) -{ - std::ostringstream filename; - filename << "/dev/ppi" << which; - const char *c_filename = filename.str().c_str(); - if ((d_fd = open (c_filename, O_RDWR)) < 0){ - int my_errno = errno; - perror (c_filename); - throw std::runtime_error ("open"); - } - -#if 0 - int mode = IEEE1284_MODE_COMPAT; - if (ioctl (d_fd, PPSETMODE, &mode) != 0){ - perror ("ppio_ppdev: PPSETMODE"); - close (d_fd); - throw std::runtime_error ("PPSETMODE"); - } -#endif -} - -ppio_ppdev::~ppio_ppdev () -{ - close (d_fd); -} - - -void -ppio_ppdev::write_data (unsigned char v) -{ - if (ioctl (d_fd, PPISDATA, &v) != 0){ - perror ("ppio_ppdev: PPISDATA"); - throw std::runtime_error ("PPISDATA"); - } -} - -unsigned char -ppio_ppdev::read_data () -{ - unsigned char v; - - if (ioctl (d_fd, PPIGDATA, &v) != 0){ - perror ("ppio_ppdev: PPIGDATA"); - throw std::runtime_error ("PPIGDATA"); - } - return v; -} - -void -ppio_ppdev::write_control (unsigned char v) -{ - unsigned char ctrl = v ^ CP_ACTIVE_LOW_BITS; - if (ioctl (d_fd, PPISCTRL, &ctrl) != 0){ - perror ("ppio_ppdev: PPISCTRL"); - throw std::runtime_error ("PPISCTRL"); - } -} - -unsigned char -ppio_ppdev::read_control () -{ - unsigned char ctrl; - if (ioctl (d_fd, PPIGCTRL, &ctrl) != 0){ - perror ("ppio_ppdev: PPIGCTRL"); - throw std::runtime_error ("PPIGCTRL"); - } - - return ctrl ^ CP_ACTIVE_LOW_BITS; -} - -unsigned char -ppio_ppdev::read_status () -{ - unsigned char status; - if (ioctl (d_fd, PPIGSTATUS, &status) != 0){ - perror ("ppio_ppdev: PPIGSTATUS"); - throw std::runtime_error ("PPIGSTATUS"); - } - return status ^ SP_ACTIVE_LOW_BITS; -} - -void -ppio_ppdev::lock () -{ -} - -void -ppio_ppdev::unlock () -{ -} -#else -/* Apparently, non real code */ - -ppio_ppdev::ppio_ppdev (int which) -{ - std::cerr << "ppio_ppdev: Not implemented on this platform\n"; - throw std::runtime_error ("not implmeneted"); -} - -ppio_ppdev::~ppio_ppdev () -{ -} - -void -ppio_ppdev::write_data (unsigned char v) -{ -} - -unsigned char -ppio_ppdev::read_data () -{ - return 0; -} - -void -ppio_ppdev::write_control (unsigned char v) -{ -} - -unsigned char -ppio_ppdev::read_control () -{ - return 0; -} - -unsigned char -ppio_ppdev::read_status () -{ - return 0; -} - -void -ppio_ppdev::lock () -{ -} - -void -ppio_ppdev::unlock () -{ -} - -#endif - -ppio_ppdev_sptr -make_ppio_ppdev (int which) -{ - return ppio_ppdev_sptr (new ppio_ppdev (which)); -} diff --git a/gnuradio-core/src/lib/io/ppio_ppdev.h b/gnuradio-core/src/lib/io/ppio_ppdev.h deleted file mode 100644 index 1f86d7e047..0000000000 --- a/gnuradio-core/src/lib/io/ppio_ppdev.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2003 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_PPIO_PPDEV_H -#define INCLUDED_PPIO_PPDEV_H - -#include <gr_core_api.h> -#include <ppio.h> - -class ppio_ppdev; -typedef boost::shared_ptr<ppio_ppdev> ppio_ppdev_sptr; - -/*! - * \brief access to parallel port bits using the linux ppdev interface - * \ingroup hardware - */ - -class GR_CORE_API ppio_ppdev : public ppio { - friend GR_CORE_API ppio_ppdev_sptr make_ppio_ppdev (int which = 0); - ppio_ppdev (int which = 0); - - public: - virtual ~ppio_ppdev (); - - virtual void write_data (unsigned char v); - virtual unsigned char read_data (); - virtual void write_control (unsigned char v); - virtual unsigned char read_control (); - virtual unsigned char read_status (); - - virtual void lock (); - virtual void unlock (); - - private: - int d_fd; -}; - -ppio_ppdev_sptr -make_ppio_ppdev (int which); - - -#endif /* INCLUDED_PPIO_PPDEV_H */ - diff --git a/gnuradio-core/src/lib/io/sdr_1000.cc b/gnuradio-core/src/lib/io/sdr_1000.cc deleted file mode 100644 index a8c2555e0e..0000000000 --- a/gnuradio-core/src/lib/io/sdr_1000.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 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 <sdr_1000.h> -#include <ppio.h> - -sdr_1000_base::sdr_1000_base (int which_pp) -{ - d_ppio = make_ppio (which_pp); - d_shadow[0] = 0; - d_shadow[1] = 0; - d_shadow[2] = 0; - d_shadow[3] = 0; - reset (); -} - -sdr_1000_base::~sdr_1000_base () -{ -} - -void -sdr_1000_base::reset () -{ - d_ppio->lock (); - d_ppio->write_control (0x0F); - d_ppio->unlock (); - write_latch (L_EXT, 0x00, 0xff); - write_latch (L_BAND, 0x00, 0xff); - write_latch (L_DDS0, 0x80, 0xff); // hold DDS in reset - write_latch (L_DDS1, 0x00, 0xff); -} - - -void -sdr_1000_base::write_latch (int which, int value, int mask) -{ - if (!(0 <= which && which <= 3)) - return; - - d_ppio->lock (); - d_shadow[which] = (d_shadow[which] & ~mask) | (value & mask); - d_ppio->write_data (d_shadow[which]); - d_ppio->write_control (0x0F ^ (1 << which)); - d_ppio->write_control (0x0F); - d_ppio->unlock (); -} diff --git a/gnuradio-core/src/lib/io/sdr_1000.h b/gnuradio-core/src/lib/io/sdr_1000.h deleted file mode 100644 index c00608a3a9..0000000000 --- a/gnuradio-core/src/lib/io/sdr_1000.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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 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_SDR_1000_H -#define INCLUDED_SDR_1000_H - -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> - -class ppio; -typedef boost::shared_ptr<ppio> ppio_sptr; - - -enum { L_EXT = 0, L_BAND = 1, L_DDS0 = 2, L_DDS1 = 3 }; - -/*! - * \brief Very low level interface to SDR 1000 xcvr hardware - * \sa sdr_1000.py for a higher level interface. - * \ingroup hardware - */ -class GR_CORE_API sdr_1000_base { - ppio_sptr d_ppio; - int d_shadow[4]; // shadow latches - -public: - - sdr_1000_base (int which_pp); - ~sdr_1000_base (); - - void reset (); - void write_latch (int which, int value, int mask); -}; - -#endif /* INCLUDED_SDR_1000_H */ diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt index a322d1b998..f3982f53cd 100644 --- a/gnuradio-core/src/lib/runtime/CMakeLists.txt +++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt @@ -110,17 +110,9 @@ endif(ENABLE_GR_CTRLPORT) # Append gnuradio-core test sources ######################################################################## list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_block.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2_derived.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_buffer.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_flowgraph.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_top_block.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_io_signature.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_vmcircbuf.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_runtime.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_set_msg_handler.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_logger.cc ) diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.h b/gnuradio-core/src/lib/runtime/gr_basic_block.h index 31081698c7..66fb72d87e 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.h +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.h @@ -301,9 +301,9 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ * void msg_handler(pmt::pmt msg); * </pre> * - * (You may want to use boost::bind to massage your callable into the - * correct form. See gr_nop.{h,cc} for an example that sets up a class - * method as the callback.) + * (You may want to use boost::bind to massage your callable into + * the correct form. See gr::blocks::nop for an example that sets + * up a class method as the callback.) * * Blocks that desire to handle messages must call this method in their * constructors to register the handler that will be invoked when messages diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.h b/gnuradio-core/src/lib/runtime/gr_top_block.h index 694e9575b4..9634b53f3c 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. + * Copyright 2007-2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -83,7 +83,7 @@ public: /*! * Wait for a flowgraph to complete. Flowgraphs complete when * either (1) all blocks indicate that they are done (typically only - * when using blocks.file_source, or gr.head, or (2) after stop() has been + * when using blocks.file_source, or blocks.head, or (2) after stop() has been * called to request shutdown. Calling wait on a top_block that is * not running IS NOT an error (wait returns w/o blocking). */ diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc deleted file mode 100644 index c3c18cac01..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ /dev/null @@ -1,448 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <qa_block_tags.h> -#include <gr_block.h> -#include <gr_top_block.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <gr_head.h> -#include <gr_annotator_alltoall.h> -#include <gr_annotator_1to1.h> -#include <gr_tags.h> - - -// ---------------------------------------------------------------- - -// set to 1 to turn on debug output -// The debug output fully checks that the tags seen are what are expected. While -// this behavior currently works with our implementation, there is no guarentee -// that the tags will be coming in this specific order, so it's dangerous to -// rely on this as a test of the tag system working. We would really want to -// tags we know we should see and then test that they all occur once, but in no -// particular order. -#define QA_TAGS_DEBUG 0 - -void -qa_block_tags::t0 () -{ - unsigned int N = 1000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_block_sptr snk (gr_make_null_sink(sizeof(int))); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, snk, 0); - - //CPPUNIT_ASSERT_THROW(src->nitems_read(0), std::runtime_error); - //CPPUNIT_ASSERT_THROW(src->nitems_written(0), std::runtime_error); - CPPUNIT_ASSERT_EQUAL(src->nitems_read(0), (uint64_t)0); - CPPUNIT_ASSERT_EQUAL(src->nitems_written(0), (uint64_t)0); - - tb->run(); - - CPPUNIT_ASSERT_THROW(src->nitems_read(0), std::invalid_argument); - CPPUNIT_ASSERT(src->nitems_written(0) >= N); - CPPUNIT_ASSERT_EQUAL(snk->nitems_read(0), (uint64_t)1000); - CPPUNIT_ASSERT_THROW(snk->nitems_written(0), std::invalid_argument); -} - - -void -qa_block_tags::t1 () -{ - int N = 40000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann4 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, ann0, 0); - - tb->connect(ann0, 0, ann1, 0); - tb->connect(ann0, 1, ann2, 0); - tb->connect(ann1, 0, ann3, 0); - tb->connect(ann2, 0, ann4, 0); - - tb->connect(ann3, 0, snk0, 0); - tb->connect(ann4, 0, snk1, 0); - - tb->run(); - - std::vector<gr_tag_t> tags0 = ann0->data(); - std::vector<gr_tag_t> tags3 = ann3->data(); - std::vector<gr_tag_t> tags4 = ann4->data(); - - // The first annotator does not receive any tags from the null sink upstream - CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); - CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8); - CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8); - -#if QA_TAGS_DEBUG - // Kludge together the tags that we know should result from the above graph - std::stringstream str0, str1, str2; - str0 << ann0->name() << ann0->unique_id(); - str1 << ann1->name() << ann1->unique_id(); - str2 << ann2->name() << ann2->unique_id(); - - pmt::pmt_t expected_tags3[8]; - expected_tags3[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags3[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags3[2] = mp(pmt::from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags3[3] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags3[4] = mp(pmt::from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags3[5] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags3[6] = mp(pmt::from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags3[7] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - - pmt::pmt_t expected_tags4[8]; - expected_tags4[0] = mp(pmt::from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); - expected_tags4[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[2] = mp(pmt::from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[4] = mp(pmt::from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[6] = mp(pmt::from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); - expected_tags4[7] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); - - std::cout << std::endl << "qa_block_tags::t1" << std::endl; - - // For annotator 3, we know it gets tags from ann0 and ann1, test this - for(size_t i = 0; i < tags3.size(); i++) { - std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags3[i]), pmt::write_string(expected_tags3[i])); - } - - // For annotator 4, we know it gets tags from ann0 and ann2, test this - std::cout << std::endl; - for(size_t i = 0; i < tags4.size(); i++) { - std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags4[i]), pmt::write_string(expected_tags4[i])); - } -#endif -} - -void -qa_block_tags::t2 () -{ - int N = 40000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann4 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk2 (gr_make_null_sink(sizeof(int))); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, ann0, 0); - - tb->connect(ann0, 0, ann1, 0); - tb->connect(ann0, 1, ann1, 1); - tb->connect(ann1, 0, ann2, 0); - tb->connect(ann1, 1, ann3, 0); - tb->connect(ann1, 2, ann4, 0); - - tb->connect(ann2, 0, snk0, 0); - tb->connect(ann3, 0, snk1, 0); - tb->connect(ann4, 0, snk2, 0); - - tb->run(); - - std::vector<gr_tag_t> tags0 = ann0->data(); - std::vector<gr_tag_t> tags1 = ann1->data(); - std::vector<gr_tag_t> tags2 = ann2->data(); - std::vector<gr_tag_t> tags3 = ann4->data(); - std::vector<gr_tag_t> tags4 = ann4->data(); - - // The first annotator does not receive any tags from the null sink upstream - CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); - CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)8); - - // Make sure the rest all have 12 tags - CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)12); - CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)12); - CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)12); - - -#if QA_TAGS_DEBUG - // Kludge together the tags that we know should result from the above graph - std::stringstream str0, str1; - str0 << ann0->name() << ann0->unique_id(); - str1 << ann1->name() << ann1->unique_id(); - - pmt::pmt_t expected_tags2[12]; - expected_tags2[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags2[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags2[2] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags2[3] = mp(pmt::from_uint64(10000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags2[4] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags2[5] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags2[6] = mp(pmt::from_uint64(20000), mp(str1.str()), mp("seq"), mp(6)); - expected_tags2[7] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags2[8] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags2[9] = mp(pmt::from_uint64(30000), mp(str1.str()), mp("seq"), mp(9)); - expected_tags2[10] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - expected_tags2[11] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); - - pmt::pmt_t expected_tags4[12]; - expected_tags4[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(2)); - expected_tags4[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags4[2] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt::from_uint64(10000), mp(str1.str()), mp("seq"), mp(5)); - expected_tags4[4] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[6] = mp(pmt::from_uint64(20000), mp(str1.str()), mp("seq"), mp(8)); - expected_tags4[7] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags4[8] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[9] = mp(pmt::from_uint64(30000), mp(str1.str()), mp("seq"), mp(11)); - expected_tags4[10] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - expected_tags4[11] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); - - std::cout << std::endl << "qa_block_tags::t2" << std::endl; - - // For annotator[2-4], we know it gets tags from ann0 and ann1 - // but the tags from the different outputs of ann1 are different for each. - // Just testing ann2 and ann4; if they are correct it would be - // inconceivable for ann3 to have it wrong. - for(size_t i = 0; i < tags2.size(); i++) { - std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags2[i]), pmt::write_string(expected_tags2[i])); - } - - std::cout << std::endl; - for(size_t i = 0; i < tags4.size(); i++) { - std::cout << "tags2[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags4[i]), pmt::write_string(expected_tags4[i])); - } -#endif -} - - -void -qa_block_tags::t3 () -{ - int N = 40000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_1to1_sptr ann0 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_1to1_sptr ann3 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_1to1_sptr ann4 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, ann0, 0); - tb->connect(head, 0, ann0, 1); - - tb->connect(ann0, 0, ann1, 0); - tb->connect(ann0, 1, ann2, 0); - tb->connect(ann1, 0, ann3, 0); - tb->connect(ann2, 0, ann4, 0); - - tb->connect(ann3, 0, snk0, 0); - tb->connect(ann4, 0, snk1, 0); - - tb->run(); - - - std::vector<gr_tag_t> tags0 = ann0->data(); - std::vector<gr_tag_t> tags3 = ann3->data(); - std::vector<gr_tag_t> tags4 = ann4->data(); - - // The first annotator does not receive any tags from the null sink upstream - CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); - CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8); - CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8); - -#if QA_TAGS_DEBUG - // Kludge together the tags that we know should result from the above graph - std::stringstream str0, str1, str2; - str0 << ann0->name() << ann0->unique_id(); - str1 << ann1->name() << ann1->unique_id(); - str2 << ann2->name() << ann2->unique_id(); - - pmt::pmt_t expected_tags3[8]; - expected_tags3[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags3[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags3[2] = mp(pmt::from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags3[3] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags3[4] = mp(pmt::from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags3[5] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags3[6] = mp(pmt::from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags3[7] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - - pmt::pmt_t expected_tags4[8]; - expected_tags4[0] = mp(pmt::from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); - expected_tags4[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[2] = mp(pmt::from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[4] = mp(pmt::from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[6] = mp(pmt::from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); - expected_tags4[7] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); - - std::cout << std::endl << "qa_block_tags::t3" << std::endl; - - // For annotator 3, we know it gets tags from ann0 and ann1, test this - for(size_t i = 0; i < tags3.size(); i++) { - std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags3[i]), pmt::write_string(expected_tags3[i])); - } - - // For annotator 4, we know it gets tags from ann0 and ann2, test this - std::cout << std::endl; - for(size_t i = 0; i < tags4.size(); i++) { - std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags4[i]), pmt::write_string(expected_tags4[i])); - } -#endif -} - - -void -qa_block_tags::t4 () -{ - int N = 40000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_1to1_sptr ann0 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_1to1_sptr ann1 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_1to1_sptr ann2 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); - - // using 1-to-1 tag propagation without having equal number of - // ins and outs. Make sure this works; will just exit run early. - tb->connect(src, 0, head, 0); - tb->connect(head, 0, ann0, 0); - tb->connect(ann0, 0, ann1, 0); - tb->connect(ann0, 1, ann2, 0); - tb->connect(ann1, 0, snk0, 0); - tb->connect(ann2, 0, snk1, 0); - - std::cerr << std::endl - << "NOTE: This is supposed to produce an error from gr_block_executor" - << std::endl; - tb->run(); -} - - -/* -void -qa_block_tags::t5 () -{ - int N = 40000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(float))); - gr_block_sptr head (gr_make_head(sizeof(float), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(float))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(float))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(1000, sizeof(float))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(float))); - - // Rate change blocks - gr_keep_one_in_n_sptr dec10 (gr_make_keep_one_in_n(sizeof(float), 10)); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, ann0, 0); - tb->connect(ann0, 0, ann1, 0); - tb->connect(ann1, 0, dec10, 0); - tb->connect(dec10, 0, ann2, 0); - tb->connect(ann2, 0, snk0, 0); - - tb->run(); - - std::vector<gr_tag_t> tags0 = ann0->data(); - std::vector<gr_tag_t> tags1 = ann1->data(); - std::vector<gr_tag_t> tags2 = ann2->data(); - - // The first annotator does not receive any tags from the null sink upstream - CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); - CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)4); - CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)8); - - -#if QA_TAGS_DEBUG - // Kludge together the tags that we know should result from the above graph - std::stringstream str0, str1, str2; - str0 << ann0->name() << ann0->unique_id(); - str1 << ann1->name() << ann1->unique_id(); - str2 << ann2->name() << ann2->unique_id(); - - pmt::pmt_t expected_tags1[5]; - expected_tags1[0] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags1[1] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); - expected_tags1[2] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags1[3] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(3)); - - pmt::pmt_t expected_tags2[10]; - expected_tags2[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags2[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags2[2] = mp(pmt::from_uint64(1000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags2[3] = mp(pmt::from_uint64(1000), mp(str0.str()), mp("seq"), mp(1)); - expected_tags2[4] = mp(pmt::from_uint64(2000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags2[5] = mp(pmt::from_uint64(2000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags2[6] = mp(pmt::from_uint64(3000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags2[7] = mp(pmt::from_uint64(3000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags2[8] = mp(pmt::from_uint64(4000), mp(str1.str()), mp("seq"), mp(4)); - expected_tags2[9] = mp(pmt::from_uint64(4000), mp(str0.str()), mp("seq"), mp(4)); - - std::cout << std::endl << "qa_block_tags::t5" << std::endl; - - // annotator 1 gets tags from annotator 0 - std::cout << "tags1.size(): " << tags1.size() << std::endl; - for(size_t i = 0; i < tags1.size(); i++) { - std::cout << "tags1[" << i << "] = " << tags1[i] << "\t\t" << expected_tags1[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags1[i]), pmt::write_string(expected_tags1[i])); - } - - // annotator 2 gets tags from annotators 0 and 1 - std::cout << std::endl; - std::cout << "tags2.size(): " << tags2.size() << std::endl; - for(size_t i = 0; i < tags2.size(); i++) { - std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags2[i]), pmt::write_string(expected_tags2[i])); - } -#endif -} -*/ diff --git a/gnuradio-core/src/lib/runtime/qa_gr_block.cc b/gnuradio-core/src/lib/runtime/qa_gr_block.cc deleted file mode 100644 index aeab5b74a8..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_gr_block.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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 <qa_gr_block.h> -#include <gr_block.h> -#include <gr_io_signature.h> -#include <gr_null_sink.h> -#include <gr_null_source.h> - - -// ---------------------------------------------------------------- - - -void -qa_gr_block::t0 () -{ - // test creation of sources - gr_block_sptr src1 (gr_make_null_source (sizeof (int))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_source"), src1->name ()); - CPPUNIT_ASSERT_EQUAL (0, src1->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src1->output_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src1->output_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof(int), - src1->output_signature()->sizeof_stream_item (0)); - - gr_block_sptr src2 (gr_make_null_source (sizeof (short))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_source"), src2->name ()); - CPPUNIT_ASSERT_EQUAL (0, src2->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src2->output_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src2->output_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof (short), - src2->output_signature()->sizeof_stream_item (0)); -} - - -void -qa_gr_block::t1 () -{ - // test creation of sinks - gr_block_sptr dst1 (gr_make_null_sink (sizeof (int))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_sink"), dst1->name ()); - CPPUNIT_ASSERT_EQUAL (1, dst1->input_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (1, dst1->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof (int), - dst1->input_signature()->sizeof_stream_item (0)); - - CPPUNIT_ASSERT_EQUAL (0, dst1->output_signature()->max_streams ()); - - gr_block_sptr dst2 (gr_make_null_sink (sizeof (short))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_sink"), dst2->name ()); - CPPUNIT_ASSERT_EQUAL (1, dst2->input_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (1, dst2->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof (short), - dst2->input_signature()->sizeof_stream_item (0)); - CPPUNIT_ASSERT_EQUAL (0, dst2->output_signature()->max_streams ()); -} - -void -qa_gr_block::t2 () -{ -} - -void -qa_gr_block::t3 () -{ -} diff --git a/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.cc b/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.cc deleted file mode 100644 index cce83cb0a0..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.cc +++ /dev/null @@ -1,245 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_gr_flowgraph.h> -#include <gr_flowgraph.h> -#include <gr_nop.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> - -void qa_gr_flowgraph::t0() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - CPPUNIT_ASSERT(fg); -} - -void qa_gr_flowgraph::t1_connect() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); -} - -void qa_gr_flowgraph::t2_connect_invalid_src_port_neg() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - CPPUNIT_ASSERT_THROW(fg->connect(nop1, -1, nop2, 0), std::invalid_argument); -} - -void qa_gr_flowgraph::t3_connect_src_port_exceeds() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - CPPUNIT_ASSERT_THROW(fg->connect(src, 1, dst, 0), std::invalid_argument); -} - -void qa_gr_flowgraph::t4_connect_invalid_dst_port_neg() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - CPPUNIT_ASSERT_THROW(fg->connect(nop1, 0, nop2, -1), std::invalid_argument); -} - -void qa_gr_flowgraph::t5_connect_dst_port_exceeds() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - CPPUNIT_ASSERT_THROW(fg->connect(src, 0, dst, 1), std::invalid_argument); -} - -void qa_gr_flowgraph::t6_connect_dst_in_use() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr src1 = gr_make_null_source(sizeof(int)); - gr_block_sptr src2 = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - fg->connect(src1, 0, dst, 0); - CPPUNIT_ASSERT_THROW(fg->connect(src2, 0, dst, 0), std::invalid_argument); -} - -void qa_gr_flowgraph::t7_connect_one_src_two_dst() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst1 = gr_make_null_sink(sizeof(int)); - gr_block_sptr dst2 = gr_make_null_sink(sizeof(int)); - - fg->connect(src, 0, dst1, 0); - fg->connect(src, 0, dst2, 0); -} - -void qa_gr_flowgraph::t8_connect_type_mismatch() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(char)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - CPPUNIT_ASSERT_THROW(fg->connect(nop1, 0, nop2, 0), std::invalid_argument); -} - -void qa_gr_flowgraph::t9_disconnect() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - fg->disconnect(nop1, 0, nop2, 0); -} - -void qa_gr_flowgraph::t10_disconnect_unconnected_block() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - gr_block_sptr nop3 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - CPPUNIT_ASSERT_THROW(fg->disconnect(nop1, 0, nop3, 0), std::invalid_argument); -} - -void qa_gr_flowgraph::t11_disconnect_unconnected_port() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - CPPUNIT_ASSERT_THROW(fg->disconnect(nop1, 0, nop2, 1), std::invalid_argument); -} - -void qa_gr_flowgraph::t12_validate() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - fg->validate(); -} - -void qa_gr_flowgraph::t13_validate_missing_input_assignment() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - fg->connect(nop1, 0, nop2, 2); - CPPUNIT_ASSERT_THROW(fg->validate(), std::runtime_error); -} - -void qa_gr_flowgraph::t14_validate_missing_output_assignment() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - fg->connect(nop1, 2, nop2, 1); - CPPUNIT_ASSERT_THROW(fg->validate(), std::runtime_error); -} - -void qa_gr_flowgraph::t15_clear() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - - CPPUNIT_ASSERT(fg->edges().size() == 1); - CPPUNIT_ASSERT(fg->calc_used_blocks().size() == 2); - - fg->clear(); - - CPPUNIT_ASSERT(fg->edges().size() == 0); - CPPUNIT_ASSERT(fg->calc_used_blocks().size() == 0); -} - -void qa_gr_flowgraph::t16_partition() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop11 = gr_make_nop(sizeof(int)); - gr_block_sptr nop12 = gr_make_nop(sizeof(int)); - gr_block_sptr nop13 = gr_make_nop(sizeof(int)); - gr_block_sptr nop14 = gr_make_nop(sizeof(int)); - - gr_block_sptr nop21 = gr_make_nop(sizeof(int)); - gr_block_sptr nop22 = gr_make_nop(sizeof(int)); - gr_block_sptr nop23 = gr_make_nop(sizeof(int)); - - gr_block_sptr nop31 = gr_make_nop(sizeof(int)); - gr_block_sptr nop32 = gr_make_nop(sizeof(int)); - - // Build disjoint graph #1 - fg->connect(nop11, 0, nop12, 0); - fg->connect(nop12, 0, nop13, 0); - fg->connect(nop13, 0, nop14, 0); - - // Build disjoint graph #2 - fg->connect(nop21, 0, nop22, 0); - fg->connect(nop22, 0, nop23, 0); - - // Build disjoint graph #3 - fg->connect(nop31, 0, nop32, 0); - - std::vector<gr_basic_block_vector_t> graphs = fg->partition(); - - CPPUNIT_ASSERT(graphs.size() == 3); - CPPUNIT_ASSERT(graphs[0].size() == 4); - CPPUNIT_ASSERT(graphs[1].size() == 3); - CPPUNIT_ASSERT(graphs[2].size() == 2); -} diff --git a/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.h b/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.h deleted file mode 100644 index 2c2686f71b..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -#ifndef INCLUDED_QA_GR_FLOWGRAPH_H -#define INCLUDED_QA_GR_FLOWGRAPH_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_gr_flowgraph : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_gr_flowgraph); - - CPPUNIT_TEST(t0); - CPPUNIT_TEST(t1_connect); - CPPUNIT_TEST(t2_connect_invalid_src_port_neg); - CPPUNIT_TEST(t3_connect_src_port_exceeds); - CPPUNIT_TEST(t4_connect_invalid_dst_port_neg); - CPPUNIT_TEST(t5_connect_dst_port_exceeds); - CPPUNIT_TEST(t6_connect_dst_in_use); - CPPUNIT_TEST(t7_connect_one_src_two_dst); - CPPUNIT_TEST(t8_connect_type_mismatch); - CPPUNIT_TEST(t9_disconnect); - CPPUNIT_TEST(t10_disconnect_unconnected_block); - CPPUNIT_TEST(t11_disconnect_unconnected_port); - CPPUNIT_TEST(t12_validate); - CPPUNIT_TEST(t13_validate_missing_input_assignment); - CPPUNIT_TEST(t14_validate_missing_output_assignment); - CPPUNIT_TEST(t15_clear); - CPPUNIT_TEST(t16_partition); - - CPPUNIT_TEST_SUITE_END(); - -private: - - void t0(); - void t1_connect(); - void t2_connect_invalid_src_port_neg(); - void t3_connect_src_port_exceeds(); - void t4_connect_invalid_dst_port_neg(); - void t5_connect_dst_port_exceeds(); - void t6_connect_dst_in_use(); - void t7_connect_one_src_two_dst(); - void t8_connect_type_mismatch(); - void t9_disconnect(); - void t10_disconnect_unconnected_block(); - void t11_disconnect_unconnected_port(); - void t12_validate(); - void t13_validate_missing_input_assignment(); - void t14_validate_missing_output_assignment(); - void t15_clear(); - void t16_partition(); -}; - -#endif /* INCLUDED_QA_GR_FLOWGRAPH_H */ diff --git a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc b/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc deleted file mode 100644 index 9844d33814..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2009 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 <qa_gr_hier_block2.h> -#include <gr_hier_block2.h> -#include <gr_io_signature.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> - -void qa_gr_hier_block2::test_make() -{ - gr_hier_block2_sptr src1(gr_make_hier_block2("test", - gr_make_io_signature(1, 1, 1 * sizeof(int)), - gr_make_io_signature(1, 1, 1 * sizeof(int)))); - - CPPUNIT_ASSERT(src1); - CPPUNIT_ASSERT_EQUAL(std::string("test"), src1->name()); - - CPPUNIT_ASSERT_EQUAL(1 * (int) sizeof(int), - src1->input_signature()->sizeof_stream_item(0)); - - CPPUNIT_ASSERT_EQUAL(1, src1->input_signature()->min_streams()); - CPPUNIT_ASSERT_EQUAL(1, src1->input_signature()->max_streams()); - - - CPPUNIT_ASSERT_EQUAL(1 * (int) sizeof(int), - src1->output_signature()->sizeof_stream_item(0)); - - CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->min_streams()); - CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->max_streams()); - -} - - diff --git a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.h b/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.h deleted file mode 100644 index 653cd27251..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 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_QA_GR_HIER_BLOCK2_H -#define INCLUDED_QA_GR_HIER_BLOCK2_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_gr_hier_block2 : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_gr_hier_block2); - - CPPUNIT_TEST(test_make); - - CPPUNIT_TEST_SUITE_END(); - -private: - void test_make(); -}; - -#endif /* INCLUDED_QA_GR_HIER_BLOCK2_H */ diff --git a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2_derived.cc b/gnuradio-core/src/lib/runtime/qa_gr_hier_block2_derived.cc deleted file mode 100644 index 060c4e2447..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2_derived.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_gr_hier_block2_derived.h> -#include <gr_top_block.h> -#include <gr_io_signature.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <gr_head.h> -#include <gr_kludge_copy.h> - -// Declare a test C++ hierarchical block - -class gr_derived_block; -typedef boost::shared_ptr<gr_derived_block> gr_derived_block_sptr; -gr_derived_block_sptr gr_make_derived_block(); - -class gr_derived_block : public gr_hier_block2 -{ -private: - friend gr_derived_block_sptr gr_make_derived_block(); - gr_derived_block(); - -public: - ~gr_derived_block(); -}; - - -gr_derived_block_sptr -gr_make_derived_block() -{ - return gnuradio::get_initial_sptr(new gr_derived_block()); -} - -gr_derived_block::gr_derived_block() - : gr_hier_block2("gr_derived_block", - gr_make_io_signature(1, 1, sizeof(int)), // Input signature - gr_make_io_signature(1, 1, sizeof(int))) // Output signature -{ - gr_block_sptr copy(gr_make_kludge_copy(sizeof(int))); - - connect(self(), 0, copy, 0); - connect(copy, 0, self(), 0); -} - -gr_derived_block::~gr_derived_block() -{ -} - -void qa_gr_hier_block2_derived::test_1() -{ - gr_top_block_sptr tb(gr_make_top_block("test")); - - gr_block_sptr src(gr_make_null_source(sizeof(int))); - gr_block_sptr head(gr_make_head(sizeof(int), 1000)); - gr_derived_block_sptr blk(gr_make_derived_block()); - gr_block_sptr dst(gr_make_null_sink(sizeof(int))); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, blk, 0); - tb->connect(blk, 0, dst, 0); - - tb->run(); -} diff --git a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2_derived.h b/gnuradio-core/src/lib/runtime/qa_gr_hier_block2_derived.h deleted file mode 100644 index 8e0a1880ce..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2_derived.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,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. - */ - -#ifndef INCLUDED_QA_GR_HIER_BLOCK2_DERIVED_H -#define INCLUDED_QA_GR_HIER_BLOCK2_DERIVED_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -// Declare a QA test case -class qa_gr_hier_block2_derived : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_gr_hier_block2_derived); - CPPUNIT_TEST(test_1); - CPPUNIT_TEST_SUITE_END(); - -private: - void test_1(); -}; - -#endif /* INCLUDED_QA_GR_HIER_BLOCK2_DERIVED_H */ diff --git a/gnuradio-core/src/lib/runtime/qa_gr_top_block.cc b/gnuradio-core/src/lib/runtime/qa_gr_top_block.cc deleted file mode 100644 index 1d3dafadf8..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_gr_top_block.cc +++ /dev/null @@ -1,285 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_gr_top_block.h> -#include <gr_top_block.h> -#include <gr_head.h> -#include <gr_nop.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <iostream> - -#define VERBOSE 0 - -void qa_gr_top_block::t0() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t0()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - CPPUNIT_ASSERT(tb); -} - -void qa_gr_top_block::t1_run() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t1()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->run(); -} - -void qa_gr_top_block::t2_start_stop_wait() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t2()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - - tb->start(); - tb->stop(); - tb->wait(); -} - -void qa_gr_top_block::t3_lock_unlock() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t3()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - tb->connect(src, 0, dst, 0); - - tb->start(); - - tb->lock(); - tb->unlock(); - - tb->stop(); - tb->wait(); -} - -void qa_gr_top_block::t4_reconfigure() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t4()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - // Start infinite flowgraph - tb->connect(src, 0, dst, 0); - tb->start(); - - // Reconfigure with gr_head in the middle - tb->lock(); - tb->disconnect(src, 0, dst, 0); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->unlock(); - - // Wait for flowgraph to end on its own - tb->wait(); -} - - -void qa_gr_top_block::t5_max_noutputs() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t5()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - // Start infinite flowgraph - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->start(100); - tb->wait(); -} - -void qa_gr_top_block::t6_reconfig_max_noutputs() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t6()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - // Start infinite flowgraph - tb->connect(src, 0, dst, 0); - tb->start(100); - - // Reconfigure with gr_head in the middle - tb->lock(); - tb->disconnect(src, 0, dst, 0); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->set_max_noutput_items(1000); - head->set_max_noutput_items(500); - tb->unlock(); - - // Wait for flowgraph to end on its own - tb->wait(); -} - -void qa_gr_top_block::t7_max_noutputs_per_block() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t7()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - head->set_max_noutput_items(100); - - // Start infinite flowgraph - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->start(); - tb->wait(); -} - -void qa_gr_top_block::t8_reconfig_max_noutputs_per_block() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t8()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - head->set_max_noutput_items(99); - - // Start infinite flowgraph - tb->connect(src, 0, dst, 0); - tb->start(201); - - // Reconfigure with gr_head in the middle - tb->lock(); - tb->disconnect(src, 0, dst, 0); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->set_max_noutput_items(1023); - head->set_max_noutput_items(513); - tb->unlock(); - - // Wait for flowgraph to end on its own - tb->wait(); -} - -void qa_gr_top_block::t9_max_output_buffer() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t9()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - head->set_max_output_buffer(1024); - - // Start infinite flowgraph - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->start(); - tb->wait(); -} - -void qa_gr_top_block::t10_reconfig_max_output_buffer() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t10()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - head->set_max_output_buffer(1000); - - // Start infinite flowgraph - tb->connect(src, 0, dst, 0); - tb->start(201); - - // Reconfigure with gr_head in the middle - tb->lock(); - gr_block_sptr nop = gr_make_nop(sizeof(int)); - nop->set_max_output_buffer(4000); - tb->disconnect(src, 0, dst, 0); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, nop, 0); - tb->connect(nop, 0, dst, 0); - tb->unlock(); - - // Wait for flowgraph to end on its own - tb->wait(); -} - -void qa_gr_top_block::t11_set_block_affinity() -{ - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(float))); - gr_block_sptr snk (gr_make_null_sink(sizeof(float))); - - std::vector<unsigned int> set(1, 0), ret; - src->set_processor_affinity(set); - - tb->connect(src, 0, snk, 0); - tb->start(); - tb->stop(); - tb->wait(); - - ret = src->processor_affinity(); - - // We only set the core affinity to 0 because we always know at - // least one thread core exists to use. - CPPUNIT_ASSERT_EQUAL(set[0], ret[0]); -} diff --git a/gnuradio-core/src/lib/runtime/qa_gr_top_block.h b/gnuradio-core/src/lib/runtime/qa_gr_top_block.h deleted file mode 100644 index 634eeab1f8..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_gr_top_block.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -#ifndef INCLUDED_QA_GR_TOP_BLOCK_H -#define INCLUDED_QA_GR_TOP_BLOCK_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_gr_top_block : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_gr_top_block); - - CPPUNIT_TEST(t0); - CPPUNIT_TEST(t1_run); - CPPUNIT_TEST(t2_start_stop_wait); - CPPUNIT_TEST(t3_lock_unlock); - CPPUNIT_TEST(t4_reconfigure); // triggers 'join never returns' bug - CPPUNIT_TEST(t5_max_noutputs); - CPPUNIT_TEST(t6_reconfig_max_noutputs); - CPPUNIT_TEST(t7_max_noutputs_per_block); - CPPUNIT_TEST(t8_reconfig_max_noutputs_per_block); - CPPUNIT_TEST(t9_max_output_buffer); - CPPUNIT_TEST(t10_reconfig_max_output_buffer); - CPPUNIT_TEST(t11_set_block_affinity); - - CPPUNIT_TEST_SUITE_END(); - -private: - - void t0(); - void t1_run(); - void t2_start_stop_wait(); - void t3_lock_unlock(); - void t4_reconfigure(); - void t5_max_noutputs(); - void t6_reconfig_max_noutputs(); - void t7_max_noutputs_per_block(); - void t8_reconfig_max_noutputs_per_block(); - void t9_max_output_buffer(); - void t10_reconfig_max_output_buffer(); - void t11_set_block_affinity(); - -}; - -#endif /* INCLUDED_QA_GR_TOP_BLOCK_H */ diff --git a/gnuradio-core/src/lib/runtime/qa_runtime.cc b/gnuradio-core/src/lib/runtime/qa_runtime.cc index 62c95ef5c4..f02fbd7d66 100644 --- a/gnuradio-core/src/lib/runtime/qa_runtime.cc +++ b/gnuradio-core/src/lib/runtime/qa_runtime.cc @@ -32,14 +32,8 @@ #include <qa_runtime.h> #include <qa_gr_vmcircbuf.h> #include <qa_gr_io_signature.h> -#include <qa_gr_block.h> -#include <qa_gr_flowgraph.h> #include <qa_gr_logger.h> -#include <qa_gr_top_block.h> -#include <qa_gr_hier_block2.h> -#include <qa_gr_hier_block2_derived.h> #include <qa_gr_buffer.h> -#include <qa_block_tags.h> #include <qa_set_msg_handler.h> CppUnit::TestSuite * diff --git a/gnuradio-core/src/lib/runtime/qa_set_msg_handler.cc b/gnuradio-core/src/lib/runtime/qa_set_msg_handler.cc deleted file mode 100644 index ac06a3f8bc..0000000000 --- a/gnuradio-core/src/lib/runtime/qa_set_msg_handler.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_set_msg_handler.h> -#include <gr_top_block.h> -#include <gr_head.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <gr_nop.h> -#include <gruel/msg_passing.h> -#include <iostream> -#include <boost/thread/thread.hpp> - - -#define VERBOSE 0 - -/* - * The gr_nop block has been instrumented so that it counts - * the number of messages sent to it. We use this feature - * to confirm that gr_nop's call to set_msg_handler is working - * correctly. - */ - -void qa_set_msg_handler::t0() -{ - static const int NMSGS = 10; - - if (VERBOSE) std::cout << "qa_set_msg_handler::t0()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_nop_sptr nop = gr_make_nop(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - tb->connect(src, 0, nop, 0); - tb->connect(nop, 0, dst, 0); - - // Must start graph before sending messages - tb->start(); - - // Send them... - pmt::pmt_t port(pmt::intern("port")); - for (int i = 0; i < NMSGS; i++){ - send(nop, port, pmt::mp(pmt::mp("example-msg"), pmt::mp(i))); - } - - // Give the messages a chance to be processed - boost::this_thread::sleep(boost::posix_time::milliseconds(100)); - - tb->stop(); - tb->wait(); - - // Confirm that the nop block received the right number of messages. - CPPUNIT_ASSERT_EQUAL(NMSGS, nop->nmsgs_received()); -} diff --git a/gnuradio-core/src/lib/runtime/test_shared_block_ptr.cc b/gnuradio-core/src/lib/runtime/test_shared_block_ptr.cc index bb4e863222..0a391c1354 100644 --- a/gnuradio-core/src/lib/runtime/test_shared_block_ptr.cc +++ b/gnuradio-core/src/lib/runtime/test_shared_block_ptr.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,16 +21,16 @@ */ #include <gr_shared_block_sptr.h> -#include <gr_vector_source_i.h> +#include <blocks/vector_source_i.h> gr_block_sptr -foo (gr_vector_source_i_sptr s) +foo (gr::blocks::vector_source_i::sptr s) { return gr_block_sptr (s); } -typedef gr_shared_block_sptr<gr_vector_source_i> gr_vector_source_i_ptrX; -//typedef boost::shared_ptr<gr_vector_source_i> gr_vector_source_i_ptrX; +typedef gr_shared_block_sptr<gr::blocks::vector_source_i> gr_vector_source_i_ptrX; +//typedef boost::shared_ptr<gr::blocks::vector_source_i> gr_vector_source_i_ptrX; gr_vector_source_i_ptrX bar (gr_vector_source_i *s) diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt index 2132e2ca09..f098597df0 100644 --- a/gnuradio-core/src/lib/swig/CMakeLists.txt +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -58,9 +58,9 @@ link_directories(${Boost_LIBRARY_DIRS}) # ---------------------------------------------------------------- set(GR_SWIG_TARGET_DEPS gnuradio_core_generated_sources - general_generated gengen_generated filter_generated pmt_swig) + general_generated filter_generated pmt_swig) -foreach(what runtime general gengen io) +foreach(what runtime general) SET(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${what}_swig_doc.i) SET(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../${what} ${CMAKE_CURRENT_BINARY_DIR}/../${what}) GR_SWIG_MAKE(gnuradio_core_${what} gnuradio_core_${what}.i) diff --git a/gnuradio-core/src/lib/swig/gnuradio_core.py b/gnuradio-core/src/lib/swig/gnuradio_core.py index 1fd558a11b..09d00fcdc1 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_core.py +++ b/gnuradio-core/src/lib/swig/gnuradio_core.py @@ -22,5 +22,3 @@ from gnuradio_core_runtime import * from gnuradio_core_general import * -from gnuradio_core_gengen import * -from gnuradio_core_io import * diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i b/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i deleted file mode 100644 index b90a5bab3e..0000000000 --- a/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009,2010 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -%include "gengen_swig_doc.i" - -#ifndef SWIGIMPORTED -%module(directors="1") gnuradio_core_gengen -#endif - - //%feature("autodoc", "1"); // generate python docstrings - -%include "gnuradio.i" // the common stuff - -%include "gengen.i" diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_io.i b/gnuradio-core/src/lib/swig/gnuradio_core_io.i deleted file mode 100644 index 522b12b347..0000000000 --- a/gnuradio-core/src/lib/swig/gnuradio_core_io.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009,2010 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -%include "io_swig_doc.i" - -#ifndef SWIGIMPORTED -%module(directors="1") gnuradio_core_io -#endif - - //%feature("autodoc", "1"); // generate python docstrings - -%include "gnuradio.i" // the common stuff - -%include "io.i" diff --git a/gnuradio-core/src/python/bin/microtune.py b/gnuradio-core/src/python/bin/microtune.py deleted file mode 100755 index fbe743f396..0000000000 --- a/gnuradio-core/src/python/bin/microtune.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# -*- Python -*- - -from gnuradio import gr -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import stdgui, fftsink -from optparse import OptionParser -from gnuradio import eng_notation - - -def main (): - parser = OptionParser (option_class=eng_option) - parser.add_option ("-g", "--gain", type="eng_float", default=-1, - help="set front end gain to GAIN [0,1000]") - parser.add_option ("-f", "--freq", type="eng_float", default=-1, - help="set front end center frequency to FREQ") - parser.add_option ("-t", "--type", type="string", default="4937", - help="select eval board type {4937 or 4702}") - parser.add_option ("-p", "--port", type="int", default=0, - help="parallel port eval board is attached to") - (options, args) = parser.parse_args () - - if options.type == "4937": - front_end = gr.microtune_4937_eval_board (options.port) - elif options.type == "4702": - front_end = gr.microtune_4702_eval_board (options.port) - else: - raise RuntimeError, "Invalid board type. Must be either -t 4937 or -t 4702" - - if options.gain != -1: - front_end.set_AGC (options.gain) - - if options.freq != -1: - if options.freq < 1e6: - options.freq = options.freq * 1e6 - - actual = front_end.set_RF_freq (options.freq) - print "microtune: actual freq = %s" % (eng_notation.num_to_str (actual),) - - -if __name__ == '__main__': - main () diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py b/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py index dfa67feffe..8597ca6497 100644 --- a/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py +++ b/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py @@ -206,7 +206,7 @@ class GrDataPlotterC(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_c([]) + return blocks.vector_source_c([]) def get_npts(self): self._npts = self.snk.nsamps() @@ -237,7 +237,7 @@ class GrDataPlotterF(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_f([]) + return blocks.vector_source_f([]) def get_npts(self): self._npts = self.snk.nsamps() @@ -265,7 +265,7 @@ class GrDataPlotterConst(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_c([]) + return blocks.vector_source_c([]) def get_npts(self): self._npts = self.snk.nsamps() @@ -304,7 +304,7 @@ class GrDataPlotterPsdC(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_c([]) + return blocks.vector_source_c([]) def get_npts(self): self._npts = self.snk.fft_size() @@ -337,7 +337,7 @@ class GrDataPlotterPsdF(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_f([]) + return blocks.vector_source_f([]) def get_npts(self): self._npts = self.snk.fft_size() @@ -367,7 +367,7 @@ class GrTimeRasterF(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_f([]) + return blocks.vector_source_f([]) def get_npts(self): self._npts = self.snk.num_cols() @@ -396,7 +396,7 @@ class GrTimeRasterB(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_b([]) + return blocks.vector_source_b([]) def get_npts(self): self._npts = self.snk.num_cols() diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/qa_cpp_py_binding.py b/gnuradio-core/src/python/gnuradio/ctrlport/qa_cpp_py_binding.py deleted file mode 100755 index 6de5d5fc9f..0000000000 --- a/gnuradio-core/src/python/gnuradio/ctrlport/qa_cpp_py_binding.py +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env python -# -# 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. -# - -# -# This program tests mixed python and c++ ctrlport exports in a single app -# - -import Ice -import sys, time, random, numpy -from gnuradio import gr, gr_unittest - -from gnuradio.ctrlport import GNURadio -from gnuradio import ctrlport -import os - -def get1(): - return "success" - -def get2(): - return "failure" - -class inc_class: - def __init__(self): - self.val = 1 - def pp(self): - self.val = self.val+1 - return self.val - -get3 = inc_class() - -def get4(): - random.seed(0) - rv = random.random() - return rv - -def get5(): - numpy.random.seed(0) - samp_t = numpy.random.randn(24)+1j*numpy.random.randn(24); - samp_f = numpy.fft.fft(samp_t); - log_pow_f = 20*numpy.log10(numpy.abs(samp_f)) - rv = list(log_pow_f) - return rv; - -def get6(): - numpy.random.seed(0) - samp_t = numpy.random.randn(1024)+1j*numpy.random.randn(1024); - rv = list(samp_t) - return rv; - -class test_cpp_py_binding(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - os.environ['GR_CONF_CONTROLPORT_ON'] = 'True' - - def tearDown(self): - self.tb = None - - def test_001(self): - v1 = gr.RPC_get_string("pyland", "v1", "unit_1_string", - "Python Exported String", "", "", "", - gr.DISPNULL) - v1.activate(get1) - - v2 = gr.RPC_get_string("pyland", "v2", "unit_2_string", - "Python Exported String", "", "", "", - gr.DISPNULL) - v2.activate(get2) - - v3 = gr.RPC_get_int("pyland", "v3", "unit_3_int", - "Python Exported Int", 0, 100, 1, - gr.DISPNULL) - v3.activate(get3.pp) - - v4 = gr.RPC_get_double("pyland", "time", "unit_4_time_double", - "Python Exported Double", 0, 1000, 1, - gr.DISPNULL) - v4.activate(get4) - - v5 = gr.RPC_get_vector_float("pyland", "fvec", "unit_5_float_vector", - "Python Exported Float Vector", [], [], [], - gr.DISPTIME | gr.DISPOPTCPLX) - v5.activate(get5) - - v6 = gr.RPC_get_vector_gr_complex("pyland", "cvec", "unit_6_gr_complex_vector", - "Python Exported Complex Vector", [], [], [], - gr.DISPXY | gr.DISPOPTSCATTER) - v6.activate(get6) - - # print some variables locally - val = get1() - rval = v1.get() - self.assertEqual(val, rval) - - val = get2() - rval = v2.get() - self.assertEqual(val, rval) - - val = get3.pp() - rval = v3.get() - self.assertEqual(val+1, rval) - - val = get4() - rval = v4.get() - self.assertEqual(val, rval) - - val = get5() - rval = v5.get() - self.assertComplexTuplesAlmostEqual(val, rval, 5) - - val = get6() - rval = v6.get() - self.assertComplexTuplesAlmostEqual(val, rval, 5) - - def test_002(self): - data = range(1,9) - - self.src = gr.vector_source_c(data) - self.p1 = gr.ctrlport_probe_c("aaa","C++ exported variable") - self.p2 = gr.ctrlport_probe_c("bbb","C++ exported variable") - probe_name = self.p2.alias() - - self.tb.connect(self.src, self.p1) - self.tb.connect(self.src, self.p2) - self.tb.start() - - # Probes return complex values as list of floats with re, im - # Imaginary parts of this data set are 0. - expected_result = [1, 0, 2, 0, 3, 0, 4, 0, - 5, 0, 6, 0, 7, 0, 8, 0] - - # Make sure we have time for flowgraph to run - time.sleep(0.1) - - # Get available endpoint - ep = gr.rpcmanager_get().endpoints()[0] - - # Initialize a simple Ice client from endpoint - ic = Ice.initialize(sys.argv) - base = ic.stringToProxy(ep) - radio = GNURadio.ControlPortPrx.checkedCast(base) - - # Get all exported knobs - ret = radio.get([probe_name + "::bbb"]) - for name in ret.keys(): - result = ret[name].value - self.assertEqual(result, expected_result) - - self.tb.stop() - -if __name__ == '__main__': - gr_unittest.run(test_cpp_py_binding, "test_cpp_py_binding.xml") - diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/qa_cpp_py_binding_set.py b/gnuradio-core/src/python/gnuradio/ctrlport/qa_cpp_py_binding_set.py deleted file mode 100755 index 4ca120099c..0000000000 --- a/gnuradio-core/src/python/gnuradio/ctrlport/qa_cpp_py_binding_set.py +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env python -# -# 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. -# - -# -# This program tests mixed python and c++ GRCP sets in a single app -# - -import Ice -import sys, time, random, numpy -from gnuradio import gr, gr_unittest - -from gnuradio.ctrlport import GNURadio -from gnuradio import ctrlport -import os - -class inc_class: - def __init__(self,val): - self.val = val; - - def _get(self): - #print "returning get (val = %s)"%(str(self.val)); - return self.val; - - def _set(self,val): - #print "updating val to %s"%(str(val)); - self.val = val; - return; - -getset1 = inc_class(10); -getset2 = inc_class(100.0); -getset3 = inc_class("test"); - -class test_cpp_py_binding_set(gr_unittest.TestCase): - def setUp(self): - self.tb = gr.top_block() - os.environ['GR_CONF_CONTROLPORT_ON'] = 'True' - - def tearDown(self): - self.tb = None - - def test_001(self): - - g1 = gr.RPC_get_int("pyland", "v1", "unit_1_int", - "Python Exported Int", 0, 100, 10, - gr.DISPNULL) - g1.activate(getset1._get) - s1 = gr.RPC_get_int("pyland", "v1", "unit_1_int", - "Python Exported Int", 0, 100, 10, - gr.DISPNULL) - s1.activate(getset1._set) - time.sleep(0.01) - - # test int variables - getset1._set(21) - val = getset1._get() - rval = g1.get() - self.assertEqual(val, rval) - - g2 = gr.RPC_get_float("pyland", "v2", "unit_2_float", - "Python Exported Float", -100, 1000.0, 100.0, - gr.DISPNULL) - g2.activate(getset2._get) - s2 = gr.RPC_get_float("pyland", "v2", "unit_2_float", - "Python Exported Float", -100, 1000.0, 100.0, - gr.DISPNULL) - s2.activate(getset2._set) - time.sleep(0.01) - - # test float variables - getset2._set(123.456) - val = getset2._get() - rval = g2.get() - self.assertAlmostEqual(val, rval, 4) - - g3 = gr.RPC_get_string("pyland", "v3", "unit_3_string", - "Python Exported String", "", "", "", - gr.DISPNULL) - g3.activate(getset3._get) - s3 = gr.RPC_get_string("pyland", "v3", "unit_3_string", - "Python Exported String", "", "", "", - gr.DISPNULL) - s3.activate(getset3._set) - time.sleep(0.01) - - # test string variables - getset3._set("third test") - val = getset3._get() - rval = g3.get() - self.assertEqual(val, rval) - - - def test_002(self): - data = range(1, 10) - - self.src = gr.vector_source_c(data, True) - self.p = gr.nop(gr.sizeof_gr_complex) - self.p.set_ctrlport_test(0); - probe_info = self.p.alias() - - self.tb.connect(self.src, self.p) - - # Get available endpoint - ep = gr.rpcmanager_get().endpoints()[0] - - # Initialize a simple Ice client from endpoint - ic = Ice.initialize(sys.argv) - base = ic.stringToProxy(ep) - radio = GNURadio.ControlPortPrx.checkedCast(base) - - self.tb.start() - - # Make sure we have time for flowgraph to run - time.sleep(0.1) - - # Get all exported knobs - key_name_test = probe_info+"::test" - ret = radio.get([key_name_test,]) - - ret[key_name_test].value = 10 - radio.set({key_name_test: ret[key_name_test]}) - - ret = radio.get([]) - result_test = ret[key_name_test].value - self.assertEqual(result_test, 10) - - self.tb.stop() - self.tb.wait() - -if __name__ == '__main__': - gr_unittest.run(test_cpp_py_binding_set, "test_cpp_py_binding_set.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py b/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py deleted file mode 100644 index 2c8cba5439..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py +++ /dev/null @@ -1,255 +0,0 @@ -# -# Copyright 2011-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. -# - -from gnuradio import gr, gr_unittest -import pmt -import numpy - -class add_2_f32_1_f32(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "add 2 f32", - in_sig = [numpy.float32, numpy.float32], - out_sig = [numpy.float32], - ) - - def work(self, input_items, output_items): - output_items[0][:] = input_items[0] + input_items[1] - return len(output_items[0]) - -class add_2_fc32_1_fc32(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "add 2 fc32", - in_sig = [numpy.complex64, numpy.complex64], - out_sig = [numpy.complex64], - ) - - def work(self, input_items, output_items): - output_items[0][:] = input_items[0] + input_items[1] - return len(output_items[0]) - -class convolve(gr.sync_block): - """ - A demonstration using block history to properly perform a convolution. - """ - def __init__(self): - gr.sync_block.__init__( - self, - name = "convolve", - in_sig = [numpy.float32], - out_sig = [numpy.float32] - ) - self._taps = [1, 0, 0, 0] - self.set_history(len(self._taps)) - - def work(self, input_items, output_items): - output_items[0][:] = numpy.convolve(input_items[0], self._taps, mode='valid') - return len(output_items[0]) - -class decim2x(gr.decim_block): - def __init__(self): - gr.decim_block.__init__( - self, - name = "decim2x", - in_sig = [numpy.float32], - out_sig = [numpy.float32], - decim = 2 - ) - - def work(self, input_items, output_items): - output_items[0][:] = input_items[0][::2] - return len(output_items[0]) - -class interp2x(gr.interp_block): - def __init__(self): - gr.interp_block.__init__( - self, - name = "interp2x", - in_sig = [numpy.float32], - out_sig = [numpy.float32], - interp = 2 - ) - - def work(self, input_items, output_items): - output_items[0][1::2] = input_items[0] - output_items[0][::2] = input_items[0] - return len(output_items[0]) - -class tag_source(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "tag source", - in_sig = None, - out_sig = [numpy.float32], - ) - - def work(self, input_items, output_items): - num_output_items = len(output_items[0]) - - #put code here to fill the output items... - - #make a new tag on the middle element every time work is called - count = self.nitems_written(0) + num_output_items/2 - key = pmt.string_to_symbol("example_key") - value = pmt.string_to_symbol("example_value") - self.add_item_tag(0, count, key, value) - - return num_output_items - -class tag_sink(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "tag sink", - in_sig = [numpy.float32], - out_sig = None, - ) - self.key = None - - def work(self, input_items, output_items): - num_input_items = len(input_items[0]) - - #put code here to process the input items... - - #print all the tags received in this work call - nread = self.nitems_read(0) - tags = self.get_tags_in_range(0, nread, nread+num_input_items) - for tag in tags: - #print tag.offset - #print pmt.symbol_to_string(tag.key) - #print pmt.symbol_to_string(tag.value) - self.key = pmt.symbol_to_string(tag.key) - - return num_input_items - -class fc32_to_f32_2(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "fc32_to_f32_2", - in_sig = [numpy.complex64], - out_sig = [(numpy.float32, 2)], - ) - - def work(self, input_items, output_items): - output_items[0][::,0] = numpy.real(input_items[0]) - output_items[0][::,1] = numpy.imag(input_items[0]) - return len(output_items[0]) - -class vector_to_stream(gr.interp_block): - def __init__(self, itemsize, nitems_per_block): - gr.interp_block.__init__( - self, - name = "vector_to_stream", - in_sig = [(itemsize, nitems_per_block)], - out_sig = [itemsize], - interp = nitems_per_block - ) - self.block_size = nitems_per_block - - def work(self, input_items, output_items): - n = 0 - for i in xrange(len(input_items[0])): - for j in xrange(self.block_size): - output_items[0][n] = input_items[0][i][j] - n += 1 - - return len(output_items[0]) - -class test_block_gateway(gr_unittest.TestCase): - - def test_add_f32(self): - tb = gr.top_block() - src0 = gr.vector_source_f([1, 3, 5, 7, 9], False) - src1 = gr.vector_source_f([0, 2, 4, 6, 8], False) - adder = add_2_f32_1_f32() - sink = gr.vector_sink_f() - tb.connect((src0, 0), (adder, 0)) - tb.connect((src1, 0), (adder, 1)) - tb.connect(adder, sink) - tb.run() - self.assertEqual(sink.data(), (1, 5, 9, 13, 17)) - - def test_add_fc32(self): - tb = gr.top_block() - src0 = gr.vector_source_c([1, 3j, 5, 7j, 9], False) - src1 = gr.vector_source_c([0, 2j, 4, 6j, 8], False) - adder = add_2_fc32_1_fc32() - sink = gr.vector_sink_c() - tb.connect((src0, 0), (adder, 0)) - tb.connect((src1, 0), (adder, 1)) - tb.connect(adder, sink) - tb.run() - self.assertEqual(sink.data(), (1, 5j, 9, 13j, 17)) - - def test_convolve(self): - tb = gr.top_block() - src = gr.vector_source_f([1, 2, 3, 4, 5, 6, 7, 8], False) - cv = convolve() - sink = gr.vector_sink_f() - tb.connect(src, cv, sink) - tb.run() - self.assertEqual(sink.data(), (1, 2, 3, 4, 5, 6, 7, 8)) - - def test_decim2x(self): - tb = gr.top_block() - src = gr.vector_source_f([1, 2, 3, 4, 5, 6, 7, 8], False) - d2x = decim2x() - sink = gr.vector_sink_f() - tb.connect(src, d2x, sink) - tb.run() - self.assertEqual(sink.data(), (1, 3, 5, 7)) - - def test_interp2x(self): - tb = gr.top_block() - src = gr.vector_source_f([1, 3, 5, 7, 9], False) - i2x = interp2x() - sink = gr.vector_sink_f() - tb.connect(src, i2x, sink) - tb.run() - self.assertEqual(sink.data(), (1, 1, 3, 3, 5, 5, 7, 7, 9, 9)) - - def test_tags(self): - src = tag_source() - sink = tag_sink() - head = gr.head(gr.sizeof_float, 50000) #should be enough items to get a tag through - tb = gr.top_block() - tb.connect(src, head, sink) - tb.run() - self.assertEqual(sink.key, "example_key") - - def test_fc32_to_f32_2(self): - tb = gr.top_block() - src = gr.vector_source_c([1+2j, 3+4j, 5+6j, 7+8j, 9+10j], False) - convert = fc32_to_f32_2() - v2s = vector_to_stream(numpy.float32, 2) - sink = gr.vector_sink_f() - tb.connect(src, convert, v2s, sink) - tb.run() - self.assertEqual(sink.data(), (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) - -if __name__ == '__main__': - gr_unittest.run(test_block_gateway, "test_block_gateway.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_copy.py b/gnuradio-core/src/python/gnuradio/gr/qa_copy.py deleted file mode 100755 index 68c8e451f3..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_copy.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009,2010 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. -# - -from gnuradio import gr, gr_unittest - -class test_copy(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_copy (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - expected_result = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - src = gr.vector_source_b(src_data) - op = gr.copy(gr.sizeof_char) - dst = gr.vector_sink_b() - self.tb.connect(src, op, dst) - self.tb.run() - dst_data = dst.data() - self.assertEqual(expected_result, dst_data) - - def test_copy_drop (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - expected_result = () - src = gr.vector_source_b(src_data) - op = gr.copy(gr.sizeof_char) - op.set_enabled(False) - dst = gr.vector_sink_b() - self.tb.connect(src, op, dst) - self.tb.run() - dst_data = dst.data() - self.assertEqual(expected_result, dst_data) - - -if __name__ == '__main__': - gr_unittest.run(test_copy, "test_copy.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_endian_swap.py b/gnuradio-core/src/python/gnuradio/gr/qa_endian_swap.py deleted file mode 100644 index 4d2555cc4d..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_endian_swap.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011,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. -# - -from gnuradio import gr, gr_unittest -import ctypes - -class test_endian_swap (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - - src_data = [1,2,3,4] - expected_result = [256, 512, 768, 1024]; - - src = gr.vector_source_s(src_data) - op = gr.endian_swap(2) - dst = gr.vector_sink_s() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - - def test_002(self): - - src_data = [1,2,3,4] - expected_result = [16777216, 33554432, 50331648, 67108864]; - - src = gr.vector_source_i(src_data) - op = gr.endian_swap(4) - dst = gr.vector_sink_i() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_endian_swap, "test_endian_swap.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_head.py b/gnuradio-core/src/python/gnuradio/gr/qa_head.py deleted file mode 100755 index d7cb354dcb..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_head.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 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. -# - -from gnuradio import gr, gr_unittest - -class test_head (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_head (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - expected_result = (1, 2, 3, 4) - src1 = gr.vector_source_i (src_data) - op = gr.head (gr.sizeof_int, 4) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op) - self.tb.connect (op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - -if __name__ == '__main__': - gr_unittest.run(test_head, "test_head.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py b/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py deleted file mode 100755 index 9ba48599af..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py +++ /dev/null @@ -1,397 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr, gr_unittest -import numpy - -class add_ff(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "add_ff", - in_sig = [numpy.float32, numpy.float32], - out_sig = [numpy.float32], - ) - - def work(self, input_items, output_items): - output_items[0][:] = input_items[0] + input_items[1] - return len(output_items[0]) - -class multiply_const_ff(gr.sync_block): - def __init__(self, k): - gr.sync_block.__init__( - self, - name = "multiply_ff", - in_sig = [numpy.float32], - out_sig = [numpy.float32], - ) - self.k = k - - def work(self, input_items, output_items): - output_items[0][:] = map(lambda x: self.k*x, input_items[0]) - return len(output_items[0]) - -class test_hier_block2(gr_unittest.TestCase): - - def setUp(self): - pass - - def tearDown(self): - pass - - def test_001_make(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - self.assertEqual("test_block", hblock.name()) - self.assertEqual(1, hblock.input_signature().max_streams()) - self.assertEqual(1, hblock.output_signature().min_streams()) - self.assertEqual(1, hblock.output_signature().max_streams()) - self.assertEqual(gr.sizeof_int, hblock.output_signature().sizeof_stream_item(0)) - - def test_002_connect_input(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - hblock.connect(hblock, nop1) - - def test_004_connect_output(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - hblock.connect(nop1, hblock) - - def test_005_connect_output_in_use(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - nop2 = gr.nop(gr.sizeof_int) - hblock.connect(nop1, hblock) - self.assertRaises(ValueError, - lambda: hblock.connect(nop2, hblock)) - - def test_006_connect_invalid_src_port_neg(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - self.assertRaises(ValueError, - lambda: hblock.connect((hblock, -1), nop1)) - - def test_005_connect_invalid_src_port_exceeds(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - self.assertRaises(ValueError, - lambda: hblock.connect((hblock, 1), nop1)) - - def test_007_connect_invalid_dst_port_neg(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - nop2 = gr.nop(gr.sizeof_int) - self.assertRaises(ValueError, - lambda: hblock.connect(nop1, (nop2, -1))) - - def test_008_connect_invalid_dst_port_exceeds(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.null_sink(gr.sizeof_int) - nop2 = gr.null_sink(gr.sizeof_int) - self.assertRaises(ValueError, - lambda: hblock.connect(nop1, (nop2, 1))) - - def test_009_check_topology(self): - hblock = gr.top_block("test_block") - hblock.check_topology(0, 0) - - def test_010_run(self): - expected = (1.0, 2.0, 3.0, 4.0) - hblock = gr.top_block("test_block") - src = gr.vector_source_f(expected, False) - sink1 = gr.vector_sink_f() - sink2 = gr.vector_sink_f() - hblock.connect(src, sink1) - hblock.connect(src, sink2) - hblock.run() - actual1 = sink1.data() - actual2 = sink2.data() - self.assertEquals(expected, actual1) - self.assertEquals(expected, actual2) - - def test_012_disconnect_input(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - hblock.connect(hblock, nop1) - hblock.disconnect(hblock, nop1) - - def test_013_disconnect_input_not_connected(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - nop2 = gr.nop(gr.sizeof_int) - hblock.connect(hblock, nop1) - self.assertRaises(ValueError, - lambda: hblock.disconnect(hblock, nop2)) - - def test_014_disconnect_input_neg(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - hblock.connect(hblock, nop1) - self.assertRaises(ValueError, - lambda: hblock.disconnect((hblock, -1), nop1)) - - def test_015_disconnect_input_exceeds(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - hblock.connect(hblock, nop1) - self.assertRaises(ValueError, - lambda: hblock.disconnect((hblock, 1), nop1)) - - def test_016_disconnect_output(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - hblock.connect(nop1, hblock) - hblock.disconnect(nop1, hblock) - - def test_017_disconnect_output_not_connected(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - nop2 = gr.nop(gr.sizeof_int) - hblock.connect(nop1, hblock) - self.assertRaises(ValueError, - lambda: hblock.disconnect(nop2, hblock)) - - def test_018_disconnect_output_neg(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - hblock.connect(hblock, nop1) - self.assertRaises(ValueError, - lambda: hblock.disconnect(nop1, (hblock, -1))) - - def test_019_disconnect_output_exceeds(self): - hblock = gr.hier_block2("test_block", - gr.io_signature(1,1,gr.sizeof_int), - gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - hblock.connect(nop1, hblock) - self.assertRaises(ValueError, - lambda: hblock.disconnect(nop1, (hblock, 1))) - - def test_020_run(self): - hblock = gr.top_block("test_block") - data = (1.0, 2.0, 3.0, 4.0) - src = gr.vector_source_f(data, False) - dst = gr.vector_sink_f() - hblock.connect(src, dst) - hblock.run() - self.assertEquals(data, dst.data()) - - def test_021_connect_single(self): - hblock = gr.top_block("test_block") - blk = gr.hier_block2("block", - gr.io_signature(0, 0, 0), - gr.io_signature(0, 0, 0)) - hblock.connect(blk) - - def test_022_connect_single_with_ports(self): - hblock = gr.top_block("test_block") - blk = gr.hier_block2("block", - gr.io_signature(1, 1, 1), - gr.io_signature(1, 1, 1)) - self.assertRaises(ValueError, - lambda: hblock.connect(blk)) - - def test_023_connect_single_twice(self): - hblock = gr.top_block("test_block") - blk = gr.hier_block2("block", - gr.io_signature(0, 0, 0), - gr.io_signature(0, 0, 0)) - hblock.connect(blk) - self.assertRaises(ValueError, - lambda: hblock.connect(blk)) - - def test_024_disconnect_single(self): - hblock = gr.top_block("test_block") - blk = gr.hier_block2("block", - gr.io_signature(0, 0, 0), - gr.io_signature(0, 0, 0)) - hblock.connect(blk) - hblock.disconnect(blk) - - def test_025_disconnect_single_not_connected(self): - hblock = gr.top_block("test_block") - blk = gr.hier_block2("block", - gr.io_signature(0, 0, 0), - gr.io_signature(0, 0, 0)) - self.assertRaises(ValueError, - lambda: hblock.disconnect(blk)) - - def test_026_run_single(self): - expected_data = (1.0,) - tb = gr.top_block("top_block") - hb = gr.hier_block2("block", - gr.io_signature(0, 0, 0), - gr.io_signature(0, 0, 0)) - src = gr.vector_source_f(expected_data) - dst = gr.vector_sink_f() - hb.connect(src, dst) - tb.connect(hb) - tb.run() - self.assertEquals(expected_data, dst.data()) - - def test_027a_internally_unconnected_input(self): - tb = gr.top_block() - hb = gr.hier_block2("block", - gr.io_signature(1, 1, 1), - gr.io_signature(1, 1, 1)) - hsrc = gr.vector_source_b([1,]) - hb.connect(hsrc, hb) # wire output internally - src = gr.vector_source_b([1, ]) - dst = gr.vector_sink_b() - tb.connect(src, hb, dst) # hb's input is not connected internally - self.assertRaises(RuntimeError, - lambda: tb.run()) - - def test_027b_internally_unconnected_output(self): - tb = gr.top_block() - - hb = gr.hier_block2("block", - gr.io_signature(1, 1, 1), - gr.io_signature(1, 1, 1)) - hdst = gr.vector_sink_b() - hb.connect(hb, hdst) # wire input internally - src = gr.vector_source_b([1, ]) - dst = gr.vector_sink_b() - tb.connect(src, hb, dst) # hb's output is not connected internally - self.assertRaises(RuntimeError, - lambda: tb.run()) - - def test_027c_fully_unconnected_output(self): - tb = gr.top_block() - hb = gr.hier_block2("block", - gr.io_signature(1, 1, 1), - gr.io_signature(1, 1, 1)) - hsrc = gr.vector_sink_b() - hb.connect(hb, hsrc) # wire input internally - src = gr.vector_source_b([1, ]) - dst = gr.vector_sink_b() - tb.connect(src, hb) # hb's output is not connected internally or externally - self.assertRaises(RuntimeError, - lambda: tb.run()) - - def test_027d_fully_unconnected_input(self): - tb = gr.top_block() - hb = gr.hier_block2("block", - gr.io_signature(1, 1, 1), - gr.io_signature(1, 1, 1)) - hdst = gr.vector_source_b([1,]) - hb.connect(hdst, hb) # wire output internally - dst = gr.vector_sink_b() - tb.connect(hb, dst) # hb's input is not connected internally or externally - self.assertRaises(RuntimeError, - lambda: tb.run()) - - def test_028_singleton_reconfigure(self): - tb = gr.top_block() - hb = gr.hier_block2("block", - gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) - src = gr.vector_source_b([1, ]) - dst = gr.vector_sink_b() - hb.connect(src, dst) - tb.connect(hb) # Singleton connect - tb.lock() - tb.disconnect_all() - tb.connect(src, dst) - tb.unlock() - - def test_029_singleton_disconnect(self): - tb = gr.top_block() - src = gr.vector_source_b([1, ]) - dst = gr.vector_sink_b() - tb.connect(src, dst) - tb.disconnect(src) # Singleton disconnect - tb.connect(src, dst) - tb.run() - self.assertEquals(dst.data(), (1,)) - - def test_030_nested_input(self): - tb = gr.top_block() - src = gr.vector_source_b([1,]) - hb1 = gr.hier_block2("hb1", - gr.io_signature(1, 1, gr.sizeof_char), - gr.io_signature(0, 0, 0)) - hb2 = gr.hier_block2("hb2", - gr.io_signature(1, 1, gr.sizeof_char), - gr.io_signature(0, 0, 0)) - dst = gr.vector_sink_b() - tb.connect(src, hb1) - hb1.connect(hb1, hb2) - hb2.connect(hb2, gr.kludge_copy(gr.sizeof_char), dst) - tb.run() - self.assertEquals(dst.data(), (1,)) - - def test_031_multiple_internal_inputs(self): - tb = gr.top_block() - src = gr.vector_source_f([1.0,]) - hb = gr.hier_block2("hb", - gr.io_signature(1, 1, gr.sizeof_float), - gr.io_signature(1, 1, gr.sizeof_float)) - m1 = multiply_const_ff(1.0) - m2 = multiply_const_ff(2.0) - add = add_ff() - hb.connect(hb, m1) # m1 is connected to hb external input #0 - hb.connect(hb, m2) # m2 is also connected to hb external input #0 - hb.connect(m1, (add, 0)) - hb.connect(m2, (add, 1)) - hb.connect(add, hb) # add is connected to hb external output #0 - dst = gr.vector_sink_f() - tb.connect(src, hb, dst) - tb.run() - self.assertEquals(dst.data(), (3.0,)) - - def test_032_nested_multiple_internal_inputs(self): - tb = gr.top_block() - src = gr.vector_source_f([1.0,]) - hb = gr.hier_block2("hb", - gr.io_signature(1, 1, gr.sizeof_float), - gr.io_signature(1, 1, gr.sizeof_float)) - hb2 = gr.hier_block2("hb", - gr.io_signature(1, 1, gr.sizeof_float), - gr.io_signature(1, 1, gr.sizeof_float)) - - m1 = multiply_const_ff(1.0) - m2 = multiply_const_ff(2.0) - add = add_ff() - hb2.connect(hb2, m1) # m1 is connected to hb2 external input #0 - hb2.connect(hb2, m2) # m2 is also connected to hb2 external input #0 - hb2.connect(m1, (add, 0)) - hb2.connect(m2, (add, 1)) - hb2.connect(add, hb2) # add is connected to hb2 external output #0 - hb.connect(hb, hb2, hb) # hb as hb2 as nested internal block - dst = gr.vector_sink_f() - tb.connect(src, hb, dst) - tb.run() - self.assertEquals(dst.data(), (3.0,)) - - -if __name__ == "__main__": - gr_unittest.run(test_hier_block2, "test_hier_block2.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_kludge_copy.py b/gnuradio-core/src/python/gnuradio/gr/qa_kludge_copy.py deleted file mode 100755 index 2a3aa44b1b..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_kludge_copy.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2010 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. -# - -from gnuradio import gr, gr_unittest -import math -import random - - -class test_kludge_copy(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - self.rng = random.Random() - self.rng.seed(0) - - def tearDown(self): - del self.tb - del self.rng - - def make_random_int_tuple(self, L): - result = [] - for x in range(L): - result.append(self.rng.randint(int(-1e9), int(+1e9))) - return tuple(result) - - - def test_001(self): - # 1 input stream; 1 output stream - src0_data = self.make_random_int_tuple(16000) - src0 = gr.vector_source_i(src0_data) - op = gr.kludge_copy(gr.sizeof_int) - dst0 = gr.vector_sink_i() - self.tb.connect(src0, op, dst0) - self.tb.run() - dst0_data = dst0.data() - self.assertEqual(src0_data, dst0_data) - - def test_002(self): - # 2 input streams; 2 output streams - src0_data = self.make_random_int_tuple(16000) - src1_data = self.make_random_int_tuple(16000) - src0 = gr.vector_source_i(src0_data) - src1 = gr.vector_source_i(src1_data) - op = gr.kludge_copy(gr.sizeof_int) - dst0 = gr.vector_sink_i() - dst1 = gr.vector_sink_i() - self.tb.connect(src0, (op, 0), dst0) - self.tb.connect(src1, (op, 1), dst1) - self.tb.run() - dst0_data = dst0.data() - dst1_data = dst1.data() - self.assertEqual(src0_data, dst0_data) - self.assertEqual(src1_data, dst1_data) - - # Note: this is disabled due to triggering bug in ticket:181 - # It only occurs with new top block code - def xtest_003(self): - # number of input streams != number of output streams - src0_data = self.make_random_int_tuple(16000) - src1_data = self.make_random_int_tuple(16000) - src0 = gr.vector_source_i(src0_data) - src1 = gr.vector_source_i(src1_data) - op = gr.kludge_copy(gr.sizeof_int) - dst0 = gr.vector_sink_i() - dst1 = gr.vector_sink_i() - self.tb.connect(src0, (op, 0), dst0) - self.tb.connect(src1, (op, 1)) - self.assertRaises(ValueError, self.tb.run) - -if __name__ == '__main__': - gr_unittest.run(test_kludge_copy, "test_kludge_copy.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_python_message_passing.py b/gnuradio-core/src/python/gnuradio/gr/qa_python_message_passing.py deleted file mode 100644 index 51f8ede4db..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_python_message_passing.py +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2013 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. -# - -from gnuradio import gr, gr_unittest -try: import pmt -except: from gruel import pmt -import numpy -import time - -# Simple block to generate messages -class message_generator(gr.sync_block): - def __init__(self, msg_list, msg_interval): - gr.sync_block.__init__( - self, - name = "message generator", - in_sig = [numpy.float32], - out_sig = None - ) - self.msg_list = msg_list - self.msg_interval = msg_interval - self.msg_ctr = 0 - self.message_port_register_out(pmt.intern('out_port')) - - - def work(self, input_items, output_items): - inLen = len(input_items[0]) - while self.msg_ctr < len(self.msg_list) and \ - (self.msg_ctr * self.msg_interval) < \ - (self.nitems_read(0) + inLen): - self.message_port_pub(pmt.intern('out_port'), - self.msg_list[self.msg_ctr]) - self.msg_ctr += 1 - return inLen - -# Simple block to consume messages -class message_consumer(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "message consumer", - in_sig = None, - out_sig = None - ) - self.msg_list = [] - self.message_port_register_in(pmt.intern('in_port')) - self.set_msg_handler(pmt.intern('in_port'), - self.handle_msg) - - def handle_msg(self, msg): - # Create a new PMT from long value and put in list - self.msg_list.append(pmt.from_long(pmt.to_long(msg))) - -class test_python_message_passing(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_000(self): - num_msgs = 10 - msg_interval = 1000 - msg_list = [] - for i in range(num_msgs): - msg_list.append(pmt.from_long(i)) - - # Create vector source with dummy data to trigger messages - src_data = [] - for i in range(num_msgs*msg_interval): - src_data.append(float(i)) - src = gr.vector_source_f(src_data, False) - msg_gen = message_generator(msg_list, msg_interval) - msg_cons = message_consumer() - - # Connect vector source to message gen - self.tb.connect(src, msg_gen) - - # Connect message generator to message consumer - self.tb.msg_connect(msg_gen, 'out_port', msg_cons, 'in_port') - - # Verify that the messgae port query functions work - self.assertEqual(pmt.symbol_to_string(pmt.vector_ref( - msg_gen.message_ports_out(), 0)), 'out_port') - self.assertEqual(pmt.symbol_to_string(pmt.vector_ref( - msg_cons.message_ports_in(), 0)), 'in_port') - - # Run to verify message passing - self.tb.start() - - # Wait for all messages to be sent - while msg_gen.msg_ctr < num_msgs: - time.sleep(0.5) - self.tb.stop() - self.tb.wait() - - # Verify that the message consumer got all the messages - self.assertEqual(num_msgs, len(msg_cons.msg_list)) - for i in range(num_msgs): - self.assertTrue(pmt.equal(msg_list[i], msg_cons.msg_list[i])) - -if __name__ == '__main__': - gr_unittest.run(test_python_message_passing, - 'test_python_message_passing.xml') diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_skiphead.py b/gnuradio-core/src/python/gnuradio/gr/qa_skiphead.py deleted file mode 100755 index 1e730398c7..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_skiphead.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007,2010 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. -# - -from gnuradio import gr, gr_unittest - -class test_skiphead (gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block () - self.src_data = [int(x) for x in range(65536)] - - def tearDown(self): - self.tb = None - - def test_skip_0(self): - skip_cnt = 0 - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - def test_skip_1(self): - skip_cnt = 1 - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - def test_skip_1023(self): - skip_cnt = 1023 - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - def test_skip_6339(self): - skip_cnt = 6339 - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - def test_skip_12678(self): - skip_cnt = 12678 - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - def test_skip_all(self): - skip_cnt = len(self.src_data) - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - -if __name__ == '__main__': - gr_unittest.run(test_skiphead, "test_skiphead.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py b/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py deleted file mode 100755 index acc06dfded..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -# 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. -# - -from gnuradio import gr, gr_unittest -import math - -class test_vector_insert(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - src_data = [float(x) for x in range(16)] - expected_result = tuple(src_data) - - period = 9177; - offset = 0; - - src = gr.null_source(1) - head = gr.head(1, 10000000); - ins = gr.vector_insert_b([1], period, offset); - dst = gr.vector_sink_b() - - self.tb.connect(src, head, ins, dst) - self.tb.run() - result_data = dst.data() - - for i in range(10000): - if(i%period == offset): - self.assertEqual(1, result_data[i]) - else: - self.assertEqual(0, result_data[i]) - -if __name__ == '__main__': - gr_unittest.run(test_vector_insert, "test_vector_insert.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_vector_map.py b/gnuradio-core/src/python/gnuradio/gr/qa_vector_map.py deleted file mode 100644 index 12f4be5898..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_vector_map.py +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env python -# -# 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. -# - -from gnuradio import gr, gr_unittest -import math - -class test_vector_map(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block() - - def tearDown (self): - self.tb = None - - def test_reversing(self): - # Chunk data in blocks of N and reverse the block contents. - N = 5 - src_data = range(0, 20) - expected_result = [] - for i in range(N-1, len(src_data), N): - for j in range(0, N): - expected_result.append(1.0*(i-j)) - mapping = [list(reversed([(0, i) for i in range(0, N)]))] - src = gr.vector_source_f(src_data, False, N) - vmap = gr.vector_map(gr.sizeof_float, (N, ), mapping) - dst = gr.vector_sink_f(N) - self.tb.connect(src, vmap, dst) - self.tb.run() - result_data = list(dst.data()) - self.assertEqual(expected_result, result_data) - - def test_vector_to_streams(self): - # Split an input vector into N streams. - N = 5 - M = 20 - src_data = range(0, M) - expected_results = [] - for n in range(0, N): - expected_results.append(range(n, M, N)) - mapping = [[(0, n)] for n in range(0, N)] - src = gr.vector_source_f(src_data, False, N) - vmap = gr.vector_map(gr.sizeof_float, (N, ), mapping) - dsts = [gr.vector_sink_f(1) for n in range(0, N)] - self.tb.connect(src, vmap) - for n in range(0, N): - self.tb.connect((vmap, n), dsts[n]) - self.tb.run() - for n in range(0, N): - result_data = list(dsts[n].data()) - self.assertEqual(expected_results[n], result_data) - - def test_interleaving(self): - # Takes 3 streams (a, b and c) - # Outputs 2 streams. - # First (d) is interleaving of a and b. - # Second (e) is interleaving of a and b and c. c is taken in - # chunks of 2 which are reversed. - A = (1, 2, 3, 4, 5) - B = (11, 12, 13, 14, 15) - C = (99, 98, 97, 96, 95, 94, 93, 92, 91, 90) - expected_D = (1, 11, 2, 12, 3, 13, 4, 14, 5, 15) - expected_E = (1, 11, 98, 99, 2, 12, 96, 97, 3, 13, 94, 95, - 4, 14, 92, 93, 5, 15, 90, 91) - mapping = [[(0, 0), (1, 0)], # mapping to produce D - [(0, 0), (1, 0), (2, 1), (2, 0)], # mapping to produce E - ] - srcA = gr.vector_source_f(A, False, 1) - srcB = gr.vector_source_f(B, False, 1) - srcC = gr.vector_source_f(C, False, 2) - vmap = gr.vector_map(gr.sizeof_int, (1, 1, 2), mapping) - dstD = gr.vector_sink_f(2) - dstE = gr.vector_sink_f(4) - self.tb.connect(srcA, (vmap, 0)) - self.tb.connect(srcB, (vmap, 1)) - self.tb.connect(srcC, (vmap, 2)) - self.tb.connect((vmap, 0), dstD) - self.tb.connect((vmap, 1), dstE) - self.tb.run() - self.assertEqual(expected_D, dstD.data()) - self.assertEqual(expected_E, dstE.data()) - - - -if __name__ == '__main__': - gr_unittest.run(test_vector_map, "test_vector_map.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_vector_sink_source.py b/gnuradio-core/src/python/gnuradio/gr/qa_vector_sink_source.py deleted file mode 100755 index 64cbbe72a3..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_vector_sink_source.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008,2010 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. -# - -from gnuradio import gr, gr_unittest -import math - -class test_vector_sink_source(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - src_data = [float(x) for x in range(16)] - expected_result = tuple(src_data) - - src = gr.vector_source_f(src_data) - dst = gr.vector_sink_f() - - self.tb.connect(src, dst) - self.tb.run() - result_data = dst.data() - self.assertEqual(expected_result, result_data) - - def test_002(self): - src_data = [float(x) for x in range(16)] - expected_result = tuple(src_data) - - src = gr.vector_source_f(src_data, False, 2) - dst = gr.vector_sink_f(2) - - self.tb.connect(src, dst) - self.tb.run() - result_data = dst.data() - self.assertEqual(expected_result, result_data) - - def test_003(self): - src_data = [float(x) for x in range(16)] - expected_result = tuple(src_data) - self.assertRaises(ValueError, lambda : gr.vector_source_f(src_data, False, 3)) - -if __name__ == '__main__': - gr_unittest.run(test_vector_sink_source, "test_vector_sink_source.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt index 7d48f35121..d77da24073 100644 --- a/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt +++ b/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt @@ -26,10 +26,8 @@ GR_PYTHON_INSTALL(FILES 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 diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/lmx2306.py b/gnuradio-core/src/python/gnuradio/gruimpl/lmx2306.py deleted file mode 100755 index aa4efc3e9c..0000000000 --- a/gnuradio-core/src/python/gnuradio/gruimpl/lmx2306.py +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env 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 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. -# - -'''Control National LMX2306 based frequency synthesizer''' - -from gnuradio import gr -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -# bottom two bits of 21 bit word select which register to program - -R_REG = 0x0 -AB_REG = 0x1 -F_REG = 0x2 - -F_counter_reset = (1 << 2) -F_phase_detector_polarity = (1 << 7) - -F_LD_tri_state = (0 << 4) -F_LD_R_divider_output = (4 << 4) -F_LD_N_divider_output = (2 << 4) -F_LD_serial_data_output = (6 << 4) -F_LD_digital_lock_detect = (1 << 4) -F_LD_open_drain = (5 << 4) -F_LD_high = (3 << 4) -F_LD_low = (7 << 4) - -# F_default = F_LD_digital_lock_detect | F_phase_detector_polarity -F_default = F_LD_open_drain | F_phase_detector_polarity - -# -# 4 control pins: -# CE always high -# LE load enable. When LE goes high, data stored in the shift register -# is loaded into one of the three registers -# CLK data is clocked in on the rising edge -# DATA single data bit. Entered MSB first - -DB_CLK = (1 << 0) -DB_DATA = (1 << 1) -DB_LE = (1 << 2) -DB_CE = (1 << 3) - -class lmx2306 (object): - '''Control the National LMX2306 PLL''' - __slots__ = ['pp', 'shadow', 'fosc', 'r', 'step_size', 'verbose'] - def __init__ (self, fosc, step_size, which_pp = 0): - '''FOSC is the frequency of the reference oscillator, - STEP_SIZE is the step between valid frequencies, - WHICH_PP specifies which parallel port to use - ''' - self.pp = gr.make_ppio (which_pp) - self.shadow = DB_CE - self.pp.lock () - self.pp.write_data (self.shadow) - self.pp.unlock () - self.verbose = False - self._set_fosc (fosc) - self._set_step (step_size) - - - def program (self, r, a, b): - if self.verbose: - print "lmx2306: r = %d a = %d b = %d" % (r, a, b) - self.pp.lock () - self._write_word (F_REG | F_default | F_counter_reset) - self._write_word (R_REG | ((r & 0x3fff) << 2)) - self._write_word (AB_REG | ((a & 0x1f) << 2) | ((b & 0x1fff) << 7)) - self._write_word (F_REG | F_default) - self.pp.unlock () - - def set_freq (self, freq): - '''Set the PLL frequency to FREQ - - Return the actual freq value set. It will be rounded down to a - multiple of step_size - ''' - divisor = int (freq / self.step_size) - actual = divisor * self.step_size - (a, b) = self._compute_ab (divisor) - self.program (self.r, a, b) - return actual - - # ---------------------------------------------------------------- - - def _set_fosc (self, ref_oscillator_freq): - self.fosc = ref_oscillator_freq - - def _set_step (self, step_size): - r = int (self.fosc / step_size) - if r * step_size != self.fosc: - raise ValueError, "step_size is not a factor of self.fosc" - if r < 3 or r > 16383: - raise ValueError, "r is out of range" - self.r = r - self.step_size = step_size - - def _compute_ab (self, divisor): - b = divisor / 8 - a = divisor - (b * 8) - if b < 3 or b > 8191 or a > b: - raise ValueError, "Invalid divisor" - return (a, b) - - def _write_word (self, w): - for i in range(21): - if w & (1 << 20): - self._set_DATA_1 () - else: - self._set_DATA_0 () - w = (w << 1) & 0x0ffffff - self._set_CLK_1 () - self._set_CLK_0 () - self._set_LE_1 () - self._set_LE_0 () - - def _set_LE_0 (self): - self.shadow = self.shadow & ~DB_LE - self.pp.write_data (self.shadow) - - def _set_LE_1 (self): - self.shadow = self.shadow | DB_LE - self.pp.write_data (self.shadow) - - def _set_CLK_0 (self): - self.shadow = self.shadow & ~DB_CLK - self.pp.write_data (self.shadow) - - def _set_CLK_1 (self): - self.shadow = self.shadow | DB_CLK - self.pp.write_data (self.shadow) - - def _set_DATA_0 (self): - self.shadow = self.shadow & ~DB_DATA - self.pp.write_data (self.shadow) - - def _set_DATA_1 (self): - self.shadow = self.shadow | DB_DATA - self.pp.write_data (self.shadow) - -if __name__ == '__main__': - parser = OptionParser (option_class=eng_option) - parser.add_option ("-o", "--fosc", type="eng_float", default=32e6, - help="set reference oscillator freq to FREQ", metavar="FREQ") - parser.add_option ("-s", "--step-size", type="eng_float", default=10e3, - help="set the frequency step size to STEP_SIZE") - parser.add_option ("-f", "--freq", type="eng_float", default=430e6, - help="set VCO frequency to FREQ") - parser.add_option ("-v", "--verbose", action="store_true", default=False) - (options, args) = parser.parse_args () - - if options.verbose: - print "fosc = %s step = %s fvco = %s" % ( - eng_notation.num_to_str (options.fosc), - eng_notation.num_to_str (options.step_size), - eng_notation.num_to_str (options.freq)) - - lmx = lmx2306 (options.fosc, options.step_size) - lmx.verbose = options.verbose - - actual = lmx.set_freq (options.freq) - - if options.verbose: - print "fvco_actual = %s delta = %s" % ( - eng_notation.num_to_str (actual), - eng_notation.num_to_str (options.freq - actual)) diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/sdr_1000.py b/gnuradio-core/src/python/gnuradio/gruimpl/sdr_1000.py deleted file mode 100644 index 5192a71554..0000000000 --- a/gnuradio-core/src/python/gnuradio/gruimpl/sdr_1000.py +++ /dev/null @@ -1,84 +0,0 @@ -# -# Copyright 2003,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 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. -# - -from gnuradio import gr - -class sdr_1000 (gr.sdr_1000_base): - "Control the DDS on the SDR-1000" - def __init__(self, pport = 0): - gr.sdr_1000_base.__init__(self, pport) - self.write_latch (3, 0x00, 0xC0) # Reset low, WRS/ low - self.write_reg (0x20, 0x40) - - def write_reg(self, addr, data): - self.write_latch (3, addr & 0x3f, 0x3f) - self.write_latch (2, data, 0xff) - self.write_latch (3, 0x40, 0x40) - self.write_latch (3, 0x00, 0x40) - - def set_freq(self, freq): - self.set_band (freq) - ftw = freq / 200e6; - for i in xrange(6): - word = int(ftw * 256) - ftw = ftw*256 - word - # print (('%d [%02x]') % (i, word)) - self.write_reg (4+i, word) - - def set_band (self, freq): - if freq <= 2.25e6: - band = 0 - elif freq <= 5.5e6: - band = 1 - elif freq <= 11e6: - band = 3 # due to wiring mistake on board - elif freq <= 22e6: - band = 2 # due to wiring mistake on board - elif freq <= 37.5e6: - band = 4 - else: - band = 5 - - self.write_latch (1, 1 << band, 0x3f) - - def set_bit (self, reg, bit, state): - val = 0x00 - if state: val = 1<<bit - self.write_latch (reg, val, 1<<bit) - - def set_tx (self, on = 1): - self.set_bit(1, 6, on) - - def set_rx (self): - self.set_bit(1, 6, 0) - - def set_gain (self, high): - self.set_bit(0, 7, high) - - def set_mute (self, mute = 1): - self.set_bit(1, 7, mute) - - def set_unmute (self): - self.set_bit(1, 7, 0) - - def set_external_pin (self, pin, on = 1): - assert (pin < 8 and pin > 0), "Out of range 1..7" - self.set_bit(0, pin-1, on) diff --git a/gnuradio-core/src/tests/CMakeLists.txt b/gnuradio-core/src/tests/CMakeLists.txt index ef58cf9ef5..7723680dd9 100644 --- a/gnuradio-core/src/tests/CMakeLists.txt +++ b/gnuradio-core/src/tests/CMakeLists.txt @@ -43,7 +43,8 @@ link_directories(${LOG4CPP_LIBRARY_DIRS}) # Build benchmarks and non-registered tests ######################################################################## set(tests_not_run #single source per test - test_runtime.cc + benchmark_nco.cc + benchmark_vco.cc test_general.cc test_vmcircbuf.cc ) diff --git a/gnuradio-core/src/tests/benchmark_nco.cc b/gnuradio-core/src/tests/benchmark_nco.cc new file mode 100644 index 0000000000..20d53e410f --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_nco.cc @@ -0,0 +1,220 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,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 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 <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_nco.h> +#include <gr_fxpt_nco.h> +#include <string.h> + +#define ITERATIONS 20000000 +#define BLOCK_SIZE (10 * 1000) // fits in cache + +#define FREQ 5003.123 + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (void test (float *x, float *y), const char *implementation_name) +{ +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + float output[2*BLOCK_SIZE]; + float *x = &output[0], *y = &output[BLOCK_SIZE]; + + // touch memory + memset(output, 0, 2*BLOCK_SIZE*sizeof(float)); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); +#endif + // do the actual work + + test (x, y); + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end = (double) clock () * (1000000. / CLOCKS_PER_SEC); + double total = clock_end - clock_start; +#endif + + printf ("%18s: cpu: %6.3f steps/sec: %10.3e\n", + implementation_name, total, ITERATIONS / total); +} + +// ---------------------------------------------------------------- +// Don't compare the _vec with other functions since memory store's +// are involved. + +void basic_sincos_vec (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS/BLOCK_SIZE; i++){ + for (int j = 0; j < BLOCK_SIZE; j++){ + nco.sincos (&x[2*j+1], &x[2*j]); + nco.step (); + } + } +} + +void native_sincos_vec (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS/BLOCK_SIZE; i++){ + nco.sincos ((gr_complex*)x, BLOCK_SIZE); + } +} + +void fxpt_sincos_vec (float *x, float *y) +{ + gr_fxpt_nco nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS/BLOCK_SIZE; i++){ + nco.sincos ((gr_complex*)x, BLOCK_SIZE); + } +} + +// ---------------------------------------------------------------- + +void native_sincos (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + nco.sincos (x, y); + nco.step (); + } +} + +void fxpt_sincos (float *x, float *y) +{ + gr_fxpt_nco nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + nco.sincos (x, y); + nco.step (); + } +} + +// ---------------------------------------------------------------- + +void native_sin (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + *x = nco.sin (); + nco.step (); + } +} + +void fxpt_sin (float *x, float *y) +{ + gr_fxpt_nco nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + *x = nco.sin (); + nco.step (); + } +} + +// ---------------------------------------------------------------- + +void nop_fct (float *x, float *y) +{ +} + +void nop_loop (float *x, float *y) +{ + for (int i = 0; i < ITERATIONS; i++){ + nop_fct (x, y); + } +} + +int +main (int argc, char **argv) +{ + benchmark (nop_loop, "nop loop"); + benchmark (native_sin, "native sine"); + benchmark (fxpt_sin, "fxpt sine"); + benchmark (native_sincos, "native sin/cos"); + benchmark (fxpt_sincos, "fxpt sin/cos"); + benchmark (basic_sincos_vec, "basic sin/cos vec"); + benchmark (native_sincos_vec, "native sin/cos vec"); + benchmark (fxpt_sincos_vec, "fxpt sin/cos vec"); +} diff --git a/gnuradio-core/src/tests/benchmark_vco.cc b/gnuradio-core/src/tests/benchmark_vco.cc new file mode 100644 index 0000000000..3a6ade78c9 --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_vco.cc @@ -0,0 +1,167 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004,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. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_vco.h> +#include <gr_fxpt_vco.h> +#include <string.h> + +#define ITERATIONS 5000000 +#define BLOCK_SIZE (10 * 1000) // fits in cache + +#define FREQ 5003.123 +#define K 4.9999999 +#define AMPLITUDE 2.444444444 + + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (void test (float *x, const float *y), const char *implementation_name) +{ +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + float output[BLOCK_SIZE]; + float input[BLOCK_SIZE]; + + // touch memory + memset(output, 0, BLOCK_SIZE*sizeof(float)); + for (int i = 0; i<BLOCK_SIZE; i++) + input[i] = sin(double(i)); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); +#endif + // do the actual work + + test (output, input); + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end = (double) clock () * (1000000. / CLOCKS_PER_SEC); + double total = clock_end - clock_start; +#endif + + printf ("%18s: cpu: %6.3f steps/sec: %10.3e\n", + implementation_name, total, ITERATIONS / total); +} + +// ---------------------------------------------------------------- + +void basic_vco (float *output, const float *input) +{ + double phase = 0; + + for (int j = 0; j < ITERATIONS/BLOCK_SIZE; j++){ + for (int i = 0; i < BLOCK_SIZE; i++){ + output[i] = cos(phase) * AMPLITUDE; + phase += input[i] * K; + + while (phase > 2 * M_PI) + phase -= 2 * M_PI; + + while (phase < -2 * M_PI) + phase += 2 * M_PI; + } + } +} + +void native_vco (float *output, const float *input) +{ + gr_vco<float,float> vco; + + for (int j = 0; j < ITERATIONS/BLOCK_SIZE; j++){ + vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE); + } + } + +void fxpt_vco (float *output, const float *input) +{ + gr_fxpt_vco vco; + + for (int j = 0; j < ITERATIONS/BLOCK_SIZE; j++){ + vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE); + } +} + +// ---------------------------------------------------------------- + +void nop_fct (float *x, const float *y) +{ +} + +void nop_loop (float *x, const float *y) +{ + for (int i = 0; i < ITERATIONS; i++){ + nop_fct (x, y); + } +} + +int +main (int argc, char **argv) +{ + benchmark (nop_loop, "nop loop"); + benchmark (basic_vco, "basic vco"); + benchmark (native_vco, "native vco"); + benchmark (fxpt_vco, "fxpt vco"); +} diff --git a/gnuradio-core/src/tests/nco_results b/gnuradio-core/src/tests/nco_results new file mode 100644 index 0000000000..5bdf5dd1cb --- /dev/null +++ b/gnuradio-core/src/tests/nco_results @@ -0,0 +1,48 @@ +================================================================ +These are on a 1.4 GHz Pentium M using g++ 3.4.1 +================================================================ + +Default compiler options -O2 + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.900 steps/sec: 1.111e+07 + fxpt sine: cpu: 0.281 steps/sec: 3.559e+07 + native sin/cos: cpu: 1.138 steps/sec: 8.789e+06 + fxpt sin/cos: cpu: 0.550 steps/sec: 1.818e+07 + +-O2 -march=pentium-m -fomit-frame-pointer + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.903 steps/sec: 1.108e+07 + fxpt sine: cpu: 0.271 steps/sec: 3.691e+07 + native sin/cos: cpu: 1.092 steps/sec: 9.159e+06 + fxpt sin/cos: cpu: 0.542 steps/sec: 1.845e+07 + +Inlined fxpt::sin & cos +-O2 -march=pentium-m -fomit-frame-pointer + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.904 steps/sec: 1.106e+07 + fxpt sine: cpu: 0.187 steps/sec: 5.348e+07 + native sin/cos: cpu: 1.091 steps/sec: 9.167e+06 + fxpt sin/cos: cpu: 0.373 steps/sec: 2.681e+07 + +================================================================ +These are on a 1.5 GHz Athon MP 1800+ +================================================================ + +Default compiler options: -O2 + + nop loop: cpu: 0.013 steps/sec: 7.693e+08 + native sine: cpu: 0.733 steps/sec: 1.364e+07 + fxpt sine: cpu: 0.210 steps/sec: 4.763e+07 + native sin/cos: cpu: 1.183 steps/sec: 8.454e+06 + fxpt sin/cos: cpu: 0.420 steps/sec: 2.381e+07 + +-O2 -fomit-frame-pointer -march=athlon-mp + + nop loop: cpu: 0.013 steps/sec: 7.693e+08 + native sine: cpu: 0.679 steps/sec: 1.473e+07 + fxpt sine: cpu: 0.200 steps/sec: 5.001e+07 + native sin/cos: cpu: 1.147 steps/sec: 8.720e+06 + fxpt sin/cos: cpu: 0.444 steps/sec: 2.253e+07 diff --git a/gnuradio-core/src/tests/test_all.cc b/gnuradio-core/src/tests/test_all.cc index fb45cbf8f4..f1fbce4e05 100644 --- a/gnuradio-core/src/tests/test_all.cc +++ b/gnuradio-core/src/tests/test_all.cc @@ -24,7 +24,6 @@ #include <cppunit/XmlOutputter.h> #include <gr_unittests.h> -#include <qa_runtime.h> #include <qa_general.h> // FIXME add atsc back in. @@ -36,7 +35,6 @@ main (int argc, char **argv) std::ofstream xmlfile(get_unittest_path("gnuradio_core_all.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); - runner.addTest (qa_runtime::suite ()); runner.addTest (qa_general::suite ()); runner.setOutputter(xmlout); diff --git a/gnuradio-core/src/tests/test_buffers.py b/gnuradio-core/src/tests/test_buffers.py index 2664c136c6..e0abb8b304 100755 --- a/gnuradio-core/src/tests/test_buffers.py +++ b/gnuradio-core/src/tests/test_buffers.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006 Free Software Foundation, Inc. +# Copyright 2006,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gru from gnuradio import audio +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -68,7 +69,7 @@ class my_graph(gr.top_block): nsamples=int(sample_rate * seconds) #1 seconds data = sig_source_f(sample_rate, 350, ampl, nsamples) - src0 = gr.vector_source_f(data) + src0 = blocks.vector_source_f(data) # gr.test (const std::string &name=std::string("gr_test"), # int min_inputs=1, int max_inputs=1, unsigned int sizeof_input_item=1, diff --git a/gnuradio-core/src/tests/test_runtime.cc b/gnuradio-core/src/tests/test_runtime.cc deleted file mode 100644 index bd5378332e..0000000000 --- a/gnuradio-core/src/tests/test_runtime.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,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 <cppunit/TextTestRunner.h> -#include <cppunit/XmlOutputter.h> - -#include <gr_unittests.h> -#include <qa_runtime.h> - -int -main (int argc, char **argv) -{ - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(get_unittest_path("gnuradio_core_runtime.xml").c_str()); - CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); - - runner.addTest (qa_runtime::suite ()); - runner.setOutputter(xmlout); - - bool was_successful = runner.run ("", false); - - return was_successful ? 0 : 1; -} |