commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r6238 - in gnuradio/branches/features/inband-usb: pmt/src/lib usrp/host/apps usrp/host/lib/inband
Date: Thu, 30 Aug 2007 21:56:00 -0600 (MDT)

Author: gnychis
Date: 2007-08-30 21:56:00 -0600 (Thu, 30 Aug 2007)
New Revision: 6238

Added:
   gnuradio/branches/features/inband-usb/usrp/host/apps/read_packets.cc
   gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_cs.cc
   gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_ping.cc
   
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_registers.cc
   
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_timestamps.cc
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_channel.h
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_interface_cs.h
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_low_level_cs.h
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx.h
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx_cs.h
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_server_cs.h
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_tx.h
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_tx_cs.h
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_inband_usb_packet.cc
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/usrp/host/apps/
   gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am
   gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_rx.cc
   gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_tx.cc
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am
   
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_inband_usb_packet.h
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_interface.mbh
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx.cc
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx.h
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx_stub.cc
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx_stub.h
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.mbh
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx.cc
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx.h
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx_stub.cc
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx_stub.h
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface.cc
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface.h
Log:
Merging -r5793:6237 from 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-08-31 
03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/pmt/src/lib/pmt.cc    2007-08-31 
03:56:00 UTC (rev 6238)
@@ -748,7 +748,24 @@
   if (x->is_uniform_vector())
     return _uniform_vector(x)->length();
 
-  // FIXME list length
+  if (x->is_pair()) {
+
+    size_t length=0;
+    pmt_t alist = x;
+
+    while (pmt_is_pair(alist)){
+      pmt_t p = pmt_car(alist);
+      if (!pmt_is_pair(p))     // malformed alist
+        throw pmt_wrong_type("pmt_length", x);
+
+      alist = pmt_cdr(alist);
+      length++;
+    }
+
+    return length;
+  }
+
+
   // FIXME dictionary length (number of entries)
 
   throw pmt_wrong_type("pmt_length", x);
@@ -944,6 +961,12 @@
 }
 
 pmt_t
+pmt_list6(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4, pmt_t x5, pmt_t x6)
+{
+  return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, pmt_cons(x5, 
pmt_cons(x6, PMT_NIL))))));
+}
+
+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-08-31 
03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/pmt/src/lib/pmt.h     2007-08-31 
03:56:00 UTC (rev 6238)
@@ -599,10 +599,17 @@
 pmt_t pmt_list4(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4);
 
 /*!
- * \brief Return a list of length 4 containing \p x1, \p x2, \p x3, \p x4, \p 
x5
+ * \brief Return a list of length 5 containing \p x1, \p x2, \p x3, \p x4, \p 
x5
  */
 pmt_t pmt_list5(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4, pmt_t x5);
 
+/*!
+ * \brief Return a list of length 6 containing \p x1, \p x2, \p x3, \p x4, \p
+ * x5, \p x6
+ */
+pmt_t pmt_list6(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4, pmt_t x5, pmt_t x6);
+
+
 /*
  * ------------------------------------------------------------------------
  *                          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-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/pmt/src/lib/qa_pmt_prims.cc   
2007-08-31 03:56:00 UTC (rev 6238)
@@ -138,6 +138,7 @@
   pmt_t s2 = pmt_string_to_symbol("s2");
   pmt_t s3 = pmt_string_to_symbol("s3");
 
+
   pmt_t c1 = pmt_cons(s1, PMT_NIL);
   CPPUNIT_ASSERT(pmt_is_pair(c1));
   CPPUNIT_ASSERT(!pmt_is_pair(s1));
@@ -150,7 +151,7 @@
   CPPUNIT_ASSERT_EQUAL(c2, pmt_cdr(c1));
   pmt_set_car(c1, s3);
   CPPUNIT_ASSERT_EQUAL(s3, pmt_car(c1));
-
+  
   CPPUNIT_ASSERT_THROW(pmt_cdr(PMT_NIL), pmt_wrong_type);
   CPPUNIT_ASSERT_THROW(pmt_car(PMT_NIL), pmt_wrong_type);
   CPPUNIT_ASSERT_THROW(pmt_set_car(s1, PMT_NIL), pmt_wrong_type);


Property changes on: gnuradio/branches/features/inband-usb/usrp/host/apps
___________________________________________________________________
Name: svn:ignore
   - Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
usrper
usrper2
test_input
test_fusb
test_usrp
test_usrp0
test_usrp_standard_rx
test_usrp_standard_tx
test_usrp_inband_rx
test_usrp_inband_tx
test_usrp_basic_rx
check_order_quickly
usrp_cal_dc_offset

   + Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
*.dat
usrper
usrper2
test_input
test_fusb
test_usrp
test_usrp0
test_usrp_standard_rx
test_usrp_standard_tx
test_usrp_inband_timestamps
test_usrp_inband_rx
test_usrp_inband_tx
test_usrp_basic_rx
check_order_quickly
usrp_cal_dc_offset
test_usrp_inband_cs
read_packets
test_usrp_inband_ping

Name: ignore
   + 

Modified: gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am    
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am    
2007-08-31 03:56:00 UTC (rev 6238)
@@ -32,10 +32,15 @@
 
 noinst_PROGRAMS =                      \
        check_order_quickly             \
+       test_usrp_inband_cs             \
+       test_usrp_inband_ping           \
+       test_usrp_inband_registers      \
+       test_usrp_inband_rx             \
        test_usrp_inband_tx             \
-       test_usrp_inband_rx             \
+       test_usrp_inband_timestamps     \
        test_usrp_standard_rx           \
-       test_usrp_standard_tx           
+       test_usrp_standard_tx           \
+       read_packets
 
 noinst_HEADERS =                       \
        time_stuff.h                    \
@@ -61,9 +66,23 @@
 usrp_cal_dc_offset_SOURCES     = usrp_cal_dc_offset.cc
 usrp_cal_dc_offset_LDADD       = $(USRP_LA)
 
+test_usrp_inband_cs_SOURCES    = test_usrp_inband_cs.cc time_stuff.c 
ui_sincos.c
+test_usrp_inband_cs_LDADD      = $(USRP_LA)
+
+test_usrp_inband_ping_SOURCES  = test_usrp_inband_ping.cc time_stuff.c
+test_usrp_inband_ping_LDADD    = $(USRP_LA)
+
 test_usrp_inband_tx_SOURCES    = test_usrp_inband_tx.cc time_stuff.c 
ui_sincos.c
 test_usrp_inband_tx_LDADD      = $(USRP_LA)
 
+test_usrp_inband_timestamps_SOURCES    = test_usrp_inband_timestamps.cc 
time_stuff.c ui_sincos.c
+test_usrp_inband_timestamps_LDADD      = $(USRP_LA)
+
+test_usrp_inband_registers_SOURCES     = test_usrp_inband_registers.cc 
time_stuff.c ui_sincos.c
+test_usrp_inband_registers_LDADD       = $(USRP_LA)
+
 test_usrp_inband_rx_SOURCES    = test_usrp_inband_rx.cc time_stuff.c 
ui_sincos.c
 test_usrp_inband_rx_LDADD      = $(USRP_LA)
 
+read_packets_SOURCES = read_packets.cc
+read_packets_LDADD = $(USRP_LA)

Copied: gnuradio/branches/features/inband-usb/usrp/host/apps/read_packets.cc 
(from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/read_packets.cc)
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/read_packets.cc        
                        (rev 0)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/read_packets.cc        
2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,103 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+#include <usrp_inband_usb_packet.h>
+#include <mb_class_registry.h>
+#include <vector>
+#include <usrp_usb_interface.h>
+#include <fstream>
+
+typedef usrp_inband_usb_packet transport_pkt;   // makes conversion to gigabit 
easy
+
+int main(int argc, char *argv[]) {
+
+  if(argc !=2) {
+    std::cout << "Usage: ./read_packets <data_file>\n";
+    return -1;
+  }
+
+  std::ifstream infile;
+  std::ofstream outfile;  
+
+  unsigned int pkt_size = transport_pkt::max_pkt_size();
+  unsigned int pkt_num=0;
+
+  transport_pkt *pkt;
+  char pkt_data[pkt_size];          // allocate the number of bytes for a 
single packet
+
+  pkt = (transport_pkt *)pkt_data;  // makes operations cleaner to read
+
+  // Open the file and read the packets, dumping information
+  infile.open(argv[1], std::ios::binary|std::ios::in);
+  if(!infile.is_open())
+    exit(-1);
+
+  //outfile.open("dump.dat",std::ios::out|std::ios::binary);  
+
+  // read 1 packet in to the memory
+  infile.read(pkt_data, pkt_size);
+
+  while(!infile.eof()) {
+  
+    printf("Packet %u\n", pkt_num);
+
+    if(pkt->start_of_burst())
+      printf("\tstart of burst\n");
+      
+    if(pkt->end_of_burst())
+      printf("\tend of burst\n");
+    
+//    if(pkt->carrier_sense())
+//      printf("\tcarrier sense\n");
+
+    printf("\tchannel: \t0x%x\n", pkt->chan());
+    printf("\ttimestamp: \t0x%x\n", pkt->timestamp());
+    //printf("\ttimestamp: \t%u\n", pkt->timestamp());
+    printf("\tlength: \t%u\n", pkt->payload_len());
+    printf("\trssi: \t%u\n", pkt->rssi());
+
+    printf("\tpayload: \n");
+    for(int i=0; i < pkt->payload_len(); i++)
+    //for(int i=0; i < pkt->max_payload(); i++)
+    {
+      printf("\t%d\t0x%x\n", i, *(pkt->payload()+i));
+      //outfile.write((const char*)(pkt->payload()+i),1);
+      //printf("\t\t0x%x\n", pkt->payload()+i);
+
+    }
+    printf("\n\n");
+
+    pkt_num++;
+  
+    // read 1 packet in to the memory
+    infile.read(pkt_data, pkt_size);
+
+  }
+
+  infile.close();
+  //outfile.close();
+
+}

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_cs.cc 
(from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_cs.cc)
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_cs.cc 
                        (rev 0)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_cs.cc 
2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,478 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <mb_mblock.h>
+#include <mb_runtime.h>
+#include <mb_runtime_nop.h>            // QA only
+#include <mb_protocol_class.h>
+#include <mb_exception.h>
+#include <mb_msg_queue.h>
+#include <mb_message.h>
+#include <mb_mblock_impl.h>
+#include <mb_msg_accepter.h>
+#include <mb_class_registry.h>
+#include <pmt.h>
+#include <ui_nco.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+#include <iostream>
+
+#include <symbols_usrp_server_cs.h>
+#include <symbols_usrp_channel.h>
+#include <symbols_usrp_low_level_cs.h>
+#include <symbols_usrp_tx.h>
+#include <symbols_usrp_rx.h>
+
+#define NBPING  10
+
+static bool verbose = false;
+
+class test_usrp_cs : public mb_mblock
+{
+  mb_port_sptr         d_tx;
+  mb_port_sptr         d_rx;
+  mb_port_sptr         d_cs;
+  pmt_t                d_tx_chan;      // returned tx channel handle
+  pmt_t                d_rx_chan;      // returned tx channel handle
+
+  struct timeval times[NBPING];
+
+  enum state_t {
+    INIT,
+    OPENING_USRP,
+    ALLOCATING_CHANNEL,
+    TRANSMITTING,
+    CLOSING_CHANNEL,
+    CLOSING_USRP,
+  };
+
+  state_t      d_state;
+  long         d_nsamples_to_send;
+  long         d_nsamples_xmitted;
+  long         d_nframes_xmitted;
+  long         d_samples_per_frame;
+  bool         d_done_sending;
+
+  // for generating sine wave output
+  ui_nco<float,float>  d_nco;
+  double               d_amplitude;
+
+ public:
+  test_usrp_cs(mb_runtime *runtime, const std::string &instance_name, pmt_t 
user_arg);
+  ~test_usrp_cs();
+  void initial_transition();
+  void handle_message(mb_message_sptr msg);
+
+ protected:
+  void open_usrp();
+  void close_usrp();
+  void allocate_channel();
+  void send_packets();
+  void enter_receiving();
+  void enter_transmitting();
+  void build_and_send_ping();
+  void build_and_send_next_frame();
+  void handle_xmit_response(pmt_t invocation_handle);
+  void enter_closing_channel();
+};
+
+test_usrp_cs::test_usrp_cs(mb_runtime *runtime, const std::string 
&instance_name, pmt_t user_arg)
+  : mb_mblock(runtime, instance_name, user_arg),
+    d_tx_chan(PMT_NIL),
+    d_rx_chan(PMT_NIL),
+    d_state(INIT), d_nsamples_to_send((long) 40e6),
+    d_nsamples_xmitted(0),
+    d_nframes_xmitted(0),
+    //d_samples_per_frame((long)(126)),
+    //d_samples_per_frame((long)(126 * 3.5)),  // non-full packet
+    d_samples_per_frame((long)(126 * 4)),      // full packet
+    d_done_sending(false),
+    d_amplitude(16384)
+{ 
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_CS] Initializing...\n";
+  
+  d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
+  d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
+  d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
+  
+  //bool fake_usrp_p = true;
+  bool fake_usrp_p = false;
+
+  // Test the TX side
+
+  pmt_t usrp_dict = pmt_make_dict();
+
+  if(fake_usrp_p) {
+    pmt_dict_set(usrp_dict, 
+                 pmt_intern("fake-usrp"),
+                            PMT_T);
+  }
+
+  // Set TX and RX interpolations
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-tx"),
+               pmt_from_long(128));
+
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-rx"),
+               pmt_from_long(16));
+
+  // Specify the RBF to use
+  pmt_dict_set(usrp_dict,
+               pmt_intern("rbf"),
+               pmt_intern("boe.rbf"));
+
+  define_component("server", "usrp_server", usrp_dict);
+
+  connect("self", "tx0", "server", "tx0");
+  connect("self", "rx0", "server", "rx0");
+  connect("self", "cs", "server", "cs");
+
+  // initialize NCO
+  double freq = 100e3;
+  int interp = 32;                         // 32 -> 4MS/s
+  double sample_rate = 128e6 / interp; 
+  d_nco.set_freq(2*M_PI * freq/sample_rate);
+
+  // FIXME need to somehow set the interp rate in the USRP.
+  // for now, we'll have the low-level code hardwire it.
+}
+
+test_usrp_cs::~test_usrp_cs()
+{
+}
+
+void
+test_usrp_cs::initial_transition()
+{
+  open_usrp();
+}
+
+void
+test_usrp_cs::handle_message(mb_message_sptr msg)
+{
+  pmt_t        event = msg->signal();
+  pmt_t data = msg->data();
+  pmt_t port_id = msg->port_id();
+
+  pmt_t handle = PMT_F;
+  pmt_t status = PMT_F;
+  std::string error_msg;
+  
+  //std::cout << msg << std::endl;
+
+  switch(d_state){
+  case OPENING_USRP:
+    if (pmt_eq(event, s_response_open)){
+      status = pmt_nth(1, data);
+      if (pmt_eq(status, PMT_T)){
+        allocate_channel();
+        return;
+      }
+      else {
+        error_msg = "failed to open usrp:";
+        goto bail;
+      }
+    }
+    goto unhandled;
+    
+  case ALLOCATING_CHANNEL:
+    if (pmt_eq(event, s_response_allocate_channel)){
+
+      if(pmt_eq(d_tx->port_symbol(), port_id)) {
+        status = pmt_nth(1, data);
+        d_tx_chan = pmt_nth(2, data);
+
+        if (pmt_eq(status, PMT_T)){
+
+          if(verbose)
+            std::cout << "[TEST_USRP_INBAND_CS] Received allocation for TX\n";
+
+          if(!pmt_eqv(d_rx_chan, PMT_NIL)) {
+            enter_receiving();
+            enter_transmitting();
+          }
+          return;
+        }
+        else {
+          error_msg = "failed to allocate channel:";
+          goto bail;
+        }
+      }
+      
+      if(pmt_eq(d_rx->port_symbol(), port_id)) {
+        status = pmt_nth(1, data);
+        d_rx_chan = pmt_nth(2, data);
+
+        if (pmt_eq(status, PMT_T)){
+
+          if(verbose)
+            std::cout << "[TEST_USRP_INBAND_CS] Received allocation for TX\n";
+          
+          if(!pmt_eqv(d_tx_chan, PMT_NIL)) {
+            enter_receiving();
+            enter_transmitting();
+          }
+          return;
+        }
+        else {
+          error_msg = "failed to allocate channel:";
+          goto bail;
+        }
+      }
+    }
+    goto unhandled;
+
+  case TRANSMITTING:
+    if (pmt_eq(event, s_response_xmit_raw_frame)){
+      handle = pmt_nth(0, data);
+      status = pmt_nth(1, data);
+
+      if (pmt_eq(status, PMT_T)){
+        handle_xmit_response(handle);
+        return;
+      }
+      else {
+        error_msg = "bad response-xmit-raw-frame:";
+        goto bail;
+      }
+    }
+    goto unhandled;
+
+  case CLOSING_CHANNEL:
+    if (pmt_eq(event, s_response_deallocate_channel)){
+      status = pmt_nth(1, data);
+
+      if (pmt_eq(status, PMT_T)){
+        close_usrp();
+        return;
+      }
+      else {
+        error_msg = "failed to deallocate channel:";
+        goto bail;
+      }
+    }
+    goto unhandled;
+
+  case CLOSING_USRP:
+    if (pmt_eq(event, s_response_close)){
+      status = pmt_nth(1, data);
+
+      if (pmt_eq(status, PMT_T)){
+        shutdown_all(PMT_T);
+        return;
+      }
+      else {
+        error_msg = "failed to close USRP:";
+        goto bail;
+      }
+    }
+    goto unhandled;
+
+  default:
+    goto unhandled;
+  }
+  return;
+
+ bail:
+  std::cerr << error_msg << data
+           << "status = " << status << std::endl;
+  shutdown_all(PMT_F);
+  return;
+
+ unhandled:
+  if(verbose)
+    std::cout << "test_usrp_inband_tx: unhandled msg: " << msg
+              << "in state "<< d_state << std::endl;
+}
+
+
+void
+test_usrp_cs::open_usrp()
+{
+  pmt_t which_usrp = pmt_from_long(0);
+
+  d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, which_usrp));
+  d_state = OPENING_USRP;
+}
+
+void
+test_usrp_cs::close_usrp()
+{
+  d_cs->send(s_cmd_close, pmt_list1(PMT_NIL));
+  d_state = CLOSING_USRP;
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_CS] Closing USRP\n";
+}
+
+void
+test_usrp_cs::allocate_channel()
+{
+  long capacity = (long) 16e6;
+  d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, 
pmt_from_long(capacity)));
+  d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, 
pmt_from_long(capacity)));
+  d_state = ALLOCATING_CHANNEL;
+}
+
+void
+test_usrp_cs::enter_receiving()
+{
+  d_rx->send(s_cmd_start_recv_raw_samples,
+             pmt_list2(PMT_F,
+                       d_rx_chan));
+}
+
+void
+test_usrp_cs::enter_transmitting()
+{
+  d_state = TRANSMITTING;
+  d_nsamples_xmitted = 0;
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_CS] Beginning transmission\n";
+
+  sleep(1);
+
+//  build_and_send_next_frame();       // fire off 4 to start pipeline
+
+  build_and_send_ping();
+  build_and_send_ping();
+  build_and_send_ping();
+  
+}
+
+void
+test_usrp_cs::build_and_send_ping()
+{
+  
+  d_tx->send(s_cmd_to_control_channel,
+             pmt_list2(PMT_NIL, pmt_list1(pmt_list2(s_op_ping_fixed,
+                                                    pmt_list2(pmt_from_long(0),
+                                                              
pmt_from_long(0))))));
+
+  std::cout << "[TEST_USRP_INBAND_CS] Ping sent" << std::endl;
+}
+
+void
+test_usrp_cs::build_and_send_next_frame()
+{
+  // allocate the uniform vector for the samples
+  // FIXME perhaps hold on to this between calls
+
+#if 1
+  long nsamples_this_frame =
+    std::min(d_nsamples_to_send - d_nsamples_xmitted,
+            d_samples_per_frame);
+#else
+  long nsamples_this_frame = d_samples_per_frame;
+#endif
+
+  if (nsamples_this_frame == 0){
+    d_done_sending = true;
+    return;
+  }
+    
+
+  size_t nshorts = 2 * nsamples_this_frame;    // 16-bit I & Q
+  pmt_t uvec = pmt_make_s16vector(nshorts, 0);
+  size_t ignore;
+  int16_t *samples = pmt_s16vector_writeable_elements(uvec, ignore);
+
+  // fill in the complex sinusoid
+
+  for (int i = 0; i < nsamples_this_frame; i++){
+
+    if (1){
+      gr_complex s;
+      d_nco.sincos(&s, 1, d_amplitude);
+      // write 16-bit i & q
+      samples[2*i] =   (int16_t) s.real();
+      samples[2*i+1] = (int16_t) s.imag();
+    }
+    else {
+      gr_complex s(d_amplitude, d_amplitude);
+
+      // write 16-bit i & q
+      samples[2*i] =   (int16_t) s.real();
+      samples[2*i+1] = (int16_t) s.imag();
+    }
+  }
+
+  pmt_t timestamp = pmt_from_long(0xffffffff); // NOW
+  d_tx->send(s_cmd_xmit_raw_frame,
+            pmt_list4(pmt_from_long(d_nframes_xmitted),  // invocation-handle
+                      d_tx_chan,                         // channel
+                      uvec,                              // the samples
+                      timestamp));
+
+  d_nsamples_xmitted += nsamples_this_frame;
+  d_nframes_xmitted++;
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_CS] Transmitted frame\n";
+}
+
+
+void
+test_usrp_cs::handle_xmit_response(pmt_t handle)
+{
+  if (d_done_sending &&
+      pmt_to_long(handle) == (d_nframes_xmitted - 1)){
+    // We're done sending and have received all responses
+    enter_closing_channel();
+  }
+
+  //build_and_send_next_frame();
+}
+
+void
+test_usrp_cs::enter_closing_channel()
+{
+  d_state = CLOSING_CHANNEL;
+  
+  d_tx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_tx_chan));
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_CS] Closing channel\n";
+}
+
+REGISTER_MBLOCK_CLASS(test_usrp_cs);
+
+
+// ----------------------------------------------------------------
+
+int
+main (int argc, char **argv)
+{
+  // handle any command line args here
+
+  mb_runtime_sptr rt = mb_make_runtime();
+  pmt_t result = PMT_NIL;
+
+  rt->run("top", "test_usrp_cs", PMT_F, &result);
+}

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_ping.cc 
(from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_ping.cc)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_ping.cc   
                            (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_ping.cc   
    2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,376 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <mb_mblock.h>
+#include <mb_runtime.h>
+#include <mb_runtime_nop.h>            // QA only
+#include <mb_protocol_class.h>
+#include <mb_exception.h>
+#include <mb_msg_queue.h>
+#include <mb_message.h>
+#include <mb_mblock_impl.h>
+#include <mb_msg_accepter.h>
+#include <mb_class_registry.h>
+#include <pmt.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+#include <iostream>
+
+// Include the symbols needed for communication with USRP server
+#include <symbols_usrp_server_cs.h>
+#include <symbols_usrp_channel.h>
+#include <symbols_usrp_low_level_cs.h>
+#include <symbols_usrp_tx.h>
+#include <symbols_usrp_rx.h>
+
+static bool verbose = false;
+
+class test_usrp_inband_ping : public mb_mblock
+{
+
+  mb_port_sptr  d_tx;   // Ports connected to the USRP server
+  mb_port_sptr  d_rx;
+  mb_port_sptr  d_cs;
+
+  pmt_t   d_tx_chan;    // Returned channel from TX allocation
+  pmt_t   d_rx_chan;    // Returned channel from RX allocation
+
+  pmt_t   d_which_usrp; // The USRP to use for the test
+
+  long    d_warm_msgs;  // The number of messages to 'warm' the USRP
+  long    d_warm_recvd; // The number of msgs received in the 'warm' state
+
+  // Keep track of current state
+  enum state_t {
+    INIT,
+    OPENING_USRP,
+    ALLOCATING_CHANNELS,
+    WARMING_USRP,
+    PINGING,
+    CLOSING_CHANNELS,
+    CLOSING_USRP,
+  };
+  state_t d_state;
+
+ public:
+  test_usrp_inband_ping(mb_runtime *runtime, const std::string &instance_name, 
pmt_t user_arg);
+  ~test_usrp_inband_ping();
+  void initial_transition();
+  void handle_message(mb_message_sptr msg);
+
+ protected:
+  void opening_usrp();
+  void allocating_channels();
+  void enter_warming_usrp();
+  void enter_pinging();
+  void build_and_send_ping();
+  void closing_channels();
+  void closing_usrp();
+};
+
+
+int
+main (int argc, char **argv)
+{
+  // handle any command line args here
+
+  mb_runtime_sptr rt = mb_make_runtime();
+  pmt_t result = PMT_NIL;
+
+  rt->run("top", "test_usrp_inband_ping", PMT_F, &result);
+}
+
+
+test_usrp_inband_ping::test_usrp_inband_ping(mb_runtime *runtime, const 
std::string &instance_name, pmt_t user_arg)
+  : mb_mblock(runtime, instance_name, user_arg),
+  d_tx_chan(PMT_NIL),
+  d_rx_chan(PMT_NIL),
+  d_which_usrp(pmt_from_long(0)),
+  d_state(INIT)
+{
+  
+  // A dictionary is used to pass parameters to the USRP
+  pmt_t usrp_dict = pmt_make_dict();
+
+  // Specify the RBF to use
+  pmt_dict_set(usrp_dict,
+               pmt_intern("rbf"),
+               pmt_intern("fixed1.rbf"));
+
+  // Set TX and RX interpolations
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-tx"),
+               pmt_from_long(128));
+
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-rx"),
+               pmt_from_long(16));
+  
+  d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
+  d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
+  d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
+
+  // Create an instance of USRP server and connect ports
+  define_component("server", "usrp_server", usrp_dict);
+  connect("self", "tx0", "server", "tx0");
+  connect("self", "rx0", "server", "rx0");
+  connect("self", "cs", "server", "cs");
+
+}
+
+test_usrp_inband_ping::~test_usrp_inband_ping()
+{
+}
+
+void
+test_usrp_inband_ping::initial_transition()
+{
+  opening_usrp();
+}
+
+// Handle message reads all incoming messages from USRP server which will be
+// initialization and ping responses.  We perform actions based on the current
+// state and the event (ie, ping response)
+void
+test_usrp_inband_ping::handle_message(mb_message_sptr msg)
+{
+  pmt_t event = msg->signal();
+  pmt_t data = msg->data();
+  pmt_t port_id = msg->port_id();
+
+  pmt_t handle = PMT_F;
+  pmt_t status = PMT_F;
+  std::string error_msg;
+
+  // Dispatch based on state
+  switch(d_state) {
+
+    //----------------------------- OPENING_USRP ----------------------------//
+    // We only expect a response from opening the USRP which should be 
succesful
+    // or failed.
+    case OPENING_USRP:
+      
+      if(pmt_eq(event, s_response_open)) {
+
+        status = pmt_nth(1, data);          // failed/succes
+        
+        if(pmt_eq(status, PMT_T)) {
+          allocating_channels();
+          return;
+        }
+        else {
+          error_msg = "failed to open usrp:";
+          goto bail;
+        }
+
+      }
+
+      goto unhandled;   // all other messages not handled in this state
+      
+    
+    //----------------------- ALLOCATING CHANNELS --------------------//
+    // When allocating channels, we need to wait for 2 responses from
+    // USRP server: one for TX and one for RX.  Both are initialized to
+    // NIL so we know to continue to the next state once both are set.
+    case ALLOCATING_CHANNELS:
+
+      // A TX allocation response
+      if(pmt_eq(event, s_response_allocate_channel)
+          && pmt_eq(d_tx->port_symbol(), port_id)) 
+      {
+        status = pmt_nth(1, data);
+        
+        // If successful response, extract the channel
+        if(pmt_eq(status, PMT_T)) {
+          
+          d_tx_chan = pmt_nth(2, data);
+
+          if(verbose)
+            std::cout << "[TEST_USRP_INBAND_PING] Received TX allocation"
+                      << " on channel " << d_tx_chan << std::endl;
+
+          // If the RX has also been allocated already, we can continue
+          if(!pmt_eqv(d_rx_chan, PMT_NIL)) 
+            enter_warming_usrp();
+
+          return;
+        }
+        else {  // TX allocation failed
+          error_msg = "failed to allocate TX channel:";
+          goto bail;
+        }
+      }
+      
+      // A RX allocation response
+      if(pmt_eq(event, s_response_allocate_channel)
+          && pmt_eq(d_rx->port_symbol(), port_id)) 
+      {
+        status = pmt_nth(1, data);
+        
+        // If successful response, extract the channel
+        if(pmt_eq(status, PMT_T)) {
+          
+          d_rx_chan = pmt_nth(2, data);
+
+          if(verbose)
+            std::cout << "[TEST_USRP_INBAND_PING] Received RX allocation"
+                      << " on channel " << d_rx_chan << std::endl;
+
+          // If the TX has also been allocated already, we can continue
+          if(!pmt_eqv(d_tx_chan, PMT_NIL)) 
+            enter_warming_usrp();
+
+          return;
+        }
+        else {  // RX allocation failed
+          error_msg = "failed to allocate RX channel:";
+          goto bail;
+        }
+      }
+
+      goto unhandled;
+
+    //----------------------- WARMING USRP --------------------//
+    // The FX2 seems to need some amount of data to be buffered
+    // before it begins reading.  We use this state to simply
+    // warm up the USRP before benchmarking pings.
+    case WARMING_USRP:
+
+      // We really don't care about the responses from the
+      // control channel in the warming stage, but once we receive
+      // the proper number of responses we switch states.
+      if(pmt_eq(event, s_response_from_control_channel)
+          && pmt_eq(d_rx->port_symbol(), port_id))
+      {
+        d_warm_recvd++;
+
+        if(d_warm_recvd > d_warm_msgs)
+          enter_pinging();
+
+        return;
+      }
+
+      goto unhandled;
+
+    case PINGING:
+      goto unhandled;
+
+    case CLOSING_CHANNELS:
+      goto unhandled;
+
+    case CLOSING_USRP:
+      goto unhandled;
+
+    case INIT:
+      goto unhandled;
+
+  }
+ 
+ // An error occured, print it, and shutdown all m-blocks
+ bail:
+  std::cerr << error_msg << data
+           << "status = " << status << std::endl;
+  shutdown_all(PMT_F);
+  return;
+
+ // Received an unhandled message for a specific state
+ unhandled:
+  if(verbose)
+    std::cout << "test_usrp_inband_tx: unhandled msg: " << msg
+              << "in state "<< d_state << std::endl;
+
+}
+
+
+// Sends a command to USRP server to open up a connection to the
+// specified USRP, which is defaulted to USRP 0 on the system
+void
+test_usrp_inband_ping::opening_usrp()
+{
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_PING] Opening USRP " 
+              << d_which_usrp << std::endl;
+
+  d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, d_which_usrp));
+  d_state = OPENING_USRP;
+}
+
+// RX and TX channels must be allocated so that the USRP server can
+// properly share bandwidth across multiple USRPs.  No commands will be
+// successful to the USRP through the USRP server on the TX or RX channels 
until
+// a bandwidth allocation has been received.
+void
+test_usrp_inband_ping::allocating_channels()
+{
+  d_state = ALLOCATING_CHANNELS;
+
+  long capacity = (long) 16e6;
+  d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, 
pmt_from_long(capacity)));
+  d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, 
pmt_from_long(capacity)));
+}
+
+// The USRP needs some amount of initial data to pass a buffering point such
+// that it begins to pull and read data from the FX2.  We send an arbitrary
+// amount of data to start the pipeline, which are just pings.
+void
+test_usrp_inband_ping::enter_warming_usrp()
+{
+  d_state = WARMING_USRP;
+
+  for(int i=0; i < d_warm_msgs; i++)
+    build_and_send_ping();
+}
+
+void
+test_usrp_inband_ping::enter_pinging()
+{
+  d_state = PINGING;
+  
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_PING] Running ping tests\n";
+
+}
+
+// Pings are sent over the TX channel using the signal 'cmd-to-control-channel'
+// to the USRP server.  Within this message there can be infinite subpackets
+// stored as a list (the second parameter) and sent.  The only subpacket we 
send
+// is a ping, interpreted by the 'op-ping-fixed' signal.
+void
+test_usrp_inband_ping::build_and_send_ping()
+{
+  
+  d_tx->send(s_cmd_to_control_channel,    // USRP server signal
+             pmt_list2(PMT_NIL,           // invocation handle 
+                       pmt_list1(pmt_list3(s_op_ping_fixed, 
+                                           pmt_from_long(0), 
+                                           pmt_from_long(0)))));
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_PING] Ping!!" << std::endl;
+}
+
+REGISTER_MBLOCK_CLASS(test_usrp_inband_ping);

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_registers.cc
 (from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_registers.cc)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_registers.cc
                          (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_registers.cc
  2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,436 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <mb_mblock.h>
+#include <mb_runtime.h>
+#include <mb_runtime_nop.h>            // QA only
+#include <mb_protocol_class.h>
+#include <mb_exception.h>
+#include <mb_msg_queue.h>
+#include <mb_message.h>
+#include <mb_mblock_impl.h>
+#include <mb_msg_accepter.h>
+#include <mb_class_registry.h>
+#include <pmt.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+#include <iostream>
+
+// Include the symbols needed for communication with USRP server
+#include <symbols_usrp_server_cs.h>
+#include <symbols_usrp_channel.h>
+#include <symbols_usrp_low_level_cs.h>
+#include <symbols_usrp_tx.h>
+#include <symbols_usrp_rx.h>
+
+static bool verbose = true;
+
+class test_usrp_inband_registers : public mb_mblock
+{
+
+  mb_port_sptr  d_tx;   // Ports connected to the USRP server
+  mb_port_sptr  d_rx;
+  mb_port_sptr  d_cs;
+
+  pmt_t   d_tx_chan;    // Returned channel from TX allocation
+  pmt_t   d_rx_chan;    // Returned channel from RX allocation
+
+  pmt_t   d_which_usrp; // The USRP to use for the test
+
+  long    d_warm_msgs;  // The number of messages to 'warm' the USRP
+  long    d_warm_recvd; // The number of msgs received in the 'warm' state
+
+  // Keep track of current state
+  enum state_t {
+    INIT,
+    OPENING_USRP,
+    ALLOCATING_CHANNELS,
+    WRITE_REGISTER,
+    READ_REGISTER,
+    CLOSING_CHANNELS,
+    CLOSING_USRP,
+  };
+  state_t d_state;
+
+ public:
+  test_usrp_inband_registers(mb_runtime *runtime, const std::string 
&instance_name, pmt_t user_arg);
+  ~test_usrp_inband_registers();
+  void initial_transition();
+  void handle_message(mb_message_sptr msg);
+
+ protected:
+  void opening_usrp();
+  void allocating_channels();
+  void write_register();
+  void read_register();
+  void closing_channels();
+  void closing_usrp();
+  void enter_receiving();
+  void build_and_send_ping();
+};
+
+
+int
+main (int argc, char **argv)
+{
+  // handle any command line args here
+
+  mb_runtime_sptr rt = mb_make_runtime();
+  pmt_t result = PMT_NIL;
+
+  rt->run("top", "test_usrp_inband_registers", PMT_F, &result);
+}
+
+
+test_usrp_inband_registers::test_usrp_inband_registers(mb_runtime *runtime, 
const std::string &instance_name, pmt_t user_arg)
+  : mb_mblock(runtime, instance_name, user_arg),
+  d_tx_chan(PMT_NIL),
+  d_rx_chan(PMT_NIL),
+  d_which_usrp(pmt_from_long(0)),
+  d_state(INIT)
+{
+  
+  // A dictionary is used to pass parameters to the USRP
+  pmt_t usrp_dict = pmt_make_dict();
+
+  // Specify the RBF to use
+  pmt_dict_set(usrp_dict,
+               pmt_intern("rbf"),
+               pmt_intern("boe2.rbf"));
+
+  // Set TX and RX interpolations
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-tx"),
+               pmt_from_long(128));
+
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-rx"),
+               pmt_from_long(16));
+  
+  d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
+  d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
+  d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
+
+  // Create an instance of USRP server and connect ports
+  define_component("server", "usrp_server", usrp_dict);
+  connect("self", "tx0", "server", "tx0");
+  connect("self", "rx0", "server", "rx0");
+  connect("self", "cs", "server", "cs");
+
+}
+
+test_usrp_inband_registers::~test_usrp_inband_registers()
+{
+}
+
+void
+test_usrp_inband_registers::initial_transition()
+{
+  opening_usrp();
+}
+
+// Handle message reads all incoming messages from USRP server which will be
+// initialization and ping responses.  We perform actions based on the current
+// state and the event (ie, ping response)
+void
+test_usrp_inband_registers::handle_message(mb_message_sptr msg)
+{
+  pmt_t event = msg->signal();
+  pmt_t data = msg->data();
+  pmt_t port_id = msg->port_id();
+
+  pmt_t handle = PMT_F;
+  pmt_t status = PMT_F;
+  std::string error_msg;
+
+  // Dispatch based on state
+  switch(d_state) {
+
+    //----------------------------- OPENING_USRP ----------------------------//
+    // We only expect a response from opening the USRP which should be 
succesful
+    // or failed.
+    case OPENING_USRP:
+      
+      if(pmt_eq(event, s_response_open)) {
+
+        status = pmt_nth(1, data);          // failed/succes
+        
+        if(pmt_eq(status, PMT_T)) {
+          allocating_channels();
+          return;
+        }
+        else {
+          error_msg = "failed to open usrp:";
+          goto bail;
+        }
+
+      }
+
+      goto unhandled;   // all other messages not handled in this state
+      
+    
+    //----------------------- ALLOCATING CHANNELS --------------------//
+    // When allocating channels, we need to wait for 2 responses from
+    // USRP server: one for TX and one for RX.  Both are initialized to
+    // NIL so we know to continue to the next state once both are set.
+    case ALLOCATING_CHANNELS:
+
+      // A TX allocation response
+      if(pmt_eq(event, s_response_allocate_channel)
+          && pmt_eq(d_tx->port_symbol(), port_id)) 
+      {
+        status = pmt_nth(1, data);
+        
+        // If successful response, extract the channel
+        if(pmt_eq(status, PMT_T)) {
+          
+          d_tx_chan = pmt_nth(2, data);
+
+          if(verbose)
+            std::cout << "[TEST_USRP_INBAND_PING] Received TX allocation"
+                      << " on channel " << d_tx_chan << std::endl;
+
+          // If the RX has also been allocated already, we can continue
+          if(!pmt_eqv(d_rx_chan, PMT_NIL)) {
+            enter_receiving();
+            write_register();
+          }
+
+          return;
+        }
+        else {  // TX allocation failed
+          error_msg = "failed to allocate TX channel:";
+          goto bail;
+        }
+      }
+      
+      // A RX allocation response
+      if(pmt_eq(event, s_response_allocate_channel)
+          && pmt_eq(d_rx->port_symbol(), port_id)) 
+      {
+        status = pmt_nth(1, data);
+        
+        // If successful response, extract the channel
+        if(pmt_eq(status, PMT_T)) {
+          
+          d_rx_chan = pmt_nth(2, data);
+
+          if(verbose)
+            std::cout << "[TEST_USRP_INBAND_PING] Received RX allocation"
+                      << " on channel " << d_rx_chan << std::endl;
+
+          // If the TX has also been allocated already, we can continue
+          if(!pmt_eqv(d_tx_chan, PMT_NIL)) {
+            enter_receiving();
+            write_register();
+          }
+
+          return;
+        }
+        else {  // RX allocation failed
+          error_msg = "failed to allocate RX channel:";
+          goto bail;
+        }
+      }
+
+      goto unhandled;
+
+    //-------------------------- WRITE REGISTER ----------------------------//
+    // In the write register state, we do not expect to receive any messages
+    // since the write does not directly generate a response until the USRP
+    // responds.
+    case WRITE_REGISTER:
+      goto unhandled;
+
+    //-------------------------- READ REGISTER ----------------------------//
+    // In the read register state, we only expect a read register response back
+    // that has the value we expect to have in it.  We read the response, 
ensure
+    // that the read was successful and display the register value.
+    case READ_REGISTER:
+
+      if(pmt_eq(event, s_response_from_control_channel)
+          && pmt_eq(d_tx->port_symbol(), port_id))
+      {
+        status = pmt_nth(1, data);
+
+        // If the read was successful, we extract the subpacket information
+        if(pmt_eq(status, PMT_T)) {
+          
+          pmt_t subp = pmt_nth(2, data);      // subpacket should be the read 
reg reply
+
+          pmt_t subp_sig  = pmt_nth(0, subp);
+          pmt_t subp_data = pmt_nth(1, subp);
+
+          if(!pmt_eqv(subp_sig, s_op_read_reg_reply)) {
+            error_msg = "received improper subpacket when expecting reg 
reply.";
+            goto bail;
+          }
+
+          pmt_t rid     = pmt_nth(0, subp_data);
+          pmt_t reg_num = pmt_nth(1, subp_data);
+          pmt_t reg_val = pmt_nth(2, subp_data);
+
+          if(verbose)
+            std::cout << "[TEST_USRP_INBAND_REGISTERS] Received read reg reply 
"
+                      << "("
+                      << "RID: " << rid << ", " 
+                      << "Reg: " << reg_num << ", "
+                      << "Val: " << reg_val
+                      << ")\n";
+          
+          // read_register();  FIX ME STATE TRANSITION
+          return;
+
+        } else {  // bail on unsuccessful write
+          error_msg = "failed to write to register.";
+          goto bail;
+        }
+      }
+      goto unhandled;
+
+    case CLOSING_CHANNELS:
+      goto unhandled;
+
+    case CLOSING_USRP:
+      goto unhandled;
+
+    case INIT:
+      goto unhandled;
+
+  }
+ 
+ // An error occured, print it, and shutdown all m-blocks
+ bail:
+  std::cerr << error_msg << data
+           << "status = " << status << std::endl;
+  shutdown_all(PMT_F);
+  return;
+
+ // Received an unhandled message for a specific state
+ unhandled:
+  if(verbose && !pmt_eq(event, s_response_recv_raw_samples))
+    std::cout << "test_usrp_inband_tx: unhandled msg: " << msg
+              << "in state "<< d_state << std::endl;
+
+}
+
+
+// Sends a command to USRP server to open up a connection to the
+// specified USRP, which is defaulted to USRP 0 on the system
+void
+test_usrp_inband_registers::opening_usrp()
+{
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_PING] Opening USRP " 
+              << d_which_usrp << std::endl;
+
+  d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, d_which_usrp));
+  d_state = OPENING_USRP;
+}
+
+// RX and TX channels must be allocated so that the USRP server can
+// properly share bandwidth across multiple USRPs.  No commands will be
+// successful to the USRP through the USRP server on the TX or RX channels 
until
+// a bandwidth allocation has been received.
+void
+test_usrp_inband_registers::allocating_channels()
+{
+  d_state = ALLOCATING_CHANNELS;
+
+  long capacity = (long) 16e6;
+  d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, 
pmt_from_long(capacity)));
+  d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, 
pmt_from_long(capacity)));
+}
+
+// After allocating the channels, a write register command will be sent to the
+// USRP.
+void
+test_usrp_inband_registers::write_register()
+{
+  d_state = WRITE_REGISTER;
+
+  long reg = 0;
+
+  d_tx->send(s_cmd_to_control_channel,    // C/S packet
+             pmt_list2(PMT_NIL,           // invoc handle
+                       pmt_list1(
+                            pmt_list2(s_op_write_reg, 
+                                      pmt_list2(
+                                      pmt_from_long(reg), 
+                                      pmt_from_long(0xbeef))))));
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_REGISTERS] Writing 0xbeef to " 
+              << reg << std::endl;
+
+  read_register();  // immediately transition to read the register
+}
+
+// Temporary: for testing pings
+void
+test_usrp_inband_registers::build_and_send_ping()
+{
+  
+  d_tx->send(s_cmd_to_control_channel,
+             pmt_list2(PMT_NIL, pmt_list1(pmt_list2(s_op_ping_fixed,
+                                                    pmt_list2(pmt_from_long(0),
+                                                              
pmt_from_long(0))))));
+
+  std::cout << "[TEST_USRP_INBAND_CS] Ping sent" << std::endl;
+}
+
+// After writing to the register, we want to read the value back and ensure 
that
+// it is the same value that we wrote.
+void
+test_usrp_inband_registers::read_register()
+{
+  d_state = READ_REGISTER;
+
+  long reg = 9;
+
+  d_tx->send(s_cmd_to_control_channel,    // C/S packet
+             pmt_list2(PMT_NIL,           // invoc handle
+                       pmt_list1(
+                            pmt_list2(s_op_read_reg, 
+                                      pmt_list2(
+                                      pmt_from_long(0),   // rid 
+                                      pmt_from_long(reg))))));
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_REGISTERS] Reading from register " 
+              << reg << std::endl;
+}
+
+// Used to enter the receiving state
+void
+test_usrp_inband_registers::enter_receiving()
+{
+  d_rx->send(s_cmd_start_recv_raw_samples,
+             pmt_list2(PMT_F,
+                       d_rx_chan));
+}
+
+REGISTER_MBLOCK_CLASS(test_usrp_inband_registers);

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_rx.cc
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_rx.cc 
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_rx.cc 
2007-08-31 03:56:00 UTC (rev 6238)
@@ -72,6 +72,8 @@
   mb_port_sptr         d_cs;
   pmt_t                d_rx_chan;      // returned tx channel handle
 
+  bool d_disk_write;
+
   enum state_t {
     INIT,
     OPENING_USRP,
@@ -103,36 +105,55 @@
 };
 
 test_usrp_rx::test_usrp_rx(mb_runtime *runtime, const std::string 
&instance_name, pmt_t user_arg)
-  : mb_mblock(runtime, instance_name, user_arg)
+  : mb_mblock(runtime, instance_name, user_arg),
+  d_disk_write(false)
 { 
   
   d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
   d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
   
-  bool fake_usrp_p = true;
-  //bool fake_usrp_p = false;
+  //bool fake_usrp_p = true;
+  bool fake_usrp_p = false;
+  
+  d_disk_write = true;
 
   // Test the TX side
 
   // Pass a dictionary to usrp_server which specifies which interface to use, 
the stub or USRP
-  pmt_t usrp_server_dict = pmt_make_dict();
+  pmt_t usrp_dict = pmt_make_dict();
 
   if(fake_usrp_p)
-    pmt_dict_set(usrp_server_dict, 
+    pmt_dict_set(usrp_dict, 
                  pmt_intern("fake-usrp"),
                             PMT_T);
+  
+  // Specify the RBF to use
+  pmt_dict_set(usrp_dict,
+               pmt_intern("rbf"),
+               pmt_intern("tmac6.rbf"));
 
-  define_component("server", "usrp_server", usrp_server_dict);
+  // Set TX and RX interpolations
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-tx"),
+               pmt_from_long(128));
 
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-rx"),
+               pmt_from_long(16));
+
+  define_component("server", "usrp_server", usrp_dict);
+
   connect("self", "rx0", "server", "rx0");
   connect("self", "cs", "server", "cs");
 
-  d_ofile.open("pdump_rx.dat",std::ios::binary|std::ios::out);
+  if(d_disk_write)
+    d_ofile.open("pdump_rx.dat",std::ios::binary|std::ios::out);
 }
 
 test_usrp_rx::~test_usrp_rx()
 {
-  d_ofile.close();
+  if(d_disk_write)
+    d_ofile.close();
 }
 
 void
@@ -290,11 +311,24 @@
   size_t n_bytes;
   
   const char *samples = (const char *) pmt_uniform_vector_elements(v_samples, 
n_bytes);
-  d_ofile.write(samples, n_bytes);
 
+  if(d_disk_write)
+    d_ofile.write(samples, n_bytes);
+
   if(verbose)
     std::cout << ".";
 
+  if (pmt_is_dict(properties)) {
+    // Read the RSSI
+    if(pmt_t rssi = pmt_dict_ref(properties, 
+                                 pmt_intern("rssi"), 
+                                 PMT_NIL)) {
+      if(!pmt_eqv(rssi, PMT_NIL)) 
+        std::cout << "RSSI: " << rssi << std::endl;
+    }
+  }
+  
+
 }
 
 void

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_timestamps.cc
 (from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_timestamps.cc)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_timestamps.cc
                         (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_timestamps.cc
 2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,508 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <mb_mblock.h>
+#include <mb_runtime.h>
+#include <mb_runtime_nop.h>            // QA only
+#include <mb_protocol_class.h>
+#include <mb_exception.h>
+#include <mb_msg_queue.h>
+#include <mb_message.h>
+#include <mb_mblock_impl.h>
+#include <mb_msg_accepter.h>
+#include <mb_class_registry.h>
+#include <pmt.h>
+#include <ui_nco.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+#include <iostream>
+
+#include <symbols_usrp_server_cs.h>
+#include <symbols_usrp_channel.h>
+#include <symbols_usrp_low_level_cs.h>
+#include <symbols_usrp_tx.h>
+#include <symbols_usrp_rx.h>
+
+#define NBPING  10
+
+static bool verbose = true;
+bool bskip = false;
+long bstep = 10000;
+long bcurr = 0;
+long incr = 0x500;
+long ptime = 0x000;
+
+class test_usrp_inband_timestamps : public mb_mblock
+{
+  mb_port_sptr         d_tx;
+  mb_port_sptr         d_rx;
+  mb_port_sptr         d_cs;
+  pmt_t                d_tx_chan;      // returned tx channel handle
+  pmt_t                d_rx_chan;      // returned tx channel handle
+
+  struct timeval times[NBPING];
+
+  enum state_t {
+    INIT,
+    OPENING_USRP,
+    ALLOCATING_CHANNEL,
+    TRANSMITTING,
+    CLOSING_CHANNEL,
+    CLOSING_USRP,
+  };
+
+  state_t      d_state;
+  long         d_nsamples_to_send;
+  long         d_nsamples_xmitted;
+  long         d_nframes_xmitted;
+  long         d_samples_per_frame;
+  bool         d_done_sending;
+
+  // for generating sine wave output
+  ui_nco<float,float>  d_nco;
+  double               d_amplitude;
+
+ public:
+  test_usrp_inband_timestamps(mb_runtime *runtime, const std::string 
&instance_name, pmt_t user_arg);
+  ~test_usrp_inband_timestamps();
+  void initial_transition();
+  void handle_message(mb_message_sptr msg);
+
+ protected:
+  void open_usrp();
+  void close_usrp();
+  void allocate_channel();
+  void send_packets();
+  void enter_receiving();
+  void enter_transmitting();
+  void build_and_send_ping();
+  void build_and_send_next_frame();
+  void handle_xmit_response(pmt_t invocation_handle);
+  void enter_closing_channel();
+};
+
+test_usrp_inband_timestamps::test_usrp_inband_timestamps(mb_runtime *runtime, 
const std::string &instance_name, pmt_t user_arg)
+  : mb_mblock(runtime, instance_name, user_arg),
+    d_tx_chan(PMT_NIL),
+    d_rx_chan(PMT_NIL),
+    d_state(INIT), d_nsamples_to_send((long) 40e6),
+    d_nsamples_xmitted(0),
+    d_nframes_xmitted(0),
+    //d_samples_per_frame((long)(126)),
+    d_samples_per_frame((long)(126 * 2)),      // non-full packet
+    //d_samples_per_frame((long)(126 * 3.5)),  // non-full packet
+    //d_samples_per_frame((long)(126 * 4)),    // full packet
+    d_done_sending(false),
+    d_amplitude(16384)
+{ 
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Initializing...\n";
+  
+  d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
+  d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
+  d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
+  
+  bool fake_usrp_p = false;
+
+  // Test the TX side
+
+  pmt_t usrp_dict = pmt_make_dict();
+
+  if(fake_usrp_p) {
+    pmt_dict_set(usrp_dict, 
+                 pmt_intern("fake-usrp"),
+                            PMT_T);
+  }
+
+  // Set TX and RX interpolations
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-tx"),
+               pmt_from_long(128));
+
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-rx"),
+               pmt_from_long(16));
+
+  // Specify the RBF to use
+  pmt_dict_set(usrp_dict,
+               pmt_intern("rbf"),
+               pmt_intern("tmac5.rbf"));
+
+  define_component("server", "usrp_server", usrp_dict);
+
+  connect("self", "tx0", "server", "tx0");
+  connect("self", "rx0", "server", "rx0");
+  connect("self", "cs", "server", "cs");
+
+  // initialize NCO
+  double freq = 100e3;
+  int interp = 32;                         // 32 -> 4MS/s
+  double sample_rate = 128e6 / interp; 
+  d_nco.set_freq(2*M_PI * freq/sample_rate);
+
+}
+
+test_usrp_inband_timestamps::~test_usrp_inband_timestamps()
+{
+}
+
+void
+test_usrp_inband_timestamps::initial_transition()
+{
+  open_usrp();
+}
+
+void
+test_usrp_inband_timestamps::handle_message(mb_message_sptr msg)
+{
+  pmt_t        event = msg->signal();
+  pmt_t data = msg->data();
+  pmt_t port_id = msg->port_id();
+
+  pmt_t handle = PMT_F;
+  pmt_t status = PMT_F;
+  std::string error_msg;
+  
+  //std::cout << msg << std::endl;
+
+  switch(d_state){
+  case OPENING_USRP:
+    if (pmt_eq(event, s_response_open)){
+      status = pmt_nth(1, data);
+      if (pmt_eq(status, PMT_T)){
+        allocate_channel();
+        return;
+      }
+      else {
+        error_msg = "failed to open usrp:";
+        goto bail;
+      }
+    }
+    goto unhandled;
+    
+  case ALLOCATING_CHANNEL:
+    if (pmt_eq(event, s_response_allocate_channel)){
+
+      if(pmt_eq(d_tx->port_symbol(), port_id)) {
+        status = pmt_nth(1, data);
+        d_tx_chan = pmt_nth(2, data);
+
+        if (pmt_eq(status, PMT_T)){
+
+          if(verbose)
+            std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Received allocation 
for TX\n";
+
+          if(!pmt_eqv(d_rx_chan, PMT_NIL)) {
+            enter_receiving();
+            enter_transmitting();
+          }
+          return;
+        }
+        else {
+          error_msg = "failed to allocate channel:";
+          goto bail;
+        }
+      }
+      
+      if(pmt_eq(d_rx->port_symbol(), port_id)) {
+        status = pmt_nth(1, data);
+        d_rx_chan = pmt_nth(2, data);
+
+        if (pmt_eq(status, PMT_T)){
+
+          if(verbose)
+            std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Received allocation 
for TX\n";
+          
+          if(!pmt_eqv(d_tx_chan, PMT_NIL)) {
+            enter_receiving();
+            enter_transmitting();
+          }
+          return;
+        }
+        else {
+          error_msg = "failed to allocate channel:";
+          goto bail;
+        }
+      }
+    }
+    goto unhandled;
+
+  case TRANSMITTING:
+    if (pmt_eq(event, s_response_xmit_raw_frame)){
+      handle = pmt_nth(0, data);
+      status = pmt_nth(1, data);
+
+      if (pmt_eq(status, PMT_T)){
+        handle_xmit_response(handle);
+        return;
+      }
+      else {
+        error_msg = "bad response-xmit-raw-frame:";
+        goto bail;
+      }
+    }
+
+    if (pmt_eq(event, s_response_from_control_channel)) {
+      std::cout << "ping response!\n";
+    }
+    goto unhandled;
+
+  case CLOSING_CHANNEL:
+    if (pmt_eq(event, s_response_deallocate_channel)){
+      status = pmt_nth(1, data);
+
+      if (pmt_eq(status, PMT_T)){
+        close_usrp();
+        return;
+      }
+      else {
+        error_msg = "failed to deallocate channel:";
+        goto bail;
+      }
+    }
+    goto unhandled;
+
+  case CLOSING_USRP:
+    if (pmt_eq(event, s_response_close)){
+      status = pmt_nth(1, data);
+
+      if (pmt_eq(status, PMT_T)){
+        shutdown_all(PMT_T);
+        return;
+      }
+      else {
+        error_msg = "failed to close USRP:";
+        goto bail;
+      }
+    }
+    goto unhandled;
+
+  default:
+    goto unhandled;
+  }
+  return;
+
+ bail:
+  std::cerr << error_msg << data
+           << "status = " << status << std::endl;
+  shutdown_all(PMT_F);
+  return;
+
+ unhandled:
+  if(verbose && 0)
+    std::cout << "test_usrp_inband_tx: unhandled msg: " << msg
+              << "in state "<< d_state << std::endl;
+}
+
+
+void
+test_usrp_inband_timestamps::open_usrp()
+{
+  pmt_t which_usrp = pmt_from_long(0);
+
+  d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, which_usrp));
+  d_state = OPENING_USRP;
+}
+
+void
+test_usrp_inband_timestamps::close_usrp()
+{
+  d_cs->send(s_cmd_close, pmt_list1(PMT_NIL));
+  d_state = CLOSING_USRP;
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Closing USRP\n";
+}
+
+void
+test_usrp_inband_timestamps::allocate_channel()
+{
+  long capacity = (long) 16e6;
+  d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, 
pmt_from_long(capacity)));
+  d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, 
pmt_from_long(capacity)));
+  d_state = ALLOCATING_CHANNEL;
+}
+
+void
+test_usrp_inband_timestamps::enter_receiving()
+{
+  d_rx->send(s_cmd_start_recv_raw_samples,
+             pmt_list2(PMT_F,
+                       d_rx_chan));
+}
+
+void
+test_usrp_inband_timestamps::enter_transmitting()
+{
+  d_state = TRANSMITTING;
+  d_nsamples_xmitted = 0;
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Beginning transmission\n";
+
+  sleep(1);
+
+  build_and_send_next_frame();
+  build_and_send_next_frame();
+  build_and_send_next_frame();
+  build_and_send_next_frame();
+
+}
+
+void
+test_usrp_inband_timestamps::build_and_send_ping()
+{
+  
+  d_tx->send(s_cmd_to_control_channel,
+             pmt_list2(PMT_NIL, pmt_list1(pmt_list2(s_op_ping_fixed,
+                                                    pmt_list2(pmt_from_long(0),
+                                                              
pmt_from_long(0))))));
+  if(verbose && 0)
+    std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Ping sent" << std::endl;
+}
+
+void
+test_usrp_inband_timestamps::build_and_send_next_frame()
+{
+  // allocate the uniform vector for the samples
+  // FIXME perhaps hold on to this between calls
+
+#if 0
+  long nsamples_this_frame =
+    std::min(d_nsamples_to_send - d_nsamples_xmitted,
+            d_samples_per_frame);
+#else
+  long nsamples_this_frame = d_samples_per_frame;
+#endif
+
+  if (nsamples_this_frame == 0){
+    d_done_sending = true;
+    return;
+  }
+    
+
+  size_t nshorts = 2 * nsamples_this_frame;    // 16-bit I & Q
+  pmt_t uvec = pmt_make_s16vector(nshorts, 0);
+  size_t ignore;
+  int16_t *samples = pmt_s16vector_writeable_elements(uvec, ignore);
+
+  // fill in the complex sinusoid
+
+  for (int i = 0; i < nsamples_this_frame; i++){
+
+    if (1){
+      gr_complex s;
+      d_nco.sincos(&s, 1, d_amplitude);
+      // write 16-bit i & q
+      samples[2*i] =   (int16_t) s.real();
+      samples[2*i+1] = (int16_t) s.imag();
+    }
+    else {
+      gr_complex s(d_amplitude, d_amplitude);
+
+      // write 16-bit i & q
+      samples[2*i] =   (int16_t) s.real();
+      samples[2*i+1] = (int16_t) s.imag();
+    }
+  }
+
+  pmt_t timestamp;
+
+  if(bskip) {
+    timestamp = pmt_from_long(0x0);    // throw away  
+    bcurr++;
+    if(bcurr == bstep) {
+      bskip = false;
+      bcurr = 0;
+    }
+  } else {
+    timestamp = pmt_from_long(0xffffffff);     // NOW
+    timestamp = pmt_from_long(ptime);
+    ptime += incr;
+    bcurr++;
+    if(bcurr == bstep) {
+      //bskip = true;
+      bcurr = 0;
+    }
+  }
+
+  std::cout << bskip << " -- " << bcurr << std::endl;
+
+  d_tx->send(s_cmd_xmit_raw_frame,
+            pmt_list4(pmt_from_long(d_nframes_xmitted),  // invocation-handle
+                      d_tx_chan,                         // channel
+                      uvec,                              // the samples
+                      timestamp));
+
+  d_nsamples_xmitted += nsamples_this_frame;
+  d_nframes_xmitted++;
+
+  if(verbose && 0)
+    std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Transmitted frame\n";
+  
+  //build_and_send_next_frame();
+}
+
+
+void
+test_usrp_inband_timestamps::handle_xmit_response(pmt_t handle)
+{
+  if (d_done_sending &&
+      pmt_to_long(handle) == (d_nframes_xmitted - 1)){
+    // We're done sending and have received all responses
+    enter_closing_channel();
+  }
+
+  build_and_send_next_frame();
+  //build_and_send_ping();
+}
+
+void
+test_usrp_inband_timestamps::enter_closing_channel()
+{
+  d_state = CLOSING_CHANNEL;
+  
+  d_tx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_tx_chan));
+
+  if(verbose)
+    std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Closing channel\n";
+}
+
+REGISTER_MBLOCK_CLASS(test_usrp_inband_timestamps);
+
+
+// ----------------------------------------------------------------
+
+int
+main (int argc, char **argv)
+{
+  // handle any command line args here
+
+  mb_runtime_sptr rt = mb_make_runtime();
+  pmt_t result = PMT_NIL;
+
+  rt->run("top", "test_usrp_inband_timestamps", PMT_F, &result);
+}

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_tx.cc
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_tx.cc 
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_tx.cc 
2007-08-31 03:56:00 UTC (rev 6238)
@@ -39,27 +39,10 @@
 #include <string.h>
 #include <iostream>
 
-// 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");
-static pmt_t s_cmd_deallocate_channel = pmt_intern("cmd-deallocate-channel");
-static pmt_t s_response_deallocate_channel = 
pmt_intern("response-deallocate-channel");
-static pmt_t s_send_deallocate_channel = pmt_intern("send-deallocate-channel");
-static pmt_t s_cmd_max_capacity = pmt_intern("cmd-max-capacity");
-static pmt_t s_response_max_capacity = pmt_intern("response-max-capacity");
-static pmt_t s_cmd_ntx_chan  = pmt_intern("cmd-ntx-chan");
-static pmt_t s_cmd_nrx_chan  = pmt_intern("cmd-nrx-chan");
-static pmt_t s_response_ntx_chan = pmt_intern("response-ntx-chan");
-static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan");
-static pmt_t s_cmd_current_capacity_allocation  = 
pmt_intern("cmd-current-capacity-allocation");
-static pmt_t s_response_current_capacity_allocation  = 
pmt_intern("response-current-capacity-allocation");
-static pmt_t s_cmd_xmit_raw_frame  = pmt_intern("cmd-xmit-raw-frame");
-static pmt_t s_response_xmit_raw_frame = pmt_intern("response-xmit-raw-frame");
+#include <symbols_usrp_server_cs.h>
+#include <symbols_usrp_channel.h>
+#include <symbols_usrp_low_level_cs.h>
+#include <symbols_usrp_tx.h>
 
 static bool verbose = false;
 
@@ -111,8 +94,9 @@
     d_state(INIT), d_nsamples_to_send((long) 40e6),
     d_nsamples_xmitted(0),
     d_nframes_xmitted(0),
-    d_samples_per_frame((long)(126 * 3.5)),    // non-full packet
-    //d_samples_per_frame((long)(126 * 4)),    // full packet
+    //d_samples_per_frame((long)(126)),
+    //d_samples_per_frame((long)(126 * 3.5)),  // non-full packet
+    d_samples_per_frame((long)(126 * 4)),      // full packet
     d_done_sending(false),
     d_amplitude(16384)
 { 
@@ -121,8 +105,8 @@
   d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
   d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
   
-  bool fake_usrp_p = true;
-  //bool fake_usrp_p = false;
+  //bool fake_usrp_p = true;
+  bool fake_usrp_p = false;
 
   // Test the TX side
 
@@ -133,7 +117,25 @@
                  pmt_intern("fake-usrp"),
                             PMT_T);
   }
+  
+  // Specify the RBF to use
+  pmt_dict_set(usrp_dict,
+               pmt_intern("rbf"),
+               pmt_intern("boe3.rbf"));
 
+  // Set TX and RX interpolations
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-tx"),
+               pmt_from_long(128));
+
+  pmt_dict_set(usrp_dict,
+               pmt_intern("interp-rx"),
+               pmt_from_long(16));
+  
+  pmt_dict_set(usrp_dict,
+               pmt_intern("rf-freq"),
+               pmt_from_long(10e6));
+
   define_component("server", "usrp_server", usrp_dict);
 
   connect("self", "tx0", "server", "tx0");
@@ -294,6 +296,15 @@
 {
   d_state = TRANSMITTING;
   d_nsamples_xmitted = 0;
+  
+  // FIXME: carrier sense hack
+//  d_tx->send(s_cmd_to_control_channel,    // C/S packet
+//             pmt_list2(PMT_NIL,           // invoc handle
+//                       pmt_list1(
+//                            pmt_list2(s_op_write_reg, 
+//                                      pmt_list2(
+//                                      pmt_from_long(1), 
+//                                      pmt_from_long(0))))));
 
   build_and_send_next_frame(); // fire off 4 to start pipeline
   build_and_send_next_frame();


Property changes on: gnuradio/branches/features/inband-usb/usrp/host/lib/inband
___________________________________________________________________
Name: svn:ignore
   - Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
test_fusb
std_paths.h
usrp_dbid.py
usrp_dbid.h
usrp_dbid.cc
usrp_server_mbh.cc
test_inband
test_usrp_inband
test_usrp_tx
*_mbh.cc

   + Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
*.swp
*.dat
test_fusb
std_paths.h
usrp_dbid.py
usrp_dbid.h
usrp_dbid.cc
usrp_server_mbh.cc
test_inband
test_usrp_inband
test_usrp_tx
*_mbh.cc


Modified: gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am      
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am      
2007-08-31 03:56:00 UTC (rev 6238)
@@ -52,6 +52,7 @@
 libusrp_inband_la_SOURCES =            \
        $(BUILT_SOURCES)                \
        ../../apps/ui_sincos.c          \
+       usrp_inband_usb_packet.cc               \
        usrp_rx.cc                      \
        usrp_rx_stub.cc                 \
        usrp_server.cc                  \

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-08-31 03:42:39 UTC (rev 6237)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
 2007-08-31 03:56:00 UTC (rev 6238)
@@ -36,32 +36,14 @@
 #include <iostream>
 #include <pmt.h>
 
+#include <symbols_usrp_server_cs.h>
+#include <symbols_usrp_tx.h>
+#include <symbols_usrp_rx.h>
+#include <symbols_usrp_channel.h>
+#include <symbols_usrp_low_level_cs.h>
+
 typedef usrp_inband_usb_packet transport_pkt;   // makes conversion to gigabit 
easy
 
-static pmt_t s_cmd_allocate_channel = pmt_intern("cmd-allocate-channel");
-static pmt_t s_cmd_close = pmt_intern("cmd-close");
-static pmt_t s_cmd_deallocate_channel = pmt_intern("cmd-deallocate-channel");
-static pmt_t s_cmd_open = pmt_intern("cmd-open");
-static pmt_t s_cmd_start_recv_raw_samples = 
pmt_intern("cmd-start-recv-raw-samples");
-static pmt_t s_cmd_stop_recv_raw_samples = 
pmt_intern("cmd-stop-recv-raw-samples");
-static pmt_t s_cmd_to_control_channel = pmt_intern("cmd-to-control-channel");
-static pmt_t s_cmd_xmit_raw_frame  = pmt_intern("cmd-xmit-raw-frame");
-static pmt_t s_cmd_max_capacity  = pmt_intern("cmd-max-capacity");
-static pmt_t s_cmd_ntx_chan  = pmt_intern("cmd-ntx-chan");
-static pmt_t s_cmd_nrx_chan  = pmt_intern("cmd-nrx-chan");
-static pmt_t s_cmd_current_capacity_allocation  = 
pmt_intern("cmd-current-capacity-allocation");
-static pmt_t s_response_allocate_channel = 
pmt_intern("response-allocate-channel");
-static pmt_t s_response_close = pmt_intern("response-close");
-static pmt_t s_response_deallocate_channel = 
pmt_intern("response-deallocate-channel");
-static pmt_t s_response_from_control_channel = 
pmt_intern("response-from-control-channel");
-static pmt_t s_response_open = pmt_intern("response-open");
-static pmt_t s_response_recv_raw_samples = 
pmt_intern("response-recv-raw-samples");
-static pmt_t s_response_xmit_raw_frame = pmt_intern("response-xmit-raw-frame");
-static pmt_t s_response_max_capacity = pmt_intern("response-max-capacity");
-static pmt_t s_response_ntx_chan = pmt_intern("response-ntx-chan");
-static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan");
-static pmt_t s_response_current_capacity_allocation  = 
pmt_intern("response-current-capacity-allocation");
-
 static bool verbose = false;
 
 // 
----------------------------------------------------------------------------------------------
@@ -1093,6 +1075,239 @@
 
 // 
----------------------------------------------------------------------------------------------
 
+class qa_cs_top : public mb_mblock
+{
+  mb_port_sptr d_tx;
+  mb_port_sptr d_rx;
+  mb_port_sptr d_cs;
+
+  long d_nmsgs_to_recv;
+  long d_nrecvd;
+
+  long d_max_capacity;
+  long d_ntx_chan, d_nrx_chan;
+
+  long d_nstatus;
+  long d_nstatus_to_recv;
+
+ public:
+  qa_cs_top(mb_runtime *runtime, const std::string &instance_name, pmt_t 
user_arg);
+  ~qa_cs_top();
+  void initial_transition();
+  void handle_message(mb_message_sptr msg);
+
+ protected:
+  void check_message(mb_message_sptr msg);
+  void run_tests();
+};
+
+qa_cs_top::qa_cs_top(mb_runtime *runtime, const std::string &instance_name, 
pmt_t user_arg)
+  : mb_mblock(runtime, instance_name, user_arg)
+{ 
+  d_nrecvd=0;
+  d_nmsgs_to_recv = 8;
+  d_nstatus=0;
+  d_nstatus_to_recv = 50;
+  
+  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_cs_top::~qa_cs_top(){}
+
+void
+qa_cs_top::initial_transition()
+{
+  run_tests();
+}
+
+void
+qa_cs_top::run_tests()
+{
+  if(verbose)
+    std::cout << "[qa_cs_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)));
+
+  d_tx->send(s_cmd_to_control_channel,
+             pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
+                       pmt_list1(
+                            pmt_list2(s_op_ping_fixed, 
+                                      pmt_list2(pmt_from_long(3), 
+                                      pmt_from_long(0))))));
+  
+  d_tx->send(s_cmd_to_control_channel,
+             pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
+                       pmt_list1(
+                            pmt_list2(s_op_write_reg, 
+                                      pmt_list2(
+                                      pmt_from_long(0x3), 
+                                      pmt_from_long(0x4))))));
+  
+  d_tx->send(s_cmd_to_control_channel,
+             pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
+                       pmt_list1(
+                            pmt_list2(s_op_write_reg_masked, 
+                                      pmt_list3(
+                                      pmt_from_long(0x3), 
+                                      pmt_from_long(0x4),
+                                      pmt_from_long(0x5))))));
+  
+  d_tx->send(s_cmd_to_control_channel,
+             pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
+                       pmt_list1(
+                            pmt_list2(s_op_read_reg, 
+                                      pmt_list2(pmt_from_long(0), 
+                                      pmt_from_long(0x6))))));
+  
+  d_tx->send(s_cmd_to_control_channel,
+             pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
+                       pmt_list1(
+                            pmt_list2(s_op_delay, 
+                                      pmt_list1(pmt_from_long(0x7))))));
+
+  pmt_t subpackets = pmt_list5(
+                        pmt_list2(s_op_ping_fixed, pmt_list2(pmt_from_long(0), 
pmt_from_long(0))),
+                        pmt_list2(s_op_delay, pmt_list1(pmt_from_long(0x7))),
+                        pmt_list2(s_op_write_reg_masked, 
pmt_list3(pmt_from_long(3),
+                                                                   
pmt_from_long(4),
+                                                                   
pmt_from_long(5))),
+                        pmt_list2(s_op_write_reg, pmt_list2(pmt_from_long(3),
+                                                            pmt_from_long(4))),
+                        pmt_list2(s_op_read_reg, pmt_list2(pmt_from_long(0),
+                                                           pmt_from_long(6)))
+                     );
+
+  d_tx->send(s_cmd_to_control_channel, 
+              pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
+                        subpackets));
+
+  pmt_t i2c_data = pmt_make_u8vector(8, 0xff);
+
+  subpackets = pmt_list2(
+                        pmt_list2(s_op_i2c_write, 
+                                  pmt_list2(pmt_from_long(8), i2c_data)),
+                        pmt_list2(s_op_i2c_read,
+                                  pmt_list3(pmt_from_long(0), 
pmt_from_long(9), pmt_from_long(1)))
+
+                     );
+
+  d_tx->send(s_cmd_to_control_channel, 
+              pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
+                        subpackets));
+  
+}
+
+void
+qa_cs_top::handle_message(mb_message_sptr msg)
+{
+  pmt_t data = msg->data();
+
+  if ((pmt_eq(msg->port_id(), d_tx->port_symbol())
+       || pmt_eq(msg->port_id(), d_rx->port_symbol()))
+       && pmt_eq(msg->signal(), s_response_allocate_channel))
+    check_message(msg);
+
+  if (pmt_eq(msg->port_id(), d_tx->port_symbol())
+      && pmt_eq(msg->signal(), s_response_from_control_channel))
+    check_message(msg);
+  
+  if (pmt_eq(msg->port_id(), d_cs->port_symbol())) {
+      
+    if(pmt_eq(msg->signal(), s_response_max_capacity)) {
+      d_max_capacity = pmt_to_long(pmt_nth(2, data));
+      if(verbose)
+        std::cout << "[qa_cs_top] USRP has max capacity of " 
+                  << d_max_capacity << "\n";
+    }
+    else if(pmt_eq(msg->signal(), s_response_ntx_chan)) {
+      d_ntx_chan = pmt_to_long(pmt_nth(2, data));
+      if(verbose)
+        std::cout << "[qa_cs_top] USRP tx channels: " 
+                  << d_ntx_chan << "\n";
+    }
+    else if(pmt_eq(msg->signal(), s_response_nrx_chan)) {
+      d_nrx_chan = pmt_to_long(pmt_nth(2, data));
+      if(verbose)
+        std::cout << "[qa_cs_top] USRP rx channels: " 
+                  << d_nrx_chan << "\n";
+    }
+    else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) {
+      check_message(msg);
+    }
+    
+    d_nstatus++;
+
+    check_message(msg);
+
+    if(d_nstatus==d_nstatus_to_recv)
+      run_tests();
+  }
+}
+
+void
+qa_cs_top::check_message(mb_message_sptr msg)
+{
+  pmt_t data = msg->data();
+  pmt_t event = msg->signal();
+
+  pmt_t expected = pmt_nth(0, data);
+  pmt_t status = pmt_nth(1, data);
+
+  pmt_t e_event = pmt_nth(0, expected);
+  pmt_t e_status = pmt_nth(1, expected);
+  
+  d_nrecvd++;
+
+
+  if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
+    if(verbose)
+      std::cout << "[qa_cs_top] Got: " << status << " Expected: " << e_status 
<< "\n";
+    shutdown_all(PMT_F);
+    return;
+  } else {
+    if(verbose)
+      std::cout << "[qa_cs_top] Received expected response for message " 
+                << d_nrecvd << " (" << event << ")\n";
+  }
+
+  if(d_nrecvd == d_nmsgs_to_recv)
+    shutdown_all(PMT_T);
+}
+
+REGISTER_MBLOCK_CLASS(qa_cs_top);
+
+// 
----------------------------------------------------------------------------------------------
+
 void 
 qa_inband_usrp_server::test_open_close()
 {
@@ -1162,3 +1377,17 @@
   
   CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
 }
+
+void
+qa_inband_usrp_server::test_cs()
+{
+  mb_runtime_sptr rt = mb_make_runtime();
+  pmt_t result = PMT_T;
+
+  // std::cout << "\n\n-----------------\n";
+  // std::cout << "  RUNNING CS TESTS  \n";
+
+  rt->run("top", "qa_cs_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-08-31 03:42:39 UTC (rev 6237)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.h
  2007-08-31 03:56:00 UTC (rev 6238)
@@ -33,6 +33,7 @@
   CPPUNIT_TEST(test_chan_deallocation);
   CPPUNIT_TEST(test_tx);
   CPPUNIT_TEST(test_rx);
+  CPPUNIT_TEST(test_cs);
   CPPUNIT_TEST_SUITE_END();
 
  private:
@@ -41,6 +42,7 @@
   void test_open_close();
   void test_tx();
   void test_rx();
+  void test_cs();
 };
 
 #endif /* INCLUDED_QA_INBAND_USRP_SERVER_H */

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_channel.h
 (from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/symbols_usrp_channel.h)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_channel.h
                           (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_channel.h
   2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,34 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_SYMBOLS_USRP_CHANNEL_H
+#define INCLUDED_SYMBOLS_USRP_CHANNEL_H
+
+#include <pmt.h>
+
+// Outgoing
+static pmt_t s_cmd_allocate_channel = pmt_intern("cmd-allocate-channel");
+static pmt_t s_cmd_deallocate_channel = pmt_intern("cmd-deallocate-channel");
+
+// Incoming
+static pmt_t s_response_allocate_channel = 
pmt_intern("response-allocate-channel");
+static pmt_t s_response_deallocate_channel = 
pmt_intern("response-deallocate-channel");
+
+#endif /* INCLUDED_SYMBOLS_USRP_CHANNEL_H */

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_interface_cs.h
 (from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/symbols_usrp_interface_cs.h)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_interface_cs.h
                              (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_interface_cs.h
      2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_SYMBOLS_USRP_INTERFACE_CS_H
+#define INCLUDED_SYMBOLS_USRP_INTERFACE_CS_H
+
+#include <pmt.h>
+
+// Outgoing
+static pmt_t s_cmd_usrp_open = pmt_intern("cmd-usrp-open");
+static pmt_t s_cmd_usrp_close = pmt_intern("cmd-usrp-close");
+static pmt_t s_cmd_usrp_ntx_chan = pmt_intern("cmd-usrp-ntx-chan");
+static pmt_t s_cmd_usrp_nrx_chan = pmt_intern("cmd-usrp-nrx-chan");
+static pmt_t s_cmd_usrp_write = pmt_intern("cmd-usrp-write");
+static pmt_t s_cmd_usrp_start_reading = pmt_intern("cmd-usrp-start-reading");
+static pmt_t s_cmd_usrp_stop_reading = pmt_intern("cmd-usrp-stop-reading");
+
+// Incoming
+static pmt_t s_response_usrp_open = pmt_intern("response-usrp-open");
+static pmt_t s_response_usrp_close = pmt_intern("response-usrp-close");
+static pmt_t s_response_usrp_ntx_chan = pmt_intern("response-usrp-ntx-chan");
+static pmt_t s_response_usrp_nrx_chan = pmt_intern("response-usrp-nrx-chan");
+static pmt_t s_response_usrp_write = pmt_intern("response-usrp-write");
+static pmt_t s_response_usrp_read = pmt_intern("response-usrp-read");
+
+#endif /* INCLUDED_SYMBOLS_USRP_INTERFACE_CS_H */

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_low_level_cs.h
 (from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/symbols_usrp_low_level_cs.h)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_low_level_cs.h
                              (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_low_level_cs.h
      2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,47 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_SYMBOLS_USRP_LOW_LEVEL_CS_H
+#define INCLUDED_SYMBOLS_USRP_LOW_LEVEL_CS_H
+
+#include <pmt.h>
+
+// Outgoing
+static pmt_t s_cmd_to_control_channel = pmt_intern("cmd-to-control-channel");
+
+// Incoming
+static pmt_t s_response_from_control_channel = 
pmt_intern("response-from-control-channel");
+
+// Subpackets
+static pmt_t s_op_ping_fixed = pmt_intern("op-ping-fixed");
+static pmt_t s_op_ping_fixed_reply = pmt_intern("op-ping-fixed-reply");
+static pmt_t s_op_write_reg = pmt_intern("op-write-reg");
+static pmt_t s_op_write_reg_masked = pmt_intern("op-write-reg-masked");
+static pmt_t s_op_read_reg = pmt_intern("op-read-reg");
+static pmt_t s_op_read_reg_reply = pmt_intern("op-read-reg-reply");
+static pmt_t s_op_i2c_write = pmt_intern("op-i2c-write");
+static pmt_t s_op_i2c_read = pmt_intern("op-i2c-read");
+static pmt_t s_op_i2c_read_reply = pmt_intern("op-i2c-read-reply");
+static pmt_t s_op_spi_write = pmt_intern("op-spi-write");
+static pmt_t s_op_spi_read = pmt_intern("op-spi-read");
+static pmt_t s_op_spi_read_reply = pmt_intern("op-spi-read-reply");
+static pmt_t s_op_delay = pmt_intern("op-delay");
+
+#endif /* INCLUDED_SYMBOLS_USRP_LOW_LEVEL_CS_H */

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx.h 
(from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/symbols_usrp_rx.h)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx.h    
                            (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx.h    
    2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,33 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_SYMBOLS_USRP_RX_H
+#define INCLUDED_SYMBOLS_USRP_RX_H
+
+#include <pmt.h>
+
+// Outgoing
+static pmt_t s_cmd_start_recv_raw_samples = 
pmt_intern("cmd-start-recv-raw-samples");
+static pmt_t s_cmd_stop_recv_raw_samples = 
pmt_intern("cmd-stop-recv-raw-samples");
+
+// Incoming
+static pmt_t s_response_recv_raw_samples = 
pmt_intern("response-recv-raw-samples");
+
+#endif /* INCLUDED_SYMBOLS_USRP_RX_H */

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx_cs.h 
(from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/symbols_usrp_rx_cs.h)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx_cs.h 
                            (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx_cs.h 
    2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_SYMBOLS_USRP_RX_CS_H
+#define INCLUDED_SYMBOLS_USRP_RX_CS_H
+
+#include <pmt.h>
+
+// Outgoing
+static pmt_t s_cmd_usrp_rx_start_reading = 
pmt_intern("cmd-usrp-rx-start-reading");
+
+// Incoming
+static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read");
+
+#endif /* INCLUDED_SYMBOLS_USRP_RX_CS_H */

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_server_cs.h
 (from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/symbols_usrp_server_cs.h)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_server_cs.h
                         (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_server_cs.h
 2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_SYMBOLS_USRP_SERVER_CS_H
+#define INCLUDED_SYMBOLS_USRP_SERVER_CS_H
+
+#include <pmt.h>
+
+// Outgoing
+static pmt_t s_cmd_open = pmt_intern("cmd-open");
+static pmt_t s_cmd_close = pmt_intern("cmd-close");
+static pmt_t s_cmd_max_capacity  = pmt_intern("cmd-max-capacity");
+static pmt_t s_cmd_ntx_chan  = pmt_intern("cmd-ntx-chan");
+static pmt_t s_cmd_nrx_chan  = pmt_intern("cmd-nrx-chan");
+static pmt_t s_cmd_current_capacity_allocation  = 
pmt_intern("cmd-current-capacity-allocation");
+
+// Incoming
+static pmt_t s_response_open = pmt_intern("response-open");
+static pmt_t s_response_close = pmt_intern("response-close");
+static pmt_t s_response_max_capacity = pmt_intern("response-max-capacity");
+static pmt_t s_response_ntx_chan = pmt_intern("response-ntx-chan");
+static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan");
+static pmt_t s_response_current_capacity_allocation  = 
pmt_intern("response-current-capacity-allocation");
+
+#endif /* INCLUDED_SYMBOLS_USRP_SERVER_CS_H */

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_tx.h 
(from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/symbols_usrp_tx.h)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_tx.h    
                            (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_tx.h    
    2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_SYMBOLS_USRP_TX_H
+#define INCLUDED_SYMBOLS_USRP_TX_H
+
+#include <pmt.h>
+
+// Outgoing
+static pmt_t s_cmd_xmit_raw_frame  = pmt_intern("cmd-xmit-raw-frame");
+
+// Incoming
+static pmt_t s_response_xmit_raw_frame = pmt_intern("response-xmit-raw-frame");
+
+#endif /* INCLUDED_SYMBOLS_USRP_TX_H */

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_tx_cs.h 
(from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/symbols_usrp_tx_cs.h)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_tx_cs.h 
                            (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_tx_cs.h 
    2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_SYMBOLS_USRP_TX_CS_H
+#define INCLUDED_SYMBOLS_USRP_TX_CS_H
+
+#include <pmt.h>
+
+// Outgoing
+static pmt_t s_cmd_usrp_tx_write = pmt_intern("cmd-usrp-tx-write");
+
+// Incoming
+static pmt_t s_response_usrp_tx_write = pmt_intern("response-usrp-tx-write");
+
+#endif /* INCLUDED_SYMBOLS_USRP_TX_CS_H */

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_inband_usb_packet.cc
 (from rev 6237, 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.cc)
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_inband_usb_packet.cc
                                (rev 0)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_inband_usb_packet.cc
        2007-08-31 03:56:00 UTC (rev 6238)
@@ -0,0 +1,749 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <usrp_inband_usb_packet.h>
+
+#include <usrp_bytesex.h>
+#include <iostream>
+#include <stdio.h>
+
+bool usrp_inband_usb_packet::align32()
+{
+  int p_len = payload_len();
+
+  int bytes_needed = 4 - (p_len % 4);
+
+  if(bytes_needed == 4)
+    return true;
+
+  // If the room left in the packet is less than the number of bytes
+  // needed, return false to indicate no room to align
+  if((MAX_PAYLOAD - p_len) < bytes_needed)
+    return false;
+    
+  p_len += bytes_needed;
+
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = p_len;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_ping(long rid, long ping_val)
+{
+  if(!align32())
+    return false;
+  
+  int p_len = payload_len();
+
+  if((MAX_PAYLOAD - p_len) < (CS_PING_LEN + CS_FIXED_LEN))
+    return false;
+
+  uint32_t ping = ( 
+      ((OP_PING_FIXED & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((CS_PING_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
+    | (ping_val & CS_PINGVAL_MASK)
+
+    );
+
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(ping);
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + CS_PING_LEN;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+
+bool usrp_inband_usb_packet::cs_ping_reply(long rid, long ping_val) 
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  if((MAX_PAYLOAD - p_len) < (CS_PING_LEN + CS_FIXED_LEN))
+    return false;
+
+  uint32_t ping = ( 
+      ((OP_PING_FIXED_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((CS_PING_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
+    | ((ping_val & CS_PINGVAL_MASK) << CS_PINGVAL_SHIFT)
+
+    );
+
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(ping);
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + CS_PING_LEN;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_write_reg(long reg_num, long val)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  if((MAX_PAYLOAD - p_len) < (CS_WRITEREG_LEN + CS_FIXED_LEN))
+    return false;
+
+  uint32_t word0 = 0;
+
+  // Build the first word which includes the register number
+  word0 = (
+      ((OP_WRITE_REG & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((CS_WRITEREG_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT)
+  );
+
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word0);
+
+  // The second word is solely the register value to be written
+  // FIXME: should this be unsigned?
+  payload += 1; 
+  *payload = host_to_usrp_u32((uint32_t) val);
+  
+  // Rebuild the header to update the payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + CS_WRITEREG_LEN;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_write_reg_masked(long reg_num, long val, long 
mask)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  if((MAX_PAYLOAD - p_len) < (CS_WRITEREGMASKED_LEN + CS_FIXED_LEN))
+    return false;
+
+  uint32_t word0 = 0;
+
+  // Build the first word which includes the register number
+  word0 = (
+      ((OP_WRITE_REG_MASKED & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((CS_WRITEREGMASKED_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT)
+  );
+
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word0);
+
+  // Skip over the first word and write the register value
+  payload += 1;
+  *payload = host_to_usrp_u32((uint32_t) val);
+
+  // Skip over the register value and write the mask
+  payload += 1;
+  *payload = host_to_usrp_u32((uint32_t) mask);
+  
+  // Rebuild the header to update the payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + CS_WRITEREGMASKED_LEN;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_read_reg(long rid, long reg_num)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  if((MAX_PAYLOAD - p_len) < (CS_READREG_LEN + CS_FIXED_LEN))
+    return false;
+
+  uint32_t read_reg = ( 
+      ((OP_READ_REG & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((CS_READREG_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
+    | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT)
+
+    );
+
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(read_reg);
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + CS_READREG_LEN;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_read_reg_reply(long rid, long reg_num, long 
reg_val)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  if((MAX_PAYLOAD - p_len) < (CS_READREGREPLY_LEN + CS_FIXED_LEN))
+    return false;
+
+  uint32_t word0 = ( 
+      ((OP_READ_REG_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((CS_READREGREPLY_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
+    | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT)
+
+    );
+
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word0);
+
+  // Hop to the next word and write the reg value
+  payload += 1;
+  *payload = host_to_usrp_u32((uint32_t) reg_val); 
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + CS_READREGREPLY_LEN;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_delay(long ticks)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  if((MAX_PAYLOAD - p_len) < (CS_DELAY_LEN + CS_FIXED_LEN))
+    return false;
+
+  uint32_t delay = ( 
+      ((OP_DELAY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((CS_DELAY_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((ticks & CS_DELAY_MASK) << CS_DELAY_SHIFT)
+
+    );
+
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(delay);
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + CS_DELAY_LEN;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_i2c_write(long i2c_addr, uint8_t *i2c_data, 
size_t data_len)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  int i2c_len = data_len + 2;   // 2 bytes between mbz and addr
+
+  if((MAX_PAYLOAD - p_len) < (i2c_len + CS_FIXED_LEN))
+    return false;
+
+  uint32_t word0 = 0;
+
+  word0 = (
+      ((OP_I2C_WRITE & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((i2c_len & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((i2c_addr & CS_I2CADDR_MASK) << CS_I2CADDR_SHIFT)
+  );
+
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+   *payload = host_to_usrp_u32(word0);
+
+   // Jump over the first word and write the data
+   // FIXME: Should the data be changed to usrp byte order?
+   payload += 1;
+   memcpy(payload, i2c_data, data_len);
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + i2c_len;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_i2c_read(long rid, long i2c_addr, long n_bytes)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  if((MAX_PAYLOAD - p_len) < (CS_I2CREAD_LEN + CS_FIXED_LEN))
+    return false;
+
+  uint32_t word0 = 0;
+  
+  word0 = ( 
+      ((OP_I2C_READ & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((CS_I2CREAD_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
+    | ((i2c_addr & CS_I2CADDR_MASK) << CS_I2CADDR_SHIFT)
+    );
+
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word0);
+
+  // Jump a word and write the number of bytes to read
+  payload += 1;
+  uint32_t word1 = 
+    (n_bytes & CS_I2CREADBYTES_MASK) << CS_I2CREADBYTES_SHIFT;
+  *payload = host_to_usrp_u32(word1);
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + CS_I2CREAD_LEN;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_i2c_read_reply(long rid, long i2c_addr, 
uint8_t *i2c_data, long i2c_data_len)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  int i2c_len = i2c_data_len + 2;
+
+  if((MAX_PAYLOAD - p_len) < (i2c_len + CS_FIXED_LEN)) 
+    return false;
+  
+  uint32_t word0 = 0;
+  
+  word0 = ( 
+      ((OP_I2C_READ_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((i2c_len & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
+    | ((i2c_addr & CS_I2CADDR_MASK) << CS_I2CADDR_SHIFT)
+    );
+
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word0);
+
+  // Jump a word and write the actual data
+  payload += 1;
+  memcpy(payload, i2c_data, i2c_data_len);
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + i2c_len;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_spi_write(long enables, long format, long 
opt_header_bytes, uint8_t *spi_data, long spi_data_len)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  int spi_len = spi_data_len + 6;
+
+  if((MAX_PAYLOAD - p_len) < (spi_len + CS_FIXED_LEN))
+    return false;
+
+  uint32_t word = 0;
+
+  // First word contains the opcode and length, then mbz
+  word = (
+      ((OP_SPI_WRITE & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((spi_len & CS_LEN_MASK) << CS_LEN_SHIFT)
+    );
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word);
+
+  payload += 1;
+
+  // Second word contains the enables, format, and optional tx bytes
+  word = 0;
+  word = (
+      ((enables & CS_SPIENABLES_MASK) << CS_SPIENABLES_SHIFT)
+    | ((format & CS_SPIFORMAT_MASK) << CS_SPIFORMAT_SHIFT)
+    | ((opt_header_bytes & CS_SPIOPT_MASK) << CS_SPIOPT_SHIFT)
+    );
+  payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word);
+
+  payload += 1;
+  memcpy(payload, spi_data, spi_data_len);
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + spi_len;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_spi_read(long rid, long enables, long format, 
long opt_header_bytes, long n_bytes)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  if((MAX_PAYLOAD - p_len) < (CS_SPIREAD_LEN + CS_FIXED_LEN))
+    return false;
+
+  uint32_t word = 0;
+
+  // First word contains the opcode, length, and RID
+  word = (
+      ((OP_SPI_READ & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((CS_SPIREAD_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
+    );
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word);
+
+  payload += 1;
+
+  // Second word contains the enables, format, and optional tx bytes
+  word = 0;
+  word = (
+      ((enables & CS_SPIENABLES_MASK) << CS_SPIENABLES_SHIFT)
+    | ((format & CS_SPIFORMAT_MASK) << CS_SPIFORMAT_SHIFT)
+    | ((opt_header_bytes & CS_SPIOPT_MASK) << CS_SPIOPT_SHIFT)
+    );
+  payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word);
+
+  payload += 1;
+
+  // The third word contains the number of bytes
+  word = 0;
+  word = (
+      ((n_bytes & CS_SPINBYTES_MASK) << CS_SPINBYTES_SHIFT)
+    );
+  payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word);
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + CS_SPIREAD_LEN;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+  
+  return true;
+}
+
+bool usrp_inband_usb_packet::cs_spi_read_reply(long rid, uint8_t *spi_data, 
long spi_data_len)
+{
+  if(!align32())
+    return false;
+
+  int p_len = payload_len();
+
+  int spi_len = spi_data_len + 2;
+
+  if((MAX_PAYLOAD - p_len) < (spi_len + CS_FIXED_LEN))
+    return false;
+
+  uint32_t word = 0;
+
+  // First word contains the opcode, length, and RID
+  word = (
+      ((OP_SPI_READ_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+    | ((spi_len & CS_LEN_MASK) << CS_LEN_SHIFT)
+    | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
+    );
+  uint32_t *payload = (uint32_t *) (d_payload + p_len);
+  *payload = host_to_usrp_u32(word);
+
+  // Jump a word and write the actual data
+  payload += 1;
+  memcpy(payload, spi_data, spi_data_len);
+
+  // Update payload length
+  int h_flags = flags();
+  int h_chan = chan();
+  int h_tag = tag();
+  int h_payload_len = payload_len() + CS_FIXED_LEN + spi_len;
+
+  set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+  return true;
+}
+
+// Takes an offset to the beginning of a subpacket and extracts the
+// length of the subpacket
+int usrp_inband_usb_packet::cs_len(int payload_offset) {
+  uint32_t subpkt = usrp_to_host_u32(*((uint32_t *)(d_payload + 
payload_offset)));
+  return (subpkt >> CS_LEN_SHIFT) & CS_LEN_MASK;
+}
+
+// The following method takes an offset within the packet payload to extract
+// a control/status subpacket and construct a pmt response which includes the
+// proper signal and arguments specified by usrp-low-level-cs.  The USRP
+// server could therefore use this to read subpackets and pass them responses
+// back up to the application.  It's arguable that only reply packets should
+// be parsed here, however we parse others for use in debugging or failure
+// reporting on the transmit side of packets.
+pmt_t usrp_inband_usb_packet::read_subpacket(int payload_offset) {
+
+  uint32_t subpkt = usrp_to_host_u32(*((uint32_t *)(d_payload + 
payload_offset)));
+  uint32_t opcode = (subpkt >> CS_OPCODE_SHIFT) & CS_OPCODE_MASK;
+  uint32_t len = (subpkt >> CS_LEN_SHIFT) & CS_LEN_MASK;
+
+  switch(opcode) {
+    
+    case OP_PING_FIXED_REPLY:
+    {
+      pmt_t rid     = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
+      pmt_t pingval = pmt_from_long((subpkt >> CS_PINGVAL_SHIFT) & 
CS_PINGVAL_MASK);
+      return pmt_list3(s_op_ping_fixed_reply, rid, pingval);
+    }
+
+    case OP_READ_REG_REPLY:
+    {
+      pmt_t rid     = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
+      pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & 
CS_REGNUM_MASK);
+
+      // To get the register value we just read the next 32 bits
+      uint32_t val  = usrp_to_host_u32(*((uint32_t *)(d_payload + 
payload_offset + 4)));
+      pmt_t reg_val = pmt_from_long(val);
+
+      return pmt_list4(s_op_read_reg_reply, rid, reg_num, reg_val);
+    }
+
+    case OP_I2C_READ_REPLY:
+    {
+      pmt_t rid       = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
+      pmt_t i2c_addr  = pmt_from_long((subpkt >> CS_I2CADDR_SHIFT) & 
CS_I2CADDR_MASK);
+
+      // Make a u8 vector to dump the data from the packet into
+      size_t i2c_data_len;
+      pmt_t i2c_data  = pmt_make_u8vector(len - 2, 0);   // skip rid+mbz+addr 
= 2 bytes
+      uint8_t *w_data  = 
+          (uint8_t *) pmt_u8vector_writeable_elements(i2c_data, i2c_data_len);
+
+      memcpy(w_data, d_payload + payload_offset + 4, i2c_data_len);  // skip 
first word
+
+      return pmt_list4(s_op_i2c_read_reply, rid, i2c_addr, i2c_data);
+    }
+
+    case OP_SPI_READ_REPLY:
+    {
+      pmt_t rid       = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
+      
+      // Make a u8 vector to dump the data from the packet into
+      size_t spi_data_len;
+      pmt_t spi_data  = pmt_make_u8vector(len - 2, 0);   // skip rid+mbz+addr 
= 2 bytes
+      uint8_t *w_data  = 
+          (uint8_t *) pmt_u8vector_writeable_elements(spi_data, spi_data_len);
+
+      memcpy(w_data, d_payload + payload_offset + 4, spi_data_len);  // skip 
first word
+
+      return pmt_list3(s_op_spi_read_reply, rid, spi_data);
+    }
+
+    case OP_PING_FIXED:
+    {
+      pmt_t rid     = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
+      pmt_t pingval = pmt_from_long((subpkt >> CS_PINGVAL_SHIFT) & 
CS_PINGVAL_MASK);
+      return pmt_list3(s_op_ping_fixed, rid, pingval);
+    }
+
+    case OP_WRITE_REG:
+    {
+      pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & 
CS_REGNUM_MASK);
+
+      // To get the register value we just read the next 32 bits
+      uint32_t val  = usrp_to_host_u32(*((uint32_t *)(d_payload + 
payload_offset + 4)));
+      pmt_t reg_val = pmt_from_long(val);
+
+      return pmt_list3(s_op_write_reg, reg_num, reg_val);
+    }
+
+    case OP_WRITE_REG_MASKED:
+    {
+      pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & 
CS_REGNUM_MASK);
+
+      // To get the register value we just read the next 32 bits
+      uint32_t val  = usrp_to_host_u32(*((uint32_t *)(d_payload + 
payload_offset + 4)));
+      pmt_t reg_val = pmt_from_long(val);
+
+      // The mask is the next 32 bits
+      uint32_t mask  = usrp_to_host_u32(*((uint32_t *)(d_payload + 
payload_offset + 8)));
+      pmt_t reg_mask = pmt_from_long(mask);
+
+      return pmt_list4(s_op_write_reg_masked, reg_num, reg_val, reg_mask);
+    }
+
+    case OP_READ_REG:
+    {
+      pmt_t rid     = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
+      pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & 
CS_REGNUM_MASK);
+
+      return pmt_list3(s_op_read_reg, rid, reg_num);
+    }
+
+    case OP_I2C_WRITE:
+    {
+      pmt_t i2c_addr    = pmt_from_long((subpkt >> CS_I2CADDR_SHIFT) & 
CS_I2CADDR_MASK);
+
+      // The length includes an extra 2 bytes for storing the mbz and addr
+      pmt_t i2c_data    = pmt_make_u8vector(len-2, 0);
+
+      // Get a writeable address to copy the data from the packet
+      size_t ignore;
+      uint8_t *w_data = (uint8_t *) pmt_u8vector_writeable_elements(i2c_data, 
ignore);
+      memcpy(w_data, d_payload + payload_offset + 4, len-2);
+
+      
+      return pmt_list3(s_op_i2c_write, i2c_addr, i2c_data);
+    }
+
+    case OP_I2C_READ:
+    {
+      pmt_t rid       = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
+      pmt_t i2c_addr  = pmt_from_long((subpkt >> CS_I2CADDR_SHIFT) & 
CS_I2CADDR_MASK);
+      
+      // The number of bytes is in the next word
+      uint32_t bytes  = usrp_to_host_u32(*((uint32_t *)(d_payload + 
payload_offset + 4)));
+      bytes = (bytes >> CS_I2CREADBYTES_SHIFT) & CS_I2CREADBYTES_MASK;
+      pmt_t i2c_bytes = pmt_from_long(bytes);
+
+      return pmt_list4(s_op_i2c_read, rid, i2c_addr, i2c_bytes);
+    }
+
+    case OP_SPI_WRITE:
+    {
+      // Nothing interesting in the first word, skip to the next
+      uint32_t word  = usrp_to_host_u32(*((uint32_t *)(d_payload + 
payload_offset + 4)));
+      pmt_t enables   = pmt_from_long((word >> CS_SPIENABLES_SHIFT) & 
CS_SPIENABLES_MASK);
+      pmt_t format    = pmt_from_long((word >> CS_SPIFORMAT_SHIFT) & 
CS_SPIFORMAT_MASK);
+      pmt_t opt       = pmt_from_long((word >> CS_SPIOPT_SHIFT) & 
CS_SPIOPT_MASK);
+
+      // From the next word and on is data
+      size_t spi_data_len;
+      pmt_t spi_data  = pmt_make_u8vector(len - 6, 0);   // skip rid+mbz+addr 
= 2 bytes
+      uint8_t *w_data  = 
+          (uint8_t *) pmt_u8vector_writeable_elements(spi_data, spi_data_len);
+
+      memcpy(w_data, d_payload + payload_offset + 8, spi_data_len);  // skip 
first 2 words
+
+      return pmt_list5(s_op_spi_write, enables, format, opt, spi_data);
+    }
+
+    case OP_SPI_READ:
+    {
+      // Read the RID from the first word, the rest is mbz
+      pmt_t rid       = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
+
+      // Continue at the next word...
+      uint32_t word  = usrp_to_host_u32(*((uint32_t *)(d_payload + 
payload_offset + 4)));
+      pmt_t enables   = pmt_from_long((word >> CS_SPIENABLES_SHIFT) & 
CS_SPIENABLES_MASK);
+      pmt_t format    = pmt_from_long((word >> CS_SPIFORMAT_SHIFT) & 
CS_SPIFORMAT_MASK);
+      pmt_t opt       = pmt_from_long((word >> CS_SPIOPT_SHIFT) & 
CS_SPIOPT_MASK);
+
+      // The number of bytes is the only thing to read in the next word
+      word  = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 
8)));
+      pmt_t n_bytes   = pmt_from_long((word >> CS_SPINBYTES_SHIFT) & 
CS_SPINBYTES_MASK);
+
+      return pmt_list6(s_op_spi_read, rid, enables, format, opt, n_bytes);
+    }
+
+    case OP_DELAY:
+    {
+      pmt_t ticks = pmt_from_long((subpkt >> CS_DELAY_SHIFT) & CS_DELAY_MASK);
+
+      return pmt_list2(s_op_delay, ticks);
+    }
+    
+    default:
+      return PMT_NIL;
+
+  }
+}
+

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_inband_usb_packet.h
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_inband_usb_packet.h
 2007-08-31 03:42:39 UTC (rev 6237)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_inband_usb_packet.h
 2007-08-31 03:56:00 UTC (rev 6238)
@@ -24,7 +24,11 @@
 
 #include <usrp_bytesex.h>
 #include <mb_mblock.h>
+#include <pmt.h>
+#include <iostream>
 
+#include <symbols_usrp_low_level_cs.h>
+
 static const int USB_PKT_SIZE = 512;   // bytes
 static const int MAX_PAYLOAD = USB_PKT_SIZE-2*sizeof(uint32_t);
 
@@ -38,12 +42,28 @@
 
 public:
 
+  enum opcodes {
+    OP_PING_FIXED         = 0x00,
+    OP_PING_FIXED_REPLY   = 0x01,
+    OP_WRITE_REG          = 0x02,
+    OP_WRITE_REG_MASKED   = 0x03,
+    OP_READ_REG           = 0x04,
+    OP_READ_REG_REPLY     = 0x05,
+    OP_I2C_WRITE          = 0x06,
+    OP_I2C_READ           = 0x07,
+    OP_I2C_READ_REPLY     = 0x08,
+    OP_SPI_WRITE          = 0x09,
+    OP_SPI_READ           = 0x0a,
+    OP_SPI_READ_REPLY     = 0x0b,
+    OP_DELAY              = 0x0c
+  };
+
   enum flags {
     FL_OVERRUN        = 0x80000000,
     FL_UNDERRUN       = 0x40000000,
     FL_DROPPED        = 0x20000000,
-    FL_END_OF_BURST   = 0x10000000,
-    FL_START_OF_BURST = 0x08000000,
+    FL_START_OF_BURST = 0x10000000,
+    FL_END_OF_BURST   = 0x08000000,
 
     FL_ALL_FLAGS      = 0xf8000000
   };
@@ -51,8 +71,8 @@
   static const int FL_OVERRUN_SHIFT = 31;
   static const int FL_UNDERRUN_SHIFT = 30;
   static const int FL_DROPPED_SHIFT = 29;
-  static const int FL_END_OF_BURST_SHIFT = 28;
-  static const int FL_START_OF_BURST_SHIFT = 27;
+  static const int FL_END_OF_BURST_SHIFT = 27;
+  static const int FL_START_OF_BURST_SHIFT = 28;
   
   static const int RSSI_MASK = 0x3f;
   static const int RSSI_SHIFT = 21;
@@ -66,6 +86,50 @@
   static const int PAYLOAD_LEN_MASK = 0x1ff;
   static const int PAYLOAD_LEN_SHIFT = 0;
 
+  // Fixed size for opcode and length fields
+  static const int CS_FIXED_LEN = 2;
+
+  static const int CS_OPCODE_MASK = 0xff;
+  static const int CS_OPCODE_SHIFT = 24;
+
+  static const int CS_LEN_MASK = 0xff;
+  static const int CS_LEN_SHIFT = 16;
+
+  static const int CS_RID_MASK = 0x3f;
+  static const int CS_RID_SHIFT = 10;
+
+  static const int CS_PING_LEN = 2;
+  static const int CS_PINGVAL_MASK = 0x3ff;
+  static const int CS_PINGVAL_SHIFT = 0;
+
+  static const int CS_WRITEREG_LEN = 6;
+  static const int CS_WRITEREGMASKED_LEN = 10;
+  static const int CS_READREG_LEN = 2;
+  static const int CS_READREGREPLY_LEN = 6;
+  static const int CS_REGNUM_MASK = 0x3ff;
+  static const int CS_REGNUM_SHIFT = 0;
+
+  static const int CS_DELAY_LEN = 2;
+  static const int CS_DELAY_MASK = 0xffff;
+  static const int CS_DELAY_SHIFT = 0;
+
+  static const int CS_I2CADDR_MASK = 0x7f;
+  static const int CS_I2CADDR_SHIFT = 0;
+
+  static const int CS_I2CREAD_LEN = 3;
+  static const int CS_I2CREADBYTES_MASK = 0x7f;
+  static const int CS_I2CREADBYTES_SHIFT = 24;
+
+  static const int CS_SPIOPT_MASK = 0xffff;
+  static const int CS_SPIOPT_SHIFT = 0;
+  static const int CS_SPIFORMAT_MASK = 0xff;
+  static const int CS_SPIFORMAT_SHIFT = 16;
+  static const int CS_SPIENABLES_MASK = 0xff;
+  static const int CS_SPIENABLES_SHIFT = 24;
+  static const int CS_SPIREAD_LEN = 7;
+  static const int CS_SPINBYTES_MASK = 0xff;
+  static const int CS_SPINBYTES_SHIFT = 24;
+
 public:
   
   void set_timestamp(uint32_t timestamp){
@@ -77,10 +141,11 @@
     word0 |= 1<<FL_END_OF_BURST_SHIFT;
     d_word0 = host_to_usrp_u32(word0);
   }
-
+  
   void set_header(int flags, int chan, int tag, int payload_len){
     uint32_t word0 =  ((flags & FL_ALL_FLAGS)
                        | ((chan & CHAN_MASK) << CHAN_SHIFT)
+                       | (1 << 15) // CARRIER SENSE HACK
                        | ((tag & TAG_MASK) << TAG_SHIFT)
                        | ((payload_len & PAYLOAD_LEN_MASK) << 
PAYLOAD_LEN_SHIFT));
     d_word0 = host_to_usrp_u32(word0);
@@ -148,6 +213,23 @@
     return USB_PKT_SIZE;
   }
 
+  // C/S methods
+  bool align32();
+  bool cs_ping(long rid, long ping_val);
+  bool cs_ping_reply(long rid, long ping_val);
+  bool cs_write_reg(long reg_num, long val);
+  bool cs_write_reg_masked(long reg_num, long val, long mask);
+  bool cs_read_reg(long rid, long reg_num);
+  bool cs_read_reg_reply(long rid, long reg_num, long reg_val);
+  bool cs_delay(long ticks);
+  bool cs_i2c_write(long i2c_addr, uint8_t *i2c_data, size_t data_len);
+  bool cs_i2c_read(long rid, long i2c_addr, long n_bytes);
+  bool cs_i2c_read_reply(long rid, long i2c_addr, uint8_t *i2c_data, long 
i2c_data_len);
+  bool cs_spi_write(long enables, long format, long opt_header_bytes, uint8_t 
*spi_data, long spi_data_len);
+  bool cs_spi_read(long rid, long enables, long format, long opt_header_bytes, 
long n_bytes);
+  bool cs_spi_read_reply(long rid, uint8_t *spi_data, long spi_data_len);
+  int cs_len(int payload_offset);
+  pmt_t read_subpacket(int payload_offset);
 };
 
 #endif

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_interface.mbh
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_interface.mbh   
    2007-08-31 03:42:39 UTC (rev 6237)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_interface.mbh   
    2007-08-31 03:56:00 UTC (rev 6238)
@@ -55,7 +55,7 @@
 ;; ----------------------------------------------------------------
 ;; usrp-tx-cs
 ;;
-;; Handles interaction between the USB interface and RX interface
+;; Handles interaction between the USB interface and TX interface
 
 (define-protocol-class usrp-tx-cs
 

Modified: gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx.cc
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx.cc       
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx.cc       
2007-08-31 03:56:00 UTC (rev 6238)
@@ -34,22 +34,33 @@
 #include <fpga_regs_common.h>
 #include <stdio.h>
 
+#include <symbols_usrp_rx_cs.h>
+
 typedef usrp_inband_usb_packet transport_pkt;
 
 static const bool verbose = false;
 
-static pmt_t s_cmd_usrp_rx_start_reading = 
pmt_intern("cmd-usrp-rx-start-reading");
-static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read");
-
 usrp_rx::usrp_rx(mb_runtime *rt, const std::string &instance_name, pmt_t 
user_arg)
-  : mb_mblock(rt, instance_name, user_arg)
+  : mb_mblock(rt, instance_name, user_arg),
+    d_disk_write(false)
 {
   d_cs = define_port("cs", "usrp-rx-cs", true, mb_port::EXTERNAL);
   
+  //d_disk_write=true;
+  
+  if(d_disk_write) {
+    d_ofile.open("rx_data.dat",std::ios::binary|std::ios::out);
+    d_cs_ofile.open("rx_cs.dat",std::ios::binary|std::ios::out);
+  }
+
 }
 
 usrp_rx::~usrp_rx() 
 {
+  if(d_disk_write) {
+    d_ofile.close();
+    d_cs_ofile.close();
+  }
 }
 
 void 
@@ -89,15 +100,16 @@
   d_urx = 
     boost::any_cast<usrp_standard_rx *>(pmt_any_ref(pmt_nth(1, data)));
 
-  pmt_t v_pkt = pmt_make_u8vector(pkt_size, 0);
-  transport_pkt *pkt = 
-    (transport_pkt *) pmt_u8vector_writeable_elements(v_pkt, ignore);
-
   if(verbose)
     std::cout << "[usrp_rx] Waiting for packets..\n";
 
   // Read by 512 which is packet size and send them back up
   while(1) {
+
+    pmt_t v_pkt = pmt_make_u8vector(pkt_size, 0);
+    transport_pkt *pkt = 
+      (transport_pkt *) pmt_u8vector_writeable_elements(v_pkt, ignore);
+
     n_read = d_urx->read(pkt, pkt_size, &underrun);
 
     if(n_read != pkt_size) {
@@ -107,10 +119,23 @@
       return;
     }
 
+    if(underrun)
+      std::cout << "[usrp_rx] Underrun\n";
+
     d_cs->send(s_response_usrp_rx_read, 
                pmt_list3(PMT_NIL, PMT_T, v_pkt));
     if(verbose)
       std::cout << "[usrp_rx] Read 1 packet\n";
+    
+    if(d_disk_write) {
+      if(pkt->chan() == 0x1f)
+        d_cs_ofile.write((const char *)pkt, transport_pkt::max_pkt_size());
+      else
+        d_ofile.write((const char *)pkt, transport_pkt::max_pkt_size());
+
+      d_cs_ofile.flush();
+      d_ofile.flush();
+    }
   }
 }
 

Modified: gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx.h
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx.h        
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx.h        
2007-08-31 03:56:00 UTC (rev 6238)
@@ -22,6 +22,7 @@
 #define INCLUDED_USRP_RX_H
 
 #include <mb_mblock.h>
+#include <fstream>
 
 class usrp_standard_rx;
 
@@ -33,6 +34,10 @@
   mb_port_sptr         d_cs;
   usrp_standard_rx     *d_urx;
   
+  bool d_disk_write;
+  std::ofstream d_ofile;
+  std::ofstream d_cs_ofile;
+  
  public:
   usrp_rx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
   ~usrp_rx();

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx_stub.cc
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx_stub.cc  
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx_stub.cc  
2007-08-31 03:56:00 UTC (rev 6238)
@@ -36,14 +36,17 @@
 #include "ui_nco.h"
 #include <fstream>
 
+#include <symbols_usrp_rx_cs.h>
+
 typedef usrp_inband_usb_packet transport_pkt;
 
 static const bool verbose = false;
 
 bool usrp_rx_stop;
 
-static pmt_t s_cmd_usrp_rx_start_reading = 
pmt_intern("cmd-usrp-rx-start-reading");
-static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read");
+// Used for the fake control packet response code to send the responses back up
+// the RX.  The TX stub dumps responses in to this queue.
+std::queue<pmt_t> d_cs_queue;
 
 usrp_rx_stub::usrp_rx_stub(mb_runtime *rt, const std::string &instance_name, 
pmt_t user_arg)
   : mb_mblock(rt, instance_name, user_arg),
@@ -91,7 +94,7 @@
   if(pmt_eq(port_id, d_cs->port_symbol())) {
 
     if(verbose)
-      std::cout << "Got start\n";
+      std::cout << "[USRP_RX_STUB] Starting...\n";
     
     if(pmt_eqv(event, s_cmd_usrp_rx_start_reading))
       read_and_respond(data);
@@ -146,12 +149,34 @@
     
     d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_T, v_pkt));
 
+    // Now lets check the shared CS queue between the TX and RX stub.  Each
+    // element in a queue is a list where the first element is an invocation
+    // handle and the second element is a PMT u8 vect representation of the
+    // CS packet response which can just be passed transparently.
+    while(!d_cs_queue.empty()) {
+      
+      pmt_t cs_pkt = d_cs_queue.front();
+      d_cs_queue.pop();
+
+      pmt_t invocation_handle = pmt_nth(0, cs_pkt);
+      pmt_t v_pkt = pmt_nth(1, cs_pkt);
+
+      d_cs->send(s_response_usrp_rx_read,   
+                 pmt_list3(invocation_handle, 
+                           PMT_T, 
+                           v_pkt));  // Take the front CS pkt
+
+      
+      if(verbose)
+        std::cout << "[USRP_RX_STUB] Received CS response from TX stub\n";
+    }
+
   }
   
   usrp_rx_stop = false;
 
   if(verbose)
-    std::cout << "[USRP_TX_STUB] Got fake RX stop\n";
+    std::cout << "[USRP_RX_STUB] Got fake RX stop\n";
 
 }
 

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx_stub.h
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx_stub.h   
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_rx_stub.h   
2007-08-31 03:56:00 UTC (rev 6238)
@@ -26,8 +26,13 @@
 #include "usrp_standard.h"
 #include "ui_nco.h"
 #include <fstream>
+#include <queue>
+#include <usrp_inband_usb_packet.h>
 
+typedef usrp_inband_usb_packet transport_pkt;
+
 extern bool usrp_rx_stop;   // used to communicate a 'stop' to the RX stub
+extern std::queue<pmt_t> d_cs_queue;
 
 /*!
  * \brief Implements the low level usb interface to the USRP

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-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc   
2007-08-31 03:56:00 UTC (rev 6238)
@@ -29,55 +29,15 @@
 #include <vector>
 #include <usrp_usb_interface.h>
 
+#include <symbols_usrp_server_cs.h>
+#include <symbols_usrp_channel.h>
+#include <symbols_usrp_tx.h>
+#include <symbols_usrp_rx.h>
+#include <symbols_usrp_low_level_cs.h>
+#include <symbols_usrp_interface_cs.h>
+
 typedef usrp_inband_usb_packet transport_pkt;   // makes conversion to gigabit 
easy
 
-// FIXME We should machine generate these by a simple preprocessor run over 
this file
-//
-// These are all the messages that we expect to receive.
-//
-// We "intern" these here (make them into symbols) so that our
-// comparisions below are effectively pointer comparisons.
-
-static pmt_t s_cmd_allocate_channel = pmt_intern("cmd-allocate-channel");
-static pmt_t s_cmd_close = pmt_intern("cmd-close");
-static pmt_t s_cmd_deallocate_channel = pmt_intern("cmd-deallocate-channel");
-static pmt_t s_cmd_open = pmt_intern("cmd-open");
-static pmt_t s_cmd_start_recv_raw_samples = 
pmt_intern("cmd-start-recv-raw-samples");
-static pmt_t s_cmd_stop_recv_raw_samples = 
pmt_intern("cmd-stop-recv-raw-samples");
-static pmt_t s_cmd_to_control_channel = pmt_intern("cmd-to-control-channel");
-static pmt_t s_cmd_xmit_raw_frame  = pmt_intern("cmd-xmit-raw-frame");
-static pmt_t s_cmd_max_capacity  = pmt_intern("cmd-max-capacity");
-static pmt_t s_cmd_ntx_chan  = pmt_intern("cmd-ntx-chan");
-static pmt_t s_cmd_nrx_chan  = pmt_intern("cmd-nrx-chan");
-static pmt_t s_cmd_current_capacity_allocation  = 
pmt_intern("cmd-current-capacity-allocation");
-static pmt_t s_response_allocate_channel = 
pmt_intern("response-allocate-channel");
-static pmt_t s_response_close = pmt_intern("response-close");
-static pmt_t s_response_deallocate_channel = 
pmt_intern("response-deallocate-channel");
-static pmt_t s_response_from_control_channel = 
pmt_intern("response-from-control-channel");
-static pmt_t s_response_open = pmt_intern("response-open");
-static pmt_t s_response_recv_raw_samples = 
pmt_intern("response-recv-raw-samples");
-static pmt_t s_response_xmit_raw_frame = pmt_intern("response-xmit-raw-frame");
-static pmt_t s_response_max_capacity = pmt_intern("response-max-capacity");
-static pmt_t s_response_ntx_chan = pmt_intern("response-ntx-chan");
-static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan");
-static pmt_t s_response_current_capacity_allocation  = 
pmt_intern("response-current-capacity-allocation");
-
-// USRP signal set
-static pmt_t s_cmd_usrp_open = pmt_intern("cmd-usrp-open");
-static pmt_t s_cmd_usrp_close = pmt_intern("cmd-usrp-close");
-static pmt_t s_cmd_usrp_write = pmt_intern("cmd-usrp-write");
-static pmt_t s_cmd_usrp_ntx_chan = pmt_intern("cmd-usrp-ntx-chan");
-static pmt_t s_cmd_usrp_nrx_chan = pmt_intern("cmd-usrp-nrx-chan");
-static pmt_t s_cmd_usrp_start_reading = pmt_intern("cmd-usrp-start-reading");
-static pmt_t s_cmd_usrp_stop_reading = pmt_intern("cmd-usrp-stop-reading");
-static pmt_t s_response_usrp_ntx_chan = pmt_intern("response-usrp-ntx-chan");
-static pmt_t s_response_usrp_nrx_chan = pmt_intern("response-usrp-nrx-chan");
-static pmt_t s_response_usrp_open = pmt_intern("response-usrp-open");
-static pmt_t s_response_usrp_close = pmt_intern("response-usrp-close");
-static pmt_t s_response_usrp_write = pmt_intern("response-usrp-write");
-static pmt_t s_response_usrp_read = pmt_intern("response-usrp-read");
-
-
 const static bool verbose = false;
 
 static std::string
@@ -137,6 +97,24 @@
 
   d_rx_chan_mask = 0;
 
+  // Initialize request ID's to 0
+  d_op_ping_fixed_rid = 0;
+  d_op_read_reg_rid = 0;
+  d_op_i2c_read_rid = 0;
+  d_op_spi_read_rid = 0;
+
+  for(int i=0; i < D_OP_PING_FIXED_MAX_RID; i++)
+    d_op_ping_fixed_owners.push_back(PMT_NIL);
+
+  for(int i=0; i < D_OP_READ_REG_MAX_RID; i++)
+    d_op_read_reg_owners.push_back(PMT_NIL);
+
+  for(int i=0; i < D_OP_I2C_READ_MAX_RID; i++)
+    d_op_i2c_read_owners.push_back(PMT_NIL);
+  
+  for(int i=0; i < D_OP_SPI_READ_MAX_RID; i++)
+    d_op_spi_read_owners.push_back(PMT_NIL);
+
   //d_fake_rx=true;
 }
 
@@ -184,7 +162,7 @@
   if(!pmt_eq(event, pmt_intern("%shutdown")))
     invocation_handle = pmt_nth(0, data);
 
-  if (verbose){
+  if (0){
     std::cout << "[USRP_SERVER] event: " << event << std::endl;
     std::cout << "[USRP_SERVER] port_id: " << port_id << std::endl;
   }
@@ -238,6 +216,11 @@
       long channel = pmt_to_long(pmt_nth(2, data));
       long port;
 
+      // Do not report back responses if they were generated from a
+      // command packet
+      if(channel == 0x1f)
+        return;
+
       // Find the port through the owner of the channel
       if((port = tx_port_index(d_chaninfo_tx[channel].owner)) !=-1 )
         d_tx[port]->send(s_response_xmit_raw_frame, 
@@ -270,7 +253,7 @@
     d_defer_queue.push(msg);
     return;
   }
-
+  
   //--------- CONTROL / STATUS ------------//
   if (pmt_eq(port_id, d_cs->port_symbol())){
     
@@ -413,7 +396,21 @@
       handle_cmd_xmit_raw_frame(d_tx[port], d_chaninfo_tx, data);
       return;
     }
+    
+    //-------------- CONTROL PACKET -----------------/
+    if (pmt_eq(event, s_cmd_to_control_channel)) {
+      
+      if(!d_opened) { 
+        d_tx[port]->send(s_response_xmit_raw_frame, 
+                         pmt_list2(invocation_handle, PMT_F));
+        return;
+      }
+      
+      handle_cmd_to_control_channel(d_tx[port], d_chaninfo_tx, data);
+      return;
 
+    }
+
     goto unhandled;
   }
 
@@ -665,6 +662,326 @@
   return;
 }
 
+void usrp_server::handle_cmd_to_control_channel(mb_port_sptr port, 
std::vector<struct channel_info> &chan_info, pmt_t data) 
+{
+
+  pmt_t invocation_handle = pmt_nth(0, data);
+  pmt_t subpackets = pmt_nth(1, data);
+
+  long n_subpkts = pmt_length(subpackets);
+  long curr_subpkt = 0;
+
+  size_t psize;
+  long payload_len = 0;
+  long channel = 0x1f;
+
+  // 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
+  // which contains the USB packets for bursting over the bus.  However to do
+  // this the packets subpackets would need to be parsed twice and their sizes
+  // would need to be determined.
+  //
+  // 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.
+  //
+  // 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);
+    payload_len = 0;
+    
+    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)) {
+
+      long urid     = pmt_to_long(pmt_nth(0, subp_data));
+      long pingval  = pmt_to_long(pmt_nth(1, subp_data));
+
+      // USRP server sets request ID's to keep track of which application gets
+      // what response back.  We do not handle wrap around, if we wrap before 
we
+      // got responses then they will be lost.  The higher 3 bits will be the
+      // user specified RID value, and the lower 3 bits will be the USRP server
+      // marking.
+      long srid = d_op_ping_fixed_rid++ % D_OP_PING_FIXED_MAX_RID;
+      long rid = (
+          ((urid & 0x07) << 3)
+        | ((srid & 0x07)));
+
+      // We use a vector to store the owner of the ping request and will use it
+      // to send the request on any RX port they own.  There is currently no 
way
+      // for the requester to specify the RX port to receive the response on.
+      d_op_ping_fixed_owners[srid] = port->port_symbol();
+
+      // Adds a ping after the previous command in the pkt
+      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[srid] = PMT_NIL;
+        d_op_ping_fixed_rid--;
+
+        goto new_packet;
+      }
+
+      if(verbose)
+        std::cout << "[USRP_SERVER] Received ping command request"
+                  << " assigning RID " << srid << std::endl;
+
+    }
+  
+    //----------- WRITE REG ---------------//
+    if(pmt_eq(subp_cmd, s_op_write_reg)) {
+      
+      long reg_num = pmt_to_long(pmt_nth(0, subp_data));
+      long val = pmt_to_long(pmt_nth(1, subp_data));
+
+      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 "
+                  << "("
+                  << "Reg: " << reg_num << ", "
+                  << "Val: " << val
+                  << ")\n";
+    }
+    
+    //------- WRITE REG MASKED ----------//
+    if(pmt_eq(subp_cmd, s_op_write_reg_masked)) {
+      
+      long reg_num = pmt_to_long(pmt_nth(0, subp_data));
+      long val = pmt_to_long(pmt_nth(1, subp_data));
+      long mask = pmt_to_long(pmt_nth(2, subp_data));
+
+      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";
+    }
+    
+    //------------ READ REG --------------//
+    if(pmt_eq(subp_cmd, s_op_read_reg)) {
+      
+      long urid     = pmt_to_long(pmt_nth(0, subp_data));
+      long reg_num  = pmt_to_long(pmt_nth(1, subp_data));
+
+      long srid = d_op_read_reg_rid++ % D_OP_READ_REG_MAX_RID;
+      long rid = (
+          ((urid & 0x07) << 3)
+        | ((srid & 0x07)));
+
+      d_op_read_reg_owners[srid] = 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[srid] = PMT_NIL;
+        d_op_read_reg_rid--;
+        
+        goto new_packet;
+      }
+      
+      if(verbose)
+        std::cout << "[USRP_SERVER] Received read register request"
+                  << " assigning RID " << srid << std::endl;
+    }
+    
+    //------------ DELAY --------------//
+    if(pmt_eq(subp_cmd, s_op_delay)) {
+
+      long ticks = pmt_to_long(pmt_nth(0, subp_data));
+
+      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 "
+                  << ticks << " ticks\n";
+    }
+
+    //--------- I2C WRITE -----------//
+    // FIXME: could check that byte count does not exceed 2^8 which
+    // is the max length in the subpacket for # of bytes to read.
+    if(pmt_eq(subp_cmd, s_op_i2c_write)) {
+      
+      long i2c_addr = pmt_to_long(pmt_nth(0, subp_data));
+      pmt_t data = pmt_nth(1, subp_data);
+
+      // Get a readable address to the data which also gives us the length
+      size_t data_len;
+      uint8_t *i2c_data = (uint8_t *) pmt_u8vector_writeable_elements(data, 
data_len);
+
+      // Make the USB packet
+      if(!pkt->cs_i2c_write(i2c_addr, i2c_data, data_len))
+      {
+        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 I2C write\n";
+    }
+  
+    //----------- I2C Read -------------//
+    if(pmt_eq(subp_cmd, s_op_i2c_read)) {
+      
+      long urid       = pmt_to_long(pmt_nth(0, subp_data));
+      long i2c_addr   = pmt_to_long(pmt_nth(1, subp_data));
+      long i2c_bytes  = pmt_to_long(pmt_nth(2, subp_data));
+
+      long srid = d_op_i2c_read_rid++ % D_OP_I2C_READ_MAX_RID;
+      long rid = (
+          ((urid & 0x07) << 3)
+        | ((srid & 0x07)));
+
+      d_op_i2c_read_owners[srid] = port->port_symbol();
+
+      if(!pkt->cs_i2c_read(rid, i2c_addr, i2c_bytes))
+      {
+        
+        d_cs_usrp->send(s_cmd_usrp_write, 
+                        pmt_list3(invocation_handle, 
+                                  pmt_from_long(channel), 
+                                  v_packet));
+
+        d_op_i2c_read_owners[srid] = PMT_NIL;
+        d_op_i2c_read_rid--;
+
+        goto new_packet;
+      }
+      
+      if(verbose)
+        std::cout << "[USRP_SERVER] Received I2C read\n";
+    }
+    
+    //--------- SPI WRITE -----------//
+    if(pmt_eq(subp_cmd, s_op_spi_write)) {
+      
+      long enables = pmt_to_long(pmt_nth(0, subp_data));
+      long format = pmt_to_long(pmt_nth(1, subp_data));
+      long opt = pmt_to_long(pmt_nth(2, subp_data));
+      pmt_t data = pmt_nth(3, subp_data);
+
+      // Get a readable address to the data which also gives us the length
+      size_t data_len;
+      uint8_t *spi_data = (uint8_t *) pmt_u8vector_writeable_elements(data, 
data_len);
+
+      // Make the USB packet
+      if(!pkt->cs_spi_write(enables, format, opt, spi_data, data_len))
+      {
+        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 SPI write\n";
+    }
+    
+    //--------- SPI READ -----------//
+    if(pmt_eq(subp_cmd, s_op_spi_read)) {
+      
+      long urid     = pmt_to_long(pmt_nth(0, subp_data));
+      long enables  = pmt_to_long(pmt_nth(1, subp_data));
+      long format   = pmt_to_long(pmt_nth(2, subp_data));
+      long opt      = pmt_to_long(pmt_nth(3, subp_data));
+      long n_bytes  = pmt_to_long(pmt_nth(4, subp_data));
+      
+      // Generate an RID for the READ
+      long srid = d_op_spi_read_rid % D_OP_SPI_READ_MAX_RID;
+      long rid = (
+          ((urid & 0x07) << 3)
+        | ((srid & 0x07)));
+      
+      d_op_spi_read_owners[srid] = port->port_symbol();
+
+      // Make the USB packet
+      if(!pkt->cs_spi_read(rid, enables, format, opt, n_bytes))
+      {
+        d_cs_usrp->send(s_cmd_usrp_write, 
+                        pmt_list3(invocation_handle, 
+                                  pmt_from_long(channel), 
+                                  v_packet));
+        
+        // Return the rid
+        d_op_spi_read_owners[srid] = PMT_NIL;
+        d_op_spi_read_rid--;
+
+        goto new_packet;
+      }
+      
+      if(verbose)
+        std::cout << "[USRP_SERVER] Received SPI read\n";
+    }
+
+    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;
+}
+
 void
 usrp_server::handle_cmd_start_recv_raw_samples(mb_port_sptr port, 
std::vector<struct channel_info> &chan_info, pmt_t data)
 {
@@ -754,9 +1071,6 @@
   size_t n_bytes;
   size_t ignore;
 
-  if(verbose)
-    std::cout << "[USRP_SERVER] Received raw samples\n";
-
   if (d_fake_rx) {
 
     pmt_t pkt = pmt_nth(2, data);
@@ -779,24 +1093,217 @@
   long payload_len = pkt->payload_len();
   long port;
 
+  // Ignore packets which seem to have incorrect size or size 0
+  if(payload_len > pkt->max_payload() || payload_len == 0)
+    return;
+  
+  // If the packet is a C/S packet, parse it separately
+  if(channel == 0x1f) {
+    parse_control_pkt(invocation_handle, pkt);
+    return;
+  }
+
   if((port = rx_port_index(d_chaninfo_rx[channel].owner)) == -1)
     return; // Don't know where to send the sample... possibility on abrupt 
close
-  
+    
   pmt_t v_samples = pmt_make_u8vector(payload_len, 0);
   uint8_t *samples = pmt_u8vector_writeable_elements(v_samples, ignore);
   
   memcpy(samples, pkt->payload(), payload_len);
 
-  d_cs->send(s_response_recv_raw_samples,
-             pmt_list5(invocation_handle,
-                       status,
-                       v_samples,
-                       pmt_from_long(pkt->timestamp()),
-                       PMT_NIL));
+  // Build a properties dictionary to store things such as the RSSI
+  pmt_t properties =  pmt_make_dict();
+
+  pmt_dict_set(properties,
+               pmt_intern("rssi"),
+               pmt_from_long(pkt->rssi()));
+
+  d_rx[port]->send(s_response_recv_raw_samples,
+                   pmt_list5(invocation_handle,
+                             status,
+                             v_samples,
+                             pmt_from_long(pkt->timestamp()),
+                             properties));
   return;
 }
 
 void
+usrp_server::parse_control_pkt(pmt_t invocation_handle, transport_pkt *pkt)
+{
+
+  long payload_len = pkt->payload_len();
+  long curr_payload = 0;
+  long port;
+  
+  // We dispatch based on the control packet type, however we can extract the
+  // opcode and the length immediately which is consistent in all responses.
+  //
+  // Since each control packet can have multiple responses, we keep reading the
+  // lengths of each subpacket until we reach the payload length.  
+  while(curr_payload < payload_len) {
+
+    pmt_t sub_packet = pkt->read_subpacket(curr_payload);
+    pmt_t op_symbol = pmt_nth(0, sub_packet);
+
+    int len = pkt->cs_len(curr_payload);
+
+    if(verbose)
+      std::cout << "[USRP_SERVER] Parsing subpacket " 
+                << op_symbol << " ... length " << len << std::endl;
+
+    //----------------- PING RESPONSE ------------------//
+    if(pmt_eq(op_symbol, s_op_ping_fixed_reply)) {
+
+      long rid      = pmt_to_long(pmt_nth(1, sub_packet));
+      pmt_t pingval = pmt_nth(2, sub_packet);
+
+      long urid = (rid >> 3) & 0x7;
+      long srid = rid & 0x7;
+      
+      if(verbose)
+        std::cout << "[USRP_SERVER] Found ping response "
+                  << "("
+                  << "URID: " << urid << ", "
+                  << "SRID: " << srid << ", "
+                  << "VAL: " << pingval 
+                  << ")\n";
+      
+      // Do some bounds checking incase of bogus/corrupt responses
+      if(srid > D_OP_PING_FIXED_MAX_RID)
+        return;
+
+      pmt_t owner = d_op_ping_fixed_owners[srid];
+
+      // FIXME: should be 1 response for all subpackets here ?
+      if((port = tx_port_index(owner)) != -1)
+        d_tx[port]->send(s_response_from_control_channel,
+                         pmt_list4(invocation_handle,
+                                   PMT_T,
+                                   pmt_list2(s_op_ping_fixed_reply, // subp
+                                             pmt_list2(pmt_from_long(urid), 
+                                                       pingval)),
+                                   pmt_from_long(pkt->timestamp())));
+    }
+    
+    //----------------- READ REG RESPONSE ------------------//
+    else if(pmt_eq(op_symbol, s_op_read_reg_reply)) {
+
+      long rid      = pmt_to_long(pmt_nth(1, sub_packet));
+      pmt_t reg_num = pmt_nth(2, sub_packet);
+      pmt_t reg_val = pmt_nth(3, sub_packet);
+
+      long urid = (rid >> 3) & 0x7;
+      long srid = rid & 0x7;
+      
+      if(verbose)
+        std::cout << "[USRP_SERVER] Found read register response "
+                  << "("
+                  << "URID: " << urid << ", "
+                  << "SRID: " << srid << ", "
+                  << "REG: " << reg_num << ", "
+                  << "VAL: " << reg_val 
+                  << ")\n";
+
+      // Do some bounds checking to avoid seg faults
+      if(srid > D_OP_READ_REG_MAX_RID)
+        return;
+      
+      pmt_t owner = d_op_read_reg_owners[srid];
+
+      // FIXME: should be 1 response for all subpackets here ?
+      if((port = tx_port_index(owner)) != -1)
+        d_tx[port]->send(s_response_from_control_channel,
+                         pmt_list4(invocation_handle,
+                                   PMT_T,
+                                   pmt_list2(s_op_read_reg_reply, // subp
+                                             pmt_list3(pmt_from_long(urid), 
+                                                       reg_num, 
+                                                       reg_val)),
+                                   pmt_from_long(pkt->timestamp())));
+    }
+
+    //------------------ I2C READ REPLY -------------------//
+    else if(pmt_eq(op_symbol, s_op_i2c_read_reply)) {
+
+      long rid        = pmt_to_long(pmt_nth(1, sub_packet));
+      pmt_t i2c_addr  = pmt_nth(2, sub_packet);
+      pmt_t i2c_data  = pmt_nth(3, sub_packet);
+
+      long urid = (rid >> 3) & 0x7;
+      long srid = rid & 0x7;
+
+      if(verbose)
+        std::cout << "[USRP_SERVER] Found i2c read reply "
+                  << "("
+                  << "URID: " << urid << ", "
+                  << "SRID: " << srid << ", "
+                  << "Addr: " << i2c_addr << ", "
+                  << "Data: " << i2c_data
+                  << ")\n";
+      
+      // Do some bounds checking to avoid seg faults
+      if(srid > D_OP_I2C_READ_MAX_RID)
+        return;
+
+      pmt_t owner = d_op_i2c_read_owners[srid];
+
+      if((port = tx_port_index(owner)) != -1)
+        d_tx[port]->send(s_response_from_control_channel,
+                         pmt_list4(invocation_handle,
+                                   PMT_T,
+                                   pmt_list2(s_op_i2c_read_reply,
+                                             pmt_list3(pmt_from_long(urid), 
+                                                       i2c_addr,
+                                                       i2c_data)),
+                                   pmt_from_long(pkt->timestamp())));
+    }
+
+    //------------------ SPI READ REPLY -------------------//
+    else if(pmt_eq(op_symbol, s_op_spi_read_reply)) {
+      
+      long rid        = pmt_to_long(pmt_nth(1, sub_packet));
+      pmt_t spi_data  = pmt_nth(2, sub_packet);
+      
+      long urid = (rid >> 3) & 0x7;
+      long srid = rid & 0x7;
+
+      if(verbose)
+        std::cout << "[USRP_SERVER] Found SPI read reply "
+                  << "("
+                  << "URID: " << urid << ", "
+                  << "SRID: " << srid << ", "
+                  << "Data: " << spi_data
+                  << ")\n";
+
+      // Bounds check the RID
+      if(srid > D_OP_SPI_READ_MAX_RID)
+        return;
+
+      pmt_t owner = d_op_spi_read_owners[srid];
+
+      if((port = tx_port_index(owner)) != -1)
+        d_tx[port]->send(s_response_from_control_channel,
+                         pmt_list4(invocation_handle,
+                                   PMT_T,
+                                   pmt_list2(s_op_spi_read_reply,
+                                             pmt_list2(pmt_from_long(urid), 
+                                                       spi_data)),
+                                   pmt_from_long(pkt->timestamp())));
+    }
+
+    // Each subpacket has an unaccounted for 2 bytes which is the opcode
+    // and the length field
+    curr_payload += len + 2;
+    
+    // All subpackets are 32-bit aligned
+    int align_offset = 4 - (curr_payload % 4);
+
+    if(align_offset != 4)
+      curr_payload += align_offset;
+  }
+}
+
+void
 usrp_server::recall_defer_queue()
 {
 
@@ -825,7 +1332,7 @@
   pmt_t invocation_handle = pmt_nth(1, signal_info);
 
   // not a valid channel number?
-  if(channel >= chan_info.size()) {
+  if(channel >= (long)chan_info.size() && channel != 0x1f) {
     port->send(response_signal, 
                pmt_list2(invocation_handle, 
                          pmt_from_long(CHANNEL_INVALID)));

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h    
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h    
2007-08-31 03:56:00 UTC (rev 6238)
@@ -25,7 +25,10 @@
 #include <vector>
 #include <queue>
 #include <fstream>
+#include <usrp_inband_usb_packet.h>
 
+typedef usrp_inband_usb_packet transport_pkt;   // makes conversion to gigabit 
easy
+
 /*!
  * \brief Implements the lowest-level mblock usb_interface to the USRP
  */
@@ -55,6 +58,23 @@
   long d_ntx_chan;
   long d_nrx_chan;
 
+  // USRP server assigns and keeps track of request IDs.  
+  long d_op_ping_fixed_rid;
+  static const long D_OP_PING_FIXED_MAX_RID = 8;
+  std::vector<pmt_t> d_op_ping_fixed_owners;
+  
+  long d_op_read_reg_rid;
+  static const long D_OP_READ_REG_MAX_RID = 8;
+  std::vector<pmt_t> d_op_read_reg_owners;
+
+  long d_op_i2c_read_rid;
+  static const long D_OP_I2C_READ_MAX_RID = 8;
+  std::vector<pmt_t> d_op_i2c_read_owners;
+
+  long d_op_spi_read_rid;
+  static const long D_OP_SPI_READ_MAX_RID = 8;
+  std::vector<pmt_t> d_op_spi_read_owners;
+
   struct channel_info {
     long assigned_capacity;   // the capacity currently assignedby the channel
     pmt_t owner;              // port ID of the owner of the channel
@@ -92,6 +112,7 @@
   void handle_cmd_allocate_channel(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   void handle_cmd_deallocate_channel(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   void handle_cmd_xmit_raw_frame(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
+  void handle_cmd_to_control_channel(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   void handle_cmd_start_recv_raw_samples(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   void handle_cmd_stop_recv_raw_samples(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   int rx_port_index(pmt_t port_id);
@@ -101,6 +122,7 @@
   void reset_channels();
   void handle_response_usrp_read(pmt_t data);
   bool check_valid(mb_port_sptr port, long channel, std::vector<struct 
channel_info> &chan_info, pmt_t signal_info);
+  void parse_control_pkt(pmt_t invocation_handle, transport_pkt *pkt);
 };
 
 #endif /* INCLUDED_USRP_SERVER_H */

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.mbh
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.mbh  
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.mbh  
2007-08-31 03:56:00 UTC (rev 6238)
@@ -127,7 +127,7 @@
 
   (:incoming
 
-   (response-from-control-channel invocation-handle status list-of-subpackets)
+   (response-from-control-channel invocation-handle status list-of-subpackets 
timestamp)
 
    )
   )

Modified: gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx.cc
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx.cc       
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx.cc       
2007-08-31 03:56:00 UTC (rev 6238)
@@ -32,22 +32,32 @@
 #include <usrp_standard.h>
 #include <stdio.h>
 
+#include <symbols_usrp_tx_cs.h>
+
 typedef usrp_inband_usb_packet transport_pkt;
 
 static const bool verbose = false;
 
-static pmt_t s_cmd_usrp_tx_write = pmt_intern("cmd-usrp-tx-write");
-static pmt_t s_response_usrp_tx_write = pmt_intern("response-usrp-tx-write");
-
 usrp_tx::usrp_tx(mb_runtime *rt, const std::string &instance_name, pmt_t 
user_arg)
-  : mb_mblock(rt, instance_name, user_arg)
+  : mb_mblock(rt, instance_name, user_arg),
+    d_disk_write(false)
 {
   d_cs = define_port("cs", "usrp-tx-cs", true, mb_port::EXTERNAL);
   
+  //d_disk_write=true;
+  
+  if(d_disk_write) {
+    d_ofile.open("tx_data.dat",std::ios::binary|std::ios::out);
+    d_cs_ofile.open("tx_cs.dat",std::ios::binary|std::ios::out);
+  }
 }
 
 usrp_tx::~usrp_tx() 
 {
+  if(d_disk_write) {
+    d_ofile.close();
+    d_cs_ofile.close();
+  }
 }
 
 void 
@@ -104,7 +114,24 @@
     d_cs->send(s_response_usrp_tx_write,
               pmt_list3(invocation_handle, PMT_F, channel));
   }
+    
+  long n_packets = 
+    static_cast<long>(std::ceil(n_bytes / 
(double)transport_pkt::max_pkt_size()));
 
+  for(int i=0; i < n_packets; i++) {
+    
+    if(d_disk_write) {
+      if(pkts[i].chan() == 0x1f)
+        d_cs_ofile.write((const char *)&pkts[i], 
transport_pkt::max_pkt_size());
+      else
+        d_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size());
+
+      d_cs_ofile.flush();
+      d_ofile.flush();
+    }
+  }
+
+
   return;
 }
 

Modified: gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx.h
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx.h        
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx.h        
2007-08-31 03:56:00 UTC (rev 6238)
@@ -22,6 +22,7 @@
 #define INCLUDED_USRP_TX_H
 
 #include <mb_mblock.h>
+#include <fstream>
 
 class usrp_standard_tx;
 
@@ -33,6 +34,10 @@
   mb_port_sptr         d_cs;
   usrp_standard_tx     *d_utx;
   
+  bool d_disk_write;
+  std::ofstream d_ofile;
+  std::ofstream d_cs_ofile;
+  
  public:
   usrp_tx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
   ~usrp_tx();

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx_stub.cc
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx_stub.cc  
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx_stub.cc  
2007-08-31 03:56:00 UTC (rev 6238)
@@ -33,14 +33,14 @@
 #include "usrp_standard.h"
 #include <stdio.h>
 #include <fstream>
+#include <usrp_rx_stub.h>
 
+#include <symbols_usrp_tx_cs.h>
+
 typedef usrp_inband_usb_packet transport_pkt;
 
 static const bool verbose = false;
 
-static pmt_t s_cmd_usrp_tx_write = pmt_intern("cmd-usrp-tx-write");
-static pmt_t s_response_usrp_tx_write = pmt_intern("response-usrp-tx-write");
-
 usrp_tx_stub::usrp_tx_stub(mb_runtime *rt, const std::string &instance_name, 
pmt_t user_arg)
   : mb_mblock(rt, instance_name, user_arg),
     d_disk_write(false)
@@ -49,14 +49,18 @@
   
   //d_disk_write=true;
   
-  if(d_disk_write)
-    d_ofile.open("pdump.dat",std::ios::binary|std::ios::out);
+  if(d_disk_write) {
+    d_ofile.open("tx_stub_data.dat",std::ios::binary|std::ios::out);
+    d_cs_ofile.open("tx_stub_cs.dat",std::ios::binary|std::ios::out);
+  }
 }
 
 usrp_tx_stub::~usrp_tx_stub() 
 {
-  if(d_disk_write)
+  if(d_disk_write) {
     d_ofile.close();
+    d_cs_ofile.close();
+  }
 }
 
 void 
@@ -91,13 +95,25 @@
 
   size_t n_bytes;
 
-  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_pkt_size()));
-    
-    for(long i=0; i<n_packets; i++)  
-      d_ofile.write((const char*) pkts[i].payload(), pkts[i].payload_len());
-    
+  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_pkt_size()));
+  
+  // Parse the packets looking for C/S packets and dump them to a disk if
+  // necessary
+  for(long i=0; i<n_packets; i++) {
+
+    if(d_disk_write) {
+      if(pkts[i].chan() == 0x1f)
+        d_cs_ofile.write((const char *)&pkts[i], 
transport_pkt::max_pkt_size());
+      else
+        d_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size());
+
+      d_cs_ofile.flush();
+      d_ofile.flush();
+    }
+
+    if(pkts[i].chan() == 0x1f)
+      parse_cs(invocation_handle, pkts[i]);
   }
 
   d_cs->send(s_response_usrp_tx_write,
@@ -106,4 +122,223 @@
   return;
 }
 
+void
+usrp_tx_stub::parse_cs(pmt_t invocation_handle, transport_pkt pkt)
+{
+  
+  long payload_len = pkt.payload_len();
+  long curr_payload = 0;
+      
+  size_t ignore;
+
+  // There is the possibility that the responses for a single USB packet full 
of
+  // CS packets will not fit back in a single USB packet, considering some
+  // responses are greater than their commands (read registers).
+ new_packet:
+  pmt_t v_pkt = pmt_make_u8vector(sizeof(transport_pkt), 0);
+  
+  transport_pkt *q_pkt =
+    (transport_pkt *) pmt_u8vector_writeable_elements(v_pkt, ignore);
+      
+  q_pkt->set_header(0, 0x1f, 0, 0);
+  q_pkt->set_timestamp(0xffffffff);
+
+  // We dispatch based on the control packet type, however we can extract the
+  // opcode and the length immediately which is consistent in all responses.
+  //
+  // Since each control packet can have multiple responses, we keep reading the
+  // lengths of each subpacket until we reach the payload length.  
+  while(curr_payload < payload_len) {
+
+    pmt_t sub_packet = pkt.read_subpacket(curr_payload);
+    pmt_t op_symbol = pmt_nth(0, sub_packet);
+
+    int len = pkt.cs_len(curr_payload);
+      
+    if(verbose)
+      std::cout << "[USRP_TX_STUB] Parsing subpacket " 
+                << op_symbol << " ... length " << len << std::endl;
+
+    //----------------- PING FIXED ------------------//
+    if(pmt_eq(op_symbol, s_op_ping_fixed)) {
+
+      long rid = pmt_to_long(pmt_nth(1, sub_packet));
+      long pingval = pmt_to_long(pmt_nth(2, sub_packet));
+
+      // Generate a reply and put it in the queue for the RX stub to read
+      if(!q_pkt->cs_ping_reply(rid, pingval))
+        goto new_packet;
+
+      if(verbose)
+        std::cout << "[USRP_TX_STUB] Generated ping response "
+                  << "("
+                  << "RID: " << rid << ", "
+                  << "VAL: " << pingval 
+                  << ")\n";
+    }
+
+    //----------------- READ REG ------------------//
+    if(pmt_eq(op_symbol, s_op_read_reg)) {
+
+      long rid = pmt_to_long(pmt_nth(1, sub_packet));
+      long reg_num = pmt_to_long(pmt_nth(2, sub_packet));
+      long reg_val = 0xdeef;
+
+      // Generate a reply and put it in the queue for the RX stub to read
+      if(!q_pkt->cs_read_reg_reply(rid, reg_num, reg_val))
+        goto new_packet;
+
+      if(verbose)
+        std::cout << "[USRP_TX_STUB] Generated read register response "
+                  << "("
+                  << "RID: " << rid << ", "
+                  << "REG: " << reg_num << ", "
+                  << "VAL: " << reg_val
+                  << ")\n";
+    }
+    
+    //----------------- DELAY ------------------//
+    if(pmt_eq(op_symbol, s_op_delay)) {
+
+      long ticks = pmt_to_long(pmt_nth(1, sub_packet));
+
+      if(verbose)
+        std::cout << "[USRP_TX_STUB] Received delay command "
+                  << "("
+                  << "Ticks: " << ticks
+                  << ")\n";
+    }
+
+    //----------------- WRITE REG ------------------//
+    if(pmt_eq(op_symbol, s_op_write_reg)) {
+
+      pmt_t reg_num = pmt_nth(1, sub_packet);
+      pmt_t reg_val = pmt_nth(2, sub_packet);
+
+      if(verbose)
+        std::cout << "[USRP_TX_STUB] Received write register command "
+                  << "("
+                  << "RegNum: " << reg_num << ", "
+                  << "Val: " << reg_val
+                  << ")\n";
+    }
+    
+    //----------------- WRITE REG MASK ---------------//
+    if(pmt_eq(op_symbol, s_op_write_reg_masked)) {
+
+      pmt_t reg_num = pmt_nth(1, sub_packet);
+      pmt_t reg_val = pmt_nth(2, sub_packet);
+      pmt_t mask    = pmt_nth(3, sub_packet);
+
+      if(verbose)
+        std::cout << "[USRP_TX_STUB] Received write register command "
+                  << "("
+                  << "RegNum: " << reg_num << ", "
+                  << "Val: " << reg_val << ", "
+                  << "Mask: " << mask
+                  << ")\n";
+    }
+
+    //---------------- I2C WRITE ------------------//
+    if(pmt_eq(op_symbol, s_op_i2c_write)) {
+      pmt_t i2c_addr  = pmt_nth(1, sub_packet);
+      pmt_t i2c_data  = pmt_nth(2, sub_packet);
+
+      if(verbose)
+        std::cout << "[USRP_TX_STUB] Received i2c write command "
+                  << "("
+                  << "Addr: " << i2c_addr << ", "
+                  << "Data: " << i2c_data
+                  << ")\n";
+    }
+
+    //---------------- I2C READ ------------------//
+    if(pmt_eq(op_symbol, s_op_i2c_read)) {
+      long rid       = pmt_to_long(pmt_nth(1, sub_packet));
+      long i2c_addr  = pmt_to_long(pmt_nth(2, sub_packet));
+      long i2c_bytes = pmt_to_long(pmt_nth(3, sub_packet));
+
+      // Create data to place as a response, filled with 0xff
+      size_t ignore;
+      pmt_t i2c_data = pmt_make_u8vector(i2c_bytes, 0xff);
+      uint8_t *w_data = (uint8_t *) pmt_u8vector_writeable_elements(i2c_data, 
ignore);
+
+      // Generate a reply and put it in the queue for the RX stub to read
+      if(!q_pkt->cs_i2c_read_reply(rid, i2c_addr, w_data, i2c_bytes))
+        goto new_packet;
+
+      if(verbose)
+        std::cout << "[USRP_TX_STUB] Received i2c read "
+                  << "("
+                  << "RID: " << rid << ", "
+                  << "Addr: " << i2c_addr << ", "
+                  << "Bytes: " << i2c_bytes
+                  << ")\n";
+    }
+    
+    //---------------- SPI WRITE ------------------//
+    if(pmt_eq(op_symbol, s_op_spi_write)) {
+      long enables  = pmt_to_long(pmt_nth(1, sub_packet));
+      long format   = pmt_to_long(pmt_nth(2, sub_packet));
+      long opt      = pmt_to_long(pmt_nth(3, sub_packet));
+      pmt_t data    = pmt_nth(4, sub_packet);
+
+      if(verbose)
+        std::cout << "[USRP_TX_STUB] Received spi write command "
+                  << "("
+                  << "Enables: " << enables << ", "
+                  << "Format: " << format << ", "
+                  << "Options: " << opt << ", "
+                  << "Data: " << data
+                  << ")\n";
+    }
+
+    //---------------- SPI READ ------------------//
+    if(pmt_eq(op_symbol, s_op_spi_read)) {
+      long rid      = pmt_to_long(pmt_nth(1, sub_packet));
+      long enables  = pmt_to_long(pmt_nth(2, sub_packet));
+      long format   = pmt_to_long(pmt_nth(3, sub_packet));
+      long opt      = pmt_to_long(pmt_nth(4, sub_packet));
+      long n_bytes  = pmt_to_long(pmt_nth(5, sub_packet));
+
+      // Create data to place as a fake response
+      size_t ignore;
+      pmt_t spi_data = pmt_make_u8vector(n_bytes, 0xff);
+      uint8_t *w_data = (uint8_t *) pmt_u8vector_writeable_elements(spi_data, 
ignore);
+
+      // Generate a reply and put it in the queue for the RX stub to read
+      if(!q_pkt->cs_spi_read_reply(rid, w_data, n_bytes))
+        goto new_packet;
+
+      if(verbose)
+        std::cout << "[USRP_TX_STUB] Received spi read command "
+                  << "("
+                  << "RID: " << rid << ", "
+                  << "Enables: " << enables << ", "
+                  << "Format: " << format << ", "
+                  << "Options: " << opt << ", "
+                  << "Bytes: " << n_bytes
+                  << ")\n";
+      
+    }
+
+    // Each subpacket has an unaccounted for 2 bytes which is the opcode
+    // and the length field
+    curr_payload += len + 2;
+
+    // All subpackets are 32-bit aligned
+    int align_offset = 4 - (curr_payload % 4);
+
+    if(align_offset != 4)
+      curr_payload += align_offset;
+
+  }
+
+  // If the packet has data in the payload, it needs queued
+  if(q_pkt->payload_len() > 0)
+    d_cs_queue.push(pmt_list2(invocation_handle, v_pkt));
+
+  return;
+}
+
 REGISTER_MBLOCK_CLASS(usrp_tx_stub);

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx_stub.h
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx_stub.h   
2007-08-31 03:42:39 UTC (rev 6237)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_tx_stub.h   
2007-08-31 03:56:00 UTC (rev 6238)
@@ -25,7 +25,10 @@
 #include <vector>
 #include "usrp_standard.h"
 #include <fstream>
+#include <usrp_inband_usb_packet.h>
 
+typedef usrp_inband_usb_packet transport_pkt;
+
 /*!
  * \brief Implements the low level usb interface to the USRP
  */
@@ -37,6 +40,7 @@
   usrp_standard_tx* d_utx;
   
   std::ofstream d_ofile;
+  std::ofstream d_cs_ofile;
 
   bool d_disk_write;
 
@@ -48,6 +52,7 @@
 
  private:
   void write(pmt_t data);
+  void parse_cs(pmt_t invocation_handle, transport_pkt pkt);
  
 };
   

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface.cc
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface.cc
    2007-08-31 03:42:39 UTC (rev 6237)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface.cc
    2007-08-31 03:56:00 UTC (rev 6238)
@@ -39,33 +39,21 @@
 
 typedef usrp_inband_usb_packet transport_pkt;
 
-static pmt_t s_cmd_usrp_open = pmt_intern("cmd-usrp-open");
-static pmt_t s_cmd_usrp_close = pmt_intern("cmd-usrp-close");
-static pmt_t s_cmd_usrp_write = pmt_intern("cmd-usrp-write");
-static pmt_t s_cmd_usrp_ntx_chan = pmt_intern("cmd-usrp-ntx-chan");
-static pmt_t s_cmd_usrp_nrx_chan = pmt_intern("cmd-usrp-nrx-chan");
-static pmt_t s_cmd_usrp_start_reading = pmt_intern("cmd-usrp-start-reading");
-static pmt_t s_cmd_usrp_stop_reading = pmt_intern("cmd-usrp-stop-reading");
-static pmt_t s_response_usrp_ntx_chan = pmt_intern("response-usrp-ntx-chan");
-static pmt_t s_response_usrp_nrx_chan = pmt_intern("response-usrp-nrx-chan");
-static pmt_t s_response_usrp_open = pmt_intern("response-usrp-open");
-static pmt_t s_response_usrp_close = pmt_intern("response-usrp-close");
-static pmt_t s_response_usrp_write = pmt_intern("response-usrp-write");
-static pmt_t s_response_usrp_read = pmt_intern("response-usrp-read");
+#include <symbols_usrp_interface_cs.h>
+#include <symbols_usrp_tx_cs.h>
+#include <symbols_usrp_rx_cs.h>
 
-// TX and RX signals
-static pmt_t s_cmd_usrp_rx_start_reading = 
pmt_intern("cmd-usrp-rx-start-reading");
-static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read");
-static pmt_t s_cmd_usrp_tx_write = pmt_intern("cmd-usrp-tx-write");
-static pmt_t s_response_usrp_tx_write = pmt_intern("response-usrp-tx-write");
-
 static const bool verbose = false;
 
 // 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_fake_usrp(false)
+  d_fake_usrp(false),
+  d_interp_tx(16),
+  d_interp_rx(16),
+  d_rf_freq(10e6),
+  d_rbf("inband_tx_rx.rbf")
 {
   // Dictionary for arguments to all of the components
   pmt_t usrp_dict = user_arg;
@@ -87,14 +75,55 @@
       }
     }
 
+    // Read the TX interpolations
+    if(pmt_t interp_tx = pmt_dict_ref(usrp_dict, 
+                                      pmt_intern("interp-tx"), 
+                                      PMT_NIL)) {
+      if(!pmt_eqv(interp_tx, PMT_NIL)) 
+        d_interp_tx = pmt_to_long(interp_tx);
+    }
+    
+    // Read the RX interpolations
+    if(pmt_t interp_rx = pmt_dict_ref(usrp_dict, 
+                                      pmt_intern("interp-rx"), 
+                                      PMT_NIL)) {
+      if(!pmt_eqv(interp_rx, PMT_NIL)) 
+        d_interp_rx = pmt_to_long(interp_rx);
+    }
+
+    // Read the RBF
+    if(pmt_t rbf = pmt_dict_ref(usrp_dict, 
+                                pmt_intern("rbf"), 
+                                PMT_NIL)) {
+      if(!pmt_eqv(rbf, PMT_NIL)) 
+        d_rbf = pmt_symbol_to_string(rbf);
+    }
+
+    // The RF center frequency
+    if(pmt_t rf_freq = pmt_dict_ref(usrp_dict, 
+                                pmt_intern("rf-freq"), 
+                                PMT_NIL)) {
+      if(!pmt_eqv(rf_freq, PMT_NIL)) 
+        d_rf_freq = pmt_to_long(rf_freq);
+    }
   }
   
   if (verbose) {
+    std::cout << "[USRP_USB_INTERFACE] Setting USRP RBF to " 
+              << d_rbf << std::endl;
+    
+    std::cout << "[USRP_USB_INTERFACE] Setting TX interpolation to " 
+              << d_interp_tx << std::endl;
+          
+    std::cout << "[USRP_USB_INTERFACE] Setting RX interpolation to " 
+              << d_interp_rx << std::endl;
+
     std::cout << "[USRP_USB_INTERFACE] Using TX interface: " 
               << tx_interface << "\n";
 
     std::cout << "[USRP_USB_INTERFACE] Using RX interface: " 
               << rx_interface << "\n";
+
   }
 
   d_cs = define_port("cs", "usrp-interface-cs", true, mb_port::EXTERNAL);      
@@ -114,7 +143,7 @@
   d_utx = NULL;
   d_urx = NULL;
   
-  //d_fpga_debug=true;   // WARNING: DO NOT ENABLE WITH D'BOARDS OTHER THAN 
BASIC TX/RX
+  d_fpga_debug=true;   // WARNING: DO NOT ENABLE WITH D'BOARDS OTHER THAN 
BASIC TX/RX
 
 }
 
@@ -218,7 +247,7 @@
   }
 
  unhandled:
-  std::cout << "[usrp_usb_interface] unhandled msg: " << msg << std::endl;
+  std::cout << "[USRP_USB_INTERFACE] unhandled msg: " << msg << std::endl;
 }
 
 void
@@ -238,16 +267,13 @@
 
   // Open up a standard RX and TX for communication with the USRP
    
-  //std::string rbf = "usrp_inband_usb.rbf";
-  std::string rbf = "";
-
   d_utx = usrp_standard_tx::make(which_usrp,
-                                32,            // 128/32 -> 4MS/s
-                                1,             // 1 channel
-                                -1,            // mux
-                                4096,          // USB block size
-                                16,            // nblocks for async transfers
-                                rbf
+                                d_interp_tx,
+                                1,                     // 1 channel
+                                -1,          // mux
+                                4096,        // USB block size
+                                16,          // nblocks for async transfers
+                                d_rbf
                                 );
   
   if(d_utx==0) {
@@ -258,7 +284,7 @@
     return;
   }
 
-  if(!d_utx->set_tx_freq (0,10e6)) {  // try setting center freq to 0
+  if(!d_utx->set_tx_freq (0,d_rf_freq)) {  // try setting center freq to 0
     if (verbose)
       std::cout << "[USRP_USB_INTERFACE] Failed to set center frequency on 
TX\n";
     reply_data = pmt_list2(invocation_handle, PMT_F);
@@ -273,12 +299,13 @@
 
   d_urx =
     usrp_standard_rx::make (which_usrp,
-                           16,         // interp = 4MS/s
-                           1,          // nchan
-                           -1,         // mux
-                           0,          // set blank mode to start
-                           4096,       // USB block size
-                           16);        // number of blocks for async transfers
+                           d_interp_rx,                
+                           1,                  // nchan
+                           -1,           // mux
+                           0,            // set blank mode to start
+                           4096,         // USB block size
+                           16,           // number of blocks for async 
transfers
+          d_rbf);
 
   if(!d_urx) {
     if (verbose)
@@ -288,7 +315,7 @@
     return;
   }
 
-  if(!d_urx->set_rx_freq (0, 10e6)) {
+  if(!d_urx->set_rx_freq (0, d_rf_freq)) {
     if (verbose)
       std::cout << "[usrp_server] Failed to set center frequency on RX\n";
     reply_data = pmt_list2(invocation_handle, PMT_F);
@@ -339,7 +366,7 @@
   pmt_t invocation_handle = pmt_nth(0, data);
   
   if(verbose)
-    std::cout << "[usrp_usb_interface] Starting RX...\n";
+    std::cout << "[USRP_USB_INTERFACE] Starting RX...\n";
 
   if(!d_fake_usrp)
     d_urx->start();
@@ -358,12 +385,12 @@
   
   if(!d_fake_usrp) {
     if(verbose)
-      std::cout << "[usrp_usb_interface] Stopping RX...\n";
+      std::cout << "[USRP_USB_INTERFACE] Stopping RX...\n";
     d_urx->stop();
   }
   else {
     if(verbose)
-      std::cout << "[usrp_usb_interface] Stopping fake RX...\n";
+      std::cout << "[USRP_USB_INTERFACE] Stopping fake RX...\n";
     usrp_rx_stop = true;  // extern to communicate with stub to wait
   }
 
@@ -381,7 +408,7 @@
   }
   
   if (verbose)
-    std::cout << "[usrp_usb_interface] Handling close request for USRP\n";
+    std::cout << "[USRP_USB_INTERFACE] Handling close request for USRP\n";
 
   delete d_utx;
   d_utx = 0;

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface.h
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface.h 
    2007-08-31 03:42:39 UTC (rev 6237)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface.h 
    2007-08-31 03:56:00 UTC (rev 6238)
@@ -46,6 +46,13 @@
 
   bool d_fake_usrp;
 
+  long d_interp_tx;
+  long d_interp_rx;
+
+  long d_rf_freq;
+
+  std::string d_rbf;
+
  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]