diff options
author | Martin Braun <martin.braun@kit.edu> | 2013-06-05 11:55:20 -0400 |
---|---|---|
committer | Martin Braun <martin.braun@kit.edu> | 2013-06-05 11:55:20 -0400 |
commit | 541410996f6f1b648b897ae3052e146577ff2cd8 (patch) | |
tree | 73c5fbd99e816dadf6727f585b178e439dc3a1d6 | |
parent | 81cba98cb1a3adec261aa6b510ee152c3a24bb0d (diff) | |
parent | f854b6afac7d24fb279f9b5078ddac0a255521d7 (diff) |
Merge branch 'maint-ofdm' into master-ofdm
Conflicts:
gr-digital/include/CMakeLists.txt
gr-digital/include/digital/CMakeLists.txt
gr-digital/lib/CMakeLists.txt
gr-digital/lib/header_payload_demux_impl.cc
gr-digital/lib/ofdm_chanest_vcvc_impl.cc
gr-digital/lib/ofdm_chanest_vcvc_impl.h
gr-digital/python/ofdm_txrx.py
gr-digital/python/qa_ofdm_chanest_vcvc.py
gr-digital/swig/digital_swig.i
-rw-r--r-- | gr-digital/examples/ofdm/ofdm_loopback.grc | 541 | ||||
-rw-r--r-- | gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml | 9 | ||||
-rw-r--r-- | gr-digital/grc/digital_ofdm_rx.xml | 4 | ||||
-rw-r--r-- | gr-digital/grc/digital_ofdm_tx.xml | 4 | ||||
-rw-r--r-- | gr-digital/include/digital/ofdm_chanest_vcvc.h | 97 | ||||
-rw-r--r-- | gr-digital/lib/header_payload_demux_impl.cc | 124 | ||||
-rw-r--r-- | gr-digital/lib/ofdm_chanest_vcvc_impl.cc | 88 | ||||
-rw-r--r-- | gr-digital/python/digital/ofdm_txrx.py | 30 | ||||
-rwxr-xr-x | gr-digital/python/digital/qa_ofdm_chanest_vcvc.py | 27 | ||||
-rw-r--r-- | gr-digital/swig/digital_swig.i | 1 |
10 files changed, 542 insertions, 383 deletions
diff --git a/gr-digital/examples/ofdm/ofdm_loopback.grc b/gr-digital/examples/ofdm/ofdm_loopback.grc index 45a6ca0869..80dd12f2a5 100644 --- a/gr-digital/examples/ofdm/ofdm_loopback.grc +++ b/gr-digital/examples/ofdm/ofdm_loopback.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Tue May 7 15:42:23 2013</timestamp> + <timestamp>Wed Jun 5 11:54:15 2013</timestamp> <block> <key>options</key> <param> @@ -107,10 +107,147 @@ </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 numpy</value> + </param> + <param> + <key>_coordinate</key> + <value>(536, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>from gnuradio.digital.utils import tagged_streams</value> + </param> + <param> + <key>_coordinate</key> + <value>(633, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>wxgui_fftsink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Rx Spectrum</value> + </param> + <param> + <key>samp_rate</key> + <value>100e3</value> + </param> + <param> + <key>baseband_freq</key> + <value>0</value> + </param> + <param> + <key>y_per_div</key> + <value>10</value> + </param> + <param> + <key>y_divs</key> + <value>10</value> + </param> + <param> + <key>ref_level</key> + <value>0</value> + </param> + <param> + <key>ref_scale</key> + <value>2.0</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>15</value> + </param> + <param> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>win</key> + <value>None</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>freqvar</key> + <value>None</value> + </param> + <param> + <key>_coordinate</key> + <value>(59, 384)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> <key>variable_slider</key> <param> <key>id</key> - <value>freq_offset</value> + <value>noise_voltage</value> </param> <param> <key>_enabled</key> @@ -118,19 +255,19 @@ </param> <param> <key>label</key> - <value>Frequency Offset (Multiples of Sub-carrier spacing)</value> + <value>Noise Amplitude</value> </param> <param> <key>value</key> - <value>0</value> + <value>0.01</value> </param> <param> <key>min</key> - <value>-3</value> + <value>0</value> </param> <param> <key>max</key> - <value>3</value> + <value>1</value> </param> <param> <key>num_steps</key> @@ -154,7 +291,7 @@ </param> <param> <key>_coordinate</key> - <value>(652, 285)</value> + <value>(695, 439)</value> </param> <param> <key>_rotation</key> @@ -165,7 +302,7 @@ <key>variable_slider</key> <param> <key>id</key> - <value>noise_voltage</value> + <value>freq_offset</value> </param> <param> <key>_enabled</key> @@ -173,19 +310,19 @@ </param> <param> <key>label</key> - <value>Noise Amplitude</value> + <value>Frequency Offset (Multiples of Sub-carrier spacing)</value> </param> <param> <key>value</key> - <value>0.01</value> + <value>0</value> </param> <param> <key>min</key> - <value>0</value> + <value>-3</value> </param> <param> <key>max</key> - <value>1</value> + <value>3</value> </param> <param> <key>num_steps</key> @@ -209,7 +346,7 @@ </param> <param> <key>_coordinate</key> - <value>(651, 416)</value> + <value>(696, 264)</value> </param> <param> <key>_rotation</key> @@ -217,45 +354,69 @@ </param> </block> <block> - <key>import</key> + <key>blocks_throttle</key> <param> <key>id</key> - <value>import_0</value> + <value>blocks_throttle_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>import</key> - <value>import numpy</value> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>samples_per_second</key> + <value>100e3</value> + </param> + <param> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(536, -1)</value> + <value>(252, 212)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <block> - <key>import</key> + <key>blocks_tag_debug</key> <param> <key>id</key> - <value>import_0_0</value> + <value>blocks_tag_debug_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>import</key> - <value>from gnuradio.digital.utils import tagged_streams</value> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>name</key> + <value>Rx Packets</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>display</key> + <value>True</value> </param> <param> <key>_coordinate</key> - <value>(633, -1)</value> + <value>(333, 367)</value> </param> <param> <key>_rotation</key> @@ -263,10 +424,10 @@ </param> </block> <block> - <key>digital_ofdm_tx</key> + <key>digital_ofdm_rx</key> <param> <key>id</key> - <value>digital_ofdm_tx_0</value> + <value>digital_ofdm_rx_0</value> </param> <param> <key>_enabled</key> @@ -282,7 +443,7 @@ </param> <param> <key>packet_len_key</key> - <value>len_tag_key</value> + <value>"rx_len"</value> </param> <param> <key>occupied_carriers</key> @@ -310,11 +471,7 @@ </param> <param> <key>payload_mod</key> - <value>"BPSK"</value> - </param> - <param> - <key>rolloff</key> - <value>0</value> + <value>"QPSK"</value> </param> <param> <key>log</key> @@ -322,7 +479,7 @@ </param> <param> <key>_coordinate</key> - <value>(390, 78)</value> + <value>(59, 258)</value> </param> <param> <key>_rotation</key> @@ -330,18 +487,22 @@ </param> </block> <block> - <key>blocks_float_to_uchar</key> + <key>variable</key> <param> <key>id</key> - <value>blocks_float_to_uchar_0</value> + <value>packet_len</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> + <key>value</key> + <value>8*2</value> + </param> + <param> <key>_coordinate</key> - <value>(230, 119)</value> + <value>(258, 64)</value> </param> <param> <key>_rotation</key> @@ -360,7 +521,7 @@ </param> <param> <key>value</key> - <value>[numpy.sin(2 * numpy.pi * 1.0/8 * x) for x in range(8*2)]</value> + <value>[numpy.sin(2 * numpy.pi * 1.0/8 * x) for x in range(packet_len)]</value> </param> <param> <key>_coordinate</key> @@ -372,10 +533,10 @@ </param> </block> <block> - <key>blocks_vector_source_x</key> + <key>blocks_vector_to_stream</key> <param> <key>id</key> - <value>blocks_vector_source_x_0</value> + <value>blocks_vector_to_stream_0</value> </param> <param> <key>_enabled</key> @@ -383,19 +544,11 @@ </param> <param> <key>type</key> - <value>float</value> - </param> - <param> - <key>vector</key> - <value>tx_signal</value> - </param> - <param> - <key>tags</key> - <value>tagged_streams.make_lengthtags((8*2*gr.sizeof_float,), (0,), tagname=len_tag_key)</value> + <value>byte</value> </param> <param> - <key>repeat</key> - <value>True</value> + <key>num_items</key> + <value>4</value> </param> <param> <key>vlen</key> @@ -403,7 +556,7 @@ </param> <param> <key>_coordinate</key> - <value>(-1, 101)</value> + <value>(261, 140)</value> </param> <param> <key>_rotation</key> @@ -411,10 +564,10 @@ </param> </block> <block> - <key>blocks_throttle</key> + <key>blocks_vector_source_x</key> <param> <key>id</key> - <value>blocks_throttle_0</value> + <value>blocks_vector_source_x_0</value> </param> <param> <key>_enabled</key> @@ -422,11 +575,19 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>float</value> </param> <param> - <key>samples_per_second</key> - <value>100e3</value> + <key>vector</key> + <value>tx_signal</value> + </param> + <param> + <key>tags</key> + <value>tagged_streams.make_lengthtags((packet_len*gr.sizeof_float,), (0,), tagname=len_tag_key)</value> + </param> + <param> + <key>repeat</key> + <value>True</value> </param> <param> <key>vlen</key> @@ -434,18 +595,18 @@ </param> <param> <key>_coordinate</key> - <value>(354, 230)</value> + <value>(-1, 101)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>blocks_tag_gate</key> + <key>blocks_stream_to_vector</key> <param> <key>id</key> - <value>blocks_tag_gate_0</value> + <value>blocks_stream_to_vector_0</value> </param> <param> <key>_enabled</key> @@ -453,30 +614,30 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>byte</value> </param> <param> - <key>vlen</key> - <value>1</value> + <key>num_items</key> + <value>4</value> </param> <param> - <key>propagate_tags</key> - <value>False</value> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(539, 230)</value> + <value>(336, 290)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>wxgui_fftsink2</key> + <key>wxgui_scopesink2</key> <param> <key>id</key> - <value>wxgui_fftsink2_0</value> + <value>wxgui_scopesink2_0</value> </param> <param> <key>_enabled</key> @@ -484,59 +645,39 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>float</value> </param> <param> <key>title</key> - <value>Rx Spectrum</value> + <value>Scope Plot</value> </param> <param> <key>samp_rate</key> - <value>100e3</value> + <value>1.0</value> </param> <param> - <key>baseband_freq</key> + <key>v_scale</key> <value>0</value> </param> <param> - <key>y_per_div</key> - <value>10</value> - </param> - <param> - <key>y_divs</key> - <value>10</value> - </param> - <param> - <key>ref_level</key> + <key>v_offset</key> <value>0</value> </param> <param> - <key>ref_scale</key> - <value>2.0</value> - </param> - <param> - <key>fft_size</key> - <value>1024</value> - </param> - <param> - <key>fft_rate</key> - <value>15</value> + <key>t_scale</key> + <value>0</value> </param> <param> - <key>peak_hold</key> + <key>ac_couple</key> <value>False</value> </param> <param> - <key>average</key> + <key>xy_mode</key> <value>False</value> </param> <param> - <key>avg_alpha</key> - <value>0</value> - </param> - <param> - <key>win</key> - <value>None</value> + <key>num_inputs</key> + <value>1</value> </param> <param> <key>win_size</key> @@ -551,51 +692,16 @@ <value></value> </param> <param> - <key>freqvar</key> - <value>None</value> - </param> - <param> - <key>_coordinate</key> - <value>(92, 463)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>channel_model</key> - <param> - <key>id</key> - <value>chan_model</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>noise_voltage</key> - <value>noise_voltage</value> - </param> - <param> - <key>freq_offset</key> - <value>1.0/fft_len * freq_offset</value> - </param> - <param> - <key>epsilon</key> - <value>1.0</value> - </param> - <param> - <key>taps</key> - <value>1.0</value> + <key>trig_mode</key> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> - <key>seed</key> - <value>0</value> + <key>y_axis_label</key> + <value>Counts</value> </param> <param> <key>_coordinate</key> - <value>(615, 86)</value> + <value>(538, 266)</value> </param> <param> <key>_rotation</key> @@ -603,14 +709,14 @@ </param> </block> <block> - <key>digital_ofdm_rx</key> + <key>digital_ofdm_tx</key> <param> <key>id</key> - <value>digital_ofdm_rx_0</value> + <value>digital_ofdm_tx_0</value> </param> <param> <key>_enabled</key> - <value>False</value> + <value>True</value> </param> <param> <key>fft_len</key> @@ -622,7 +728,7 @@ </param> <param> <key>packet_len_key</key> - <value>"rx_len"</value> + <value>len_tag_key</value> </param> <param> <key>occupied_carriers</key> @@ -650,34 +756,19 @@ </param> <param> <key>payload_mod</key> - <value>"BPSK"</value> - </param> - <param> - <key>log</key> - <value>False</value> - </param> - <param> - <key>_coordinate</key> - <value>(92, 307)</value> + <value>"QPSK"</value> </param> <param> - <key>_rotation</key> + <key>rolloff</key> <value>0</value> </param> - </block> - <block> - <key>blocks_uchar_to_float</key> <param> - <key>id</key> - <value>blocks_uchar_to_float_0</value> - </param> - <param> - <key>_enabled</key> + <key>log</key> <value>False</value> </param> <param> <key>_coordinate</key> - <value>(332, 340)</value> + <value>(464, 77)</value> </param> <param> <key>_rotation</key> @@ -685,38 +776,38 @@ </param> </block> <block> - <key>blocks_tag_debug</key> + <key>channels_channel_model</key> <param> <key>id</key> - <value>blocks_tag_debug_0</value> + <value>channels_channel_model_0</value> </param> <param> <key>_enabled</key> - <value>False</value> + <value>True</value> </param> <param> - <key>type</key> - <value>byte</value> + <key>noise_voltage</key> + <value>noise_voltage</value> </param> <param> - <key>name</key> - <value>Rx Packets</value> + <key>freq_offset</key> + <value>freq_offset * 1.0/fft_len</value> </param> <param> - <key>num_inputs</key> - <value>1</value> + <key>epsilon</key> + <value>1.0</value> </param> <param> - <key>vlen</key> - <value>1</value> + <key>taps</key> + <value>1.0 + 1.0j</value> </param> <param> - <key>display</key> - <value>True</value> + <key>seed</key> + <value>0</value> </param> <param> <key>_coordinate</key> - <value>(336, 412)</value> + <value>(747, 85)</value> </param> <param> <key>_rotation</key> @@ -724,94 +815,44 @@ </param> </block> <block> - <key>wxgui_scopesink2</key> + <key>blocks_tag_gate</key> <param> <key>id</key> - <value>wxgui_scopesink2_0</value> + <value>blocks_tag_gate_0</value> </param> <param> <key>_enabled</key> - <value>False</value> + <value>True</value> </param> <param> <key>type</key> - <value>float</value> - </param> - <param> - <key>title</key> - <value>Scope Plot</value> - </param> - <param> - <key>samp_rate</key> - <value>1.0</value> - </param> - <param> - <key>v_scale</key> - <value>0</value> - </param> - <param> - <key>v_offset</key> - <value>0</value> - </param> - <param> - <key>t_scale</key> - <value>0</value> - </param> - <param> - <key>ac_couple</key> - <value>False</value> - </param> - <param> - <key>xy_mode</key> - <value>False</value> + <value>complex</value> </param> <param> - <key>num_inputs</key> + <key>vlen</key> <value>1</value> </param> <param> - <key>win_size</key> - <value></value> - </param> - <param> - <key>grid_pos</key> - <value></value> - </param> - <param> - <key>notebook</key> - <value></value> - </param> - <param> - <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> - </param> - <param> - <key>y_axis_label</key> - <value>Counts</value> + <key>propagate_tags</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(504, 314)</value> + <value>(508, 212)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <connection> <source_block_id>blocks_vector_source_x_0</source_block_id> - <sink_block_id>blocks_float_to_uchar_0</sink_block_id> + <sink_block_id>blocks_vector_to_stream_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>digital_ofdm_tx_0</source_block_id> - <sink_block_id>chan_model</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_float_to_uchar_0</source_block_id> + <source_block_id>blocks_vector_to_stream_0</source_block_id> <sink_block_id>digital_ofdm_tx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -830,31 +871,37 @@ </connection> <connection> <source_block_id>digital_ofdm_rx_0</source_block_id> - <sink_block_id>blocks_uchar_to_float_0</sink_block_id> + <sink_block_id>blocks_stream_to_vector_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_uchar_to_float_0</source_block_id> - <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <source_block_id>digital_ofdm_rx_0</source_block_id> + <sink_block_id>blocks_tag_debug_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>digital_ofdm_rx_0</source_block_id> - <sink_block_id>blocks_tag_debug_0</sink_block_id> + <source_block_id>blocks_tag_gate_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>chan_model</source_block_id> - <sink_block_id>blocks_tag_gate_0</sink_block_id> + <source_block_id>blocks_stream_to_vector_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_tag_gate_0</source_block_id> - <sink_block_id>blocks_throttle_0</sink_block_id> + <source_block_id>digital_ofdm_tx_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>blocks_tag_gate_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml b/gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml index 28b33ef3c5..2a0c24e528 100644 --- a/gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml +++ b/gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml @@ -2,7 +2,7 @@ <name>OFDM Frame Equalizer</name> <key>digital_ofdm_frame_equalizer_vcvc</key> <import>from gnuradio import digital</import> - <make>digital.ofdm_frame_equalizer_vcvc($equalizer, $cp_len, $len_tag_key, $propagate_channel_state)</make> + <make>digital.ofdm_frame_equalizer_vcvc($equalizer, $cp_len, $len_tag_key, $propagate_channel_state, $fixed_frame_len)</make> <param> <name>FFT length</name> <key>fft_len</key> @@ -38,6 +38,13 @@ <key>False</key> </option> </param> + <param> + <name>Fixed frame length</name> + <key>fixed_frame_len</key> + <value>0</value> + <type>int</type> + <hide>#if $fixed_frame_len then 'none' else 'part'#</hide> + </param> <sink> <name>in</name> <type>complex</type> diff --git a/gr-digital/grc/digital_ofdm_rx.xml b/gr-digital/grc/digital_ofdm_rx.xml index 38222265a7..6f10a2e944 100644 --- a/gr-digital/grc/digital_ofdm_rx.xml +++ b/gr-digital/grc/digital_ofdm_rx.xml @@ -10,10 +10,10 @@ #if $occupied_carriers() occupied_carriers=$occupied_carriers, #end if - #if $occupied_carriers() + #if $pilot_carriers() pilot_carriers=$pilot_carriers, #end if - #if $occupied_carriers() + #if $pilot_symbols() pilot_symbols=$pilot_symbols, #end if #if $sync_word1() diff --git a/gr-digital/grc/digital_ofdm_tx.xml b/gr-digital/grc/digital_ofdm_tx.xml index 034d34a2a5..cde045d840 100644 --- a/gr-digital/grc/digital_ofdm_tx.xml +++ b/gr-digital/grc/digital_ofdm_tx.xml @@ -9,10 +9,10 @@ #if $occupied_carriers() occupied_carriers=$occupied_carriers, #end if - #if $occupied_carriers() + #if $pilot_carriers() pilot_carriers=$pilot_carriers, #end if - #if $occupied_carriers() + #if $pilot_carriers() pilot_symbols=$pilot_symbols, #end if #if $sync_word1() diff --git a/gr-digital/include/digital/ofdm_chanest_vcvc.h b/gr-digital/include/digital/ofdm_chanest_vcvc.h new file mode 100644 index 0000000000..da9479399a --- /dev/null +++ b/gr-digital/include/digital/ofdm_chanest_vcvc.h @@ -0,0 +1,97 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H +#define INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H + +#include <digital/api.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Estimate channel and coarse frequency offset for OFDM from preambles + * \ingroup ofdm_blk + * \ingroup syncronizers_blk + * + * Input: OFDM symbols (in frequency domain). The first one (or two) symbols are expected + * to be synchronisation symbols, which are used to estimate the coarse freq offset + * and the initial equalizer taps (these symbols are removed from the stream). + * The following \p n_data_symbols are passed through unmodified (the actual equalisation + * must be done elsewhere). + * Output: The data symbols, without the synchronisation symbols. + * The first data symbol passed through has two tags: + * 'ofdm_sync_carr_offset' (integer), the coarse frequency offset as number of carriers, + * and 'ofdm_sync_eq_taps' (complex vector). + * Any tags attached to the synchronisation symbols are attached to the first data + * symbol. All other tags are propagated as expected. + * + * Note: The vector on ofdm_sync_eq_taps is already frequency-corrected, whereas the rest is not. + * + * This block assumes the frequency offset is even (i.e. an integer multiple of 2). + * + * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization for OFDM", + * Communications, IEEE Transactions on, 1997. + * [2] K.D. Kammeyer, "Nachrichtenuebertragung," Chapter. 16.3.2. + */ + class DIGITAL_API ofdm_chanest_vcvc : virtual public gr_block + { + public: + typedef boost::shared_ptr<ofdm_chanest_vcvc> sptr; + + /*! + * \param sync_symbol1 First synchronisation symbol in the frequency domain. Its length must be + * the FFT length. For Schmidl & Cox synchronisation, every second sub-carrier + * has to be zero. + * \param sync_symbol2 Second synchronisation symbol in the frequency domain. Must be equal to + * the FFT length, or zero length if only one synchronisation symbol is used. + * Using this symbol is how synchronisation is described in [1]. Leaving this + * empty forces us to interpolate the equalizer taps. + * If you are using an unusual sub-carrier configuration (e.g. because of OFDMA), + * this sync symbol is used to identify the active sub-carriers. If you only + * have one synchronisation symbol, set the active sub-carriers to a non-zero + * value in here, and also set \p force_one_sync_symbol parameter to true. + * \param n_data_symbols The number of data symbols following each set of synchronisation symbols. + * Must be at least 1. + * \param eq_noise_red_len If non-zero, noise reduction for the equalizer taps is done according + * to [2]. In this case, it is the channel influence time in number of + * samples. A good value is usually the length of the cyclic prefix. + * \param max_carr_offset Limit the number of sub-carriers the frequency offset can maximally be. + * Leave this zero to try all possibilities. + * \param force_one_sync_symbol See \p sync_symbol2. + */ + static sptr make( + const std::vector<gr_complex> &sync_symbol1, + const std::vector<gr_complex> &sync_symbol2, + int n_data_symbols, + int eq_noise_red_len=0, + int max_carr_offset=-1, + bool force_one_sync_symbol=false + ); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H */ + diff --git a/gr-digital/lib/header_payload_demux_impl.cc b/gr-digital/lib/header_payload_demux_impl.cc index be1095d6cc..71868733b6 100644 --- a/gr-digital/lib/header_payload_demux_impl.cc +++ b/gr-digital/lib/header_payload_demux_impl.cc @@ -1,5 +1,5 @@ /* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. +/* Copyright 2012,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -27,8 +27,11 @@ #include <gnuradio/io_signature.h> #include "header_payload_demux_impl.h" + namespace gr { namespace digital { + // FIXME this is a completely arbitrary number, and depends on the signal params and the buffer sizes + const int MAX_SYMBOLS = 100; enum demux_states_t { STATE_IDLE, @@ -89,7 +92,9 @@ namespace gr { if (d_items_per_symbol < 1 || d_gi < 0 || d_itemsize < 1) { throw std::invalid_argument("Items and symbol sizes must be at least 1."); } - set_output_multiple(d_items_per_symbol); + if (!d_output_symbols) { + set_output_multiple(d_items_per_symbol); + } message_port_register_in(msg_port_id); } @@ -100,10 +105,20 @@ namespace gr { void header_payload_demux_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) { - // noutput_items is an integer multiple of d_items_per_symbol! + int n_items_reqd = 0; + if (d_state == STATE_HEADER) { + n_items_reqd = d_header_len * (d_items_per_symbol + d_gi); + //} else if (d_state == STATE_HEADER) { + } else { + n_items_reqd = noutput_items * (d_items_per_symbol + d_gi); + if (!d_output_symbols) { + // here, noutput_items is an integer multiple of d_items_per_symbol! + n_items_reqd /= d_items_per_symbol; + } + } + for (unsigned i = 0; i < ninput_items_required.size(); i++) { - ninput_items_required[i] = - noutput_items / d_items_per_symbol * (d_items_per_symbol + d_gi); + ninput_items_required[i] = n_items_reqd; } } @@ -119,59 +134,66 @@ namespace gr { int nread = 0; bool exit_loop = false; - int produced_hdr = 0; int produced_payload = 0; - // FIXME ninput_items[1] does not have to be defined O_o - while (nread < noutput_items && nread < ninput_items[0] && nread < ninput_items[1] && !exit_loop) { + while ( + nread < noutput_items + && nread < ninput_items[0] + && (ninput_items.size() == 1 || nread < ninput_items[1]) + && !exit_loop + ) { switch (d_state) { - case STATE_IDLE: - // 1) Search for a trigger signal on input 1 (if present) - // 2) Search for a trigger tag, make sure it's the first one - // The first trigger to be found is used! - // 3) Make sure the right number of items is skipped - // 4) If trigger found, switch to STATE_HEADER - if (find_trigger_signal(nread, noutput_items, input_items)) { - d_remaining_symbols = d_header_len; - d_state = STATE_HEADER; - in += nread * d_itemsize; - } - break; + case STATE_IDLE: + // 1) Search for a trigger signal on input 1 (if present) + // 2) Search for a trigger tag, make sure it's the first one + // The first trigger to be found is used! + // 3) Make sure the right number of items is skipped + // 4) If trigger found, switch to STATE_HEADER + if (find_trigger_signal(nread, noutput_items, input_items)) { + d_remaining_symbols = d_header_len; + d_state = STATE_HEADER; + in += nread * d_itemsize; + } + break; - case STATE_HEADER: - copy_symbol(in, out_header, 0, nread, produced_hdr); - if (d_remaining_symbols == 0) { - d_state = STATE_WAIT_FOR_MSG; - exit_loop = true; - } - break; + case STATE_HEADER: + copy_symbol(in, out_header, 0, nread, produced_hdr); + if (d_remaining_symbols == 0) { + d_state = STATE_WAIT_FOR_MSG; + exit_loop = true; + } + break; - case STATE_WAIT_FOR_MSG: - if (empty_p(msg_port_id)) return 0; //no message available - // If we're in this state, nread is zero (because previous state exits loop) - // 1) Wait for msg (blocking call) - // 2) set d_remaining_symbols - // 3) Write tags - // 4) fall through to next state - d_remaining_symbols = -1; - if (!parse_header_data_msg()) { - d_state = STATE_IDLE; - exit_loop = true; - break; - } - d_state = STATE_PAYLOAD; + case STATE_WAIT_FOR_MSG: + if (empty_p(msg_port_id)) return 0; //no message available + // If we're in this state, nread is zero (because previous state exits loop) + // 1) Wait for msg (blocking call) + // 2) set d_remaining_symbols + // 3) Write tags + // 4) fall through to next state + d_remaining_symbols = -1; + // TODO MAX_SYMBOLS depends on the buffer size in the payload demod chain + if (!parse_header_data_msg() || d_remaining_symbols > MAX_SYMBOLS) { + if (d_remaining_symbols > MAX_SYMBOLS) { + GR_LOG_INFO(d_logger, "Detected a packet larger than max frame size"); + } + d_state = STATE_IDLE; + exit_loop = true; + break; + } + d_state = STATE_PAYLOAD; - case STATE_PAYLOAD: - copy_symbol(in, out_payload, 1, nread, produced_payload); - if (d_remaining_symbols == 0) { - d_state = STATE_IDLE; - exit_loop = true; - } - break; + case STATE_PAYLOAD: + copy_symbol(in, out_payload, 1, nread, produced_payload); + if (d_remaining_symbols == 0) { + d_state = STATE_IDLE; + exit_loop = true; + } + break; - default: - throw std::runtime_error("invalid state"); + default: + throw std::runtime_error("invalid state"); } /* switch */ } /* while(nread < noutput_items) */ @@ -225,7 +247,7 @@ namespace gr { bool header_payload_demux_impl::parse_header_data_msg() { - pmt::pmt_t msg(delete_head_blocking(msg_port_id)); + pmt::pmt_t msg(delete_head_nowait(msg_port_id)); if (pmt::is_integer(msg)) { d_remaining_symbols = pmt::to_long(msg); add_item_tag(1, nitems_written(1), d_len_tag_key, msg); diff --git a/gr-digital/lib/ofdm_chanest_vcvc_impl.cc b/gr-digital/lib/ofdm_chanest_vcvc_impl.cc index f8aebec60d..8d2c17ca8b 100644 --- a/gr-digital/lib/ofdm_chanest_vcvc_impl.cc +++ b/gr-digital/lib/ofdm_chanest_vcvc_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013 Free Software Foundation, Inc. + * Copyright 2012,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -125,7 +125,8 @@ namespace gr { } } - set_relative_rate((double) n_data_symbols / (n_data_symbols + d_n_sync_syms)); + set_output_multiple(d_n_data_syms); + set_relative_rate((double) d_n_data_syms / (d_n_data_syms + d_n_sync_syms)); set_tag_propagation_policy(TPP_DONT); } @@ -223,13 +224,7 @@ namespace gr { } - // 1) Go through all the frames available on the input buffer - // 2) Estimate the coarse freq. offset and the eq. taps from the - // input symbol(s) - // 3) Copy the data symbols to the output - // 4) Copy all other tags onto the output. A tag that was on - // a sync symbol is copied onto the first data symbol. - // 5) Add the new tags for carrier offset and eq. taps + // Operates on a per-frame basis int ofdm_chanest_vcvc_impl::general_work (int noutput_items, gr_vector_int &ninput_items, @@ -238,54 +233,47 @@ namespace gr { { const gr_complex *in = (const gr_complex *) input_items[0]; gr_complex *out = (gr_complex *) output_items[0]; - int n_frames = noutput_items/d_n_data_syms; const int framesize = d_n_sync_syms + d_n_data_syms; - for (int i = 0; i < n_frames; i++) { - int carr_offset = 0; - if (d_max_neg_carr_offset || d_max_pos_carr_offset) - carr_offset = get_carr_offset(in, in+d_fft_len); - std::vector<gr_complex> chan_taps(d_fft_len, 0); - get_chan_taps(in, in+d_fft_len, carr_offset, chan_taps); + // Channel info estimation + int carr_offset = get_carr_offset(in, in+d_fft_len); + std::vector<gr_complex> chan_taps(d_fft_len, 0); + get_chan_taps(in, in+d_fft_len, carr_offset, chan_taps); + add_item_tag(0, nitems_written(0), + pmt::string_to_symbol("ofdm_sync_carr_offset"), + pmt::from_long(carr_offset)); + add_item_tag(0, nitems_written(0), + pmt::string_to_symbol("ofdm_sync_chan_taps"), + pmt::init_c32vector(d_fft_len, chan_taps)); - if (output_items.size() == 2) { - gr_complex *out_chantaps = ((gr_complex *) output_items[1]) + i * d_fft_len; - memcpy((void *) out_chantaps, (void *) &chan_taps[0], sizeof(gr_complex) * d_fft_len); - produce(1, 1); - } - - memcpy((void *) out, - (void *) &in[d_n_sync_syms * d_fft_len], - sizeof(gr_complex) * d_fft_len * d_n_data_syms); - in += framesize * d_fft_len; - out += d_n_data_syms * d_fft_len; - - std::vector<tag_t> tags; - get_tags_in_range(tags, 0, - nitems_read(0)+i*framesize, - nitems_read(0)+(i+1)*framesize); + // Copy data symbols + if (output_items.size() == 2) { + gr_complex *out_chantaps = ((gr_complex *) output_items[1]); + memcpy((void *) out_chantaps, (void *) &chan_taps[0], sizeof(gr_complex) * d_fft_len); + produce(1, 1); + } + memcpy((void *) out, + (void *) &in[d_n_sync_syms * d_fft_len], + sizeof(gr_complex) * d_fft_len * d_n_data_syms); - for (unsigned t = 0; t < tags.size(); t++) { - int offset = tags[t].offset - (nitems_read(0) + i*framesize); - if (offset < d_n_sync_syms) { - offset = 0; - } else { - offset -= d_n_sync_syms; - } - tags[t].offset = offset + nitems_written(0) + i*d_n_data_syms; - add_item_tag(0, tags[t]); + // Propagate tags + std::vector<gr::tag_t> tags; + get_tags_in_range(tags, 0, + nitems_read(0), + nitems_read(0)+framesize); + for (unsigned t = 0; t < tags.size(); t++) { + int offset = tags[t].offset - nitems_read(0); + if (offset < d_n_sync_syms) { + offset = 0; + } else { + offset -= d_n_sync_syms; } - - add_item_tag(0, nitems_written(0) + i*d_n_data_syms, - pmt::string_to_symbol("ofdm_sync_carr_offset"), - pmt::from_long(carr_offset)); - add_item_tag(0, nitems_written(0) + i*d_n_data_syms, - pmt::string_to_symbol("ofdm_sync_chan_taps"), - pmt::init_c32vector(d_fft_len, chan_taps)); + tags[t].offset = offset + nitems_written(0); + add_item_tag(0, tags[t]); } - produce(0, n_frames * d_n_data_syms); - consume_each(n_frames * framesize); + produce(0, d_n_data_syms); + consume_each(framesize); return WORK_CALLED_PRODUCE; } diff --git a/gr-digital/python/digital/ofdm_txrx.py b/gr-digital/python/digital/ofdm_txrx.py index 8f1b4c5f02..a48a48db41 100644 --- a/gr-digital/python/digital/ofdm_txrx.py +++ b/gr-digital/python/digital/ofdm_txrx.py @@ -335,18 +335,19 @@ class ofdm_rx(gr.hier_block2): packet_length_tag_key, frame_length_tag_key, packet_num_tag_key, - bps_header + bps_header, + bps_payload ) header_parser = digital.packet_headerparser_b(header_formatter.formatter()) self.connect((hpd, 0), header_fft, chanest, header_eq, header_serializer, header_demod, header_parser) self.msg_connect(header_parser, "header_data", hpd, "header_data") if debug_log: - self.connect((chanest, 1), blocks.file_sink(512, 'channel-estimate.dat')) - self.connect((chanest, 0), blocks.file_sink(512, 'post-hdr-chanest.dat')) - self.connect(header_eq, blocks.file_sink(512, 'post-hdr-eq.dat')) - self.connect(header_serializer, blocks.file_sink(8, 'post-hdr-serializer.dat')) - self.connect(header_demod, blocks.file_sink(1, 'post-hdr-demod.dat')) - self.connect(header_demod, blocks.tag_debug(1, 'post-hdr-demod.dat')) + self.connect((chanest, 1), blocks.file_sink(gr.sizeof_gr_complex * fft_len, 'channel-estimate.dat')) + self.connect((chanest, 0), blocks.file_sink(gr.sizeof_gr_complex * fft_len, 'post-hdr-chanest.dat')) + self.connect((chanest, 0), blocks.tag_debug(gr.sizeof_gr_complex * fft_len, 'post-hdr-chanest')) + self.connect(header_eq, blocks.file_sink(gr.sizeof_gr_complex * fft_len, 'post-hdr-eq.dat')) + self.connect(header_serializer, blocks.file_sink(gr.sizeof_gr_complex, 'post-hdr-serializer.dat')) + self.connect(header_demod, blocks.file_sink(1, 'post-hdr-demod.dat')) ### Payload demod #################################################### payload_fft = fft.fft_vcc(self.fft_len, True, (), True) payload_constellation = _get_constellation(bps_payload) @@ -373,13 +374,12 @@ class ofdm_rx(gr.hier_block2): crc = digital.crc32_bb(True, self.packet_length_tag_key) self.connect((hpd, 1), payload_fft, payload_eq, payload_serializer, payload_demod, repack, crc, self) if debug_log: - self.connect((hpd, 1), blocks.tag_debug(8*64, 'post-hpd')); - self.connect(payload_fft, blocks.file_sink(8*64, 'post-payload-fft.dat')) - self.connect(payload_eq, blocks.file_sink(8*64, 'post-payload-eq.dat')) - self.connect(payload_serializer, blocks.file_sink(8, 'post-payload-serializer.dat')) - self.connect(payload_demod, blocks.file_sink(1, 'post-payload-demod.dat')) - self.connect(repack, blocks.file_sink(1, 'post-payload-repack.dat')) - self.connect(crc, blocks.file_sink(1, 'post-payload-crc.dat')) - self.connect(crc, blocks.tag_debug(1, 'post-payload-crc')) + self.connect((hpd, 1), blocks.tag_debug(gr.sizeof_gr_complex*fft_len, 'post-hpd')); + self.connect(payload_fft, blocks.file_sink(gr.sizeof_gr_complex*fft_len, 'post-payload-fft.dat')) + self.connect(payload_eq, blocks.file_sink(gr.sizeof_gr_complex*fft_len, 'post-payload-eq.dat')) + self.connect(payload_serializer, blocks.file_sink(gr.sizeof_gr_complex, 'post-payload-serializer.dat')) + self.connect(payload_demod, blocks.file_sink(1, 'post-payload-demod.dat')) + self.connect(repack, blocks.file_sink(1, 'post-payload-repack.dat')) + self.connect(crc, blocks.file_sink(1, 'post-payload-crc.dat')) diff --git a/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py b/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py index e6b331b2a8..c365cf8483 100755 --- a/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py +++ b/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py @@ -76,21 +76,20 @@ class qa_ofdm_sync_eqinit_vcvc (gr_unittest.TestCase): self.tb.run() self.assertEqual(shift_tuple(sink.data(), -carr_offset), data_symbol) tags = sink.tags() - detected_tags = { - 'ofdm_sync_carr_offset': False, - 'test_tag_1': False, - 'test_tag_2': False - } + ptags = {} for tag in tags: - if pmt.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': - carr_offset_hat = pmt.to_long(tag.value) - self.assertEqual(pmt.to_long(tag.value), carr_offset) - if pmt.symbol_to_string(tag.key) == 'test_tag_1': - self.assertEqual(tag.offset, 0) - if pmt.symbol_to_string(tag.key) == 'test_tag_2': - self.assertEqual(tag.offset, 0) - detected_tags[pmt.symbol_to_string(tag.key)] = True - self.assertTrue(all(detected_tags.values())) + ptag = gr.tag_to_python(tag) + ptags[ptag.key] = (ptag.value, ptag.offset) + if ptag.key == 'ofdm_sync_chan_taps': + ptags[ptag.key] = (None, ptag.offset) + expected_tags = { + 'ofdm_sync_carr_offset': (-2, 0), + 'ofdm_sync_chan_taps': (None, 0), + 'test_tag_1': (23, 0), + 'test_tag_2': (42, 0), + } + self.assertEqual(ptags, expected_tags) + def test_002_offset_1sym (self): """ Add a frequency offset, check if it's correctly detected. diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i index b130e5da4b..fb0b97aa11 100644 --- a/gr-digital/swig/digital_swig.i +++ b/gr-digital/swig/digital_swig.i @@ -232,4 +232,3 @@ GR_SWIG_BLOCK_MAGIC_FACTORY(digital, cpmmod_bc, gmskmod_bc); %include "constellation.i" %include "packet_header.i" %include "ofdm_equalizer.i" - |