muhahah burst tagging works, ruc receives acks
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<name>Burst Tagger</name>
|
||||
<key>ccs_burst_tagger</key>
|
||||
<category>CCS</category>
|
||||
<import>import pmt</import>
|
||||
<import>import ccs</import>
|
||||
<make>ccs.burst_tagger($tag_name)</make>
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "burst_tagger_impl.h"
|
||||
#include <gnuradio/io_signature.h>
|
||||
|
||||
#define dout std::cout
|
||||
|
||||
namespace gr {
|
||||
namespace ccs {
|
||||
|
||||
@@ -27,12 +29,35 @@ burst_tagger_impl::burst_tagger_impl(pmt::pmt_t tag_name)
|
||||
: gr::sync_block("burst_tagger",
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex))),
|
||||
d_tag_name(tag_name) {
|
||||
d_tag_name(tag_name),
|
||||
d_copy(0) {
|
||||
}
|
||||
|
||||
burst_tagger_impl::~burst_tagger_impl() {
|
||||
}
|
||||
|
||||
void
|
||||
burst_tagger_impl::add_sob(uint64_t item) {
|
||||
dout << "burst tagger: insert sob at: " << item << std::endl;
|
||||
|
||||
const pmt::pmt_t sob_key = pmt::string_to_symbol("tx_sob");
|
||||
const pmt::pmt_t value = pmt::PMT_T;
|
||||
const pmt::pmt_t srcid = pmt::string_to_symbol(alias());
|
||||
add_item_tag(0, item, sob_key, value, srcid);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
burst_tagger_impl::add_eob(uint64_t item) {
|
||||
dout << "burst tagger: insert eob at: " << item << std::endl;
|
||||
|
||||
const pmt::pmt_t eob_key = pmt::string_to_symbol("tx_eob");
|
||||
const pmt::pmt_t value = pmt::PMT_T;
|
||||
const pmt::pmt_t srcid = pmt::string_to_symbol(alias());
|
||||
add_item_tag(0, item, eob_key, value, srcid);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
burst_tagger_impl::work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
@@ -41,17 +66,47 @@ burst_tagger_impl::work(int noutput_items,
|
||||
const gr_complex *in = (const gr_complex*)input_items[0];
|
||||
gr_complex *out = (gr_complex*)output_items[0];
|
||||
|
||||
std::vector<gr::tag_t> tags;
|
||||
const uint64_t nread = nitems_read(0);
|
||||
|
||||
get_tags_in_range(tags, 0, nread, nread + noutput_items - 1,
|
||||
d_tag_name);
|
||||
std::sort(tags.begin(), tags.end(), tag_t::offset_compare);
|
||||
if(!d_copy) {
|
||||
dout << "nothing to copy, searching for tags" << std::endl;
|
||||
std::vector<gr::tag_t> tags;
|
||||
const uint64_t nread = nitems_read(0);
|
||||
|
||||
if(tags.size()) {
|
||||
get_tags_in_range(tags, 0, nread, nread + noutput_items - 1,
|
||||
d_tag_name);
|
||||
std::sort(tags.begin(), tags.end(), tag_t::offset_compare);
|
||||
|
||||
// copy until the first tag
|
||||
if(tags.size()) {
|
||||
dout << "tags found" << std::endl;
|
||||
tag_t tag = tags.front();
|
||||
if(tag.offset == nitems_read(0)) {
|
||||
d_copy = pmt::to_uint64(tag.value) * 128;
|
||||
dout << "tag is at current offset -- packet len " << d_copy << " items read " << nitems_read(0) << std::endl;
|
||||
add_sob(nitems_written(0));
|
||||
} else {
|
||||
uint64_t cpy = std::min((uint64_t)noutput_items, tag.offset - nitems_written(0));
|
||||
dout << "tag is not at current offset copying " << cpy << std::endl;
|
||||
std::memcpy(out, in, cpy * sizeof(gr_complex));
|
||||
return cpy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return noutput_items;
|
||||
if(d_copy) {
|
||||
int cpy = std::min(d_copy, noutput_items);
|
||||
dout << "packet copy " << cpy << std::endl;
|
||||
std::memcpy(out, in, cpy * sizeof(gr_complex));
|
||||
d_copy -= cpy;
|
||||
if(d_copy == 0) {
|
||||
add_eob(nitems_written(0) + cpy - 1);
|
||||
}
|
||||
return cpy;
|
||||
} else {
|
||||
dout << "copy random stuff " << std::endl;
|
||||
std::memcpy(out, in, noutput_items * sizeof(gr_complex));
|
||||
return noutput_items;
|
||||
}
|
||||
}
|
||||
|
||||
burst_tagger::sptr burst_tagger::make(pmt::pmt_t tag_name) {
|
||||
|
||||
@@ -28,7 +28,11 @@ namespace ccs {
|
||||
|
||||
class burst_tagger_impl : public burst_tagger {
|
||||
private:
|
||||
void add_eob(uint64_t item);
|
||||
void add_sob(uint64_t item);
|
||||
|
||||
pmt::pmt_t d_tag_name;
|
||||
int d_copy;
|
||||
|
||||
public:
|
||||
burst_tagger_impl(pmt::pmt_t tag_name);
|
||||
|
||||
Reference in New Issue
Block a user