commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 24/46: zeromq: Fix doxygen and memcpy for v


From: git
Subject: [Commit-gnuradio] [gnuradio] 24/46: zeromq: Fix doxygen and memcpy for vlen
Date: Fri, 16 May 2014 19:37:15 +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 ea2b698dbad69cf5ae62c7cac3a7506d776b0dcd
Author: Johannes Schmitz <address@hidden>
Date:   Wed May 7 17:59:01 2014 +0200

    zeromq: Fix doxygen and memcpy for vlen
---
 gr-zeromq/include/gnuradio/zeromq/pub_sink.h    |  3 ++-
 gr-zeromq/include/gnuradio/zeromq/pull_source.h |  1 +
 gr-zeromq/include/gnuradio/zeromq/push_sink.h   |  1 +
 gr-zeromq/include/gnuradio/zeromq/rep_sink.h    |  1 +
 gr-zeromq/include/gnuradio/zeromq/req_source.h  |  2 +-
 gr-zeromq/lib/pub_sink_impl.cc                  | 14 ++++++------
 gr-zeromq/lib/pub_sink_impl.h                   |  3 ++-
 gr-zeromq/lib/pull_source_impl.cc               | 29 +++++++++++++------------
 gr-zeromq/lib/pull_source_impl.h                |  1 +
 gr-zeromq/lib/push_sink_impl.cc                 |  9 ++++----
 gr-zeromq/lib/push_sink_impl.h                  |  1 +
 gr-zeromq/lib/rep_sink_impl.cc                  | 10 ++++-----
 gr-zeromq/lib/rep_sink_impl.h                   |  1 +
 gr-zeromq/lib/req_source_impl.cc                | 27 +++++++++++------------
 gr-zeromq/lib/req_source_impl.h                 |  1 +
 15 files changed, 57 insertions(+), 47 deletions(-)

diff --git a/gr-zeromq/include/gnuradio/zeromq/pub_sink.h 
b/gr-zeromq/include/gnuradio/zeromq/pub_sink.h
index 7c5734e..46ad80b 100644
--- a/gr-zeromq/include/gnuradio/zeromq/pub_sink.h
+++ b/gr-zeromq/include/gnuradio/zeromq/pub_sink.h
@@ -49,10 +49,11 @@ namespace gr {
        * \brief Return a shared_ptr to a new instance of zeromq::pub_sink.
        *
        * \param itemsize Size of a stream item in bytes
+       * \param vlen Vector length of the input items. Note that one vector is 
one item.
        * \param address  ZMQ socket address specifier
        * \param blocking Indicate whether blocking sends should be used, 
default true.
        */
-      static sptr make(size_t itemsize, char *address, bool blocking=true);
+      static sptr make(size_t itemsize, size_t vlen, char *address, bool 
blocking=true);
     };
 
   } // namespace zeromq
diff --git a/gr-zeromq/include/gnuradio/zeromq/pull_source.h 
b/gr-zeromq/include/gnuradio/zeromq/pull_source.h
index 12c1005..4306931 100644
--- a/gr-zeromq/include/gnuradio/zeromq/pull_source.h
+++ b/gr-zeromq/include/gnuradio/zeromq/pull_source.h
@@ -46,6 +46,7 @@ namespace gr {
        * \brief Return a shared_ptr to a new instance of 
gr::zeromq::pull_source.
        *
        * \param itemsize Size of a stream item in bytes
+       * \param vlen Vector length of the input items. Note that one vector is 
one item.
        * \param address  ZMQ socket address specifier
        * \param timeout  Receive timeout in seconds, default is 100ms, 1us 
increments
        *
diff --git a/gr-zeromq/include/gnuradio/zeromq/push_sink.h 
b/gr-zeromq/include/gnuradio/zeromq/push_sink.h
index 2f68e44..46ad6a4 100644
--- a/gr-zeromq/include/gnuradio/zeromq/push_sink.h
+++ b/gr-zeromq/include/gnuradio/zeromq/push_sink.h
@@ -50,6 +50,7 @@ namespace gr {
        * \brief Return a shared_ptr to a new instance of gr::zeromq::push_sink
        *
        * \param itemsize Size of a stream item in bytes
+       * \param vlen Vector length of the input items. Note that one vector is 
one item.
        * \param address  ZMQ socket address specifier
        * \param blocking Indicate whether blocking sends should be used, 
default true.
        *
diff --git a/gr-zeromq/include/gnuradio/zeromq/rep_sink.h 
b/gr-zeromq/include/gnuradio/zeromq/rep_sink.h
index 9c2cafb..374607e 100644
--- a/gr-zeromq/include/gnuradio/zeromq/rep_sink.h
+++ b/gr-zeromq/include/gnuradio/zeromq/rep_sink.h
@@ -48,6 +48,7 @@ namespace gr {
        * \brief Return a shared_ptr to a new instance of zeromq::rep_sink.
        *
        * \param itemsize Size of a stream item in bytes
+       * \param vlen Vector length of the input items. Note that one vector is 
one item.
        * \param address  ZMQ socket address specifier
        * \param timeout  Timeout for request poll, in seconds
        * \param blocking Indicate whether blocking sends should be used, 
default true.
diff --git a/gr-zeromq/include/gnuradio/zeromq/req_source.h 
b/gr-zeromq/include/gnuradio/zeromq/req_source.h
index 5d3f380..5fc3682 100644
--- a/gr-zeromq/include/gnuradio/zeromq/req_source.h
+++ b/gr-zeromq/include/gnuradio/zeromq/req_source.h
@@ -47,7 +47,7 @@ namespace gr {
        *
        *
        * \param itemsize Size of a stream item in bytes
-       * \param vlen of the input items.
+       * \param vlen Vector length of the input items. Note that one vector is 
one item.
        * \param address  ZMQ socket address specifier
        * \param timeout  Receive timeout in seconds, default is 100ms, 1us 
increments
        *
diff --git a/gr-zeromq/lib/pub_sink_impl.cc b/gr-zeromq/lib/pub_sink_impl.cc
index 086e995..0700239 100644
--- a/gr-zeromq/lib/pub_sink_impl.cc
+++ b/gr-zeromq/lib/pub_sink_impl.cc
@@ -31,17 +31,17 @@ namespace gr {
   namespace zeromq {
 
     pub_sink::sptr
-    pub_sink::make(size_t itemsize, char *address, bool blocking)
+    pub_sink::make(size_t itemsize, size_t vlen, char *address, bool blocking)
     {
       return gnuradio::get_initial_sptr
-       (new pub_sink_impl(itemsize, address, blocking));
+       (new pub_sink_impl(itemsize, vlen, address, blocking));
     }
 
-    pub_sink_impl::pub_sink_impl(size_t itemsize, char *address, bool blocking)
+    pub_sink_impl::pub_sink_impl(size_t itemsize, size_t vlen, char *address, 
bool blocking)
       : gr::sync_block("pub_sink",
-                       gr::io_signature::make(1, 1, itemsize),
+                       gr::io_signature::make(1, 1, itemsize * vlen),
                        gr::io_signature::make(0, 0, 0)),
-        d_itemsize(itemsize), d_blocking(blocking)
+        d_itemsize(itemsize), d_vlen(vlen), d_blocking(blocking)
     {
       d_context = new zmq::context_t(1);
       d_socket = new zmq::socket_t(*d_context, ZMQ_PUB);
@@ -62,8 +62,8 @@ namespace gr {
       const char *in = (const char *)input_items[0];
 
       // create message copy and send
-      zmq::message_t msg(d_itemsize*noutput_items);
-      memcpy((void *)msg.data(), in, d_itemsize*noutput_items);
+      zmq::message_t msg(d_itemsize*d_vlen*noutput_items);
+      memcpy((void *)msg.data(), in, d_itemsize*d_vlen*noutput_items);
       d_socket->send(msg, d_blocking ? 0 : ZMQ_NOBLOCK);
 
       return noutput_items;
diff --git a/gr-zeromq/lib/pub_sink_impl.h b/gr-zeromq/lib/pub_sink_impl.h
index d1cb02d..6d36e20 100644
--- a/gr-zeromq/lib/pub_sink_impl.h
+++ b/gr-zeromq/lib/pub_sink_impl.h
@@ -33,12 +33,13 @@ namespace gr {
     {
     private:
       size_t          d_itemsize;
+      size_t          d_vlen;
       bool            d_blocking;
       zmq::context_t  *d_context;
       zmq::socket_t   *d_socket;
 
     public:
-      pub_sink_impl(size_t itemsize, char *address, bool blocking);
+      pub_sink_impl(size_t itemsize, size_t vlen, char *address, bool 
blocking);
       ~pub_sink_impl();
 
       int work(int noutput_items,
diff --git a/gr-zeromq/lib/pull_source_impl.cc 
b/gr-zeromq/lib/pull_source_impl.cc
index 9b9e50a..b29a056 100644
--- a/gr-zeromq/lib/pull_source_impl.cc
+++ b/gr-zeromq/lib/pull_source_impl.cc
@@ -41,7 +41,7 @@ namespace gr {
       : gr::sync_block("pull_source",
                        gr::io_signature::make(0, 0, 0),
                        gr::io_signature::make(1, 1, itemsize * vlen)),
-        d_itemsize(itemsize)
+        d_itemsize(itemsize), d_vlen(vlen)
     {
       d_timeout = timeout >= 0 ? (int)(timeout*1e6) : 0;
       d_context = new zmq::context_t(1);
@@ -71,21 +71,22 @@ namespace gr {
       //  If we got a reply, process
       if (items[0].revents & ZMQ_POLLIN) {
 
-       // Receive data
-       zmq::message_t msg;
-       d_socket->recv(&msg);
+           // Receive data
+           zmq::message_t msg;
+        std::cout << "pull before" << std::endl;
+           d_socket->recv(&msg);
+        std::cout << "pull after" << std::endl;
+           // Copy to ouput buffer and return
+           if (msg.size() >= d_itemsize*d_vlen*noutput_items) {
+             memcpy(out, (void *)msg.data(), d_itemsize*d_vlen*noutput_items);
 
-       // Copy to ouput buffer and return
-       if (msg.size() >= d_itemsize*noutput_items) {
-         memcpy(out, (void *)msg.data(), d_itemsize*noutput_items);
+             return noutput_items;
+           }
+           else {
+             memcpy(out, (void *)msg.data(), msg.size());
 
-         return noutput_items;
-       }
-       else {
-         memcpy(out, (void *)msg.data(), msg.size());
-
-         return msg.size()/d_itemsize;
-       }
+             return msg.size()/(d_itemsize*d_vlen);
+           }
       }
       else {
        return 0; // FIXME: someday when the scheduler does all the poll/selects
diff --git a/gr-zeromq/lib/pull_source_impl.h b/gr-zeromq/lib/pull_source_impl.h
index 3e56bdc..de2e903 100644
--- a/gr-zeromq/lib/pull_source_impl.h
+++ b/gr-zeromq/lib/pull_source_impl.h
@@ -33,6 +33,7 @@ namespace gr {
     {
     private:
       size_t          d_itemsize;
+      size_t          d_vlen;
       int             d_timeout; // microseconds, -1 is blocking
       zmq::context_t  *d_context;
       zmq::socket_t   *d_socket;
diff --git a/gr-zeromq/lib/push_sink_impl.cc b/gr-zeromq/lib/push_sink_impl.cc
index 43ccd9d..1438e52 100644
--- a/gr-zeromq/lib/push_sink_impl.cc
+++ b/gr-zeromq/lib/push_sink_impl.cc
@@ -41,7 +41,7 @@ namespace gr {
       : gr::sync_block("push_sink",
                        gr::io_signature::make(1, 1, itemsize * vlen),
                        gr::io_signature::make(0, 0, 0)),
-        d_itemsize(itemsize)
+        d_itemsize(itemsize), d_vlen(vlen)
     {
       d_blocking = blocking;
       d_context = new zmq::context_t(1);
@@ -63,10 +63,11 @@ namespace gr {
       const char *in = (const char *) input_items[0];
 
       // create message copy and send
-      zmq::message_t msg(d_itemsize*noutput_items);
-      memcpy((void *)msg.data(), in, d_itemsize*noutput_items);
+      zmq::message_t msg(d_itemsize*d_vlen*noutput_items);
+      memcpy((void *)msg.data(), in, d_itemsize*d_vlen*noutput_items);
+      std::cout << "before" << std::endl;
       d_socket->send(msg, d_blocking ? 0 : ZMQ_NOBLOCK);
-
+      std::cout << "after" << std::endl;
       return noutput_items;
     }
 
diff --git a/gr-zeromq/lib/push_sink_impl.h b/gr-zeromq/lib/push_sink_impl.h
index 77f1f60..76ee2c2 100644
--- a/gr-zeromq/lib/push_sink_impl.h
+++ b/gr-zeromq/lib/push_sink_impl.h
@@ -33,6 +33,7 @@ namespace gr {
     {
     private:
       size_t          d_itemsize;
+      size_t          d_vlen;
       bool            d_blocking;
       zmq::context_t  *d_context;
       zmq::socket_t   *d_socket;
diff --git a/gr-zeromq/lib/rep_sink_impl.cc b/gr-zeromq/lib/rep_sink_impl.cc
index 38bb7d7..7e5f43d 100644
--- a/gr-zeromq/lib/rep_sink_impl.cc
+++ b/gr-zeromq/lib/rep_sink_impl.cc
@@ -41,7 +41,7 @@ namespace gr {
       : gr::sync_block("rep_sink",
                       gr::io_signature::make(1, 1, itemsize * vlen),
                       gr::io_signature::make(0, 0, 0)),
-        d_itemsize(itemsize), d_blocking(blocking)
+        d_itemsize(itemsize), d_vlen(vlen), d_blocking(blocking)
     {
       d_timeout = timeout >= 0 ? (int)(timeout*1e6) : 0;
       d_context = new zmq::context_t(1);
@@ -74,15 +74,15 @@ namespace gr {
 
        // create message copy and send
        if (noutput_items < req_output_items) {
-         zmq::message_t msg(d_itemsize*noutput_items);
-         memcpy((void *)msg.data(), in, d_itemsize*noutput_items);
+         zmq::message_t msg(d_itemsize*d_vlen*noutput_items);
+         memcpy((void *)msg.data(), in, d_itemsize*d_vlen*noutput_items);
          d_socket->send(msg, d_blocking ? 0 : ZMQ_NOBLOCK);
 
          return noutput_items;
        }
        else {
-         zmq::message_t msg(d_itemsize*req_output_items);
-         memcpy((void *)msg.data(), in, d_itemsize*req_output_items);
+         zmq::message_t msg(d_itemsize*d_vlen*req_output_items);
+         memcpy((void *)msg.data(), in, d_itemsize*d_vlen*req_output_items);
          d_socket->send(msg, d_blocking ? 0 : ZMQ_NOBLOCK);
 
          return req_output_items;
diff --git a/gr-zeromq/lib/rep_sink_impl.h b/gr-zeromq/lib/rep_sink_impl.h
index 0996d53..17e1da7 100644
--- a/gr-zeromq/lib/rep_sink_impl.h
+++ b/gr-zeromq/lib/rep_sink_impl.h
@@ -33,6 +33,7 @@ namespace gr {
     {
     private:
       size_t          d_itemsize;
+      size_t          d_vlen;
       int             d_timeout;
       zmq::context_t  *d_context;
       zmq::socket_t   *d_socket;
diff --git a/gr-zeromq/lib/req_source_impl.cc b/gr-zeromq/lib/req_source_impl.cc
index ffe31f9..8dedf6c 100644
--- a/gr-zeromq/lib/req_source_impl.cc
+++ b/gr-zeromq/lib/req_source_impl.cc
@@ -41,7 +41,7 @@ namespace gr {
       : gr::sync_block("req_source",
                       gr::io_signature::make(0, 0, 0),
                       gr::io_signature::make(1, 1, itemsize * vlen)),
-        d_itemsize(itemsize)
+        d_itemsize(itemsize), d_vlen(vlen)
     {
       d_context = new zmq::context_t(1);
       d_socket = new zmq::socket_t(*d_context, ZMQ_REQ);
@@ -56,8 +56,8 @@ namespace gr {
 
     int
     req_source_impl::work(int noutput_items,
-                            gr_vector_const_void_star &input_items,
-                            gr_vector_void_star &output_items)
+                          gr_vector_const_void_star &input_items,
+                          gr_vector_void_star &output_items)
     {
       char *out = (char*)output_items[0];
 
@@ -66,10 +66,10 @@ namespace gr {
 
       //  If we got a reply, process
       if (itemsout[0].revents & ZMQ_POLLOUT) {
-       // Request data, FIXME non portable
-       zmq::message_t request(sizeof(int));
-       memcpy ((void *) request.data (), &noutput_items, sizeof(int));
-       d_socket->send(request);
+        // Request data, FIXME non portable
+        zmq::message_t request(sizeof(int));
+        memcpy ((void *) request.data (), &noutput_items, sizeof(int));
+        d_socket->send(request);
       }
 
       zmq::pollitem_t itemsin[] = { { *d_socket, 0, ZMQ_POLLIN, 0 } };
@@ -77,14 +77,13 @@ namespace gr {
 
       //  If we got a reply, process
       if (itemsin[0].revents & ZMQ_POLLIN) {
-       // Receive data
-       zmq::message_t reply;
-       d_socket->recv(&reply);
+        // Receive data
+        zmq::message_t reply;
+        d_socket->recv(&reply);
 
-       // Copy to ouput buffer and return
-       memcpy(out, (void *)reply.data(), reply.size());
-
-       return reply.size()/d_itemsize;
+        // Copy to ouput buffer and return
+        memcpy(out, (void *)reply.data(), reply.size());
+        return reply.size()/(d_itemsize*d_vlen);
       }
 
       return 0;
diff --git a/gr-zeromq/lib/req_source_impl.h b/gr-zeromq/lib/req_source_impl.h
index 6c87b48..4d40f80 100644
--- a/gr-zeromq/lib/req_source_impl.h
+++ b/gr-zeromq/lib/req_source_impl.h
@@ -33,6 +33,7 @@ namespace gr {
     {
     private:
       size_t          d_itemsize;
+      size_t          d_vlen;
       zmq::context_t  *d_context;
       zmq::socket_t   *d_socket;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]