[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 13/29: zmq: adding header information
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 13/29: zmq: adding header information |
Date: |
Tue, 13 Jan 2015 01:04:27 +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 232a9bc8f9e05671e54fc204ed209dc8e7948f7f
Author: Tim O'Shea <address@hidden>
Date: Sun Dec 28 12:47:07 2014 +0100
zmq: adding header information
---
gr-zeromq/lib/tag_headers.cc | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/gr-zeromq/lib/tag_headers.cc b/gr-zeromq/lib/tag_headers.cc
index c47bac7..c970666 100644
--- a/gr-zeromq/lib/tag_headers.cc
+++ b/gr-zeromq/lib/tag_headers.cc
@@ -25,14 +25,23 @@
#include <sstream>
#include <cstring>
+#define GR_HEADER_MAGIC 0x5FF0
+#define GR_HEADER_VERSION 0x01
+
namespace gr {
namespace zeromq {
std::string
gen_tag_header(uint64_t &offset, std::vector<gr::tag_t> &tags) {
+ uint16_t header_magic = GR_HEADER_MAGIC;
+ uint8_t header_version = GR_HEADER_VERSION;
+
std::stringstream ss;
size_t ntags = tags.size();
+ ss.write( reinterpret_cast< const char* >( &header_magic ),
sizeof(uint16_t) );
+ ss.write( reinterpret_cast< const char* >( &header_version ),
sizeof(uint8_t) );
+
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("");
@@ -55,10 +64,23 @@ namespace gr {
std::istringstream iss( buf_in );
size_t rcv_ntags;
+
+ uint16_t header_magic;
+ uint8_t header_version;
+
+ iss.read( (char*)&header_magic, sizeof(uint16_t ) );
+ iss.read( (char*)&header_version, sizeof(uint8_t ) );
+ if(header_magic != GR_HEADER_MAGIC){
+ throw std::runtime_error("gr header magic does not match!");
+ }
+ if(header_version != 1){
+ throw std::runtime_error("gr header version too high!");
+ }
+
iss.read( (char*)&offset_out, sizeof(uint64_t ) );
iss.read( (char*)&rcv_ntags, sizeof(size_t ) );
//std::cout << "RX TAGS: (offset="<<offset_out<<"
ntags="<<rcv_ntags<<")\n";
- int rd_offset = sizeof(uint64_t) + sizeof(size_t);
+ int rd_offset = sizeof(uint16_t) + sizeof(uint8_t) + sizeof(uint64_t) +
sizeof(size_t);
std::stringbuf sb( iss.str().substr(rd_offset) );
for(size_t i=0; i<rcv_ntags; i++){
- [Commit-gnuradio] [gnuradio] branch master updated (5cb307e -> 1581681), git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 13/29: zmq: adding header information,
git <=
- [Commit-gnuradio] [gnuradio] 11/29: zeromq: fix segfault in tag_headers, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 16/29: zmq: naming cleanup, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 17/29: zmq: pull_msg_source should be working, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 20/29: zeromq: cleanup and convert pub_msg_sink to derive from gr::block, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 23/29: zeromq: cleanup and made pull_msg_source derive from gr::block, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 07/29: zmq: all source blocks should now support tag headers, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 06/29: zmq: hoisting tag parsing into helper function, should now be easy to use in other zmq blocks, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 14/29: zmq: Adding zmq pub/sub blocks for message passing, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 21/29: zeromq: cleanup and convert sub_msg_source to derive from gr::block, git, 2015/01/12
- [Commit-gnuradio] [gnuradio] 22/29: zeromq: cleanup and converted push_msg_sink to derive from gr::block, git, 2015/01/12