[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/04: digital: added callback function set
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/04: digital: added callback function set_header_formatter to packet_headergenerator_bb |
Date: |
Thu, 22 Jan 2015 23:38:45 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 492a0b4dd240f2dd6bd441bbfda304d216c43d4c
Author: fengzhe29888 <address@hidden>
Date: Wed Jan 21 18:37:13 2015 -0500
digital: added callback function set_header_formatter to
packet_headergenerator_bb
Update packet_headergenerator_bb.h
digital: updated the callback function by passing by value
removed const
---
gr-digital/grc/digital_packet_headergenerator_bb.xml | 1 +
gr-digital/include/gnuradio/digital/packet_headergenerator_bb.h | 2 ++
gr-digital/lib/packet_headergenerator_bb_impl.cc | 8 +++++++-
gr-digital/lib/packet_headergenerator_bb_impl.h | 2 ++
4 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/gr-digital/grc/digital_packet_headergenerator_bb.xml
b/gr-digital/grc/digital_packet_headergenerator_bb.xml
index 25dfcbb..f069b52 100644
--- a/gr-digital/grc/digital_packet_headergenerator_bb.xml
+++ b/gr-digital/grc/digital_packet_headergenerator_bb.xml
@@ -3,6 +3,7 @@
<key>digital_packet_headergenerator_bb</key>
<import>from gnuradio import digital</import>
<make>digital.packet_headergenerator_bb($header_formatter,
$len_tag_key)</make>
+ <callback>set_header_formatter($header_formatter)</callback>
<param>
<name>Formatter Object</name>
<key>header_formatter</key>
diff --git a/gr-digital/include/gnuradio/digital/packet_headergenerator_bb.h
b/gr-digital/include/gnuradio/digital/packet_headergenerator_bb.h
index 1ad67b7..c5b6b3e 100644
--- a/gr-digital/include/gnuradio/digital/packet_headergenerator_bb.h
+++ b/gr-digital/include/gnuradio/digital/packet_headergenerator_bb.h
@@ -64,6 +64,8 @@ namespace gr {
static sptr make(
long header_len,
const std::string &len_tag_key = "packet_len");
+
+ virtual void set_header_formatter(packet_header_default::sptr
header_formatter)=0;
};
} // namespace digital
diff --git a/gr-digital/lib/packet_headergenerator_bb_impl.cc
b/gr-digital/lib/packet_headergenerator_bb_impl.cc
index def050d..27f3b00 100644
--- a/gr-digital/lib/packet_headergenerator_bb_impl.cc
+++ b/gr-digital/lib/packet_headergenerator_bb_impl.cc
@@ -68,7 +68,12 @@ namespace gr {
set_relative_rate(d_formatter->header_len());
set_tag_propagation_policy(TPP_DONT);
}
-
+void
+
packet_headergenerator_bb_impl::set_header_formatter(packet_header_default::sptr
header_formatter)
+ {
+ gr::thread::scoped_lock guard(d_setlock);
+ d_formatter=header_formatter;
+ }
packet_headergenerator_bb_impl::~packet_headergenerator_bb_impl()
{
}
@@ -79,6 +84,7 @@ namespace gr {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
+ gr::thread::scoped_lock guard(d_setlock);
unsigned char *out = (unsigned char *) output_items[0];
std::vector<tag_t> tags;
diff --git a/gr-digital/lib/packet_headergenerator_bb_impl.h
b/gr-digital/lib/packet_headergenerator_bb_impl.h
index 3cca23f..b4a4a0d 100644
--- a/gr-digital/lib/packet_headergenerator_bb_impl.h
+++ b/gr-digital/lib/packet_headergenerator_bb_impl.h
@@ -39,6 +39,8 @@ namespace gr {
);
~packet_headergenerator_bb_impl();
+ void set_header_formatter(packet_header_default::sptr header_formatter);
+
void remove_length_tags(const std::vector<std::vector<tag_t> > &tags) {};
int calculate_output_stream_length(const gr_vector_int &ninput_items) {
return d_formatter->header_len(); };