[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/04: blocks: added callback functions to
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/04: blocks: added callback functions to stream_to_tagged_stream |
Date: |
Thu, 22 Jan 2015 23:02:00 +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 e6102cc8988778f7dfc000ab11b05eadd007a586
Author: fengzhe29888 <address@hidden>
Date: Thu Jan 22 10:39:58 2015 -0500
blocks: added callback functions to stream_to_tagged_stream
---
gr-blocks/grc/blocks_stream_to_tagged_stream.xml | 2 ++
gr-blocks/include/gnuradio/blocks/stream_to_tagged_stream.h | 2 ++
gr-blocks/lib/stream_to_tagged_stream_impl.cc | 13 +++++++++++++
gr-blocks/lib/stream_to_tagged_stream_impl.h | 2 ++
4 files changed, 19 insertions(+)
diff --git a/gr-blocks/grc/blocks_stream_to_tagged_stream.xml
b/gr-blocks/grc/blocks_stream_to_tagged_stream.xml
index cf35e75..c2af70c 100644
--- a/gr-blocks/grc/blocks_stream_to_tagged_stream.xml
+++ b/gr-blocks/grc/blocks_stream_to_tagged_stream.xml
@@ -4,6 +4,8 @@
<key>blocks_stream_to_tagged_stream</key>
<import>from gnuradio import blocks</import>
<make>blocks.stream_to_tagged_stream($type.size, $vlen, $packet_len,
$len_tag_key)</make>
+ <callback>set_packet_len($packet_len)</callback>
+ <callback>set_packet_len_pmt($packet_len)</callback>
<param>
<name>Type</name>
<key>type</key>
diff --git a/gr-blocks/include/gnuradio/blocks/stream_to_tagged_stream.h
b/gr-blocks/include/gnuradio/blocks/stream_to_tagged_stream.h
index bc72ea9..9b390b6 100644
--- a/gr-blocks/include/gnuradio/blocks/stream_to_tagged_stream.h
+++ b/gr-blocks/include/gnuradio/blocks/stream_to_tagged_stream.h
@@ -59,6 +59,8 @@ namespace gr {
unsigned packet_len,
const std::string &len_tag_key
);
+ virtual void set_packet_len(unsigned packet_len) =0;
+ virtual void set_packet_len_pmt(unsigned packet_len) =0;
};
} // namespace blocks
diff --git a/gr-blocks/lib/stream_to_tagged_stream_impl.cc
b/gr-blocks/lib/stream_to_tagged_stream_impl.cc
index 341961b..58e1a9c 100644
--- a/gr-blocks/lib/stream_to_tagged_stream_impl.cc
+++ b/gr-blocks/lib/stream_to_tagged_stream_impl.cc
@@ -53,11 +53,24 @@ namespace gr {
{
}
+ void
+ stream_to_tagged_stream_impl::set_packet_len(unsigned packet_len)
+ {
+ gr::thread::scoped_lock guard(d_setlock);
+ d_packet_len = packet_len;
+ }
+ void
+ stream_to_tagged_stream_impl::set_packet_len_pmt(unsigned packet_len)
+ {
+ gr::thread::scoped_lock guard(d_setlock);
+ d_packet_len_pmt=pmt::from_long(packet_len);
+ }
int
stream_to_tagged_stream_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
+ gr::thread::scoped_lock guard(d_setlock);
const unsigned char *in = (const unsigned char *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
// Copy data
diff --git a/gr-blocks/lib/stream_to_tagged_stream_impl.h
b/gr-blocks/lib/stream_to_tagged_stream_impl.h
index 106d90b..dc9c117 100644
--- a/gr-blocks/lib/stream_to_tagged_stream_impl.h
+++ b/gr-blocks/lib/stream_to_tagged_stream_impl.h
@@ -40,6 +40,8 @@ namespace gr {
public:
stream_to_tagged_stream_impl(size_t itemsize, int vlen, unsigned
packet_len, const std::string &tag_len_key);
~stream_to_tagged_stream_impl();
+ void set_packet_len(unsigned packet_len);
+ void set_packet_len_pmt(unsigned packet_len);
int work(int noutput_items,
gr_vector_const_void_star &input_items,