delete packet_pad block
This commit is contained in:
@@ -12,7 +12,6 @@ install(FILES
|
|||||||
foo_random_periodic_msg_source.block.yml
|
foo_random_periodic_msg_source.block.yml
|
||||||
foo_valve.block.yml
|
foo_valve.block.yml
|
||||||
foo_channel_model.block.yml
|
foo_channel_model.block.yml
|
||||||
foo_packet_pad.block.yml
|
|
||||||
foo_rtt_measure.block.yml
|
foo_rtt_measure.block.yml
|
||||||
foo_wireshark_connector.block.yml
|
foo_wireshark_connector.block.yml
|
||||||
foo_packet_dropper.block.yml
|
foo_packet_dropper.block.yml
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
# auto-generated by grc.converter
|
|
||||||
|
|
||||||
id: foo_packet_pad
|
|
||||||
label: Packet Pad
|
|
||||||
category: '[Foo]'
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
- id: debug
|
|
||||||
label: Debug
|
|
||||||
dtype: bool
|
|
||||||
default: 'False'
|
|
||||||
options: ['True', 'False']
|
|
||||||
option_labels: [Enable, Disable]
|
|
||||||
- id: delay
|
|
||||||
label: Delay
|
|
||||||
dtype: bool
|
|
||||||
default: 'False'
|
|
||||||
options: ['True', 'False']
|
|
||||||
option_labels: [Enable, Disable]
|
|
||||||
- id: delay_sec
|
|
||||||
label: Delay Sec
|
|
||||||
dtype: real
|
|
||||||
default: '0.001'
|
|
||||||
- id: pad_front
|
|
||||||
label: Pad Front
|
|
||||||
dtype: int
|
|
||||||
default: '0'
|
|
||||||
- id: pad_tail
|
|
||||||
label: Pad Tail
|
|
||||||
dtype: int
|
|
||||||
default: '0'
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
- domain: stream
|
|
||||||
dtype: complex
|
|
||||||
multiplicity: '1'
|
|
||||||
|
|
||||||
outputs:
|
|
||||||
- domain: stream
|
|
||||||
dtype: complex
|
|
||||||
multiplicity: '1'
|
|
||||||
asserts:
|
|
||||||
- ${ pad_front >= 0 }
|
|
||||||
- ${ pad_tail >= 0 }
|
|
||||||
- ${ delay_sec > 0 }
|
|
||||||
|
|
||||||
templates:
|
|
||||||
imports: import foo
|
|
||||||
make: foo.packet_pad(${debug}, ${delay}, ${delay_sec}, ${pad_front}, ${pad_tail})
|
|
||||||
|
|
||||||
file_format: 1
|
|
||||||
@@ -14,7 +14,6 @@ install(FILES
|
|||||||
burst_tagger.h
|
burst_tagger.h
|
||||||
channel_model.h
|
channel_model.h
|
||||||
packet_dropper.h
|
packet_dropper.h
|
||||||
packet_pad.h
|
|
||||||
packet_pad2.h
|
packet_pad2.h
|
||||||
periodic_msg_source.h
|
periodic_msg_source.h
|
||||||
random_periodic_msg_source.h
|
random_periodic_msg_source.h
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
|
||||||
*
|
|
||||||
* This program 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 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#ifndef INCLUDED_FOO_PACKET_PAD_H
|
|
||||||
#define INCLUDED_FOO_PACKET_PAD_H
|
|
||||||
|
|
||||||
#include <foo/api.h>
|
|
||||||
#include <gnuradio/block.h>
|
|
||||||
|
|
||||||
namespace gr {
|
|
||||||
namespace foo {
|
|
||||||
|
|
||||||
class FOO_API packet_pad : virtual public gr::block
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
typedef std::shared_ptr<packet_pad> sptr;
|
|
||||||
static sptr make(bool debug = false, bool delay=false, double delay_sec=0.01, unsigned int pad_front = 0, unsigned int pad_tail = 0);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace foo
|
|
||||||
} // namespace gr
|
|
||||||
|
|
||||||
#endif /* INCLUDED_FOO_PACKET_PAD_H */
|
|
||||||
@@ -23,7 +23,6 @@ list(APPEND foo_sources
|
|||||||
channel_model_impl.cc
|
channel_model_impl.cc
|
||||||
packet_dropper_impl.cc
|
packet_dropper_impl.cc
|
||||||
packet_pad2.cc
|
packet_pad2.cc
|
||||||
packet_pad_impl.cc
|
|
||||||
periodic_msg_source_impl.cc
|
periodic_msg_source_impl.cc
|
||||||
random_periodic_msg_source_impl.cc
|
random_periodic_msg_source_impl.cc
|
||||||
rtt_measure_impl.cc
|
rtt_measure_impl.cc
|
||||||
|
|||||||
@@ -1,190 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
|
||||||
*
|
|
||||||
* This program 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 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include "packet_pad_impl.h"
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <gnuradio/io_signature.h>
|
|
||||||
#include <iostream>
|
|
||||||
#ifdef FOO_UHD
|
|
||||||
#include <uhd/types/time_spec.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace gr::foo;
|
|
||||||
|
|
||||||
#define dout d_debug && std::cout
|
|
||||||
|
|
||||||
packet_pad_impl::packet_pad_impl(bool debug, bool delay, double delay_sec,
|
|
||||||
unsigned int pad_front, unsigned int pad_tail) : block("packet_pad",
|
|
||||||
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
|
||||||
gr::io_signature::make(1, 1, sizeof(gr_complex))),
|
|
||||||
d_debug(debug),
|
|
||||||
d_pad_front(pad_front),
|
|
||||||
d_pad_tail(pad_tail),
|
|
||||||
d_pad(0),
|
|
||||||
d_eob(false),
|
|
||||||
d_delay(delay),
|
|
||||||
d_delay_sec(delay_sec) {
|
|
||||||
|
|
||||||
set_relative_rate(1);
|
|
||||||
set_tag_propagation_policy(block::TPP_DONT);
|
|
||||||
}
|
|
||||||
|
|
||||||
packet_pad_impl::~packet_pad_impl(){
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
packet_pad_impl::add_sob(uint64_t item) {
|
|
||||||
dout << "PACKET PAD: insert sob at: " << item << std::endl;
|
|
||||||
|
|
||||||
static const pmt::pmt_t sob_key = pmt::string_to_symbol("tx_sob");
|
|
||||||
static const pmt::pmt_t value = pmt::PMT_T;
|
|
||||||
static const pmt::pmt_t srcid = pmt::string_to_symbol(alias());
|
|
||||||
add_item_tag(0, item, sob_key, value, srcid);
|
|
||||||
|
|
||||||
#ifdef FOO_UHD
|
|
||||||
if(d_delay) {
|
|
||||||
static const pmt::pmt_t time_key = pmt::string_to_symbol("tx_time");
|
|
||||||
double t_now(
|
|
||||||
std::chrono::duration<double>(std::chrono::system_clock::now()
|
|
||||||
.time_since_epoch()
|
|
||||||
).count()
|
|
||||||
);
|
|
||||||
uhd::time_spec_t now = uhd::time_spec_t(t_now)
|
|
||||||
+ uhd::time_spec_t(d_delay_sec);
|
|
||||||
|
|
||||||
const pmt::pmt_t time_value = pmt::make_tuple(
|
|
||||||
pmt::from_uint64(now.get_full_secs()),
|
|
||||||
pmt::from_double(now.get_frac_secs())
|
|
||||||
);
|
|
||||||
add_item_tag(0, item, time_key, time_value, srcid);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
packet_pad_impl::add_eob(uint64_t item) {
|
|
||||||
dout << "PACKET PAD: insert eob at: " << item << std::endl;
|
|
||||||
|
|
||||||
static const pmt::pmt_t eob_key = pmt::string_to_symbol("tx_eob");
|
|
||||||
static const pmt::pmt_t value = pmt::PMT_T;
|
|
||||||
static const pmt::pmt_t srcid = pmt::string_to_symbol(alias());
|
|
||||||
add_item_tag(0, item, eob_key, value, srcid);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
packet_pad_impl::general_work (int noutput_items, gr_vector_int& ninput_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];
|
|
||||||
|
|
||||||
int ninput = ninput_items[0];
|
|
||||||
int noutput = noutput_items;
|
|
||||||
|
|
||||||
dout << "call: pad " << d_pad << " ninput " << ninput << " noutput " << noutput << std::endl;
|
|
||||||
|
|
||||||
// pad zeros
|
|
||||||
if(d_pad) {
|
|
||||||
int n = std::min(d_pad, noutput);
|
|
||||||
std::memset(out, 0, n * sizeof(gr_complex));
|
|
||||||
d_pad -= n;
|
|
||||||
|
|
||||||
dout << "padded zeros: " << n << std::endl;
|
|
||||||
|
|
||||||
// add end of burst tag
|
|
||||||
if(!d_pad && d_eob) {
|
|
||||||
d_eob = false;
|
|
||||||
add_eob(nitems_written(0) + n - 1);
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
// search for tags
|
|
||||||
const uint64_t nread = this->nitems_read(0);
|
|
||||||
std::vector<gr::tag_t> tags;
|
|
||||||
get_tags_in_range(tags, 0, nread, nread + ninput);
|
|
||||||
std::sort(tags.begin(), tags.end(), tag_t::offset_compare);
|
|
||||||
|
|
||||||
uint64_t n = std::min(ninput, noutput);
|
|
||||||
|
|
||||||
if(tags.size()) {
|
|
||||||
tag_t t = tags[0];
|
|
||||||
|
|
||||||
dout << "found tag: " << pmt::symbol_to_string(t.key) << std::endl;
|
|
||||||
|
|
||||||
uint64_t read = nitems_read(0);
|
|
||||||
if(t.offset != read) {
|
|
||||||
dout << "tag does not start at current offset" << std::endl;
|
|
||||||
n = std::min(n, t.offset - read);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if(pmt::equal(t.key, pmt::mp("tx_sob"))) {
|
|
||||||
dout << "tx_sob tag" << std::endl;
|
|
||||||
add_sob(nitems_written(0));
|
|
||||||
d_pad = d_pad_front;
|
|
||||||
remove_item_tag(0, t);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
|
||||||
} else if(pmt::equal(t.key, pmt::mp("tx_eob"))) {
|
|
||||||
dout << "tx_eob tag" << std::endl;
|
|
||||||
d_pad = d_pad_tail;
|
|
||||||
d_eob = true;
|
|
||||||
if(n) {
|
|
||||||
|
|
||||||
if(!d_pad) {
|
|
||||||
add_eob(nitems_written(0));
|
|
||||||
d_eob = false;
|
|
||||||
}
|
|
||||||
memcpy(out, in, sizeof(gr_complex));
|
|
||||||
consume(0, 1);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
dout << "unknown tag" << std::endl;
|
|
||||||
if(tags.size() > 1) {
|
|
||||||
n = std::min(n, tags[1].offset - read);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dout << "copying : " << n << std::endl;
|
|
||||||
|
|
||||||
std::memcpy(out, in, n * sizeof(gr_complex));
|
|
||||||
consume(0, n);
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
packet_pad_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(d_pad) {
|
|
||||||
ninput_items_required[0] = 0;
|
|
||||||
} else {
|
|
||||||
ninput_items_required[0] = noutput_items;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
packet_pad::sptr
|
|
||||||
packet_pad::make(bool debug, bool delay, double delay_sec, unsigned int pad_front, unsigned int pad_tail) {
|
|
||||||
return gnuradio::get_initial_sptr(new packet_pad_impl(debug, delay, delay_sec, pad_front, pad_tail));
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013 Bastian Bloessl <bloessl@ccs-labs.org>.
|
|
||||||
*
|
|
||||||
* 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_FOO_PACKET_PAD_IMPL_H
|
|
||||||
#define INCLUDED_FOO_PACKET_PAD_IMPL_H
|
|
||||||
|
|
||||||
#include <foo/packet_pad.h>
|
|
||||||
|
|
||||||
namespace gr {
|
|
||||||
namespace foo {
|
|
||||||
|
|
||||||
class packet_pad_impl : public packet_pad {
|
|
||||||
private:
|
|
||||||
void add_eob(uint64_t item);
|
|
||||||
void add_sob(uint64_t item);
|
|
||||||
|
|
||||||
bool d_debug;
|
|
||||||
bool d_delay;
|
|
||||||
double d_delay_sec;
|
|
||||||
|
|
||||||
int d_pad_front;
|
|
||||||
int d_pad_tail;
|
|
||||||
|
|
||||||
int d_pad;
|
|
||||||
bool d_eob;
|
|
||||||
|
|
||||||
public:
|
|
||||||
packet_pad_impl(bool debug, bool delay, double delay_sec,
|
|
||||||
unsigned int pad_front, unsigned int pad_tail);
|
|
||||||
|
|
||||||
~packet_pad_impl();
|
|
||||||
|
|
||||||
int general_work (int noutput_items,
|
|
||||||
gr_vector_int& ninput_items,
|
|
||||||
gr_vector_const_void_star& input_items,
|
|
||||||
gr_vector_void_star& output_items);
|
|
||||||
void forecast (int noutput_items,
|
|
||||||
gr_vector_int &ninput_items_required);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace foo
|
|
||||||
} // namespace gr
|
|
||||||
|
|
||||||
#endif /* INCLUDED_FOO_BURST_TAGGER_IMPL_H */
|
|
||||||
|
|
||||||
@@ -35,7 +35,6 @@ list(APPEND foo_python_files
|
|||||||
channel_model_python.cc
|
channel_model_python.cc
|
||||||
packet_dropper_python.cc
|
packet_dropper_python.cc
|
||||||
packet_pad2_python.cc
|
packet_pad2_python.cc
|
||||||
packet_pad_python.cc
|
|
||||||
pad_tagged_stream_python.cc
|
pad_tagged_stream_python.cc
|
||||||
periodic_msg_source_python.cc
|
periodic_msg_source_python.cc
|
||||||
random_periodic_msg_source_python.cc
|
random_periodic_msg_source_python.cc
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* This file is part of GNU Radio
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "pydoc_macros.h"
|
|
||||||
#define D(...) DOC(gr,foo, __VA_ARGS__ )
|
|
||||||
/*
|
|
||||||
This file contains placeholders for docstrings for the Python bindings.
|
|
||||||
Do not edit! These were automatically extracted during the binding process
|
|
||||||
and will be overwritten during the build process
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const char *__doc_gr_foo_packet_pad = R"doc()doc";
|
|
||||||
|
|
||||||
|
|
||||||
static const char *__doc_gr_foo_packet_pad_packet_pad = R"doc()doc";
|
|
||||||
|
|
||||||
|
|
||||||
static const char *__doc_gr_foo_packet_pad_make = R"doc()doc";
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* This file is part of GNU Radio
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***********************************************************************************/
|
|
||||||
/* This file is automatically generated using bindtool and can be manually edited */
|
|
||||||
/* The following lines can be configured to regenerate this file during cmake */
|
|
||||||
/* If manual edits are made, the following tags should be modified accordingly. */
|
|
||||||
/* BINDTOOL_GEN_AUTOMATIC(0) */
|
|
||||||
/* BINDTOOL_USE_PYGCCXML(0) */
|
|
||||||
/* BINDTOOL_HEADER_FILE(packet_pad.h) */
|
|
||||||
/* BINDTOOL_HEADER_FILE_HASH(80e623b2c0e35d7918618f96aff3c11c) */
|
|
||||||
/***********************************************************************************/
|
|
||||||
|
|
||||||
#include <pybind11/complex.h>
|
|
||||||
#include <pybind11/pybind11.h>
|
|
||||||
#include <pybind11/stl.h>
|
|
||||||
|
|
||||||
namespace py = pybind11;
|
|
||||||
|
|
||||||
#include <foo/packet_pad.h>
|
|
||||||
// pydoc.h is automatically generated in the build directory
|
|
||||||
#include <packet_pad_pydoc.h>
|
|
||||||
|
|
||||||
void bind_packet_pad(py::module& m)
|
|
||||||
{
|
|
||||||
|
|
||||||
using packet_pad = ::gr::foo::packet_pad;
|
|
||||||
|
|
||||||
|
|
||||||
py::class_<packet_pad, gr::block, gr::basic_block,
|
|
||||||
std::shared_ptr<packet_pad>>(m, "packet_pad", D(packet_pad))
|
|
||||||
|
|
||||||
.def(py::init(&packet_pad::make),
|
|
||||||
py::arg("debug") = false,
|
|
||||||
py::arg("delay") = false,
|
|
||||||
py::arg("delay_sec") = 0.01,
|
|
||||||
py::arg("pad_front") = 0,
|
|
||||||
py::arg("pad_tail") = 0,
|
|
||||||
D(packet_pad,make)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -25,7 +25,6 @@ void bind_burst_tagger(py::module& m);
|
|||||||
void bind_channel_model(py::module& m);
|
void bind_channel_model(py::module& m);
|
||||||
void bind_packet_dropper(py::module& m);
|
void bind_packet_dropper(py::module& m);
|
||||||
void bind_packet_pad2(py::module& m);
|
void bind_packet_pad2(py::module& m);
|
||||||
void bind_packet_pad(py::module& m);
|
|
||||||
void bind_pad_tagged_stream(py::module& m);
|
void bind_pad_tagged_stream(py::module& m);
|
||||||
void bind_periodic_msg_source(py::module& m);
|
void bind_periodic_msg_source(py::module& m);
|
||||||
void bind_random_periodic_msg_source(py::module& m);
|
void bind_random_periodic_msg_source(py::module& m);
|
||||||
@@ -62,7 +61,6 @@ PYBIND11_MODULE(foo_python, m)
|
|||||||
bind_channel_model(m);
|
bind_channel_model(m);
|
||||||
bind_packet_dropper(m);
|
bind_packet_dropper(m);
|
||||||
bind_packet_pad2(m);
|
bind_packet_pad2(m);
|
||||||
bind_packet_pad(m);
|
|
||||||
bind_pad_tagged_stream(m);
|
bind_pad_tagged_stream(m);
|
||||||
bind_periodic_msg_source(m);
|
bind_periodic_msg_source(m);
|
||||||
bind_random_periodic_msg_source(m);
|
bind_random_periodic_msg_source(m);
|
||||||
|
|||||||
Reference in New Issue
Block a user