commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5583 - gnuradio/branches/developers/gnychis/inband/us


From: gnychis
Subject: [Commit-gnuradio] r5583 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Fri, 1 Jun 2007 08:37:42 -0600 (MDT)

Author: gnychis
Date: 2007-06-01 08:37:41 -0600 (Fri, 01 Jun 2007)
New Revision: 5583

Modified:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_usrp_inband.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.mbh
   
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.mbh
Log:
Adding loopback functionality to the USRP interface and test_usrp_inband code.  

This is *untested* in hardware so far.

Adding loopback functionality required an rx-mode argument to the cmd-open so 
that applications can enable the loopback at the time of setting up the RX side.


Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_usrp_inband.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_usrp_inband.cc
        2007-05-31 18:37:02 UTC (rev 5582)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_usrp_inband.cc
        2007-06-01 14:37:41 UTC (rev 5583)
@@ -31,6 +31,7 @@
 #include <mb_protocol_class.h>
 #include <mb_class_registry.h>
 #include <pmt.h>
+#include "usrp_standard.h"
 
 typedef usrp_inband_usb_packet transport_pkt; 
 
@@ -56,14 +57,59 @@
 static pmt_t s_cmd_xmit_raw_frame  = pmt_intern("cmd-xmit-raw-frame");
 static pmt_t s_response_xmit_raw_frame = pmt_intern("response-xmit-raw-frame");
 
+bool loopback_p = false;
+bool counting_p = false;
+char *prog_name;
+
+static void
+set_progname (char *path)
+{
+  char *p = strrchr (path, '/');
+  if (p != 0)
+    prog_name = p+1;
+  else
+    prog_name = path;
+}
+
+static void
+usage()
+{
+  fprintf (stderr, "usage: %s [-l]\n", prog_name);
+  fprintf (stderr, "  [-l] digital loopback in FPGA\n");
+  fprintf (stderr, "  [-c] counting in FPGA\n");
+
+  exit(1);
+}
+
 int
 main(int argc, char **argv)
 {
-  std::cout << "[test_usrp_inband] Starting...\n";
+  int ch;
 
+  set_progname(argv[0]);
+
   mb_runtime_sptr rt = mb_make_runtime();
   pmt_t result = PMT_T;
 
+  while ((ch = getopt(argc, argv, "lc")) != EOF) {
+    switch(ch) {
+    
+      case 'l':
+        loopback_p = true;
+        break;
+
+      case 'c':
+        counting_p = true;
+        break;
+
+      default:
+        usage();
+    }
+  }
+
+
+  std::cout << "[test_usrp_inband] Starting...\n";
+
   rt->run("top", "test_usrp_inband_top", PMT_F, &result);
 }
 
@@ -218,7 +264,15 @@
 test_usrp_inband_top::open_usrp()
 {
   pmt_t usrp = pmt_from_long(0);
-  d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, usrp));
+
+  long rx_mode = 0;
+
+  if(loopback_p)
+    rx_mode |= usrp_standard_rx::FPGA_MODE_LOOPBACK;
+  if(counting_p)
+    rx_mode |= usrp_standard_rx::FPGA_MODE_COUNTING;
+
+  d_cs->send(s_cmd_open, pmt_list3(PMT_NIL, usrp, pmt_from_long(rx_mode)));
 }
 
 void

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-05-31 18:37:02 UTC (rev 5582)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-06-01 14:37:41 UTC (rev 5583)
@@ -233,10 +233,6 @@
 
     if (pmt_eq(event, s_cmd_open)){
 
-      // extract args from data
-      invocation_handle = pmt_nth(0, data);
-      long which_usrp = pmt_to_long(pmt_nth(1, data)); // integer usrp id, 
usually 0
-
 #ifdef FAKE_USRP_TESTS
       
       // When we are testing a fake USRP we don't need to open the interface 
and just
@@ -245,9 +241,10 @@
       d_cs->send(s_response_open, reply_data);
 
  #else
-      
-      d_cs_usrp->send(s_cmd_usrp_open, pmt_list2(PMT_NIL, 
pmt_from_long(which_usrp)));
 
+      // the parameters are the same to the low level interface, so we just 
pass 'data' along
+      d_cs_usrp->send(s_cmd_usrp_open, data);
+
  #endif
       
       return;

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.mbh
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.mbh
    2007-05-31 18:37:02 UTC (rev 5582)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.mbh
    2007-06-01 14:37:41 UTC (rev 5583)
@@ -237,7 +237,7 @@
 (define-protocol-class usrp-server-cs
 
   (:outgoing
-   (cmd-open invocation-handle which-usrp)
+   (cmd-open invocation-handle which-usrp rx-mode)
    (cmd-close invocation-handle)
    (cmd-max-capacity invocation-handle)
    (cmd-ntx-chan invocation-handle)

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-05-31 18:37:02 UTC (rev 5582)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
      2007-06-01 14:37:41 UTC (rev 5583)
@@ -113,6 +113,7 @@
 {
   pmt_t invocation_handle = pmt_nth(0, data);
   long which_usrp = pmt_to_long(pmt_nth(1, data));
+  long rx_mode = pmt_to_long(pmt_nth(2, data));
   pmt_t reply_data;
 
   std::cout << "[USRP_USB_INTERFACE] Handling open request for USRP " << 
which_usrp << "\n";
@@ -146,6 +147,7 @@
     16,               // interp = 32.0MB/s
     d_nrx_chan,                
     -1,               // mux
+    rx_mode,
     4096,             // USB block size
     16);              // number of blocks for async transfers
 
@@ -164,6 +166,10 @@
   }
   
   std::cout << "[USRP_USB_INTERFACE] Setup RX channel\n";
+  if(rx_mode & usrp_standard_rx::FPGA_MODE_LOOPBACK)
+    std::cout << "[USRP_USB_INTERFACE]   - loopback enabled\n";
+  if(rx_mode & usrp_standard_rx::FPGA_MODE_COUNTING)
+    std::cout << "[USRP_USB_INTERFACE]   - counting enabled\n";
 
   d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T));
 }

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.mbh
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.mbh
     2007-05-31 18:37:02 UTC (rev 5582)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.mbh
     2007-06-01 14:37:41 UTC (rev 5583)
@@ -34,7 +34,7 @@
 (define-protocol-class usrp-usb-interface-cs
 
   (:outgoing
-   (cmd-usrp-open invocation-handle which-usrp)
+   (cmd-usrp-open invocation-handle which-usrp rx-mode)
    (cmd-usrp-close invocation-handle)
    (cmd-usrp-ntx-chan invocation-handle)
    (cmd-usrp-nrx-chan invocation-handle)





reply via email to

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