commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r6696 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Thu, 25 Oct 2007 21:18:49 -0600 (MDT)

Author: gnychis
Date: 2007-10-25 21:18:49 -0600 (Thu, 25 Oct 2007)
New Revision: 6696

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_server.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
Log:
Changing the way usrp_server generates internal register writes, since if it
calls the handler method it will use up RID's when it never cares about the
responses.  It also requires more than the maximum number of RIDs to reset all
of the registers and initialize them, which if all of the RIDs are used the
handler method will throw away the register writes.

Adding a global constant for the CS channel 0x1f, so the number is more
recognizable, simply easier to read, and easier to change.


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-10-26 03:15:03 UTC (rev 6695)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-10-26 03:18:49 UTC (rev 6696)
@@ -31,6 +31,7 @@
 
 static const int USB_PKT_SIZE = 512;   // bytes
 static const int MAX_PAYLOAD = USB_PKT_SIZE-2*sizeof(uint32_t);
+static const int CONTROL_CHAN = 0x1f;
 
 class usrp_inband_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-10-26 03:15:03 UTC (rev 6695)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-10-26 03:18:49 UTC (rev 6696)
@@ -207,6 +207,7 @@
       pmt_t status = pmt_nth(1, data);
       d_cs->send(s_response_open, pmt_list2(invocation_handle, status));
 
+      //reset_all_registers();
       initialize_registers();
 
       if(pmt_eqv(status,PMT_T)) {
@@ -240,7 +241,7 @@
 
       // Do not report back responses if they were generated from a
       // command packet
-      if(channel == 0x1f)
+      if(channel == CONTROL_CHAN)
         return;
 
       // Find the port through the owner of the channel
@@ -718,7 +719,7 @@
 
   size_t psize;
   long payload_len = 0;
-  long channel = 0x1f;
+  long channel = CONTROL_CHAN;
 
   // The design of the following code is optimized for simplicity, not
   // performance.  To performance optimize this code, the total size in bytes
@@ -1137,7 +1138,7 @@
     return;
   
   // If the packet is a C/S packet, parse it separately
-  if(channel == 0x1f) {
+  if(channel == CONTROL_CHAN) {
     parse_control_pkt(invocation_handle, pkt);
     return;
   }
@@ -1377,7 +1378,7 @@
   pmt_t invocation_handle = pmt_nth(1, signal_info);
 
   // not a valid channel number?
-  if(channel >= (long)chan_info.size() && channel != 0x1f) {
+  if(channel >= (long)chan_info.size() && channel != CONTROL_CHAN) {
     port->send(response_signal, 
                pmt_list2(invocation_handle, 
                          s_err_channel_invalid));
@@ -1513,7 +1514,7 @@
   set_register(FR_RX_FREQ_3, 0);
 
   // DEBUGGING
-  check_register_initialization();
+  //check_register_initialization();
 }
 
 // FIXME: used for debugging to determine if all the registers are actually
@@ -1600,17 +1601,44 @@
   read_register(FR_RX_FREQ_3);
 }
 
+void
+usrp_server::reset_all_registers()
+{
+  for(int i=0; i<64; i++)
+    set_register(i, 0);
+}
+
 // THIS IS ONLY FOR INTERNAL USRP_SERVER USAGE
+//
+// This function needs to create its own USB packet and not use
+// handle_cmd_to_control_channel because in many cases such as initialization,
+// the number of register writes needed are more than the number of RID's.  If
+// there are no RID's left for use then handle_cmd_to_control_channel() will
+// throw away the request.  This allows usrp_server to generate its own 
register
+// writes without eating up RID's, since usrp_server does not really care about
+// the response.
 void
 usrp_server::set_register(long reg, long val)
 {
-  handle_cmd_to_control_channel(d_tx[0], d_chaninfo_tx,
-    pmt_list2(PMT_NIL,  // empty invoc handle
-              pmt_list1(pmt_list2(s_op_write_reg,
-                        pmt_list2(pmt_from_long(reg),
-                                  pmt_from_long(val))))));
+  size_t psize;
+  long payload_len = 0;
+
+  pmt_t v_packet = pmt_make_u8vector(sizeof(transport_pkt), 0);
+  transport_pkt *pkt = (transport_pkt *) 
pmt_u8vector_writeable_elements(v_packet, psize);
+  
+  pkt->set_header(0, CONTROL_CHAN, 0, payload_len);
+  pkt->set_timestamp(0xffffffff);
+
+  pkt->cs_write_reg(reg, val);
+
+  d_cs_usrp->send(s_cmd_usrp_write, 
+                  pmt_list3(PMT_NIL, 
+                            pmt_from_long(CONTROL_CHAN), 
+                            v_packet));
 }
 
+// Only for internal usrp_server usage.  Structed the same way as
+// set_register().
 void
 usrp_server::read_register(long reg)
 {

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h  
    2007-10-26 03:15:03 UTC (rev 6695)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h  
    2007-10-26 03:18:49 UTC (rev 6696)
@@ -125,6 +125,7 @@
   void set_register(long reg, long val);
   void read_register(long reg);
   void check_register_initialization();
+  void reset_all_registers();
 };
 
 #endif /* INCLUDED_USRP_SERVER_H */





reply via email to

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