commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r5896 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Tue, 3 Jul 2007 09:39:44 -0600 (MDT)

Author: gnychis
Date: 2007-07-03 09:39:44 -0600 (Tue, 03 Jul 2007)
New Revision: 5896

Modified:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
Log:
Added functionality to create new USB packets when a subpacket is attempted to
be inserted into a USB packet that has no more room in the payload.  The current
USB packet will be sent, then a new one will be created the subpacket will be
placed in it.  This repeats until all of the CS subpackets are sent via a USB
packet.


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-07-03 15:13:18 UTC (rev 5895)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-07-03 15:39:44 UTC (rev 5896)
@@ -660,7 +660,8 @@
   pmt_t invocation_handle = pmt_nth(0, data);
   pmt_t subpackets = pmt_nth(1, data);
 
-  long n_subpackets = pmt_length(subpackets);
+  long n_subpkts = pmt_length(subpackets);
+  long curr_subpkt = 0;
 
   size_t psize;
   long payload_len = 0;
@@ -676,13 +677,12 @@
   // The approach taken is to keep parsing the subpackets and putting them in 
to
   // USB packets.  Once the USB packet is full, a write is sent for it and
   // another packet is created.
-
-  for(int i=0; i < n_subpackets; i++) {
-
-    pmt_t subp = pmt_nth(i, subpackets);
-    pmt_t subp_cmd = pmt_nth(0, subp);
-    pmt_t subp_data = pmt_nth(1, subp);
-
+  //
+  // The subpacket creation methods will return false if the subpacket will not
+  // fit in to the current USB packet.  In these cases a new USB packet is
+  // created and the old is sent.
+  
+  new_packet:
     // This code needs to become "smart" and only make a new packet when full
     pmt_t v_packet = pmt_make_u8vector(sizeof(transport_pkt), 0);
     transport_pkt *pkt = (transport_pkt *) 
pmt_u8vector_writeable_elements(v_packet, psize);
@@ -691,7 +691,12 @@
     pkt->set_header(0, channel, 0, payload_len);
     pkt->set_timestamp(0xffffffff);
 
+  while(curr_subpkt < n_subpkts) {
 
+    pmt_t subp = pmt_nth(curr_subpkt, subpackets);
+    pmt_t subp_cmd = pmt_nth(0, subp);
+    pmt_t subp_data = pmt_nth(1, subp);
+
     //--------- PING FIXED --------------//
     if(pmt_eq(subp_cmd, s_op_ping_fixed)) {
 
@@ -708,8 +713,20 @@
       d_op_ping_fixed_owners[rid] = port->port_symbol();
 
       // Adds a ping after the previous command in the pkt
-      pkt->cs_ping(rid, pingval);
+      if(!pkt->cs_ping(rid, pingval))
+      {
+        d_cs_usrp->send(s_cmd_usrp_write, 
+                        pmt_list3(invocation_handle, 
+                                  pmt_from_long(channel), 
+                                  v_packet));
 
+        // Return the RID
+        d_op_ping_fixed_owners[rid] = PMT_NIL;
+        d_op_ping_fixed_rid--;
+
+        goto new_packet;
+      }
+
       if(verbose)
         std::cout << "[USRP_SERVER] Received ping command request"
                   << " assigning RID " << rid << std::endl;
@@ -722,7 +739,15 @@
       long reg_num = pmt_to_long(pmt_nth(0, subp_data));
       long val = pmt_to_long(pmt_nth(1, subp_data));
 
-      pkt->cs_write_reg(reg_num, val);
+      if(!pkt->cs_write_reg(reg_num, val))
+      {
+        d_cs_usrp->send(s_cmd_usrp_write, 
+                        pmt_list3(invocation_handle, 
+                                  pmt_from_long(channel), 
+                                  v_packet));
+        
+        goto new_packet;
+      }
       
       if(verbose)
         std::cout << "[USRP_SERVER] Received write register request\n";
@@ -735,7 +760,15 @@
       long val = pmt_to_long(pmt_nth(1, subp_data));
       long mask = pmt_to_long(pmt_nth(2, subp_data));
 
-      pkt->cs_write_reg_masked(reg_num, val, mask);
+      if(!pkt->cs_write_reg_masked(reg_num, val, mask))
+      {
+        d_cs_usrp->send(s_cmd_usrp_write, 
+                        pmt_list3(invocation_handle, 
+                                  pmt_from_long(channel), 
+                                  v_packet));
+        
+        goto new_packet;
+      }
       
       if(verbose)
         std::cout << "[USRP_SERVER] Received write register masked request\n";
@@ -745,9 +778,23 @@
     if(pmt_eq(subp_cmd, s_op_read_reg)) {
       
       long reg_num = pmt_to_long(pmt_nth(1, subp_data));
-      long rid = d_op_read_reg_rid++ % D_OP_PING_FIXED_MAX_RID;
 
-      pkt->cs_read_reg(rid, reg_num);
+      long rid = d_op_read_reg_rid++ % D_OP_READ_REG_MAX_RID;
+      d_op_read_reg_owners[rid] = port->port_symbol();
+
+      if(!pkt->cs_read_reg(rid, reg_num))
+      {
+        d_cs_usrp->send(s_cmd_usrp_write, 
+                        pmt_list3(invocation_handle, 
+                                  pmt_from_long(channel), 
+                                  v_packet));
+
+        // Return the rid
+        d_op_read_reg_owners[rid] = PMT_NIL;
+        d_op_read_reg_rid--;
+        
+        goto new_packet;
+      }
       
       if(verbose)
         std::cout << "[USRP_SERVER] Received read register request"
@@ -759,7 +806,15 @@
 
       long ticks = pmt_to_long(pmt_nth(0, subp_data));
 
-      pkt->cs_delay(ticks);
+      if(!pkt->cs_delay(ticks))
+      {
+        d_cs_usrp->send(s_cmd_usrp_write, 
+                        pmt_list3(invocation_handle, 
+                                  pmt_from_long(channel), 
+                                  v_packet));
+        
+        goto new_packet;
+      }
       
       if(verbose)
         std::cout << "[USRP_SERVER] Received delay request of "
@@ -770,8 +825,19 @@
                     pmt_list3(invocation_handle, 
                               pmt_from_long(channel), 
                               v_packet));
+
+    curr_subpkt++;
+
   }
 
+  // If the current packets length is > 0, we know there are subpackets that
+  // need to be sent out still.
+  if(pkt->payload_len() > 0)
+    d_cs_usrp->send(s_cmd_usrp_write, 
+                    pmt_list3(invocation_handle, 
+                              pmt_from_long(channel), 
+                              v_packet));
+
   return;
 }
 





reply via email to

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