add tx delay to packet pad
This commit is contained in:
+25
-1
@@ -5,7 +5,7 @@
|
||||
<key>foo_packet_pad</key>
|
||||
<category>Foo</category>
|
||||
<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>
|
||||
<name>Debug</name>
|
||||
@@ -22,6 +22,29 @@
|
||||
<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>
|
||||
@@ -39,6 +62,7 @@
|
||||
|
||||
<check>$pad_front >= 0</check>
|
||||
<check>$pad_tail >= 0</check>
|
||||
<check>$delay_sec > 0</check>
|
||||
|
||||
<sink>
|
||||
<name>in</name>
|
||||
|
||||
@@ -28,7 +28,7 @@ class FOO_API packet_pad : virtual public gr::block
|
||||
public:
|
||||
|
||||
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})
|
||||
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")
|
||||
|
||||
########################################################################
|
||||
|
||||
+23
-4
@@ -18,19 +18,24 @@
|
||||
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <iostream>
|
||||
#include <sys/time.h>
|
||||
#include <uhd/types/time_spec.hpp>
|
||||
|
||||
using namespace gr::foo;
|
||||
|
||||
#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))),
|
||||
d_debug(debug),
|
||||
d_pad_front(pad_front),
|
||||
d_pad_tail(pad_tail),
|
||||
d_pad(0),
|
||||
d_eob(false) {
|
||||
d_eob(false),
|
||||
d_delay(delay),
|
||||
d_delay_sec(delay_sec) {
|
||||
|
||||
set_relative_rate(1);
|
||||
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 srcid = pmt::string_to_symbol(alias());
|
||||
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
|
||||
@@ -159,6 +178,6 @@ packet_pad_impl::forecast (int noutput_items, gr_vector_int &ninput_items_requir
|
||||
}
|
||||
|
||||
packet_pad::sptr
|
||||
packet_pad::make(bool debug, unsigned int pad_front, unsigned int pad_tail) {
|
||||
return gnuradio::get_initial_sptr(new packet_pad_impl(debug, pad_front, 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, delay, delay_sec, pad_front, pad_tail));
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace foo {
|
||||
void add_sob(uint64_t item);
|
||||
|
||||
bool d_debug;
|
||||
bool d_delay;
|
||||
double d_delay_sec;
|
||||
|
||||
int d_pad_front;
|
||||
int d_pad_tail;
|
||||
@@ -39,8 +41,8 @@ namespace foo {
|
||||
bool d_eob;
|
||||
|
||||
public:
|
||||
packet_pad_impl(bool debug, unsigned int pad_front,
|
||||
unsigned int pad_tail);
|
||||
packet_pad_impl(bool debug, bool delay, double delay_sec,
|
||||
unsigned int pad_front, unsigned int pad_tail);
|
||||
|
||||
~packet_pad_impl();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user