commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r5697 - in gnuradio/branches/developers/gnychis/inband/usrp/host: apps lib/inband
Date: Tue, 5 Jun 2007 17:29:06 -0600 (MDT)

Author: gnychis
Date: 2007-06-05 17:29:06 -0600 (Tue, 05 Jun 2007)
New Revision: 5697

Modified:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx_stub.cc
   
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:
Fixed bug in usrp_tx_stub where the number of packets was being computed 
incorrectly

QA code for TX also fixed up to handle TX response "throw aways" when closes 
are sent before receiving all responses.


Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
   2007-06-05 23:18:13 UTC (rev 5696)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
   2007-06-05 23:29:06 UTC (rev 5697)
@@ -129,8 +129,8 @@
 
   if(fake_usrp_p) {
     pmt_dict_set(usrp_dict, 
-                 pmt_intern("usrp-tx"),
-                            pmt_intern("usrp_tx_stub"));
+                 pmt_intern("fake-usrp"),
+                            PMT_T);
   }
 
   define_component("server", "usrp_server", usrp_dict);

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
   2007-06-05 23:18:13 UTC (rev 5696)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
   2007-06-05 23:29:06 UTC (rev 5697)
@@ -106,8 +106,7 @@
  
   // Use the stub with the usrp_server
   pmt_t usrp_server_dict = pmt_make_dict();
-  pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"),
-              pmt_intern("usrp_usb_interface_stub"));
+  pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
 
   // Test the TX side
   define_component("server", "usrp_server", usrp_server_dict);
@@ -283,7 +282,7 @@
 
   // Use the stub with the usrp_server
   pmt_t usrp_server_dict = pmt_make_dict();
-  pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"), 
pmt_intern("usrp_usb_interface_stub"));
+  pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
 
   // Test the TX side
   define_component("server", "usrp_server", usrp_server_dict);
@@ -503,7 +502,7 @@
 
   // Use the stub with the usrp_server
   pmt_t usrp_server_dict = pmt_make_dict();
-  pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"), 
pmt_intern("usrp_usb_interface_stub"));
+  pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
 
   // Test the TX side
   define_component("server", "usrp_server", usrp_server_dict);
@@ -616,7 +615,7 @@
   : mb_mblock(runtime, instance_name, user_arg)
 { 
 
-  d_nmsg_to_recv=12;
+  d_nmsg_to_recv=10;
   d_nmsg_recvd=0;
   
   d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
@@ -625,7 +624,7 @@
 
   // Use the stub with the usrp_server
   pmt_t usrp_server_dict = pmt_make_dict();
-  pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"), 
pmt_intern("usrp_usb_interface_stub"));
+  pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
 
   // Test the TX side
   define_component("server", "usrp_server", usrp_server_dict);
@@ -651,7 +650,7 @@
   // A transmit before an open should fail
   d_tx->send(s_cmd_xmit_raw_frame, 
pmt_list4(pmt_list2(s_response_xmit_raw_frame,PMT_F), pmt_from_long(0), 
pmt_make_u32vector(transport_pkt::max_payload()/4, 0), pmt_from_long(0)));
   
-  // Open, and now try an xmit again which should be successful
+  // Now open
   d_cs->send(s_cmd_open, pmt_list2(pmt_list2(s_response_open,PMT_T), 
pmt_from_long(0)));
 
   // Try to transmit on a channel that we have no allocation for
@@ -798,7 +797,7 @@
     return;
   } else {
     // std::cout << "[qa_tx_top] Received expected CS response for message ("
-    // << msg->signal() << ")\n";
+     //<< msg->signal() << ")\n";
   }
 
 }
@@ -849,8 +848,7 @@
 
   // Use the stub with the usrp_server
   pmt_t usrp_server_dict = pmt_make_dict();
-  //pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"), 
pmt_intern("usrp_usb_interface_stub"));
-  pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"), 
pmt_intern("usrp_usb_interface"));  // FIXME
+  pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
 
   // Test the TX side
   define_component("server", "usrp_server", usrp_server_dict);

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-05 23:18:13 UTC (rev 5696)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-06-05 23:29:06 UTC (rev 5697)
@@ -210,7 +210,7 @@
     else if (pmt_eq(event, s_response_usrp_close)) {
       pmt_t status = pmt_nth(1, data);
       d_cs->send(s_response_close, pmt_list2(invocation_handle, status));
-      
+
       if(pmt_eqv(status,PMT_T)) {
         d_opened = false;
         d_defer = false;
@@ -225,11 +225,12 @@
       
       pmt_t status = pmt_nth(1, data);
       long channel = pmt_to_long(pmt_nth(2, data));
+      long port;
 
       // Find the port through the owner of the channel
-      long port = tx_port_index(d_chaninfo_tx[channel].owner);
-      d_tx[port]->send(s_response_xmit_raw_frame, 
-                       pmt_list2(invocation_handle, status));
+      if((port = tx_port_index(d_chaninfo_tx[channel].owner)) !=-1 )
+        d_tx[port]->send(s_response_xmit_raw_frame, 
+                         pmt_list2(invocation_handle, status));
       return;
     }
     //--------------- USRP READ ---------------//
@@ -360,19 +361,23 @@
     if(!d_opened) { 
 
       long port;
+
       if((port = tx_port_index(port_id)) != -1) {
 
         d_tx[port]->send(s_response_allocate_channel, 
                           pmt_list3(invocation_handle, 
                                     PMT_F, 
                                     pmt_from_long(0)));
-      } else {
-
-        port = rx_port_index(port_id);
+        return;
+      }
+      
+      
+      if((port = rx_port_index(port_id)) != -1) {
         d_rx[port]->send(s_response_allocate_channel, 
                          pmt_list3(invocation_handle, 
                                    PMT_F, 
                                    pmt_from_long(0)));
+        return;
       }
       return;
     }
@@ -393,13 +398,15 @@
                          pmt_list3(invocation_handle, 
                                    PMT_F, 
                                    pmt_from_long(0)));
-      } else {
+        return;
+      }
 
-        port = rx_port_index(port_id);
+      if((port = rx_port_index(port_id)) != -1) {
         d_rx[port]->send(s_response_deallocate_channel, 
                           pmt_list3(invocation_handle, 
                                     PMT_F, 
                                     pmt_from_long(0)));
+        return;
       }
       return;
     }
@@ -421,9 +428,9 @@
     }
 
     if(!d_opened) {    // check the USRP was opened
-      port = tx_port_index(port_id);
-      d_tx[port]->send(s_response_xmit_raw_frame, 
-                       pmt_list2(invocation_handle, PMT_F));
+      if((port = tx_port_index(port_id)) != -1)
+        d_tx[port]->send(s_response_xmit_raw_frame, 
+                         pmt_list2(invocation_handle, PMT_F));
       return;
     }
     
@@ -444,9 +451,9 @@
     }
     
     if(!d_opened) {
-      port = rx_port_index(port_id);
-      d_rx[port]->send(s_response_recv_raw_samples,
-                       pmt_list2(invocation_handle, PMT_F));
+      if((port = rx_port_index(port_id)) != -1)
+        d_rx[port]->send(s_response_recv_raw_samples,
+                         pmt_list2(invocation_handle, PMT_F));
       return;
     }
 
@@ -701,14 +708,16 @@
     memcpy(pkts[n].payload(), 
            (uint8_t *)samples+(max_payload_len * n), 
            payload_len);
+  
   }
 
+
   pkts[n_packets-1].set_end_of_burst(); // set the last packet's end of burst
 
   if (verbose)
     std::cout << "[USRP_SERVER] Received raw frame invocation: " 
               << invocation_handle << std::endl;
-
+    
   // The actual response to the write will be generated by a
   // s_response_usrp_write
   d_cs_usrp->send(s_cmd_usrp_write, 

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx_stub.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx_stub.cc
    2007-06-05 23:18:13 UTC (rev 5696)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx_stub.cc
    2007-06-05 23:29:06 UTC (rev 5697)
@@ -47,7 +47,7 @@
 {
   d_cs = define_port("cs", "usrp-tx-cs", true, mb_port::EXTERNAL);
   
-  d_disk_write=true;
+  //d_disk_write=true;
   
   if(d_disk_write)
     d_ofile.open("pdump.dat",std::ios::binary|std::ios::out);
@@ -76,7 +76,7 @@
   // want to make sure its at least what we want
   if(pmt_eq(port_id, d_cs->port_symbol())) {
     
-    if(pmt_eqv(event, s_cmd_usrp_tx_write))
+    if(pmt_eqv(event, s_cmd_usrp_tx_write)) 
       write(data);
   }
 }
@@ -90,14 +90,14 @@
   d_utx = boost::any_cast<usrp_standard_tx *>(pmt_any_ref(pmt_nth(3, data)));
 
   size_t n_bytes;
-  bool underrun;  // this will need to go, as it is taken care of in the 
packet headers
 
   if(d_disk_write) {
     transport_pkt *pkts = (transport_pkt *) 
pmt_u8vector_writeable_elements(v_packets, n_bytes);
-    long n_packets = static_cast<long>(std::ceil(n_bytes / 
(double)transport_pkt::max_payload()));
+    long n_packets = static_cast<long>(std::ceil(n_bytes / 
(double)transport_pkt::max_pkt_size()));
     
-    for(int i=0; i<(int)n_packets; i++) 
+    for(long i=0; i<n_packets; i++)  
       d_ofile.write((const char*) pkts[i].payload(), pkts[i].payload_len());
+    
   }
 
   d_cs->send(s_response_usrp_tx_write,

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-05 23:18:13 UTC (rev 5696)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
      2007-06-05 23:29:06 UTC (rev 5697)
@@ -60,7 +60,8 @@
 // need to take number of TX and RX channels as parameter
 usrp_usb_interface::usrp_usb_interface(mb_runtime *rt, const std::string 
&instance_name, pmt_t user_arg)
   : mb_mblock(rt, instance_name, user_arg),
-  d_fpga_debug(false)
+  d_fpga_debug(false),
+  d_fake_usrp(false)
 {
   // Dictionary for arguments to all of the components
   pmt_t usrp_dict = user_arg;
@@ -70,19 +71,11 @@
   std::string rx_interface = "usrp_rx";
   
   if (pmt_is_dict(usrp_dict)) {
-
-    if(pmt_dict_has_key(usrp_dict, pmt_intern("usrp-tx")))
-      tx_interface =
-        pmt_symbol_to_string(pmt_dict_ref(usrp_dict,
-            pmt_intern("usrp-tx"),
-            PMT_NIL));
-    
-    if(pmt_dict_has_key(usrp_dict, pmt_intern("usrp-rx")))
-      rx_interface =
-        pmt_symbol_to_string(pmt_dict_ref(usrp_dict,
-            pmt_intern("usrp-rx"),
-            PMT_NIL));
-  
+    if(pmt_dict_has_key(usrp_dict, pmt_intern("fake-usrp"))) {
+      tx_interface = "usrp_tx_stub";
+      rx_interface = "usrp_rx_stub";
+      d_fake_usrp=true;
+     }
   }
   
   if (verbose) {
@@ -208,6 +201,7 @@
                  pmt_list3(invocation_handle,
                            status,
                            channel));
+
       return;
     }
 
@@ -224,6 +218,11 @@
   pmt_t invocation_handle = pmt_nth(0, data);
   long which_usrp = pmt_to_long(pmt_nth(1, data));
   pmt_t reply_data;
+ 
+  if(d_fake_usrp) {
+    d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T));
+    return;
+  }
 
   if (verbose)
     std::cout << "[USRP_USB_INTERFACE] Handling open request for USRP " << 
which_usrp << "\n";
@@ -330,7 +329,8 @@
 {
   pmt_t invocation_handle = pmt_nth(0, data);
 
-  d_urx->start();
+  if(!d_fake_usrp)
+    d_urx->start();
 
   pmt_t rx_handle = pmt_make_any(d_urx);
 
@@ -346,6 +346,11 @@
 usrp_usb_interface::handle_cmd_close(pmt_t data)
 {
   pmt_t invocation_handle = pmt_nth(0, data);
+
+  if(d_fake_usrp) {
+    d_cs->send(s_response_usrp_close, pmt_list2(invocation_handle, PMT_T));
+    return;
+  }
   
   if (verbose)
     std::cout << "[usrp_usb_interface] Handling close request for USRP\n";

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-05 23:18:13 UTC (rev 5696)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
       2007-06-05 23:29:06 UTC (rev 5697)
@@ -44,6 +44,8 @@
 
   long d_fpga_debug;
 
+  bool d_fake_usrp;
+
  public:
   usrp_usb_interface(mb_runtime *rt, const std::string &instance_name, pmt_t 
user_arg);
   ~usrp_usb_interface();





reply via email to

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