commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r5536 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Wed, 23 May 2007 10:14:25 -0600 (MDT)

Author: gnychis
Date: 2007-05-23 10:14:25 -0600 (Wed, 23 May 2007)
New Revision: 5536

Modified:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_usrp_inband.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
Log:
Tested out low level USRP code in hardware, successfully open channel, write to 
the bus and close the USRP

Shifted the channel numbers of 0,1,2...  to 1,2,... since the USRP recognizes 
TXA and RXA as channel 1, not 0

USRP server only opens 1 channel for now, get an error trying to open both 
channels, that I'm not sure if it is a lack of daughterboards on my second 
channel or something else


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-05-23 13:21:36 UTC (rev 5535)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
   2007-05-23 16:14:25 UTC (rev 5536)
@@ -551,19 +551,19 @@
   d_xmit_to_recv++;
 
   // Test 2: 1 packet, of exact size... since we are using 32-bit samples we 
divide by 4
-  d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(1), 
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_payload()/4, 
0), pmt_from_long(0)));
+  d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(1), 
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_pkt_size()/4, 
0), pmt_from_long(0)));
   d_xmit_to_recv++;
 
   // Test 3: 2 packets, a spill over of 1 sample into the second packet
-  d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(2), 
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_payload()/4+1, 
0), pmt_from_long(0)));
+  d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(2), 
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_pkt_size()/4+1, 
0), pmt_from_long(0)));
   d_xmit_to_recv++;
 
   // Test 4: 2 packets of exact payload size
-  d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(2), 
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_payload()/4*2, 
0), pmt_from_long(0)));
+  d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(2), 
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_pkt_size()/4*2, 
0), pmt_from_long(0)));
   d_xmit_to_recv++;
   
   // Test 4: 2 full packets, and 1 packet with a single sample (which is 3)
-  d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(3), 
pmt_from_long(d_tx_chan), 
pmt_make_u32vector(transport_pkt::max_payload()/4*2+1, 0), pmt_from_long(0)));
+  d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(3), 
pmt_from_long(d_tx_chan), 
pmt_make_u32vector(transport_pkt::max_pkt_size()/4*2+1, 0), pmt_from_long(0)));
   d_xmit_to_recv++;
 
 }

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-23 13:21:36 UTC (rev 5535)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_usrp_inband.cc
        2007-05-23 16:14:25 UTC (rev 5536)
@@ -37,6 +37,8 @@
 // Signal set for the USRP server
 static pmt_t s_cmd_open = pmt_intern("cmd-open");
 static pmt_t s_response_open = pmt_intern("response-open");
+static pmt_t s_cmd_close = pmt_intern("cmd-close");
+static pmt_t s_response_close = pmt_intern("response-close");
 static pmt_t s_cmd_allocate_channel = pmt_intern("cmd-allocate-channel");
 static pmt_t s_response_allocate_channel = 
pmt_intern("response-allocate-channel");
 static pmt_t s_send_allocate_channel = pmt_intern("send-allocate-channel");
@@ -70,6 +72,8 @@
   mb_port_sptr d_tx;
   mb_port_sptr d_cs;
 
+  long d_tx_chan;
+
  public:
   test_usrp_inband_top(mb_runtime *runtime, const std::string &instance_name, 
pmt_t user_arg);
   ~test_usrp_inband_top();
@@ -77,8 +81,11 @@
   void handle_message(mb_message_sptr msg);
 
  protected:
+  void open_usrp();
+  void close_usrp();
   void check_message(mb_message_sptr msg);
-  void run_tests();
+  void allocate_channel();
+  void send_packets();
 };
 
 test_usrp_inband_top::test_usrp_inband_top(mb_runtime *runtime, const 
std::string &instance_name, pmt_t user_arg)
@@ -102,9 +109,7 @@
 void
 test_usrp_inband_top::initial_transition()
 {
-  pmt_t usrp = pmt_from_long(1);
-
-  d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, usrp));
+  open_usrp();
 }
 
 void
@@ -114,24 +119,112 @@
   pmt_t port_id = msg->port_id();      // which port it came in on
   pmt_t data = msg->data();
   pmt_t metadata = msg->metadata();
+  pmt_t status;
 
-
   if (pmt_eq(port_id, d_cs->port_symbol())) {  // message came in on our 
control/status port
 
     //---------- OPEN RESPONSE ----------//
     if (pmt_eq(event, s_response_open)) {
-      pmt_t status = pmt_nth(1, data);
+      status = pmt_nth(1, data);
 
       if(pmt_eq(status, PMT_T)) {
         std::cout << "[TEST_USRP_INBAND_TOP] Success opening USRP\n";
       }
       else {
         std::cout << "[TEST_USRP_INBAND_TOP] Received error message opening 
USRP\n";
+        shutdown_all(PMT_F);
       }
+
+      allocate_channel();
+
+      return;
     }
+    //--------- CLOSE RESPONSE -----------//
+    else if (pmt_eq(event, s_response_close)) {
+      status = pmt_nth(1, data);
+      
+      if(pmt_eq(status, PMT_T)) {
+        std::cout << "[TEST_USRP_INBAND_TOP] Successfully closed USRP\n";
+      }
+      else {
+        std::cout << "[TEST_USRP_INBAND_TOP] Received error message closing 
USRP\n";
+        shutdown_all(PMT_F);
+      }
 
+      shutdown_all(PMT_T);
+
+      return;
+    }
   }
+    
+  if (pmt_eq(port_id, d_tx->port_symbol())) {
 
+    //---------- ALLOCATE RESPONSE ---------//
+    if(pmt_eq(event, s_response_allocate_channel)) {
+      status = pmt_nth(1, data);
+      pmt_t channel = pmt_nth(2, data);
+
+      if(pmt_eq(status, PMT_T)) {
+        d_tx_chan = pmt_to_long(channel);
+        std::cout << "[TEST_USRP_INBAND_TOP] Received allocation on channel " 
<< d_tx_chan << "\n";
+      }
+      else {
+        std::cout << "[TEST_USRP_INBAND_TOP] Error allocating channel\n";
+        shutdown_all(PMT_F);
+      }
+      
+      send_packets();
+
+      return;
+    }
+    //----------- XMIT RESPONSE ------------//
+    else if(pmt_eq(event, s_response_xmit_raw_frame)) {
+      status = pmt_nth(1, data);
+
+      if(pmt_eq(status, PMT_T)) {
+        std::cout << "[TEST_USRP_INBAND_TOP] Transmission successful\n";
+      }
+      else {
+        std::cout << "[TEST_USRP_INBAND_TOP] Failed transmission\n";
+        shutdown_all(PMT_F);
+      }
+
+      close_usrp();
+
+      return;
+    }
+  }
+
+  std::cout << "[TEST_USRP_INBAND_TOP] Received unhandled message: " << event 
<< "\n";
 }
 
+void
+test_usrp_inband_top::allocate_channel()
+{
+  std::cout << "[TEST_USRP_INBAND_TOP] Requesting channel allocation...\n";
+  
+  d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
+}
+
+void
+test_usrp_inband_top::send_packets()
+{
+  std::cout << "[TEST_USRP_INBAND_TOP] Sending single packet..\n";
+  d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(1), 
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_pkt_size()/4, 
0), pmt_from_long(0)));
+  
+}
+
+void
+test_usrp_inband_top::open_usrp()
+{
+  pmt_t usrp = pmt_from_long(0);
+  d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, usrp));
+}
+
+void
+test_usrp_inband_top::close_usrp()
+{
+  d_cs->send(s_cmd_close, pmt_list1(PMT_NIL));
+}
+
 REGISTER_MBLOCK_CLASS(test_usrp_inband_top);

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-05-23 13:21:36 UTC (rev 5535)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-05-23 16:14:25 UTC (rev 5536)
@@ -144,6 +144,10 @@
     return MAX_PAYLOAD;
   }
 
+  static int max_pkt_size() {
+    return USB_PKT_SIZE;
+  }
+
 };
 
 #endif

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-23 13:21:36 UTC (rev 5535)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-05-23 16:14:25 UTC (rev 5536)
@@ -141,7 +141,7 @@
 
   // Initialize capacity on each channel to 0 and to no owner
   // Also initialize the USRP standard tx/rx pointers to NULL
-  for(int chan=0; chan < d_ntx_chan; chan++) {
+  for(int chan=1; chan <= d_ntx_chan; chan++) {
     d_chaninfo_tx[chan].assigned_capacity = 0;
     d_chaninfo_tx[chan].owner = PMT_NIL;
   }
@@ -161,7 +161,7 @@
 
   d_nrx_chan = pmt_to_long(chans);
 
-  for(int chan=0; chan < d_nrx_chan; chan++) {
+  for(int chan=1; chan <= d_nrx_chan; chan++) {
     d_chaninfo_rx[chan].assigned_capacity = 0;
     d_chaninfo_rx[chan].owner = PMT_NIL;
   }
@@ -233,7 +233,6 @@
 
     if (pmt_eq(event, s_cmd_open)){
 
-      std::cout << "[USRP_SERVER] Received open msg\n";
       // 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
@@ -254,7 +253,17 @@
       return;
     }
     else if (pmt_eq(event, s_cmd_close)){
-      // ...
+      invocation_handle = pmt_nth(0, data);
+
+#ifdef FAKE_USRP_TESTS
+      // Just respond successfully if using fake USRP
+      reply_data = pmt_list2(invocation_handle, PMT_T);
+      d_cs->send(s_response_close, reply_data);
+#else
+      d_cs_usrp->send(s_cmd_usrp_close, pmt_list1(PMT_NIL));
+#endif
+
+      return;
     }
     else if (pmt_eq(event, s_cmd_max_capacity)) {
       invocation_handle = pmt_nth(0, data);
@@ -358,10 +367,10 @@
 long usrp_server::current_capacity_allocation() {
   long capacity = 0;
 
-  for(int chan=0; chan < d_ntx_chan; chan++) 
+  for(int chan=1; chan <= d_ntx_chan; chan++) 
     capacity += d_chaninfo_tx[chan].assigned_capacity;
 
-  for(int chan=0; chan < d_nrx_chan; chan++)
+  for(int chan=1; chan <= d_nrx_chan; chan++)
     capacity += d_chaninfo_rx[chan].assigned_capacity;
 
   return capacity;
@@ -386,7 +395,7 @@
     }
 
     // Find a free channel, assign the capacity and respond
-    for(chan=0; chan < d_ntx_chan; chan++) {
+    for(chan=1; chan <= d_ntx_chan; chan++) {
       if(d_chaninfo_tx[chan].owner == PMT_NIL) {
         d_chaninfo_tx[chan].owner = port_id;
         d_chaninfo_tx[chan].assigned_capacity = rqstd_capacity;
@@ -412,7 +421,7 @@
       return;
     }
 
-    for(chan=0; chan < d_nrx_chan; chan++) {
+    for(chan=1; chan <= d_nrx_chan; chan++) {
       if(d_chaninfo_rx[chan].owner == PMT_NIL) {
         d_chaninfo_rx[chan].owner = port_id;
         d_chaninfo_rx[chan].assigned_capacity = rqstd_capacity;
@@ -443,7 +452,7 @@
   // of the channel, and if so remove the assigned capacity.
   if((port = tx_port_index(port_id)) != -1) {
   
-    if(channel >= d_ntx_chan) {
+    if(channel > d_ntx_chan) {
       reply_data = pmt_list2(invocation_handle, 
pmt_from_long(CHANNEL_INVALID));   // not a legit channel number
       d_tx[port]->send(s_response_deallocate_channel, reply_data);
       return;
@@ -466,7 +475,7 @@
   // Repeated process on the RX side
   if((port = rx_port_index(port_id)) != -1) {
   
-    if(channel >= d_nrx_chan) {
+    if(channel > d_nrx_chan) {
       reply_data = pmt_list2(invocation_handle, 
pmt_from_long(CHANNEL_INVALID));   // not a legit channel number
       d_rx[port]->send(s_response_deallocate_channel, reply_data);
       return;
@@ -505,7 +514,7 @@
   // of the channel to send the frame
   if((port = tx_port_index(port_id)) != -1) {
   
-    if(channel >= d_ntx_chan) {
+    if(channel > d_ntx_chan) {
       reply_data = pmt_list2(invocation_handle, 
pmt_from_long(CHANNEL_INVALID));   // not a legit channel number
       d_tx[port]->send(s_response_xmit_raw_frame, reply_data);
       return;

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-23 13:21:36 UTC (rev 5535)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
      2007-05-23 16:14:25 UTC (rev 5536)
@@ -54,10 +54,10 @@
   d_nrx_chan = 2;
 
   // Initialize NULLs for the channel pointers
-  for(int i=0; i < d_ntx_chan; i++)
+  for(int i=0; i < d_ntx_chan+1; i++)   // +1 as the channels start at 1
     d_utx.push_back(NULL);
 
-  for(int i=0; i < d_nrx_chan; i++)
+  for(int i=0; i < d_nrx_chan+1; i++)
     d_urx.push_back(NULL);
 }
 
@@ -125,7 +125,10 @@
    
   // I'm not sure if i should be opening up all RX and TX channels,  but given 
that
   // one is not specified in the signal, I am assuming so.
-  for(int chan=0; chan < d_ntx_chan; chan++) {
+  //
+  // FIXME: usrp_open_interface:usb_claim_interface: failed interface 1
+  //  ... when trying to open two channels
+  for(int chan=1; chan < d_ntx_chan; chan++) {
     d_utx[chan] = usrp_standard_tx::make (which_usrp,
       16,               // interp = 32.0MB/s
       chan,                
@@ -147,9 +150,11 @@
       return;
     }
 
+    std::cout << "[USRP_USB_INTERFACE] Setup TX channel " << chan << ", 
running...";
     d_utx[chan]->start();  // not sure if this is the appropriate place to 
start yet
+    std::cout << "done!\n";
   }
-  for(int chan=0; chan < d_nrx_chan; chan++) {
+  for(int chan=1; chan < d_nrx_chan; chan++) {
     d_urx[chan] = usrp_standard_rx::make (which_usrp,
       16,               // interp = 32.0MB/s
       chan,                
@@ -171,8 +176,12 @@
       return;
     }
 
+    std::cout << "[USRP_USB_INTERFACE] Setup RX channel " << chan << ", 
running...";
     d_urx[chan]->start();  // not sure if this is the appropriate place to 
start yet
+    std::cout << "done!\n";
   }
+
+  d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T));
 }
 
 void





reply via email to

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