From 4e7d048aeb80f95b19cebed9d76b79e6cbe64a9a Mon Sep 17 00:00:00 2001
From: eb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Date: Thu, 13 Sep 2007 23:21:41 +0000
Subject: Merged r6329:6428 of features/inband-usb + distcheck fixes into
 trunk.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@6429 221aa14e-8319-0410-a670-987f0aec2ac5
---
 usrp/host/lib/inband/usrp_inband_usb_packet.h |  3 ++-
 usrp/host/lib/inband/usrp_rx.cc               |  2 +-
 usrp/host/lib/inband/usrp_rx_stub.cc          |  2 +-
 usrp/host/lib/inband/usrp_rx_stub.h           |  2 +-
 usrp/host/lib/inband/usrp_server.cc           | 29 +++++++++++++++++++++++++--
 usrp/host/lib/inband/usrp_server.mbh          |  4 ++--
 usrp/host/lib/inband/usrp_usb_interface.cc    | 16 +++++++--------
 usrp/host/lib/inband/usrp_usb_interface.h     |  2 +-
 8 files changed, 43 insertions(+), 17 deletions(-)

(limited to 'usrp/host/lib')

diff --git a/usrp/host/lib/inband/usrp_inband_usb_packet.h b/usrp/host/lib/inband/usrp_inband_usb_packet.h
index 9290f55ae5..8c19b1aeba 100644
--- a/usrp/host/lib/inband/usrp_inband_usb_packet.h
+++ b/usrp/host/lib/inband/usrp_inband_usb_packet.h
@@ -64,8 +64,9 @@ public:
     FL_DROPPED        = 0x20000000,
     FL_START_OF_BURST = 0x10000000,
     FL_END_OF_BURST   = 0x08000000,
+    FL_CARRIER_SENSE  = 0x04000000,
 
-    FL_ALL_FLAGS      = 0xf8000000
+    FL_ALL_FLAGS      = 0xfc000000
   };
 
   static const int FL_OVERRUN_SHIFT = 31;
diff --git a/usrp/host/lib/inband/usrp_rx.cc b/usrp/host/lib/inband/usrp_rx.cc
index 7344a6e898..caa2d71754 100644
--- a/usrp/host/lib/inband/usrp_rx.cc
+++ b/usrp/host/lib/inband/usrp_rx.cc
@@ -119,7 +119,7 @@ usrp_rx::read_and_respond(pmt_t data)
       return;
     }
 
-    if(underrun)
+    if(underrun && verbose && 0)
       std::cout << "[usrp_rx] Underrun\n";
 
     d_cs->send(s_response_usrp_rx_read, 
diff --git a/usrp/host/lib/inband/usrp_rx_stub.cc b/usrp/host/lib/inband/usrp_rx_stub.cc
index bf78ddf27a..5ea8135aaf 100644
--- a/usrp/host/lib/inband/usrp_rx_stub.cc
+++ b/usrp/host/lib/inband/usrp_rx_stub.cc
@@ -33,7 +33,7 @@
 #include <fpga_regs_common.h>
 #include "usrp_standard.h"
 #include <stdio.h>
-#include "ui_nco.h"
+#include <ui_nco.h>
 #include <fstream>
 
 #include <symbols_usrp_rx_cs.h>
diff --git a/usrp/host/lib/inband/usrp_rx_stub.h b/usrp/host/lib/inband/usrp_rx_stub.h
index 483af5b487..5a75bf00ac 100644
--- a/usrp/host/lib/inband/usrp_rx_stub.h
+++ b/usrp/host/lib/inband/usrp_rx_stub.h
@@ -24,7 +24,7 @@
 #include <mb_mblock.h>
 #include <vector>
 #include "usrp_standard.h"
-#include "ui_nco.h"
+#include <ui_nco.h>
 #include <fstream>
 #include <queue>
 #include <usrp_inband_usb_packet.h>
diff --git a/usrp/host/lib/inband/usrp_server.cc b/usrp/host/lib/inband/usrp_server.cc
index 760397dc75..d73c7d5253 100644
--- a/usrp/host/lib/inband/usrp_server.cc
+++ b/usrp/host/lib/inband/usrp_server.cc
@@ -53,6 +53,8 @@ usrp_server::usrp_server(mb_runtime *rt, const std::string &instance_name, pmt_t
   : mb_mblock(rt, instance_name, user_arg),
   d_fake_rx(false)
 {
+  if(verbose)
+    std::cout << "[USRP_SERVER] Initializing...\n";
 
   // Dictionary for arguments to all of the components
   pmt_t usrp_dict = user_arg;
@@ -596,11 +598,26 @@ void usrp_server::handle_cmd_xmit_raw_frame(mb_port_sptr port, std::vector<struc
   long channel = pmt_to_long(pmt_nth(1, data));
   const void *samples = pmt_uniform_vector_elements(pmt_nth(2, data), n_bytes);
   long timestamp = pmt_to_long(pmt_nth(3, data));
+  pmt_t properties = pmt_nth(4, data);
   
   // Ensure the channel is valid and the caller owns the port
   if(!check_valid(port, channel, chan_info,
                   pmt_list2(s_response_xmit_raw_frame, invocation_handle)))
     return;
+
+  // Read information from the properties of the packet
+  bool carrier_sense = false;
+  if(pmt_is_dict(properties)) {
+
+    // Check if carrier sense is enabled for the frame
+    if(pmt_t p_carrier_sense = pmt_dict_ref(properties, 
+                                            pmt_intern("carrier-sense"), 
+                                            PMT_NIL)) {
+      if(pmt_eqv(p_carrier_sense, PMT_T)) 
+        carrier_sense = true;
+    }
+  }
+
   
   // Determine the number of packets to allocate contiguous memory for
   // bursting over the USB and get a pointer to the memory to be used in
@@ -619,8 +636,16 @@ void usrp_server::handle_cmd_xmit_raw_frame(mb_port_sptr port, std::vector<struc
       std::min((long)(n_bytes-(n*max_payload_len)), (long)max_payload_len);
   
     if(n == 0) { // first packet gets start of burst flag and timestamp
-      pkts[n].set_header(pkts[n].FL_START_OF_BURST, channel, 0, payload_len);
+      
+      if(carrier_sense)
+        pkts[n].set_header(pkts[n].FL_START_OF_BURST 
+                           | pkts[n].FL_CARRIER_SENSE, 
+                           channel, 0, payload_len);
+      else
+        pkts[n].set_header(pkts[n].FL_START_OF_BURST, channel, 0, payload_len);
+
       pkts[n].set_timestamp(timestamp);
+    
     } else {
       pkts[n].set_header(0, channel, 0, payload_len);
       pkts[n].set_timestamp(0xffffffff);
@@ -635,7 +660,7 @@ void usrp_server::handle_cmd_xmit_raw_frame(mb_port_sptr port, std::vector<struc
 
   pkts[n_packets-1].set_end_of_burst(); // set the last packet's end of burst
 
-  if (verbose)
+  if (verbose && 0)
     std::cout << "[USRP_SERVER] Received raw frame invocation: " 
               << invocation_handle << std::endl;
     
diff --git a/usrp/host/lib/inband/usrp_server.mbh b/usrp/host/lib/inband/usrp_server.mbh
index 06ec4b996a..3fd0db139b 100644
--- a/usrp/host/lib/inband/usrp_server.mbh
+++ b/usrp/host/lib/inband/usrp_server.mbh
@@ -106,7 +106,7 @@
 ;;   (op-ping-fixed-reply rid ping-value)
 ;;   (op-write-reg reg-number reg-value)
 ;;   (op-write-reg-masked reg-number reg-value mask-value)
-;;   (op-read-reg rid reg-number reg-value)
+;;   (op-read-reg rid reg-number)
 ;;   (op-read-reg-reply rid reg-number reg-value)
 ;;   (op-i2c-write i2c-addr u8-vec)
 ;;   (op-i2c-read rid i2c-addr nbytes)
@@ -144,7 +144,7 @@
 
   (:outgoing
 
-   (cmd-xmit-raw-frame invocation-handle channel samples timestamp)
+   (cmd-xmit-raw-frame invocation-handle channel samples timestamp properties)
 
    ;; The argument channel must be an integer.  It specifies the
    ;; channel on which the frame of samples will be be sent.
diff --git a/usrp/host/lib/inband/usrp_usb_interface.cc b/usrp/host/lib/inband/usrp_usb_interface.cc
index b2ccba81b8..269ed2706d 100644
--- a/usrp/host/lib/inband/usrp_usb_interface.cc
+++ b/usrp/host/lib/inband/usrp_usb_interface.cc
@@ -53,8 +53,8 @@ usrp_usb_interface::usrp_usb_interface(mb_runtime *rt, const std::string &instan
   : mb_mblock(rt, instance_name, user_arg),
   d_fpga_debug(false),
   d_fake_usrp(false),
-  d_interp_tx(16),
-  d_interp_rx(16),
+  d_interp_tx(128),
+  d_decim_rx(128),
   d_rf_freq(10e6),
   d_rbf("inband_tx_rx.rbf")
 {
@@ -87,11 +87,11 @@ usrp_usb_interface::usrp_usb_interface(mb_runtime *rt, const std::string &instan
     }
     
     // Read the RX interpolations
-    if(pmt_t interp_rx = pmt_dict_ref(usrp_dict, 
-                                      pmt_intern("interp-rx"), 
+    if(pmt_t decim_rx = pmt_dict_ref(usrp_dict, 
+                                      pmt_intern("decim-rx"), 
                                       PMT_NIL)) {
-      if(!pmt_eqv(interp_rx, PMT_NIL)) 
-        d_interp_rx = pmt_to_long(interp_rx);
+      if(!pmt_eqv(decim_rx, PMT_NIL)) 
+        d_decim_rx = pmt_to_long(decim_rx);
     }
 
     // Read the RBF
@@ -119,7 +119,7 @@ usrp_usb_interface::usrp_usb_interface(mb_runtime *rt, const std::string &instan
               << d_interp_tx << std::endl;
           
     std::cout << "[USRP_USB_INTERFACE] Setting RX interpolation to " 
-              << d_interp_rx << std::endl;
+              << d_decim_rx << std::endl;
 
     std::cout << "[USRP_USB_INTERFACE] Using TX interface: " 
               << tx_interface << "\n";
@@ -305,7 +305,7 @@ usrp_usb_interface::handle_cmd_open(pmt_t data)
 
   d_urx =
     usrp_standard_rx::make (which_usrp,
-			    d_interp_rx,		
+			    d_decim_rx,		
 			    1,		        // nchan
 			    -1,           // mux
 			    0,            // set blank mode to start
diff --git a/usrp/host/lib/inband/usrp_usb_interface.h b/usrp/host/lib/inband/usrp_usb_interface.h
index 42cda7af15..8efce2ff66 100644
--- a/usrp/host/lib/inband/usrp_usb_interface.h
+++ b/usrp/host/lib/inband/usrp_usb_interface.h
@@ -47,7 +47,7 @@ class usrp_usb_interface : public mb_mblock
   bool d_fake_usrp;
 
   long d_interp_tx;
-  long d_interp_rx;
+  long d_decim_rx;
 
   long d_rf_freq;
 
-- 
cgit v1.2.3