commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 59/148: WIP host mods to send vrt packets


From: git
Subject: [Commit-gnuradio] [gnuradio] 59/148: WIP host mods to send vrt packets
Date: Mon, 15 Aug 2016 00:47:24 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

nwest pushed a commit to annotated tag old_usrp_devel_udp
in repository gnuradio.

commit a616ef1620869e0d526bde2b2c92b5f83ec4f7d5
Author: Josh Blum <address@hidden>
Date:   Fri Dec 11 17:00:33 2009 -0800

    WIP host mods to send vrt packets
---
 usrp2/host/lib/ring.h        |  1 -
 usrp2/host/lib/usrp2_impl.cc | 54 +++++++++++++++++++++++++-------------------
 usrp2/host/lib/usrp2_impl.h  |  4 +++-
 3 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/usrp2/host/lib/ring.h b/usrp2/host/lib/ring.h
index 2547a7e..8672f82 100644
--- a/usrp2/host/lib/ring.h
+++ b/usrp2/host/lib/ring.h
@@ -25,7 +25,6 @@
 #include <vector>
 #include <boost/shared_ptr.hpp>
 #include <gruel/thread.h>
-#include <vrt/expanded_header.h>
 
 namespace usrp2 {
 
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index 155804a..102f5cb 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -27,7 +27,6 @@
 #include <gruel/realtime.h>
 #include <gruel/sys_pri.h>
 #include <usrp2_types.h>
-#include <usrp2/rx_sample_handler.h>
 #include "usrp2_impl.h"
 #include "control.h"
 #include <stdexcept>
@@ -36,6 +35,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include <string.h>
+#include <vrt/expanded_header.h>
 
 static const int DEFAULT_RX_SCALE = 1024;
 
@@ -160,6 +160,7 @@ namespace usrp2 {
 
   usrp2::impl::impl(transport::sptr data_transport, transport::sptr 
ctrl_transport) :
       d_next_rid(0),
+      d_tx_pkt_cnt(0),
       d_tx_interp(0),
       d_rx_decim(0),
       d_ctrl_transport(ctrl_transport),
@@ -705,38 +706,45 @@ namespace usrp2 {
 
     size_t n = 0;
     for (size_t fn = 0; fn < nframes; fn++){
-      uint32_t timestamp = 0;
-      uint32_t flags = 0;
-
-      if (fn == 0){
-       timestamp = metadata->timestamp;
-       if (metadata->send_now)
-         flags |= U2P_TX_IMMEDIATE;
-       if (metadata->start_of_burst)
-         flags |= U2P_TX_START_OF_BURST;
+      uint32_t burst_flags = 0;
+
+      if (fn == 0 and metadata->start_of_burst){
+        burst_flags |= VRTH_START_OF_BURST;
       }
-      if (fn > 0){
-       flags |= U2P_TX_IMMEDIATE;
+      if (fn == last_frame and metadata->end_of_burst){
+        burst_flags |= VRTH_END_OF_BURST;
       }
-      if (fn == last_frame){
-       if (metadata->end_of_burst)
-         flags |= U2P_TX_END_OF_BURST;
+      if (metadata->send_now){
+        burst_flags |= VRTH_START_OF_BURST | VRTH_END_OF_BURST;
       }
 
-      //setup the fixed header
-      u2_fixed_hdr_t   fixed_hdr;
-      u2p_set_word0(&fixed_hdr, flags, channel);
-      u2p_set_timestamp(&fixed_hdr, timestamp);
-
+      //calculate the packet length
       size_t i = std::min((size_t) U2_MAX_SAMPLES, nitems - n);
 
+      //setup the header
+      uint32_t vrt_if_data_pkt_hdr[2];
+      d_tx_pkt_cnt++; //increment the tx packet count
+      vrt_if_data_pkt_hdr[0] =
+        VRTH_PT_IF_DATA_WITH_SID |
+        burst_flags              |
+        (i & VRTH_PKT_SIZE_MASK) |
+        ((d_tx_pkt_cnt << VRTH_PKT_CNT_SHIFT) & VRTH_PKT_CNT_MASK);
+      vrt_if_data_pkt_hdr[1] = channel;
+
+      //make the header nbo
+      for (size_t j = 0; j < dimof(vrt_if_data_pkt_hdr); j++){
+        printf("0x%.8x\n", vrt_if_data_pkt_hdr[j]);
+        vrt_if_data_pkt_hdr[j] = htonx(vrt_if_data_pkt_hdr[i]);
+      }
+
+      //pack the iovecs with the header and data
       iovec iov[2];
-      iov[0].iov_base = &fixed_hdr;
-      iov[0].iov_len = sizeof(fixed_hdr);
+      iov[0].iov_base = vrt_if_data_pkt_hdr;
+      iov[0].iov_len = sizeof(vrt_if_data_pkt_hdr);
       iov[1].iov_base = const_cast<uint32_t *>(&items[n]);
       iov[1].iov_len = i * sizeof(uint32_t);
 
-      if (not d_data_transport->sendv(iov, 2)){
+      if (not d_data_transport->sendv(iov, dimof(iov))){
         return false;
       }
 
diff --git a/usrp2/host/lib/usrp2_impl.h b/usrp2/host/lib/usrp2_impl.h
index 4958298..cd54bd5 100644
--- a/usrp2/host/lib/usrp2_impl.h
+++ b/usrp2/host/lib/usrp2_impl.h
@@ -26,12 +26,13 @@
 #include <boost/scoped_ptr.hpp>
 #include <boost/thread.hpp>
 #include "control.h"
-#include "ring.h"
 #include "transport.h"
 #include <string>
 
 #define MAX_SUBPKT_LEN 252
 
+#define dimof(_x) (sizeof(_x)/sizeof(_x[0]))
+
 namespace usrp2 {
 
   class usrp2_tune_result;
@@ -55,6 +56,7 @@ namespace usrp2 {
     static const size_t NRIDS = 256;
 
     int            d_next_rid;
+    int            d_tx_pkt_cnt;
 
     // all pending_replies are stack allocated, thus no possibility of leaking 
these
     pending_reply *d_pending_replies[NRIDS]; // indexed by 8-bit reply id



reply via email to

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