commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5729 - in gnuradio/branches/developers/gnychis/inband


From: gnychis
Subject: [Commit-gnuradio] r5729 - in gnuradio/branches/developers/gnychis/inband/usrp/host: apps lib/inband
Date: Wed, 6 Jun 2007 23:22:12 -0600 (MDT)

Author: gnychis
Date: 2007-06-06 23:22:11 -0600 (Wed, 06 Jun 2007)
New Revision: 5729

Modified:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_interface.mbh
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
Log:
Added functionality to 'stop' receiving in the stub, and have tested it in the 
stub using the test app.

RX needs QA code which tests this still, and this needs to be tested in 
hardware.


Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
   2007-06-07 03:54:57 UTC (rev 5728)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
   2007-06-07 05:22:11 UTC (rev 5729)
@@ -64,6 +64,8 @@
 static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan");
 static pmt_t s_response_current_capacity_allocation  = 
pmt_intern("response-current-capacity-allocation");
 
+static bool verbose = false;
+
 class test_usrp_rx : public mb_mblock
 {
   mb_port_sptr         d_rx;
@@ -289,7 +291,10 @@
   
   const char *samples = (const char *) pmt_uniform_vector_elements(v_samples, 
n_bytes);
   d_ofile.write(samples, n_bytes);
-  std::cout << ".";
+
+  if(verbose)
+    std::cout << ".";
+
 }
 
 void

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_interface.mbh
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_interface.mbh
 2007-06-07 03:54:57 UTC (rev 5728)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_interface.mbh
 2007-06-07 05:22:11 UTC (rev 5729)
@@ -77,6 +77,7 @@
 
   (:outgoing
    (cmd-usrp-rx-start-reading invocation-handle rx-handle)
+   (cmd-usrp-rx-stop-reading invocation-handle)
    )
 
   (:incoming

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc 
2007-06-07 03:54:57 UTC (rev 5728)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc 
2007-06-07 05:22:11 UTC (rev 5729)
@@ -91,7 +91,7 @@
 
   if(verbose)
     std::cout << "[usrp_rx] Waiting for packets..\n";
-  
+
   // Read by 512 which is packet size and send them back up
   while(1) {
     n_read = d_urx->read(pkt, pkt_size, &underrun);

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
    2007-06-07 03:54:57 UTC (rev 5728)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
    2007-06-07 05:22:11 UTC (rev 5729)
@@ -39,6 +39,8 @@
 
 static const bool verbose = false;
 
+bool usrp_rx_stop;
+
 static pmt_t s_cmd_usrp_rx_start_reading = 
pmt_intern("cmd-usrp-rx-start-reading");
 static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read");
 
@@ -56,7 +58,7 @@
   double sample_rate = 128e6 / interp; 
   d_nco.set_freq(2*M_PI * freq/sample_rate);
 
-  d_disk_write = true;
+  //d_disk_write = true;
   
   if(d_disk_write)
     d_ofile.open("raw_rx.dat",std::ios::binary|std::ios::out);
@@ -94,8 +96,10 @@
 usrp_rx_stub::read_and_respond(pmt_t data)
 {
 
-  while(1) {
+  usrp_rx_stop = false;
 
+  while(!usrp_rx_stop) {
+
     long nsamples_this_frame = d_samples_per_frame;
 
     size_t nshorts = 2 * nsamples_this_frame;  // 16-bit I & Q
@@ -139,6 +143,7 @@
     d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_T, v_pkt));
 
   }
+
 }
 
 REGISTER_MBLOCK_CLASS(usrp_rx_stub);

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-06-07 03:54:57 UTC (rev 5728)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-06-07 05:22:11 UTC (rev 5729)
@@ -69,6 +69,7 @@
 static pmt_t s_cmd_usrp_ntx_chan = pmt_intern("cmd-usrp-ntx-chan");
 static pmt_t s_cmd_usrp_nrx_chan = pmt_intern("cmd-usrp-nrx-chan");
 static pmt_t s_cmd_usrp_start_reading = pmt_intern("cmd-usrp-start-reading");
+static pmt_t s_cmd_usrp_stop_reading = pmt_intern("cmd-usrp-stop-reading");
 static pmt_t s_response_usrp_ntx_chan = pmt_intern("response-usrp-ntx-chan");
 static pmt_t s_response_usrp_nrx_chan = pmt_intern("response-usrp-nrx-chan");
 static pmt_t s_response_usrp_open = pmt_intern("response-usrp-open");
@@ -458,7 +459,10 @@
       if(!d_opened) 
         return;
 
-      //handle_cmd_stop_recv_raw_samples(port, data);
+      // FIX ME : no response for stopping? even if error? (permissions)
+      
+      handle_cmd_stop_recv_raw_samples(d_rx[port], d_chaninfo_rx, data);
+
       return;
     }
 
@@ -694,6 +698,41 @@
   return;
 }
 
+void
+usrp_server::handle_cmd_stop_recv_raw_samples(
+                        mb_port_sptr port, 
+                        std::vector<struct channel_info> &chan_info, 
+                        pmt_t data)
+{
+  pmt_t invocation_handle = pmt_nth(0, data);
+  long channel = pmt_to_long(pmt_nth(1, data));
+
+  // FIX ME : we have no responses to send an error...
+  // 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;
+
+  // Remove this hosts bit from the receiver mask
+  d_rx_chan_mask &= ~(1<<channel);
+
+  // We only need to generate a 'start reading' command down to the
+  // low level interface if no other channel is already reading
+  //
+  // We carry this over the CS interface because the lower level
+  // interface does not care about the channel, we only demux it
+  // at the usrp_server on responses.
+  if(d_rx_chan_mask == 0) {
+    
+    if(verbose)
+      std::cout << "[USRP_SERVER] Sending stop reading request down\n";
+
+    d_cs_usrp->send(s_cmd_usrp_stop_reading, pmt_list1(invocation_handle));
+  }
+  
+  return;
+}
+
 // Read the packet header, determine the port by the channel owner
 void
 usrp_server::handle_response_usrp_read(pmt_t data)

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h  
    2007-06-07 03:54:57 UTC (rev 5728)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h  
    2007-06-07 05:22:11 UTC (rev 5729)
@@ -93,6 +93,7 @@
   void handle_cmd_deallocate_channel(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   void handle_cmd_xmit_raw_frame(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   void handle_cmd_start_recv_raw_samples(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
+  void handle_cmd_stop_recv_raw_samples(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   int rx_port_index(pmt_t port_id);
   int tx_port_index(pmt_t port_id);
   long current_capacity_allocation();

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
      2007-06-07 03:54:57 UTC (rev 5728)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
      2007-06-07 05:22:11 UTC (rev 5729)
@@ -42,6 +42,7 @@
 static pmt_t s_cmd_usrp_ntx_chan = pmt_intern("cmd-usrp-ntx-chan");
 static pmt_t s_cmd_usrp_nrx_chan = pmt_intern("cmd-usrp-nrx-chan");
 static pmt_t s_cmd_usrp_start_reading = pmt_intern("cmd-usrp-start-reading");
+static pmt_t s_cmd_usrp_stop_reading = pmt_intern("cmd-usrp-stop-reading");
 static pmt_t s_response_usrp_ntx_chan = pmt_intern("response-usrp-ntx-chan");
 static pmt_t s_response_usrp_nrx_chan = pmt_intern("response-usrp-nrx-chan");
 static pmt_t s_response_usrp_open = pmt_intern("response-usrp-open");
@@ -172,6 +173,11 @@
       handle_cmd_start_reading(data);
       return;
     }
+    //-------- STOP READING --------//
+    else if(pmt_eq(event, s_cmd_usrp_stop_reading)) {
+      handle_cmd_stop_reading(data);
+      return;
+    }
 
     goto unhandled;
   }
@@ -328,6 +334,9 @@
 usrp_usb_interface::handle_cmd_start_reading(pmt_t data)
 {
   pmt_t invocation_handle = pmt_nth(0, data);
+  
+  if(verbose)
+    std::cout << "[usrp_usb_interface] Starting RX...\n";
 
   if(!d_fake_usrp)
     d_urx->start();
@@ -336,9 +345,22 @@
 
   d_rx_cs->send(s_cmd_usrp_rx_start_reading, pmt_list2(PMT_NIL, rx_handle));
 
+  return;
+}
+
+void
+usrp_usb_interface::handle_cmd_stop_reading(pmt_t data)
+{
+  pmt_t invocation_handle = pmt_nth(0, data);
+  
   if(verbose)
-    std::cout << "[usrp_usb_interface] Starting RX...\n";
+    std::cout << "[usrp_usb_interface] Stopping RX...\n";
 
+  if(!d_fake_usrp)
+    d_urx->stop();
+  else
+    usrp_rx_stop = true;  // extern to communicate with stub to wait
+
   return;
 }
 

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
       2007-06-07 03:54:57 UTC (rev 5728)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
       2007-06-07 05:22:11 UTC (rev 5729)
@@ -25,6 +25,8 @@
 #include <vector>
 #include "usrp_standard.h"
 
+extern bool usrp_rx_stop;   // used to communicate a 'stop' to the RX stub
+
 /*!
  * \brief Implements the low level usb interface to the USRP
  */
@@ -57,6 +59,7 @@
   void handle_cmd_close(pmt_t data);
   void handle_cmd_write(pmt_t data);
   void handle_cmd_start_reading(pmt_t data);
+  void handle_cmd_stop_reading(pmt_t data);
  
 };
   





reply via email to

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