diff options
author | Martin Braun <martin.braun@kit.edu> | 2013-10-30 23:41:37 +0100 |
---|---|---|
committer | Martin Braun <martin.braun@kit.edu> | 2013-11-03 19:20:38 +0100 |
commit | a4225692e6f3db974dcbda9d93ede13a561029a6 (patch) | |
tree | ed3db126374bb6addc449a9910af848d22c18563 | |
parent | b6159b2a63e69542acb0ccf801fb887b0ef0f8a9 (diff) |
digital: carrier allocator tag propagation now handles sync words properly
3 files changed, 62 insertions, 4 deletions
diff --git a/gr-digital/include/gnuradio/digital/ofdm_carrier_allocator_cvc.h b/gr-digital/include/gnuradio/digital/ofdm_carrier_allocator_cvc.h index 26b11fceb4..1ea90a67d5 100644 --- a/gr-digital/include/gnuradio/digital/ofdm_carrier_allocator_cvc.h +++ b/gr-digital/include/gnuradio/digital/ofdm_carrier_allocator_cvc.h @@ -56,6 +56,12 @@ namespace gr { * with negative numbers, or with indexes larger than \p fft_len/2. Index -1 and index * \p fft_len-1 both identify the carrier below the DC carrier. * + * Tags are propagated such that a tag on an incoming complex symbol is mapped to the + * corresponding OFDM symbol. There is one exception: If a tag is on the first OFDM + * symbol, it is assumed that this tag should stay there, so it is moved to the front + * even if a sync word is included (any other tags will never be attached to the + * sync word). This allows tags to control the transmit timing to pass through in the + * correct position. */ class DIGITAL_API ofdm_carrier_allocator_cvc : virtual public tagged_stream_block { diff --git a/gr-digital/lib/ofdm_carrier_allocator_cvc_impl.cc b/gr-digital/lib/ofdm_carrier_allocator_cvc_impl.cc index 467718e424..171fd95934 100644 --- a/gr-digital/lib/ofdm_carrier_allocator_cvc_impl.cc +++ b/gr-digital/lib/ofdm_carrier_allocator_cvc_impl.cc @@ -150,7 +150,7 @@ namespace gr { } // Copy data symbols - long n_ofdm_symbols = 0; + long n_ofdm_symbols = 0; // Number of output items int curr_set = 0; int symbols_to_allocate = d_occupied_carriers[0].size(); int symbols_allocated = 0; @@ -162,9 +162,12 @@ namespace gr { nitems_read(0)+std::min(i+symbols_to_allocate, (int) ninput_items[0]) ); for (unsigned t = 0; t < tags.size(); t++) { - add_item_tag(0, nitems_written(0)+n_ofdm_symbols, + add_item_tag( + 0, + nitems_written(0) + n_ofdm_symbols + (n_ofdm_symbols == 0 ? 0 : d_sync_words.size()), tags[t].key, - tags[t].value); + tags[t].value + ); } n_ofdm_symbols++; } diff --git a/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py b/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py index 5c95e6e335..b1732fa94a 100755 --- a/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py +++ b/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py @@ -113,6 +113,55 @@ class qa_digital_carrier_allocator_cvc (gr_unittest.TestCase): self.tb.run () self.assertEqual(sink.data(), expected_result) + def test_002_t (self): + """ + once again, but this time add a sync word + """ + fft_len = 6 + sync_word = (0,) * fft_len + tx_symbols = (1, 2, 3, 4, 5, 6) + pilot_symbols = ((1j,),) + occupied_carriers = ((-1, 1, 2),) + pilot_carriers = ((3,),) + expected_result = sync_word + (1j, 0, 1, 0, 2, 3) + (1j, 0, 4, 0, 5, 6) + tag_name = "len" + tag = gr.tag_t() + tag.offset = 0 + tag.key = pmt.string_to_symbol(tag_name) + tag.value = pmt.from_long(len(tx_symbols)) + special_tag1 = gr.tag_t() + special_tag1.offset = 0 + special_tag1.key = pmt.string_to_symbol("spam") + special_tag1.value = pmt.to_pmt(23) + special_tag2 = gr.tag_t() + special_tag2.offset = 4 + special_tag2.key = pmt.string_to_symbol("eggs") + special_tag2.value = pmt.to_pmt(42) + src = blocks.vector_source_c( + tx_symbols, False, 1, + (tag, special_tag1, special_tag2) + ) + alloc = digital.ofdm_carrier_allocator_cvc( + fft_len, + occupied_carriers, + pilot_carriers, + pilot_symbols, + sync_words=(sync_word,), + len_tag_key=tag_name + ) + sink = blocks.vector_sink_c(fft_len) + self.tb.connect(src, alloc, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_result) + tags = [gr.tag_to_python(x) for x in sink.tags()] + tags = sorted([(x.offset, x.key, x.value) for x in tags]) + tags_expected = [ + (0, 'len', 3), + (0, 'spam', 23), + (2, 'eggs', 42), + ] + self.assertEqual(tags, tags_expected) + def test_003_t (self): """ more advanced: @@ -156,7 +205,7 @@ class qa_digital_carrier_allocator_cvc (gr_unittest.TestCase): testtag4.offset = 2*len(tx_symbols)-1 # Last OFDM symbol of packet 2 testtag4.key = pmt.string_to_symbol('tag4') testtag4.value = pmt.from_long(0) - src = blocks.vector_source_c(tx_symbols * 2, False, 1, + src = blocks.vector_source_c(tx_symbols * 2, False, 1, (tag1, tag2, testtag1, testtag2, testtag3, testtag4)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, |