commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r6741 - in gnuradio/branches/features/inband-usb: pmt/


From: gnychis
Subject: [Commit-gnuradio] r6741 - in gnuradio/branches/features/inband-usb: pmt/src/lib usrp/host/lib/inband
Date: Mon, 29 Oct 2007 12:31:27 -0600 (MDT)

Author: gnychis
Date: 2007-10-29 12:31:27 -0600 (Mon, 29 Oct 2007)
New Revision: 6741

Modified:
   gnuradio/branches/features/inband-usb/pmt/src/lib/pmt.cc
   gnuradio/branches/features/inband-usb/pmt/src/lib/pmt.h
   gnuradio/branches/features/inband-usb/pmt/src/lib/qa_pmt_prims.cc
   gnuradio/branches/features/inband-usb/pmt/src/lib/qa_pmt_prims.h
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.h
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
Log:
Merging from -r6730:6740 developers/gnychis/inband


Modified: gnuradio/branches/features/inband-usb/pmt/src/lib/pmt.cc
===================================================================
--- gnuradio/branches/features/inband-usb/pmt/src/lib/pmt.cc    2007-10-29 
17:46:38 UTC (rev 6740)
+++ gnuradio/branches/features/inband-usb/pmt/src/lib/pmt.cc    2007-10-29 
18:31:27 UTC (rev 6741)
@@ -962,6 +962,12 @@
 }
 
 pmt_t
+pmt_list_add(pmt_t list, pmt_t item)
+{
+  return pmt_reverse(pmt_cons(item, pmt_reverse(list)));
+}
+
+pmt_t
 pmt_caar(pmt_t pair)
 {
   return (pmt_car(pmt_car(pair)));

Modified: gnuradio/branches/features/inband-usb/pmt/src/lib/pmt.h
===================================================================
--- gnuradio/branches/features/inband-usb/pmt/src/lib/pmt.h     2007-10-29 
17:46:38 UTC (rev 6740)
+++ gnuradio/branches/features/inband-usb/pmt/src/lib/pmt.h     2007-10-29 
18:31:27 UTC (rev 6741)
@@ -609,7 +609,12 @@
  */
 pmt_t pmt_list6(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4, pmt_t x5, pmt_t x6);
 
+/*!
+ * \brief Return \p list with \p item added to it.
+ */
+pmt_t pmt_list_add(pmt_t list, pmt_t item);
 
+
 /*
  * ------------------------------------------------------------------------
  *                          read / write

Modified: gnuradio/branches/features/inband-usb/pmt/src/lib/qa_pmt_prims.cc
===================================================================
--- gnuradio/branches/features/inband-usb/pmt/src/lib/qa_pmt_prims.cc   
2007-10-29 17:46:38 UTC (rev 6740)
+++ gnuradio/branches/features/inband-usb/pmt/src/lib/qa_pmt_prims.cc   
2007-10-29 18:31:27 UTC (rev 6741)
@@ -301,6 +301,20 @@
   CPPUNIT_ASSERT_EQUAL(std::string("k0"), pmt_write_string(k0));
 }
 
+void
+qa_pmt_prims::test_lists()
+{
+  pmt_t s0 = pmt_intern("s0");
+  pmt_t s1 = pmt_intern("s1");
+  pmt_t s2 = pmt_intern("s2");
+  pmt_t s3 = pmt_intern("s3");
+
+  pmt_t l1 = pmt_list4(s0, s1, s2, s3);
+  pmt_t l2 = pmt_list3(s0, s1, s2);
+  pmt_t l3 = pmt_list_add(l2, s3);
+  CPPUNIT_ASSERT(pmt_equal(l1, l3));
+}
+
 // ------------------------------------------------------------------------
 
 // class foo is used in test_any below.

Modified: gnuradio/branches/features/inband-usb/pmt/src/lib/qa_pmt_prims.h
===================================================================
--- gnuradio/branches/features/inband-usb/pmt/src/lib/qa_pmt_prims.h    
2007-10-29 17:46:38 UTC (rev 6740)
+++ gnuradio/branches/features/inband-usb/pmt/src/lib/qa_pmt_prims.h    
2007-10-29 18:31:27 UTC (rev 6741)
@@ -40,6 +40,7 @@
   CPPUNIT_TEST(test_dict);
   CPPUNIT_TEST(test_any);
   CPPUNIT_TEST(test_io);
+  CPPUNIT_TEST(test_lists);
   CPPUNIT_TEST(test_serialize);
   CPPUNIT_TEST_SUITE_END();
 
@@ -56,6 +57,7 @@
   void test_dict();
   void test_any();
   void test_io();
+  void test_lists();
   void test_serialize();
 };
 

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
 2007-10-29 17:46:38 UTC (rev 6740)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
 2007-10-29 18:31:27 UTC (rev 6741)
@@ -1080,7 +1080,161 @@
 
 REGISTER_MBLOCK_CLASS(qa_rx_top);
 
+// 
----------------------------------------------------------------------------------------------
 
+class qa_rid_top : public mb_mblock
+{
+  mb_port_sptr d_tx;
+  mb_port_sptr d_rx;
+  mb_port_sptr d_cs;
+
+  long d_npongs;
+  long d_tcycles;
+  long d_cycles;
+  long d_max_rid;
+  
+  mb_time d_t0;
+  double d_delta_t;
+
+ public:
+  qa_rid_top(mb_runtime *runtime, const std::string &instance_name, pmt_t 
user_arg);
+  ~qa_rid_top();
+  void initial_transition();
+  void handle_message(mb_message_sptr msg);
+
+ protected:
+  void run_tests();
+  void send_max_pings();
+};
+
+qa_rid_top::qa_rid_top(mb_runtime *runtime, const std::string &instance_name, 
pmt_t user_arg)
+  : mb_mblock(runtime, instance_name, user_arg)
+{ 
+  d_npongs = 0;
+  d_tcycles = 3;
+  d_cycles = d_tcycles;
+  d_max_rid = usrp_server::D_MAX_RID;
+  d_delta_t = 0.1;
+
+
+  d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
+  d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
+  d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
+ 
+  // Use the stub with the usrp_server
+  pmt_t usrp_server_dict = pmt_make_dict();
+  pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
+
+  // Test the TX side
+  define_component("server", "usrp_server", usrp_server_dict);
+  connect("self", "tx0", "server", "tx0");
+  connect("self", "rx0", "server", "rx0");
+  connect("self", "cs", "server", "cs");
+
+}
+
+qa_rid_top::~qa_rid_top(){}
+
+void
+qa_rid_top::initial_transition()
+{
+  run_tests();
+}
+
+void
+qa_rid_top::run_tests()
+{
+  if(verbose)
+    std::cout << "[qa_rid_top] Starting tests...\n";
+  
+  // Retrieve information about the USRP, then run tests
+  d_cs->send(s_cmd_open, 
+             pmt_list2(pmt_list2(s_response_open, PMT_T), 
+             pmt_from_long(0)));
+
+  // should be able to allocate 1 byte
+  d_tx->send(s_cmd_allocate_channel, 
+             pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T), 
+                       pmt_from_long(1)));
+  
+  d_rx->send(s_cmd_allocate_channel, 
+             pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T), 
+                       pmt_from_long(1)));
+  
+  // Need to start receiving to read from the USRP to get C/S responses
+  d_rx->send(s_cmd_start_recv_raw_samples, 
+             pmt_list2(PMT_NIL, 
+                       pmt_from_long(0)));
+
+  // Build a subpacket of MAX_RID pings and wait a small amount for all of the
+  // responses and fire off another MAX_RID.  If MAX_RID*2 responses are
+  // received, the RID recycling is working correctly.
+  // Schedule a timer in which we expect to have received all of the responses,
+  // which will send off another MAX_RID worth.
+  send_max_pings();
+  d_t0 = mb_time::time();
+  schedule_one_shot_timeout(d_t0 + d_delta_t, PMT_NIL);
+}
+
+void
+qa_rid_top::send_max_pings()
+{
+  pmt_t ping = pmt_list2(s_op_ping_fixed,
+                         pmt_list2(pmt_from_long(0),
+                                   pmt_from_long(0)));
+
+  pmt_t sub_packets = PMT_NIL;
+
+  for(int i=0; i<d_max_rid; i++) 
+    sub_packets = pmt_list_add(sub_packets, ping);
+
+  d_tx->send(s_cmd_to_control_channel,
+             pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
+                       sub_packets));
+}
+
+void
+qa_rid_top::handle_message(mb_message_sptr msg)
+{
+  pmt_t data = msg->data();
+  pmt_t event = msg->signal();
+
+  // If we get a timeout we ensure we got a maximum RID number of responses.
+  if(pmt_eq(event, s_timeout)) {
+    if(verbose)
+      std::cout << "[qa_rid_top] Got timeout, received so far: " 
+                << d_npongs << "\n";
+
+    d_cycles--;
+    
+    if(d_cycles==0 && d_npongs == d_max_rid*d_tcycles) {
+      shutdown_all(PMT_T);
+    }
+    else if(d_cycles==0) {
+
+      std::cout << "[qa_rid_top] d_npongs: " << d_npongs
+                << " expected: " << d_max_rid*d_tcycles
+                << std::endl;
+
+      shutdown_all(PMT_F);
+    }
+    else {
+      send_max_pings();
+      d_t0 = mb_time::time();
+      schedule_one_shot_timeout(d_t0 + d_delta_t, PMT_NIL);
+    }
+
+  }
+  else if(pmt_eq(event, s_response_from_control_channel))
+  {
+    d_npongs++;
+  }
+
+}
+
+REGISTER_MBLOCK_CLASS(qa_rid_top);
+
+
 // 
----------------------------------------------------------------------------------------------
 
 class qa_cs_top : public mb_mblock
@@ -1399,3 +1553,17 @@
   
   CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
 }
+
+void
+qa_inband_usrp_server::test_rid()
+{
+  mb_runtime_sptr rt = mb_make_runtime();
+  pmt_t result = PMT_T;
+
+  // std::cout << "\n\n-----------------\n";
+  // std::cout << "  RUNNING RID TESTS  \n";
+
+  rt->run("top", "qa_rid_top", PMT_F, &result);
+  
+  CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
+}

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.h
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.h
  2007-10-29 17:46:38 UTC (rev 6740)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.h
  2007-10-29 18:31:27 UTC (rev 6741)
@@ -34,6 +34,7 @@
   CPPUNIT_TEST(test_tx);
   CPPUNIT_TEST(test_rx);
   CPPUNIT_TEST(test_cs);
+  CPPUNIT_TEST(test_rid);
   CPPUNIT_TEST_SUITE_END();
 
  private:
@@ -43,6 +44,7 @@
   void test_tx();
   void test_rx();
   void test_cs();
+  void test_rid();
 };
 
 #endif /* INCLUDED_QA_INBAND_USRP_SERVER_H */

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc   
2007-10-29 17:46:38 UTC (rev 6740)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc   
2007-10-29 18:31:27 UTC (rev 6741)
@@ -801,6 +801,9 @@
   long payload_len = 0;
   long channel = CONTROL_CHAN;
 
+  if(verbose)
+    std::cout << "[USRP_SERVER] Handling " << n_subpkts << " commands\n";
+
   // The design of the following code is optimized for simplicity, not
   // performance.  To performance optimize this code, the total size in bytes
   // needed for all of the CS packets is needed to allocate contiguous memory





reply via email to

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