add tx delay to packet pad
This commit is contained in:
+25
-1
@@ -5,7 +5,7 @@
|
|||||||
<key>foo_packet_pad</key>
|
<key>foo_packet_pad</key>
|
||||||
<category>Foo</category>
|
<category>Foo</category>
|
||||||
<import>import foo</import>
|
<import>import foo</import>
|
||||||
<make>foo.packet_pad($debug, $pad_front, $pad_tail)</make>
|
<make>foo.packet_pad($debug, $delay, $delay_sec, $pad_front, $pad_tail)</make>
|
||||||
|
|
||||||
<param>
|
<param>
|
||||||
<name>Debug</name>
|
<name>Debug</name>
|
||||||
@@ -23,6 +23,29 @@
|
|||||||
</option>
|
</option>
|
||||||
</param>
|
</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>
|
<param>
|
||||||
<name>Pad Front</name>
|
<name>Pad Front</name>
|
||||||
<key>pad_front</key>
|
<key>pad_front</key>
|
||||||
@@ -39,6 +62,7 @@
|
|||||||
|
|
||||||
<check>$pad_front >= 0</check>
|
<check>$pad_front >= 0</check>
|
||||||
<check>$pad_tail >= 0</check>
|
<check>$pad_tail >= 0</check>
|
||||||
|
<check>$delay_sec > 0</check>
|
||||||
|
|
||||||
<sink>
|
<sink>
|
||||||
<name>in</name>
|
<name>in</name>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class FOO_API packet_pad : virtual public gr::block
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
typedef boost::shared_ptr<packet_pad> sptr;
|
typedef boost::shared_ptr<packet_pad> sptr;
|
||||||
static sptr make(bool debug = false, unsigned int pad_front = 0, unsigned int pad_tail = 0);
|
static sptr make(bool debug = false, bool delay=false, double delay_sec=0.01, unsigned int pad_front = 0, unsigned int pad_tail = 0);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ list(APPEND foo_sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(gnuradio-foo SHARED ${foo_sources})
|
add_library(gnuradio-foo SHARED ${foo_sources})
|
||||||
target_link_libraries(gnuradio-foo ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_PMT_LIBRARIES})
|
target_link_libraries(gnuradio-foo ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_PMT_LIBRARIES} uhd)
|
||||||
set_target_properties(gnuradio-foo PROPERTIES DEFINE_SYMBOL "gnuradio_foo_EXPORTS")
|
set_target_properties(gnuradio-foo PROPERTIES DEFINE_SYMBOL "gnuradio_foo_EXPORTS")
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|||||||
+23
-4
@@ -18,19 +18,24 @@
|
|||||||
|
|
||||||
#include <gnuradio/io_signature.h>
|
#include <gnuradio/io_signature.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <uhd/types/time_spec.hpp>
|
||||||
|
|
||||||
using namespace gr::foo;
|
using namespace gr::foo;
|
||||||
|
|
||||||
#define dout d_debug && std::cout
|
#define dout d_debug && std::cout
|
||||||
|
|
||||||
packet_pad_impl::packet_pad_impl(bool debug, unsigned int pad_front, unsigned int pad_tail) : block("packet_pad",
|
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)),
|
||||||
gr::io_signature::make(1, 1, sizeof(gr_complex))),
|
gr::io_signature::make(1, 1, sizeof(gr_complex))),
|
||||||
d_debug(debug),
|
d_debug(debug),
|
||||||
d_pad_front(pad_front),
|
d_pad_front(pad_front),
|
||||||
d_pad_tail(pad_tail),
|
d_pad_tail(pad_tail),
|
||||||
d_pad(0),
|
d_pad(0),
|
||||||
d_eob(false) {
|
d_eob(false),
|
||||||
|
d_delay(delay),
|
||||||
|
d_delay_sec(delay_sec) {
|
||||||
|
|
||||||
set_relative_rate(1);
|
set_relative_rate(1);
|
||||||
set_tag_propagation_policy(block::TPP_DONT);
|
set_tag_propagation_policy(block::TPP_DONT);
|
||||||
@@ -47,6 +52,20 @@ packet_pad_impl::add_sob(uint64_t item) {
|
|||||||
static const pmt::pmt_t value = pmt::PMT_T;
|
static const pmt::pmt_t value = pmt::PMT_T;
|
||||||
static const pmt::pmt_t srcid = pmt::string_to_symbol(alias());
|
static const pmt::pmt_t srcid = pmt::string_to_symbol(alias());
|
||||||
add_item_tag(0, item, sob_key, value, srcid);
|
add_item_tag(0, item, sob_key, value, srcid);
|
||||||
|
|
||||||
|
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, item, time_key, time_value, srcid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -159,6 +178,6 @@ packet_pad_impl::forecast (int noutput_items, gr_vector_int &ninput_items_requir
|
|||||||
}
|
}
|
||||||
|
|
||||||
packet_pad::sptr
|
packet_pad::sptr
|
||||||
packet_pad::make(bool debug, unsigned int pad_front, unsigned int pad_tail) {
|
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, pad_front, pad_tail));
|
return gnuradio::get_initial_sptr(new packet_pad_impl(debug, delay, delay_sec, pad_front, pad_tail));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ namespace foo {
|
|||||||
void add_sob(uint64_t item);
|
void add_sob(uint64_t item);
|
||||||
|
|
||||||
bool d_debug;
|
bool d_debug;
|
||||||
|
bool d_delay;
|
||||||
|
double d_delay_sec;
|
||||||
|
|
||||||
int d_pad_front;
|
int d_pad_front;
|
||||||
int d_pad_tail;
|
int d_pad_tail;
|
||||||
@@ -39,8 +41,8 @@ namespace foo {
|
|||||||
bool d_eob;
|
bool d_eob;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
packet_pad_impl(bool debug, unsigned int pad_front,
|
packet_pad_impl(bool debug, bool delay, double delay_sec,
|
||||||
unsigned int pad_tail);
|
unsigned int pad_front, unsigned int pad_tail);
|
||||||
|
|
||||||
~packet_pad_impl();
|
~packet_pad_impl();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user