Thomas Kolb
be4ad84982
This block is used to mark the start of the actual data, as needed by the Header/Payload Demultiplexer, instead of the beginning of the preamble, as needed by the frequency estimator.
96 lines
2.7 KiB
C++
96 lines
2.7 KiB
C++
/* -*- c++ -*- */
|
|
/*
|
|
* Copyright 2019 Thomas Kolb.
|
|
*
|
|
* This is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This software 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 software; 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 <gnuradio/io_signature.h>
|
|
#include "insert_delayed_tag_impl.h"
|
|
|
|
namespace gr {
|
|
namespace hamnet70 {
|
|
|
|
insert_delayed_tag::sptr
|
|
insert_delayed_tag::make(const std::string &trigger_tag, const std::string &insert_tag, size_t delay)
|
|
{
|
|
return gnuradio::get_initial_sptr
|
|
(new insert_delayed_tag_impl(trigger_tag, insert_tag, delay));
|
|
}
|
|
|
|
/*
|
|
* The private constructor
|
|
*/
|
|
insert_delayed_tag_impl::insert_delayed_tag_impl(const std::string &trigger_tag, const std::string &insert_tag, size_t delay)
|
|
: gr::sync_block("insert_delayed_tag",
|
|
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
|
gr::io_signature::make(1, 1, sizeof(gr_complex))),
|
|
d_triggerTagName(pmt::intern(trigger_tag)),
|
|
d_insertTagName(pmt::intern(insert_tag)),
|
|
d_delay(delay),
|
|
d_countdownToTag(-1)
|
|
{}
|
|
|
|
/*
|
|
* Our virtual destructor.
|
|
*/
|
|
insert_delayed_tag_impl::~insert_delayed_tag_impl()
|
|
{
|
|
}
|
|
|
|
int
|
|
insert_delayed_tag_impl::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];
|
|
|
|
std::vector<tag_t> tags;
|
|
get_tags_in_window(tags, 0, 0, noutput_items, pmt::intern("corr_est")); // FIXME: make name variable
|
|
size_t tagidx = 0;
|
|
|
|
for(size_t i = 0; i < noutput_items; i++) {
|
|
if((tagidx < tags.size()) && (tags[tagidx].offset == nitems_read(0) + i)) {
|
|
d_countdownToTag = static_cast<int>(d_delay);
|
|
tagidx++;
|
|
}
|
|
|
|
if(d_countdownToTag >= 0) {
|
|
d_countdownToTag--;
|
|
|
|
if(d_countdownToTag == 0) {
|
|
add_item_tag(0, nitems_read(0) + i, d_insertTagName, pmt::PMT_NIL);
|
|
}
|
|
}
|
|
|
|
*out = *in;
|
|
out++;
|
|
in++;
|
|
}
|
|
|
|
// Tell runtime system how many output items we produced.
|
|
return noutput_items;
|
|
}
|
|
|
|
} /* namespace hamnet70 */
|
|
} /* namespace gr */
|
|
|