gr-hamnet70: added a block for delaying tags
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.
This commit is contained in:
parent
664d8fe0e6
commit
be4ad84982
|
@ -21,5 +21,6 @@ install(FILES
|
||||||
hamnet70_correct_phase_from_tag.xml
|
hamnet70_correct_phase_from_tag.xml
|
||||||
hamnet70_correct_frequency.xml
|
hamnet70_correct_frequency.xml
|
||||||
hamnet70_freq_est_lr.xml
|
hamnet70_freq_est_lr.xml
|
||||||
hamnet70_pid_controller.xml DESTINATION share/gnuradio/grc/blocks
|
hamnet70_pid_controller.xml
|
||||||
|
hamnet70_insert_delayed_tag.xml DESTINATION share/gnuradio/grc/blocks
|
||||||
)
|
)
|
||||||
|
|
33
gr-hamnet70/grc/hamnet70_insert_delayed_tag.xml
Normal file
33
gr-hamnet70/grc/hamnet70_insert_delayed_tag.xml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<block>
|
||||||
|
<name>Insert Delayed Tag</name>
|
||||||
|
<key>hamnet70_insert_delayed_tag</key>
|
||||||
|
<category>[hamnet70]</category>
|
||||||
|
<import>import hamnet70</import>
|
||||||
|
<make>hamnet70.insert_delayed_tag($trigger_tag, $insert_tag, $delay)</make>
|
||||||
|
<param>
|
||||||
|
<name>Trigger Tag Name</name>
|
||||||
|
<key>trigger_tag</key>
|
||||||
|
<type>string</type>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Inserted Tag Name</name>
|
||||||
|
<key>insert_tag</key>
|
||||||
|
<type>string</type>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Delay</name>
|
||||||
|
<key>delay</key>
|
||||||
|
<type>int</type>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<sink>
|
||||||
|
<name>in</name>
|
||||||
|
<type>complex</type>
|
||||||
|
</sink>
|
||||||
|
|
||||||
|
<source>
|
||||||
|
<name>out</name>
|
||||||
|
<type>complex</type>
|
||||||
|
</source>
|
||||||
|
</block>
|
|
@ -26,5 +26,6 @@ install(FILES
|
||||||
correct_phase_from_tag.h
|
correct_phase_from_tag.h
|
||||||
correct_frequency.h
|
correct_frequency.h
|
||||||
freq_est_lr.h
|
freq_est_lr.h
|
||||||
pid_controller.h DESTINATION include/hamnet70
|
pid_controller.h
|
||||||
|
insert_delayed_tag.h DESTINATION include/hamnet70
|
||||||
)
|
)
|
||||||
|
|
56
gr-hamnet70/include/hamnet70/insert_delayed_tag.h
Normal file
56
gr-hamnet70/include/hamnet70/insert_delayed_tag.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/* -*- 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INCLUDED_HAMNET70_INSERT_DELAYED_TAG_H
|
||||||
|
#define INCLUDED_HAMNET70_INSERT_DELAYED_TAG_H
|
||||||
|
|
||||||
|
#include <hamnet70/api.h>
|
||||||
|
#include <gnuradio/sync_block.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace hamnet70 {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief <+description of block+>
|
||||||
|
* \ingroup hamnet70
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class HAMNET70_API insert_delayed_tag : virtual public gr::sync_block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef boost::shared_ptr<insert_delayed_tag> sptr;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Return a shared_ptr to a new instance of hamnet70::insert_delayed_tag.
|
||||||
|
*
|
||||||
|
* To avoid accidental use of raw pointers, hamnet70::insert_delayed_tag's
|
||||||
|
* constructor is in a private implementation
|
||||||
|
* class. hamnet70::insert_delayed_tag::make is the public interface for
|
||||||
|
* creating new instances.
|
||||||
|
*/
|
||||||
|
static sptr make(const std::string &trigger_tag, const std::string &insert_tag, size_t delay);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace hamnet70
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_HAMNET70_INSERT_DELAYED_TAG_H */
|
||||||
|
|
|
@ -30,6 +30,7 @@ list(APPEND hamnet70_sources
|
||||||
correct_frequency_impl.cc
|
correct_frequency_impl.cc
|
||||||
freq_est_lr_impl.cc
|
freq_est_lr_impl.cc
|
||||||
pid_controller_impl.cc
|
pid_controller_impl.cc
|
||||||
|
insert_delayed_tag_impl.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
set(hamnet70_sources "${hamnet70_sources}" PARENT_SCOPE)
|
set(hamnet70_sources "${hamnet70_sources}" PARENT_SCOPE)
|
||||||
|
|
95
gr-hamnet70/lib/insert_delayed_tag_impl.cc
Normal file
95
gr-hamnet70/lib/insert_delayed_tag_impl.cc
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
/* -*- 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 */
|
||||||
|
|
51
gr-hamnet70/lib/insert_delayed_tag_impl.h
Normal file
51
gr-hamnet70/lib/insert_delayed_tag_impl.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/* -*- 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_HAMNET70_INSERT_DELAYED_TAG_IMPL_H
|
||||||
|
#define INCLUDED_HAMNET70_INSERT_DELAYED_TAG_IMPL_H
|
||||||
|
|
||||||
|
#include <hamnet70/insert_delayed_tag.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace hamnet70 {
|
||||||
|
|
||||||
|
class insert_delayed_tag_impl : public insert_delayed_tag
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
pmt::pmt_t d_triggerTagName;
|
||||||
|
pmt::pmt_t d_insertTagName;
|
||||||
|
size_t d_delay;
|
||||||
|
int d_countdownToTag;
|
||||||
|
|
||||||
|
public:
|
||||||
|
insert_delayed_tag_impl(const std::string &trigger_tag, const std::string &insert_tag, size_t delay);
|
||||||
|
~insert_delayed_tag_impl();
|
||||||
|
|
||||||
|
// Where all the action really happens
|
||||||
|
int work(int noutput_items,
|
||||||
|
gr_vector_const_void_star &input_items,
|
||||||
|
gr_vector_void_star &output_items);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace hamnet70
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_HAMNET70_INSERT_DELAYED_TAG_IMPL_H */
|
||||||
|
|
|
@ -46,3 +46,4 @@ set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig)
|
||||||
##GR_ADD_TEST(qa_correct_frequency ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_correct_frequency.py)
|
##GR_ADD_TEST(qa_correct_frequency ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_correct_frequency.py)
|
||||||
#GR_ADD_TEST(qa_freq_est_lr ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_freq_est_lr.py)
|
#GR_ADD_TEST(qa_freq_est_lr ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_freq_est_lr.py)
|
||||||
#GR_ADD_TEST(qa_pid_controller ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_pid_controller.py)
|
#GR_ADD_TEST(qa_pid_controller ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_pid_controller.py)
|
||||||
|
#GR_ADD_TEST(qa_insert_delayed_tag ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_insert_delayed_tag.py)
|
||||||
|
|
41
gr-hamnet70/python/qa_insert_delayed_tag.py
Executable file
41
gr-hamnet70/python/qa_insert_delayed_tag.py
Executable file
|
@ -0,0 +1,41 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
from gnuradio import gr, gr_unittest
|
||||||
|
from gnuradio import blocks
|
||||||
|
import hamnet70_swig as hamnet70
|
||||||
|
|
||||||
|
class qa_insert_delayed_tag (gr_unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp (self):
|
||||||
|
self.tb = gr.top_block ()
|
||||||
|
|
||||||
|
def tearDown (self):
|
||||||
|
self.tb = None
|
||||||
|
|
||||||
|
def test_001_t (self):
|
||||||
|
# set up fg
|
||||||
|
self.tb.run ()
|
||||||
|
# check data
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
gr_unittest.run(qa_insert_delayed_tag, "qa_insert_delayed_tag.xml")
|
|
@ -12,6 +12,7 @@
|
||||||
#include "hamnet70/correct_frequency.h"
|
#include "hamnet70/correct_frequency.h"
|
||||||
#include "hamnet70/freq_est_lr.h"
|
#include "hamnet70/freq_est_lr.h"
|
||||||
#include "hamnet70/pid_controller.h"
|
#include "hamnet70/pid_controller.h"
|
||||||
|
#include "hamnet70/insert_delayed_tag.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,3 +25,5 @@ GR_SWIG_BLOCK_MAGIC2(hamnet70, correct_frequency);
|
||||||
GR_SWIG_BLOCK_MAGIC2(hamnet70, freq_est_lr);
|
GR_SWIG_BLOCK_MAGIC2(hamnet70, freq_est_lr);
|
||||||
%include "hamnet70/pid_controller.h"
|
%include "hamnet70/pid_controller.h"
|
||||||
GR_SWIG_BLOCK_MAGIC2(hamnet70, pid_controller);
|
GR_SWIG_BLOCK_MAGIC2(hamnet70, pid_controller);
|
||||||
|
%include "hamnet70/insert_delayed_tag.h"
|
||||||
|
GR_SWIG_BLOCK_MAGIC2(hamnet70, insert_delayed_tag);
|
||||||
|
|
Loading…
Reference in a new issue