add packet pad2 block
this block inserts sob/eob, padding and delay
This commit is contained in:
@@ -21,6 +21,7 @@ install(FILES
|
|||||||
foo_burst_tagger.xml
|
foo_burst_tagger.xml
|
||||||
foo_packet_dropper.xml
|
foo_packet_dropper.xml
|
||||||
foo_packet_pad.xml
|
foo_packet_pad.xml
|
||||||
|
foo_packet_pad2.xml
|
||||||
foo_periodic_msg_source.xml
|
foo_periodic_msg_source.xml
|
||||||
foo_rtt_measure.xml
|
foo_rtt_measure.xml
|
||||||
foo_wireshark_connector.xml
|
foo_wireshark_connector.xml
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<block>
|
||||||
|
<name>Packet Pad2</name>
|
||||||
|
<key>foo_packet_pad2</key>
|
||||||
|
<category>Foo</category>
|
||||||
|
<import>import foo</import>
|
||||||
|
<make>foo.packet_pad2($debug, $delay, $delay_sec, $pad_front, $pad_tail)</make>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Debug</name>
|
||||||
|
<key>debug</key>
|
||||||
|
<value>False</value>
|
||||||
|
<type>bool</type>
|
||||||
|
|
||||||
|
<option>
|
||||||
|
<name>Enable</name>
|
||||||
|
<key>True</key>
|
||||||
|
</option>
|
||||||
|
<option>
|
||||||
|
<name>Disable</name>
|
||||||
|
<key>False</key>
|
||||||
|
</option>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Delay</name>
|
||||||
|
<key>delay</key>
|
||||||
|
<value>False</value>
|
||||||
|
<type>bool</type>
|
||||||
|
|
||||||
|
<option>
|
||||||
|
<name>Enable</name>
|
||||||
|
<key>True</key>
|
||||||
|
</option>
|
||||||
|
<option>
|
||||||
|
<name>Disable</name>
|
||||||
|
<key>False</key>
|
||||||
|
</option>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Delay Sec</name>
|
||||||
|
<key>delay_sec</key>
|
||||||
|
<value>0.001</value>
|
||||||
|
<type>real</type>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Pad Front</name>
|
||||||
|
<key>pad_front</key>
|
||||||
|
<value>0</value>
|
||||||
|
<type>int</type>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Pad Tail</name>
|
||||||
|
<key>pad_tail</key>
|
||||||
|
<value>0</value>
|
||||||
|
<type>int</type>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<check>$pad_front >= 0</check>
|
||||||
|
<check>$pad_tail >= 0</check>
|
||||||
|
<check>$delay_sec > 0</check>
|
||||||
|
|
||||||
|
<sink>
|
||||||
|
<name>in</name>
|
||||||
|
<type>complex</type>
|
||||||
|
<nports>1</nports>
|
||||||
|
</sink>
|
||||||
|
|
||||||
|
<source>
|
||||||
|
<name>out</name>
|
||||||
|
<type>complex</type>
|
||||||
|
<nports>1</nports>
|
||||||
|
</source>
|
||||||
|
|
||||||
|
</block>
|
||||||
@@ -25,6 +25,7 @@ install(FILES
|
|||||||
burst_tagger.h
|
burst_tagger.h
|
||||||
packet_dropper.h
|
packet_dropper.h
|
||||||
packet_pad.h
|
packet_pad.h
|
||||||
|
packet_pad2.h
|
||||||
periodic_msg_source.h
|
periodic_msg_source.h
|
||||||
wireshark_connector.h
|
wireshark_connector.h
|
||||||
rtt_measure.h
|
rtt_measure.h
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 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_PAD2_H
|
||||||
|
#define INCLUDED_FOO_PACKET_PAD2_H
|
||||||
|
|
||||||
|
#include <foo/api.h>
|
||||||
|
#include <gnuradio/tagged_stream_block.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace foo {
|
||||||
|
|
||||||
|
class FOO_API packet_pad2 : virtual public gr::tagged_stream_block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<packet_pad2> 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_PAD2_H */
|
||||||
@@ -35,6 +35,7 @@ list(APPEND foo_sources
|
|||||||
burst_tagger_impl.cc
|
burst_tagger_impl.cc
|
||||||
packet_dropper_impl.cc
|
packet_dropper_impl.cc
|
||||||
packet_pad_impl.cc
|
packet_pad_impl.cc
|
||||||
|
packet_pad2.cc
|
||||||
periodic_msg_source_impl.cc
|
periodic_msg_source_impl.cc
|
||||||
wireshark_connector_impl.cc
|
wireshark_connector_impl.cc
|
||||||
rtt_measure_impl.cc
|
rtt_measure_impl.cc
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* 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 <foo/packet_pad2.h>
|
||||||
|
|
||||||
|
#include <gnuradio/io_signature.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <uhd/types/time_spec.hpp>
|
||||||
|
|
||||||
|
using namespace gr::foo;
|
||||||
|
|
||||||
|
|
||||||
|
class packet_pad2_impl : public packet_pad2 {
|
||||||
|
|
||||||
|
public:
|
||||||
|
packet_pad2_impl(bool debug, bool delay, double delay_sec, unsigned int pad_front, unsigned int pad_tail) : tagged_stream_block("foo_packet_pad2",
|
||||||
|
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
||||||
|
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
||||||
|
"packet_len"),
|
||||||
|
d_debug(debug),
|
||||||
|
d_delay(delay),
|
||||||
|
d_delay_sec(delay_sec),
|
||||||
|
d_pad_front(pad_front),
|
||||||
|
d_pad_tail(pad_tail) {
|
||||||
|
set_tag_propagation_policy(block::TPP_DONT);
|
||||||
|
}
|
||||||
|
|
||||||
|
~packet_pad2_impl(){
|
||||||
|
}
|
||||||
|
|
||||||
|
int calculate_output_stream_length(const gr_vector_int &ninput_items) {
|
||||||
|
return ninput_items[0] + d_pad_front + d_pad_tail;
|
||||||
|
}
|
||||||
|
|
||||||
|
int 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];
|
||||||
|
|
||||||
|
std::memset(out, 0x00, sizeof(gr_complex) * ninput_items[0] + d_pad_front + d_pad_tail);
|
||||||
|
|
||||||
|
std::memcpy(out + d_pad_front, in, sizeof(gr_complex) * ninput_items[0]);
|
||||||
|
|
||||||
|
|
||||||
|
int produced = ninput_items[0] + d_pad_front + d_pad_tail;
|
||||||
|
const pmt::pmt_t value = pmt::PMT_T;
|
||||||
|
const pmt::pmt_t src = pmt::string_to_symbol(alias());
|
||||||
|
|
||||||
|
add_item_tag(0, nitems_written(0), pmt::mp("tx_sob"), value, src);
|
||||||
|
add_item_tag(0, nitems_written(0) + produced - 1, pmt::mp("tx_eob"), value, src);
|
||||||
|
|
||||||
|
if(d_delay) {
|
||||||
|
static const pmt::pmt_t time_key = pmt::string_to_symbol("tx_time");
|
||||||
|
struct timeval t;
|
||||||
|
gettimeofday(&t, NULL);
|
||||||
|
uhd::time_spec_t now = uhd::time_spec_t(t.tv_sec + t.tv_usec / 1000000.0)
|
||||||
|
+ 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, nitems_written(0), time_key, time_value, src);
|
||||||
|
}
|
||||||
|
|
||||||
|
return produced;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool d_debug;
|
||||||
|
bool d_delay;
|
||||||
|
double d_delay_sec;
|
||||||
|
unsigned int d_pad_front;
|
||||||
|
unsigned int d_pad_tail;
|
||||||
|
};
|
||||||
|
|
||||||
|
packet_pad2::sptr
|
||||||
|
packet_pad2::make(bool debug, bool delay, double delay_sec, unsigned int pad_front, unsigned int pad_tail) {
|
||||||
|
return gnuradio::get_initial_sptr(new packet_pad2_impl(debug, delay, delay_sec, pad_front, pad_tail));
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "foo/burst_tagger.h"
|
#include "foo/burst_tagger.h"
|
||||||
#include "foo/packet_dropper.h"
|
#include "foo/packet_dropper.h"
|
||||||
#include "foo/packet_pad.h"
|
#include "foo/packet_pad.h"
|
||||||
|
#include "foo/packet_pad2.h"
|
||||||
#include "foo/periodic_msg_source.h"
|
#include "foo/periodic_msg_source.h"
|
||||||
#include "foo/wireshark_connector.h"
|
#include "foo/wireshark_connector.h"
|
||||||
#include "foo/rtt_measure.h"
|
#include "foo/rtt_measure.h"
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
%include "foo/burst_tagger.h"
|
%include "foo/burst_tagger.h"
|
||||||
%include "foo/packet_dropper.h"
|
%include "foo/packet_dropper.h"
|
||||||
%include "foo/packet_pad.h"
|
%include "foo/packet_pad.h"
|
||||||
|
%include "foo/packet_pad2.h"
|
||||||
%include "foo/periodic_msg_source.h"
|
%include "foo/periodic_msg_source.h"
|
||||||
%include "foo/wireshark_connector.h"
|
%include "foo/wireshark_connector.h"
|
||||||
%include "foo/rtt_measure.h"
|
%include "foo/rtt_measure.h"
|
||||||
@@ -26,6 +28,7 @@
|
|||||||
GR_SWIG_BLOCK_MAGIC2(foo, burst_tagger);
|
GR_SWIG_BLOCK_MAGIC2(foo, burst_tagger);
|
||||||
GR_SWIG_BLOCK_MAGIC2(foo, packet_dropper);
|
GR_SWIG_BLOCK_MAGIC2(foo, packet_dropper);
|
||||||
GR_SWIG_BLOCK_MAGIC2(foo, packet_pad);
|
GR_SWIG_BLOCK_MAGIC2(foo, packet_pad);
|
||||||
|
GR_SWIG_BLOCK_MAGIC2(foo, packet_pad2);
|
||||||
GR_SWIG_BLOCK_MAGIC2(foo, periodic_msg_source);
|
GR_SWIG_BLOCK_MAGIC2(foo, periodic_msg_source);
|
||||||
GR_SWIG_BLOCK_MAGIC2(foo, wireshark_connector);
|
GR_SWIG_BLOCK_MAGIC2(foo, wireshark_connector);
|
||||||
GR_SWIG_BLOCK_MAGIC2(foo, rtt_measure);
|
GR_SWIG_BLOCK_MAGIC2(foo, rtt_measure);
|
||||||
|
|||||||
Reference in New Issue
Block a user