diff options
Diffstat (limited to 'gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc')
-rw-r--r-- | gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc index 4446306a8b..70e840d778 100644 --- a/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc +++ b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc @@ -29,6 +29,9 @@ #define M_TWOPI (2*M_PI) +static const pmt::pmt_t CARR_OFFSET_KEY = pmt::mp("ofdm_sync_carr_offset"); +static const pmt::pmt_t CHAN_TAPS_KEY = pmt::mp("ofdm_sync_chan_taps"); + namespace gr { namespace digital { @@ -36,14 +39,14 @@ namespace gr { ofdm_frame_equalizer_vcvc::make( ofdm_equalizer_base::sptr equalizer, int cp_len, - const std::string &len_tag_key, + const std::string &tsb_key, bool propagate_channel_state, int fixed_frame_len ) { return gnuradio::get_initial_sptr ( new ofdm_frame_equalizer_vcvc_impl( - equalizer, cp_len, len_tag_key, propagate_channel_state, fixed_frame_len + equalizer, cp_len, tsb_key, propagate_channel_state, fixed_frame_len ) ); } @@ -51,13 +54,13 @@ namespace gr { ofdm_frame_equalizer_vcvc_impl::ofdm_frame_equalizer_vcvc_impl( ofdm_equalizer_base::sptr equalizer, int cp_len, - const std::string &len_tag_key, + const std::string &tsb_key, bool propagate_channel_state, int fixed_frame_len ) : tagged_stream_block("ofdm_frame_equalizer_vcvc", io_signature::make(1, 1, sizeof (gr_complex) * equalizer->fft_len()), io_signature::make(1, 1, sizeof (gr_complex) * equalizer->fft_len()), - len_tag_key), + tsb_key), d_fft_len(equalizer->fft_len()), d_cp_len(cp_len), d_eq(equalizer), @@ -65,16 +68,18 @@ namespace gr { d_fixed_frame_len(fixed_frame_len), d_channel_state(equalizer->fft_len(), gr_complex(1, 0)) { - if (len_tag_key.empty() && fixed_frame_len == 0) { - throw std::invalid_argument("Either specify a length tag or a frame length!"); + if (tsb_key.empty() && fixed_frame_len == 0) { + throw std::invalid_argument("Either specify a TSB tag or a fixed frame length!"); } if (d_fixed_frame_len < 0) { - throw std::invalid_argument("Invalid frame length!"); + throw std::invalid_argument("Invalid frame length!"); } if (d_fixed_frame_len) { - set_output_multiple(d_fixed_frame_len); + set_output_multiple(d_fixed_frame_len); } set_relative_rate(1.0); + // Really, we have TPP_ONE_TO_ONE, but the channel state is not propagated + set_tag_propagation_policy(TPP_DONT); } ofdm_frame_equalizer_vcvc_impl::~ofdm_frame_equalizer_vcvc_impl() @@ -83,18 +88,17 @@ namespace gr { void ofdm_frame_equalizer_vcvc_impl::parse_length_tags( - const std::vector<std::vector<tag_t> > &tags, - gr_vector_int &n_input_items_reqd - ){ + const std::vector<std::vector<tag_t> > &tags, + gr_vector_int &n_input_items_reqd + ) { if (d_fixed_frame_len) { - n_input_items_reqd[0] = d_fixed_frame_len; + n_input_items_reqd[0] = d_fixed_frame_len; } else { - for (unsigned k = 0; k < tags[0].size(); k++) { - if (tags[0][k].key == pmt::string_to_symbol(d_length_tag_key_str)) { - n_input_items_reqd[0] = pmt::to_long(tags[0][k].value); - remove_item_tag(0, tags[0][k]); - } - } + for (unsigned k = 0; k < tags[0].size(); k++) { + if (tags[0][k].key == pmt::string_to_symbol(d_length_tag_key_str)) { + n_input_items_reqd[0] = pmt::to_long(tags[0][k].value); + } + } } } @@ -114,15 +118,14 @@ namespace gr { } std::vector<tag_t> tags; - get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+1); + get_tags_in_window(tags, 0, 0, 1); for (unsigned i = 0; i < tags.size(); i++) { - if (pmt::symbol_to_string(tags[i].key) == "ofdm_sync_chan_taps") { - d_channel_state = pmt::c32vector_elements(tags[i].value); - remove_item_tag(0, tags[i]); - } - if (pmt::symbol_to_string(tags[i].key) == "ofdm_sync_carr_offset") { - carrier_offset = pmt::to_long(tags[i].value); - } + if (pmt::symbol_to_string(tags[i].key) == "ofdm_sync_chan_taps") { + d_channel_state = pmt::c32vector_elements(tags[i].value); + } + if (pmt::symbol_to_string(tags[i].key) == "ofdm_sync_carr_offset") { + carrier_offset = pmt::to_long(tags[i].value); + } } // Copy the frame and the channel state vector such that the symbols are shifted to the correct position @@ -157,7 +160,16 @@ namespace gr { // Update the channel state regarding the frequency offset phase_correction = gr_expj(M_TWOPI * carrier_offset * d_cp_len / d_fft_len * frame_len); for (int k = 0; k < d_fft_len; k++) { - d_channel_state[k] *= phase_correction; + d_channel_state[k] *= phase_correction; + } + + // Propagate tags (except for the channel state and the TSB tag) + get_tags_in_window(tags, 0, 0, frame_len); + for (size_t i = 0; i < tags.size(); i++) { + if (tags[i].key != CHAN_TAPS_KEY + and tags[i].key != pmt::mp(d_length_tag_key_str)) { + add_item_tag(0, tags[i]); + } } // Housekeeping |