[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 05/29: zmq: hoisting header encoding to hel
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 05/29: zmq: hoisting header encoding to helper function |
Date: |
Tue, 13 Jan 2015 01:04:26 +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 e8cfb9953c5daf77ac249804e014f28c10523631
Author: Tim O'Shea <address@hidden>
Date: Mon Oct 27 18:15:20 2014 -0400
zmq: hoisting header encoding to helper function
---
gr-zeromq/lib/pub_sink_impl.cc | 25 +++++++------------------
gr-zeromq/lib/tag_headers.h | 24 ++++++++++++++++++++++++
2 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/gr-zeromq/lib/pub_sink_impl.cc b/gr-zeromq/lib/pub_sink_impl.cc
index 7b57e27..43819f3 100644
--- a/gr-zeromq/lib/pub_sink_impl.cc
+++ b/gr-zeromq/lib/pub_sink_impl.cc
@@ -26,6 +26,7 @@
#include <gnuradio/io_signature.h>
#include "pub_sink_impl.h"
+#include "tag_headers.h"
#include <sstream>
#include <cstring>
@@ -72,31 +73,19 @@ namespace gr {
const char *in = (const char *)input_items[0];
// encode the current offset, # tags, and tags into header
- size_t headlen(0);
- std::stringstream ss;
+ std::string header("");
if(d_pass_tags){
+ uint64_t offset = nitems_read(0);
std::vector<gr::tag_t> tags;
get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+noutput_items);
- size_t ntags = tags.size();
- ss.write( reinterpret_cast< const char* >( nitems_read(0) ),
sizeof(uint64_t) ); // offset
- ss.write( reinterpret_cast< const char* >( &ntags ), sizeof(size_t) );
// num tags
- std::stringbuf sb("");
- for(size_t i=0; i<tags.size(); i++){
- ss.write( reinterpret_cast< const char* >( &tags[i].offset ),
sizeof(uint64_t) ); // offset
- sb.str("");
- pmt::serialize( tags[i].key, sb );
// key
- pmt::serialize( tags[i].value, sb );
// value
- pmt::serialize( tags[i].srcid, sb );
// srcid
- ss.write( sb.str().c_str() , sb.str().length() ); // offset
- }
- headlen = ss.gcount();
+ header = gen_tag_header( offset, tags );
}
// create message copy and send
- zmq::message_t msg(headlen + d_itemsize*d_vlen*noutput_items);
+ zmq::message_t msg(header.length() + d_itemsize*d_vlen*noutput_items);
if(d_pass_tags)
- memcpy((void*) msg.data(), ss.str().c_str(), ss.str().length() );
- memcpy((uint8_t *)msg.data() + headlen, in,
d_itemsize*d_vlen*noutput_items);
+ memcpy((void*) msg.data(), header.c_str(), header.length() );
+ memcpy((uint8_t *)msg.data() + header.length(), in,
d_itemsize*d_vlen*noutput_items);
d_socket->send(msg);
return noutput_items;
diff --git a/gr-zeromq/lib/tag_headers.h b/gr-zeromq/lib/tag_headers.h
new file mode 100644
index 0000000..0a4dfee
--- /dev/null
+++ b/gr-zeromq/lib/tag_headers.h
@@ -0,0 +1,24 @@
+
+#include <gnuradio/io_signature.h>
+#include <gnuradio/block.h>
+#include <sstream>
+#include <cstring>
+
+std::string gen_tag_header(uint64_t &offset, std::vector<gr::tag_t> &tags){
+ std::stringstream ss;
+ size_t ntags = tags.size();
+ ss.write( reinterpret_cast< const char* >( offset ), sizeof(uint64_t) );
// offset
+ ss.write( reinterpret_cast< const char* >( &ntags ), sizeof(size_t) );
// num tags
+ std::stringbuf sb("");
+ for(size_t i=0; i<tags.size(); i++){
+ ss.write( reinterpret_cast< const char* >( &tags[i].offset ),
sizeof(uint64_t) ); // offset
+ sb.str("");
+ pmt::serialize( tags[i].key, sb );
// key
+ pmt::serialize( tags[i].value, sb );
// value
+ pmt::serialize( tags[i].srcid, sb );
// srcid
+ ss.write( sb.str().c_str() , sb.str().length() ); // offset
+ }
+ return ss.str();
+}
+
+
- [Commit-gnuradio] [gnuradio] 12/29: zmq: stream tag passing now works, (continued)
- [Commit-gnuradio] [gnuradio] 12/29: zmq: stream tag passing now works, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 19/29: Merge remote-tracking branch 'osh/zmqtags' into zmq_tags, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 29/29: Merge branch 'maint', git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 26/29: zeromq: added msg passing example, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 03/29: zmq: default to not pass tags (compatible wire format), git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 02/29: zmq: tags should now be serializing and deserializing correctly for pub_sink/sub_source, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 27/29: zeromq: minor cleanup, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 25/29: zeromq: cleanup and made req_msg_source derive from gr::block, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 09/29: zmq: include pass_tags option default to false in all blocks' grc definitions, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 18/29: zmq: rep/req msg blocks now working, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 05/29: zmq: hoisting header encoding to helper function,
git <=
- [Commit-gnuradio] [gnuradio] 04/29: zmq: adding pass tags option to zmq pub/sub block grc xml defs, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 15/29: zmq: building working versions of additional zmq message blocks in place (push/pull + rep/req), git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 28/29: zeromq: added stream tag passing example, git, 2015/01/12