commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5643 - in gnuradio/branches/features/inband-usb: . us


From: eb
Subject: [Commit-gnuradio] r5643 - in gnuradio/branches/features/inband-usb: . usrp/host/apps usrp/host/lib/inband
Date: Sun, 3 Jun 2007 14:32:37 -0600 (MDT)

Author: eb
Date: 2007-06-03 14:32:36 -0600 (Sun, 03 Jun 2007)
New Revision: 5643

Added:
   gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_tx.cc
   gnuradio/branches/features/inband-usb/usrp/host/apps/ui_nco.h
   gnuradio/branches/features/inband-usb/usrp/host/apps/ui_sincos.c
   gnuradio/branches/features/inband-usb/usrp/host/apps/ui_sincos.h
Modified:
   gnuradio/branches/features/inband-usb/Makefile.common
   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/lib/inband/
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/gen_test_packets.py
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/test_usrp_inband.cc
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_interface.mbh
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
   gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.mbh
   
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_stub.cc
   
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface_stub.h
Log:
merged eb/ibu -r5616:5642 in features/inband-usb

Modified: gnuradio/branches/features/inband-usb/Makefile.common
===================================================================
--- gnuradio/branches/features/inband-usb/Makefile.common       2007-06-03 
20:13:15 UTC (rev 5642)
+++ gnuradio/branches/features/inband-usb/Makefile.common       2007-06-03 
20:32:36 UTC (rev 5643)
@@ -76,7 +76,9 @@
 USRP_INCLUDES = -I$(top_srcdir)/usrp/host/lib/legacy \
                -I$(top_srcdir)/usrp/host/lib/inband \
                -I$(top_srcdir)/usrp/firmware/include
-USRP_LA = $(top_builddir)/usrp/host/lib/legacy/libusrp.la
+USRP_LA = \
+       $(top_builddir)/usrp/host/lib/legacy/libusrp.la        \
+       $(top_builddir)/usrp/host/lib/inband/libusrp_inband.la
 
 # How to link the PMT library from inside the tree
 PMT_INCLUDES = -I$(top_srcdir)/pmt/src/lib


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_basic_rx
check_order_quickly
usrp_cal_dc_offset
   + 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


Modified: gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am    
2007-06-03 20:13:15 UTC (rev 5642)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am    
2007-06-03 20:32:36 UTC (rev 5643)
@@ -21,14 +21,18 @@
 
 include $(top_srcdir)/Makefile.common
 
-INCLUDES = $(USRP_INCLUDES) $(BOOST_CFLAGS)
+INCLUDES =     \
+       $(DEFINES) $(OMNITHREAD_INCLUDES) $(PMT_INCLUDES) $(MBLOCK_INCLUDES) \
+       $(USRP_INCLUDES) $(BOOST_CFLAGS) $(CPPUNIT_INCLUDES)
 
+
 bin_PROGRAMS =                         \
        usrper                          \
        usrp_cal_dc_offset              
 
 noinst_PROGRAMS =                      \
        check_order_quickly             \
+       test_usrp_inband_tx             \
        test_usrp_standard_rx           \
        test_usrp_standard_tx           
 
@@ -53,3 +57,7 @@
 
 usrp_cal_dc_offset_SOURCES     = usrp_cal_dc_offset.cc
 usrp_cal_dc_offset_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)
+

Copied: 
gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_tx.cc 
(from rev 5642, 
gnuradio/branches/developers/eb/ibu/usrp/host/apps/test_usrp_inband_tx.cc)
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_tx.cc 
                        (rev 0)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/test_usrp_inband_tx.cc 
2007-06-03 20:32:36 UTC (rev 5643)
@@ -0,0 +1,393 @@
+/* -*- 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 <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");
+
+
+class test_usrp_tx : public mb_mblock
+{
+  mb_port_sptr         d_tx;
+  mb_port_sptr         d_cs;
+  pmt_t                d_tx_chan;      // returned tx channel handle
+
+  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_tx(mb_runtime *runtime, const std::string &instance_name, pmt_t 
user_arg);
+  ~test_usrp_tx();
+  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_transmitting();
+  void build_and_send_next_frame();
+  void handle_xmit_response(pmt_t invocation_handle);
+  void enter_closing_channel();
+};
+
+test_usrp_tx::test_usrp_tx(mb_runtime *runtime, const std::string 
&instance_name, pmt_t user_arg)
+  : mb_mblock(runtime, instance_name, user_arg),
+    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_done_sending(false),
+    d_amplitude(16384)
+{ 
+  // std::cout << "[TEST_USRP_TX] Initializing...\n";
+  
+  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;
+
+  // 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();
+
+  if(fake_usrp_p)
+    pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"),
+                pmt_intern("usrp_usb_interface_stub"));
+
+  define_component("server", "usrp_server", usrp_server_dict);
+
+  connect("self", "tx0", "server", "tx0");
+  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_tx::~test_usrp_tx()
+{
+}
+
+void
+test_usrp_tx::initial_transition()
+{
+  open_usrp();
+}
+
+void
+test_usrp_tx::handle_message(mb_message_sptr msg)
+{
+  pmt_t        event = msg->signal();
+  pmt_t data = msg->data();
+
+  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)){
+      status = pmt_nth(1, data);
+      d_tx_chan = pmt_nth(2, data);
+
+      if (pmt_eq(status, PMT_T)){
+       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:
+  std::cout << "test_usrp_inband_tx: unhandled msg: " << msg
+           << "in state "<< d_state << std::endl;
+}
+
+
+void
+test_usrp_tx::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_tx::close_usrp()
+{
+  d_cs->send(s_cmd_close, pmt_list1(PMT_NIL));
+  d_state = CLOSING_USRP;
+}
+
+void
+test_usrp_tx::allocate_channel()
+{
+  long capacity = (long) 16e6;
+  d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, 
pmt_from_long(capacity)));
+  d_state = ALLOCATING_CHANNEL;
+}
+
+void
+test_usrp_tx::enter_transmitting()
+{
+  d_state = TRANSMITTING;
+  d_nsamples_xmitted = 0;
+
+  build_and_send_next_frame(); // fire off 4 to start pipeline
+  build_and_send_next_frame();
+  build_and_send_next_frame();
+  build_and_send_next_frame();
+}
+
+void
+test_usrp_tx::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 (0){
+      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++;
+}
+
+
+void
+test_usrp_tx::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_tx::enter_closing_channel()
+{
+  d_state = CLOSING_CHANNEL;
+  
+  d_tx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_tx_chan));
+}
+
+REGISTER_MBLOCK_CLASS(test_usrp_tx);
+
+
+// ----------------------------------------------------------------
+
+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_tx", PMT_F, &result);
+}

Copied: gnuradio/branches/features/inband-usb/usrp/host/apps/ui_nco.h (from rev 
5642, gnuradio/branches/developers/eb/ibu/usrp/host/apps/ui_nco.h)
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/ui_nco.h               
                (rev 0)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/ui_nco.h       
2007-06-03 20:32:36 UTC (rev 5643)
@@ -0,0 +1,202 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2002 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef INCLUDED_UI_NCO_H
+#define INCLUDED_UI_NCO_H
+
+
+#include <vector>
+#include <ui_sincos.h>
+#include <cmath>
+
+#include <complex>
+typedef std::complex<float>                    gr_complex;
+
+
+/*!
+ * \brief base class template for Numerically Controlled Oscillator (NCO)
+ */
+
+
+//FIXME  Eventually generalize this to fixed point
+
+template<class o_type, class i_type> 
+class ui_nco {
+public:
+  ui_nco () : phase (0), phase_inc(0) {}
+
+  virtual ~ui_nco () {}
+
+  // radians
+  void set_phase (double angle) {
+    phase = angle;
+  }
+
+  void adjust_phase (double delta_phase) {
+    phase += delta_phase;
+  }
+
+
+  // angle_rate is in radians / step
+  void set_freq (double angle_rate){
+    phase_inc = angle_rate;
+  }
+
+  // angle_rate is a delta in radians / step
+  void adjust_freq (double delta_angle_rate)
+  {
+    phase_inc += delta_angle_rate;
+  }
+
+  // increment current phase angle
+
+  void step () 
+  { 
+    phase += phase_inc; 
+    if (fabs (phase) > M_PI){
+      
+      while (phase > M_PI)
+       phase -= 2*M_PI;
+
+      while (phase < -M_PI)
+       phase += 2*M_PI;
+    }
+  }
+
+  void step (int n)
+  {
+    phase += phase_inc * n;
+    if (fabs (phase) > M_PI){
+      
+      while (phase > M_PI)
+       phase -= 2*M_PI;
+
+      while (phase < -M_PI)
+       phase += 2*M_PI;
+    }
+  }
+
+  // units are radians / step
+  double get_phase () const { return phase; }
+  double get_freq () const { return phase_inc; }
+
+  // compute sin and cos for current phase angle
+  void sincos (float *sinx, float *cosx) const;
+
+  // compute cos or sin for current phase angle
+  float cos () const { return std::cos (phase); }
+  float sin () const { return std::sin (phase); }
+
+  // compute a block at a time
+  void sin (float *output, int noutput_items, double ampl = 1.0);
+  void cos (float *output, int noutput_items, double ampl = 1.0);
+  void sincos (gr_complex *output, int noutput_items, double ampl = 1.0);
+  void sin (short *output, int noutput_items, double ampl = 1.0);
+  void cos (short *output, int noutput_items, double ampl = 1.0);
+  void sin (int *output, int noutput_items, double ampl = 1.0);
+  void cos (int *output, int noutput_items, double ampl = 1.0);
+
+protected:
+  double phase;
+  double phase_inc;
+};
+
+template<class o_type, class i_type> 
+void
+ui_nco<o_type,i_type>::sincos (float *sinx, float *cosx) const
+{
+  ui_sincosf (phase, sinx, cosx);
+}
+
+template<class o_type, class i_type> 
+void
+ui_nco<o_type,i_type>::sin (float *output, int noutput_items, double ampl)
+{
+  for (int i = 0; i < noutput_items; i++){
+    output[i] = (float)(sin () * ampl);
+    step ();
+  }
+}
+
+template<class o_type, class i_type> 
+void
+ui_nco<o_type,i_type>::cos (float *output, int noutput_items, double ampl)
+{
+  for (int i = 0; i < noutput_items; i++){
+    output[i] = (float)(cos () * ampl);
+    step ();
+  }
+}
+
+template<class o_type, class i_type> 
+void
+ui_nco<o_type,i_type>::sin (short *output, int noutput_items, double ampl)
+{
+  for (int i = 0; i < noutput_items; i++){
+    output[i] = (short)(sin() * ampl);
+    step ();
+  }
+}
+
+template<class o_type, class i_type> 
+void
+ui_nco<o_type,i_type>::cos (short *output, int noutput_items, double ampl)
+{
+  for (int i = 0; i < noutput_items; i++){
+    output[i] = (short)(cos () * ampl);
+    step ();
+  }
+}
+
+template<class o_type, class i_type> 
+void
+ui_nco<o_type,i_type>::sin (int *output, int noutput_items, double ampl)
+{
+  for (int i = 0; i < noutput_items; i++){
+    output[i] = (int)(sin () * ampl);
+    step ();
+  }
+}
+
+template<class o_type, class i_type> 
+void
+ui_nco<o_type,i_type>::cos (int *output, int noutput_items, double ampl)
+{
+  for (int i = 0; i < noutput_items; i++){
+    output[i] = (int)(cos () * ampl);
+    step ();
+  }
+}
+
+template<class o_type, class i_type> 
+void
+ui_nco<o_type,i_type>::sincos (gr_complex *output, int noutput_items, double 
ampl)
+{
+  for (int i = 0; i < noutput_items; i++){
+    float cosx, sinx;
+    sincos (&sinx, &cosx);
+    output[i] = gr_complex(cosx * ampl, sinx * ampl);
+    step ();
+  }
+}
+
+#endif /* INCLUDED_UI_NCO_H */
+

Copied: gnuradio/branches/features/inband-usb/usrp/host/apps/ui_sincos.c (from 
rev 5642, gnuradio/branches/developers/eb/ibu/usrp/host/apps/ui_sincos.c)
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/ui_sincos.c            
                (rev 0)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/ui_sincos.c    
2007-06-03 20:32:36 UTC (rev 5643)
@@ -0,0 +1,81 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define _GNU_SOURCE            // ask for GNU extensions if available
+
+#include <ui_sincos.h>
+#include <math.h>
+
+// ----------------------------------------------------------------
+
+#if defined (HAVE_SINCOS)
+
+void
+ui_sincos (double x, double *sinx, double *cosx)
+{
+  sincos (x, sinx, cosx);
+}
+
+#else
+
+void
+ui_sincos (double x, double *sinx, double *cosx)
+{
+  *sinx = sin (x);
+  *cosx = cos (x);
+}
+
+#endif
+
+// ----------------------------------------------------------------
+
+#if defined (HAVE_SINCOSF)
+
+void
+ui_sincosf (float x, float *sinx, float *cosx)
+{
+  sincosf (x, sinx, cosx);
+}
+
+#elif defined (HAVE_SINF) && defined (HAVE_COSF)
+
+void
+ui_sincosf (float x, float *sinx, float *cosx)
+{
+  *sinx = sinf (x);
+  *cosx = cosf (x);
+}
+
+#else
+
+void
+ui_sincosf (float x, float *sinx, float *cosx)
+{
+  *sinx = sin (x);
+  *cosx = cos (x);
+}
+
+#endif

Copied: gnuradio/branches/features/inband-usb/usrp/host/apps/ui_sincos.h (from 
rev 5642, gnuradio/branches/developers/eb/ibu/usrp/host/apps/ui_sincos.h)
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/ui_sincos.h            
                (rev 0)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/ui_sincos.h    
2007-06-03 20:32:36 UTC (rev 5643)
@@ -0,0 +1,39 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2002,2004 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_UI_SINCOS_H
+#define INCLUDED_UI_SINCOS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+  
+// compute sine and cosine at the same time
+
+void ui_sincos (double x, double *sin, double *cos);
+void ui_sincosf (float x, float *sin, float *cos);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif /* INCLUDED_UI_SINCOS_H */


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

   + 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


Modified: gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am      
2007-06-03 20:13:15 UTC (rev 5642)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am      
2007-06-03 20:32:36 UTC (rev 5643)
@@ -57,15 +57,15 @@
 
 libusrp_inband_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
 
-libusrp_inband_la_LIBADD =             \
-       $(MBLOCK_LA)                    \
-       $(USRP_LA)                              \
+libusrp_inband_la_LIBADD =                                     \
+       $(MBLOCK_LA)                                            \
+       $(top_builddir)/usrp/host/lib/legacy/libusrp.la         \
        -lstdc++
 
 include_HEADERS =                      \
        usrp_server.h                           \
        usrp_usb_interface.h \
-       usrp_inband_usb_packet.h \      
+       usrp_inband_usb_packet.h \
        usrp_usb_interface_stub.h
 
 noinst_HEADERS =                       \
@@ -81,8 +81,7 @@
 libusrp_inband_qa_la_SOURCES =         \
        qa_inband.cc                    \
        qa_inband_packet_prims.cc       \
-       qa_inband_usrp_server.cc        \
-       fake_usrp.cc
+       qa_inband_usrp_server.cc        
 
 # magic flags
 libusrp_inband_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid-version

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/gen_test_packets.py
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/gen_test_packets.py  
    2007-06-03 20:13:15 UTC (rev 5642)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/gen_test_packets.py  
    2007-06-03 20:32:36 UTC (rev 5643)
@@ -83,5 +83,6 @@
     assert pkt_gen_1.next() == 16002    # 2*sum(1, 2, ..., 126) == 126 * 127
 
 if __name__ == '__main__':
+    random.seed(0)
     
gen_all_valid_packet_lengths_1_channel(open("all_valid_packet_lengths_1_channel.dat",
 "w"))
     
gen_all_valid_packet_lengths_2_channels(open("all_valid_packet_lengths_2_channels.dat",
 "w"))

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-06-03 20:13:15 UTC (rev 5642)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
 2007-06-03 20:32:36 UTC (rev 5643)
@@ -101,10 +101,11 @@
  
   // Use the stub with the usrp_server
   pmt_t usrp_server_dict = pmt_make_dict();
-  pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"), 
pmt_intern("usrp_usb_interface_stub"));
+  pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"),
+              pmt_intern("usrp_usb_interface_stub"));
 
   // Test the TX side
-  define_component("server", "usrp_server", pmt_list1(usrp_server_dict));
+  define_component("server", "usrp_server", usrp_server_dict);
   connect("self", "tx0", "server", "tx0");
   connect("self", "rx0", "server", "rx0");
   connect("self", "cs", "server", "cs");
@@ -130,7 +131,7 @@
 void
 qa_alloc_top::run_tests()
 {
-  std::cout << "[qa_alloc_top] Starting tests...\n";
+  // std::cout << "[qa_alloc_top] Starting tests...\n";
   // should be able to allocate 1 byte
   d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
   
@@ -173,15 +174,15 @@
       
     if(pmt_eq(msg->signal(), s_response_max_capacity)) {
       d_max_capacity = pmt_to_long(pmt_nth(2, data));
-      std::cout << "[qa_alloc_top] USRP has max capacity of " << 
d_max_capacity << "\n";
+      // std::cout << "[qa_alloc_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));
-      std::cout << "[qa_alloc_top] USRP tx channels: " << d_ntx_chan << "\n";
+      // std::cout << "[qa_alloc_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));
-      std::cout << "[qa_alloc_top] USRP rx channels: " << d_nrx_chan << "\n";
+      // std::cout << "[qa_alloc_top] USRP rx channels: " << d_nrx_chan << 
"\n";
     }
     else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) {
       check_message(msg);
@@ -208,10 +209,11 @@
 
 
   if(!pmt_eqv(expected_result, result)) {
-    std::cout << "Got: " << result << " Expected: " << expected_result << "\n";
+    // std::cout << "Got: " << result << " Expected: " << expected_result << 
"\n";
     shutdown_all(PMT_F);
+    return;
   } else {
-    std::cout << "[qa_alloc_top] Received expected response for message " << 
d_nrecvd << "\n";
+    // std::cout << "[qa_alloc_top] Received expected response for message " 
<< d_nrecvd << "\n";
   }
 
   if(d_nrecvd == d_nmsgs_to_recv)
@@ -275,7 +277,7 @@
   pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"), 
pmt_intern("usrp_usb_interface_stub"));
 
   // Test the TX side
-  define_component("server", "usrp_server", pmt_list1(usrp_server_dict));
+  define_component("server", "usrp_server", usrp_server_dict);
   connect("self", "tx0", "server", "tx0");
   connect("self", "rx0", "server", "rx0");
   connect("self", "cs", "server", "cs");
@@ -296,7 +298,7 @@
 void
 qa_dealloc_top::allocate_max()
 {
-  std::cout << "[qa_dealloc_top] Max allocating...\n";
+  // std::cout << "[qa_dealloc_top] Max allocating...\n";
 
   // Keep allocating until we hit the maximum number of channels
   for(int i=0; i < d_ntx_chan; i++) {
@@ -364,15 +366,15 @@
       
     if(pmt_eq(msg->signal(), s_response_max_capacity)) {
       d_max_capacity = pmt_to_long(pmt_nth(2, data));
-      std::cout << "[qa_dealloc_top] USRP has max capacity of " << 
d_max_capacity << "\n";
+      // std::cout << "[qa_dealloc_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));
-      std::cout << "[qa_dealloc_top] USRP tx channels: " << d_ntx_chan << "\n";
+      // std::cout << "[qa_dealloc_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));
-      std::cout << "[qa_dealloc_top] USRP rx channels: " << d_nrx_chan << "\n";
+      // std::cout << "[qa_dealloc_top] USRP rx channels: " << d_nrx_chan << 
"\n";
     }
     else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) {
       // the final command is a capacity check which should be 0, then we 
shutdown
@@ -403,10 +405,11 @@
   d_ndealloc_recvd++;
 
   if(!pmt_eqv(expected_result, result)) {
-    std::cout << "Got: " << result << " Expected: " << expected_result << "\n";
+    // std::cout << "Got: " << result << " Expected: " << expected_result << 
"\n";
     shutdown_all(PMT_F);
+    return;
   } else {
-    std::cout << "[qa_dealloc_top] Received expected deallocation response for 
message " << d_ndealloc_recvd << "\n";
+    // std::cout << "[qa_dealloc_top] Received expected deallocation response 
for message " << d_ndealloc_recvd << "\n";
   }
 }
 
@@ -422,8 +425,9 @@
   d_nalloc_recvd++;
 
   if(pmt_eqv(status, PMT_F)) {
-    std::cout << "[qa_dealloc_top] Unexpected error response when allocating 
channels\n";
+    // std::cout << "[qa_dealloc_top] Unexpected error response when 
allocating channels\n";
     shutdown_all(PMT_F);
+    return;
   } else {
     // store all of the allocate channel numbers
     if(pmt_eq(msg->port_id(), d_tx->port_symbol()))
@@ -434,14 +438,14 @@
 
   if(d_nalloc_recvd == d_nalloc_to_recv) {
     
-    std::cout << "[qa_dealloc_top] Allocated TX channels: ";
+    // std::cout << "[qa_dealloc_top] Allocated TX channels: ";
     for(int i=0; i < (int)d_tx_chans.size(); i++)
       std::cout << d_tx_chans[i] << " ";
 
-    std::cout << "\n[qa_dealloc_top] Allocated RX channels: ";
+    // std::cout << "\n[qa_dealloc_top] Allocated RX channels: ";
     for(int i=0; i < (int)d_rx_chans.size(); i++)
       std::cout << d_rx_chans[i] << " ";
-    std::cout << "\n";
+    // std::cout << "\n";
 
     deallocate_all();   // once we've allocated all of our channels, try to 
dealloc them
   }
@@ -485,7 +489,7 @@
   pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"), 
pmt_intern("usrp_usb_interface_stub"));
 
   // Test the TX side
-  define_component("server", "usrp_server", pmt_list1(usrp_server_dict));
+  define_component("server", "usrp_server", usrp_server_dict);
   connect("self", "cs", "server", "cs");
 }
 
@@ -500,7 +504,7 @@
 void
 qa_open_close_top::run_tests()
 {
-  std::cout << "[qa_open_close_top] Starting tests\n";
+  // std::cout << "[qa_open_close_top] Starting tests\n";
 
   // A close before an open should fail
   d_cs->send(s_cmd_close, pmt_list1(PMT_F));
@@ -546,10 +550,10 @@
   pmt_t result = pmt_nth(1, data);
 
   if(!pmt_eqv(expected_result, result)) {
-    std::cout << "[qa_open_close_top] FAILED check_cs... Got: " << result << " 
Expected: " << expected_result << " for event " << msg->signal() << "\n";
+    // std::cout << "[qa_open_close_top] FAILED check_cs... Got: " << result 
<< " Expected: " << expected_result << " for event " << msg->signal() << "\n";
     shutdown_all(PMT_F);
   } else {
-    std::cout << "[qa_open_close_top] Received expected CS response for 
message (" << msg->signal() << ")\n";
+    // std::cout << "[qa_open_close_top] Received expected CS response for 
message (" << msg->signal() << ")\n";
   }
 
 }
@@ -603,7 +607,7 @@
   pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"), 
pmt_intern("usrp_usb_interface_stub"));
 
   // Test the TX side
-  define_component("server", "usrp_server", pmt_list1(usrp_server_dict));
+  define_component("server", "usrp_server", usrp_server_dict);
   connect("self", "tx0", "server", "tx0");
   connect("self", "rx0", "server", "rx0");
   connect("self", "cs", "server", "cs");
@@ -620,7 +624,7 @@
 void
 qa_tx_top::run_tests()
 {
-  std::cout << "[qa_tx_top] Starting tests\n";
+  // std::cout << "[qa_tx_top] Starting tests\n";
 
   // A transmit before an open should fail
   d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(PMT_F, pmt_from_long(0), 
pmt_make_u32vector(transport_pkt::max_payload()/4, 0), pmt_from_long(0)));
@@ -674,8 +678,10 @@
 
   d_nmsg_recvd++;
 
-  if(d_nmsg_to_recv == d_nmsg_recvd)
+  if(d_nmsg_to_recv == d_nmsg_recvd){
     shutdown_all(PMT_T);
+    return;
+  }
 }
 
 void
@@ -687,10 +693,11 @@
   pmt_t result = pmt_nth(1, data);
 
   if(!pmt_eqv(expected_result, result)) {
-    std::cout << "[qa_tx_top] FAILED check_deallocation... Got: " << result << 
" Expected: " << expected_result << "\n";
+    // std::cout << "[qa_tx_top] FAILED check_deallocation... Got: " << result 
<< " Expected: " << expected_result << "\n";
     shutdown_all(PMT_F);
+    return;
   } else {
-    std::cout << "[qa_tx_top] Received expected deallocation response for 
message\n";
+    // std::cout << "[qa_tx_top] Received expected deallocation response for 
message\n";
   }
 }
 
@@ -704,10 +711,11 @@
   pmt_t channel = pmt_nth(2, data);
   
   if(!pmt_eqv(expected_result, result)) {
-    std::cout << "[qa_tx_top] FAILED check_allocation... Got: " << result << " 
Expected: " << expected_result << " for event " << msg->signal() << ")\n";
+    // std::cout << "[qa_tx_top] FAILED check_allocation... Got: " << result 
<< " Expected: " << expected_result << " for event " << msg->signal() << ")\n";
     shutdown_all(PMT_F);
+    return;
   } else {
-    std::cout << "[qa_tx_top] Received expected allocation response for 
message\n";
+    // std::cout << "[qa_tx_top] Received expected allocation response for 
message\n";
   }
   
   if(pmt_eqv(result, PMT_T)) {
@@ -728,10 +736,13 @@
   pmt_t result = pmt_nth(1, data);
   
   if(!pmt_eqv(expected_result, result)) {
-    std::cout << "[qa_tx_top] FAILED check_xmit... Got: " << result << " 
Expected: " << expected_result << " for event " << msg->signal() << ")\n";
+    //std::cout << "[qa_tx_top] FAILED check_xmit... Got: " << result
+    // << " Expected: " << expected_result
+    // << " for event " << msg->signal() << ")\n";
     shutdown_all(PMT_F);
+    return;
   } else {
-    std::cout << "[qa_tx_top] Received expected xmit response for message\n";
+    // std::cout << "[qa_tx_top] Received expected xmit response for 
message\n";
   }
 }
 
@@ -744,10 +755,12 @@
   pmt_t result = pmt_nth(1, data);
 
   if(!pmt_eqv(expected_result, result)) {
-    std::cout << "[qa_tx_top] FAILED check_cs... Got: " << result << " 
Expected: " << expected_result << " for event " << msg->signal() << "\n";
+    // std::cout << "[qa_tx_top] FAILED check_cs... Got: " << result << " 
Expected: " << expected_result << " for event " << msg->signal() << "\n";
     shutdown_all(PMT_F);
+    return;
   } else {
-    std::cout << "[qa_tx_top] Received expected CS response for message (" << 
msg->signal() << ")\n";
+    // std::cout << "[qa_tx_top] Received expected CS response for message ("
+    // << msg->signal() << ")\n";
   }
 
 }
@@ -763,8 +776,8 @@
   mb_runtime_sptr rt = mb_make_runtime();
   pmt_t result = PMT_T;
 
-  std::cout << "\n\n----------------------------\n";
-  std::cout << "    RUNNING OPEN/CLOSE TESTS  \n";
+  // std::cout << "\n\n----------------------------\n";
+  // std::cout << "    RUNNING OPEN/CLOSE TESTS  \n";
 
   rt->run("top", "qa_open_close_top", PMT_F, &result);
 
@@ -777,8 +790,8 @@
   mb_runtime_sptr rt = mb_make_runtime();
   pmt_t result = PMT_T;
 
-  std::cout << "\n\n----------------------------\n";
-  std::cout << "    RUNNING ALLOCATION TESTS  \n";
+  // std::cout << "\n\n----------------------------\n";
+  // std::cout << "    RUNNING ALLOCATION TESTS  \n";
 
   rt->run("top", "qa_alloc_top", PMT_F, &result);
   
@@ -791,8 +804,8 @@
   mb_runtime_sptr rt = mb_make_runtime();
   pmt_t result = PMT_T;
 
-  std::cout << "\n\n----------------------------\n";
-  std::cout << "  RUNNING DEALLOCATION TESTS  \n";
+  // std::cout << "\n\n----------------------------\n";
+  // std::cout << "  RUNNING DEALLOCATION TESTS  \n";
 
   rt->run("top", "qa_dealloc_top", PMT_F, &result);
   
@@ -805,8 +818,8 @@
   mb_runtime_sptr rt = mb_make_runtime();
   pmt_t result = PMT_T;
 
-  std::cout << "\n\n-----------------\n";
-  std::cout << "  RUNNING TX TESTS  \n";
+  // std::cout << "\n\n-----------------\n";
+  // std::cout << "  RUNNING TX TESTS  \n";
 
   rt->run("top", "qa_tx_top", PMT_F, &result);
   

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/test_usrp_inband.cc
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/test_usrp_inband.cc  
    2007-06-03 20:13:15 UTC (rev 5642)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/test_usrp_inband.cc  
    2007-06-03 20:32:36 UTC (rev 5643)
@@ -156,7 +156,7 @@
   if(fake_usrp_p)
     pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"), 
pmt_intern("usrp_usb_interface_stub"));
 
-  define_component("server", "usrp_server", pmt_list1(usrp_server_dict));
+  define_component("server", "usrp_server", usrp_server_dict);
   connect("self", "tx0", "server", "tx0");
   connect("self", "cs", "server", "cs");
 }

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-06-03 20:13:15 UTC (rev 5642)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_interface.mbh   
    2007-06-03 20:32:36 UTC (rev 5643)
@@ -38,7 +38,7 @@
    (cmd-usrp-close invocation-handle)
    (cmd-usrp-ntx-chan invocation-handle)
    (cmd-usrp-nrx-chan invocation-handle)
-   (cmd-usrp-write invocation-handle channel data n-bytes)
+   (cmd-usrp-write invocation-handle channel data)
    )
 
   (:incoming

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-06-03 20:13:15 UTC (rev 5642)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc   
2007-06-03 20:32:36 UTC (rev 5643)
@@ -75,6 +75,9 @@
 static pmt_t s_response_usrp_close = pmt_intern("response-usrp-close");
 static pmt_t s_response_usrp_write = pmt_intern("response-usrp-write");
 
+
+const static bool verbose = false;
+
 static std::string
 str(long x)
 {
@@ -91,17 +94,18 @@
   std::string usrp_interface = "usrp_usb_interface";
 
   // a dictionary is given for usrp server parameters, such as the interface 
to use
-  pmt_t usrp_dict = pmt_nth(0, user_arg);
+  pmt_t usrp_dict = user_arg;
   
-  if(!pmt_eqv(usrp_dict, PMT_NIL)) {
+  if (pmt_is_dict(usrp_dict) && pmt_dict_has_key(usrp_dict, 
pmt_intern("usrp-interface"))){
+    usrp_interface =
+      pmt_symbol_to_string(pmt_dict_ref(usrp_dict,
+                                       pmt_intern("usrp-interface"),
+                                       PMT_NIL));
+  }
 
-    if(pmt_dict_has_key(usrp_dict, pmt_intern("usrp-interface"))) 
-      usrp_interface = pmt_write_string(pmt_dict_ref(usrp_dict, 
pmt_intern("usrp-interface"), PMT_NIL));
+  if (verbose)
+    std::cout << "[USRP_SERVER] Using interface: " << usrp_interface << "\n";
 
-  }
-      
-  std::cout << "[USRP_SERVER] Using interface: " << usrp_interface << "\n";
-
   // control & status port
   d_cs = define_port("cs", "usrp-server-cs", true, mb_port::EXTERNAL); 
   d_cs_usrp = define_port("cs_usrp", "usrp-interface-cs", false, 
mb_port::INTERNAL);   
@@ -166,7 +170,7 @@
   pmt_t reply_data;
   pmt_t status;
 
-  if (1){
+  if (verbose){
     std::cout << "[USRP_SERVER] event: " << event << std::endl;
     std::cout << "[USRP_SERVER] port_id: " << port_id << std::endl;
   }
@@ -228,7 +232,8 @@
 
   // Checking for defer on all other messages
   if(d_defer) {
-    std::cout << "[USRP_SERVER] Received msg while deferring (" << 
msg->signal() << ")\n";
+    if (verbose)
+      std::cout << "[USRP_SERVER] Received msg while deferring (" << 
msg->signal() << ")\n";
     d_defer_queue.push(msg);
     return;
   }
@@ -421,7 +426,8 @@
       }
     }
 
-    std::cout << "[USRP_SERVER] Couldnt find a TX chan\n";
+    if (verbose)
+      std::cout << "[USRP_SERVER] Couldnt find a TX chan\n";
 
     reply_data = pmt_list3(invocation_handle, pmt_from_long(CHANNEL_UNAVAIL), 
PMT_NIL);  // no free TX chan found
     d_tx[port]->send(s_response_allocate_channel, reply_data);
@@ -447,7 +453,8 @@
       }
     }
 
-    std::cout << "[USRP_SERVER] Couldnt find a RX chan\n";
+    if (verbose)
+      std::cout << "[USRP_SERVER] Couldnt find a RX chan\n";
     reply_data = pmt_list3(invocation_handle, pmt_from_long(CHANNEL_UNAVAIL), 
PMT_NIL);  // no free RX chan found
     d_rx[port]->send(s_response_allocate_channel, reply_data);
     return;
@@ -567,10 +574,11 @@
 
     pkts[n_packets-1].set_end_of_burst();   // set the last packet's end of 
burst
 
-    std::cout << "[USRP_SERVER] Received raw frame invocation: " << 
invocation_handle << std::endl;
+    if (verbose)
+      std::cout << "[USRP_SERVER] Received raw frame invocation: " << 
invocation_handle << std::endl;
 
     // The actual response to the write will be generated by a 
s_response_usrp_write
-    d_cs_usrp->send(s_cmd_usrp_write, pmt_list4(invocation_handle, 
pmt_from_long(channel), v_packets, 
pmt_from_long(n_packets*transport_pkt::max_pkt_size())));
+    d_cs_usrp->send(s_cmd_usrp_write, pmt_list3(invocation_handle, 
pmt_from_long(channel), v_packets));
 
   }
 }

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-06-03 20:13:15 UTC (rev 5642)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.mbh  
2007-06-03 20:32:36 UTC (rev 5643)
@@ -40,9 +40,8 @@
 ;; mechanism to match asynchronous responses with the commands that
 ;; generated them.
 ;;
-;; status is either #t, indicating success, or a pair containing
-;; (status-code . message), where status-code is a symbol and message
-;; is a string.
+;; status is either #t, indicating success, or a symbol indicating an error.
+;; All symbol's names shall begin with %error-
 
 
 ;; ----------------------------------------------------------------

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-06-03 20:13:15 UTC (rev 5642)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface.cc
    2007-06-03 20:32:36 UTC (rev 5643)
@@ -29,6 +29,7 @@
 #include <usrp_usb_interface.h>
 #include <usrp_inband_usb_packet.h>
 #include "usrp_standard.h"
+#include <stdio.h>
 
 typedef usrp_inband_usb_packet transport_pkt;
 
@@ -43,6 +44,8 @@
 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 const bool verbose = true;
+
 // 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)
@@ -115,26 +118,34 @@
   long which_usrp = pmt_to_long(pmt_nth(1, data));
   pmt_t reply_data;
 
-  std::cout << "[USRP_USB_INTERFACE] Handling open request for USRP " << 
which_usrp << "\n";
+  if (verbose)
+    std::cout << "[USRP_USB_INTERFACE] Handling open request for USRP " << 
which_usrp << "\n";
 
   // Open up a standard RX and TX for communication with the USRP
    
-  d_utx = usrp_standard_tx::make (which_usrp,
-    16,               // interp = 32.0MB/s
-    d_ntx_chan,                
-    -1,               // mux
-    4096,             // USB block size
-    16);              // number of blocks for async transfers
+  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
+                                );
+  
   if(d_utx==0) {
-    std::cout << "[USRP_USB_INTERFACE] Failed to open TX\n";
+    if (verbose)
+      std::cout << "[USRP_USB_INTERFACE] Failed to open TX\n";
     reply_data = pmt_list2(invocation_handle, PMT_F);
     d_cs->send(s_response_usrp_open, reply_data);
     return;
   }
 
-  if(!d_utx->set_tx_freq (0,0)) {  // try setting center freq to 0
-    std::cout << "[USRP_USB_INTERFACE] Failed to set center frequency on TX\n";
+  if(!d_utx->set_tx_freq (0,10e6)) {  // 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);
     d_cs->send(s_response_usrp_open, reply_data);
     return;
@@ -142,33 +153,38 @@
 
   d_utx->start();
 
-  std::cout << "[USRP_USB_INTERFACE] Setup TX channel\n";
+  if (verbose)
+    std::cout << "[USRP_USB_INTERFACE] Setup TX channel\n";
 
-  d_urx = usrp_standard_rx::make (which_usrp,
-    16,               // interp = 32.0MB/s
-    d_nrx_chan,                
-    -1,               // mux
-    0,                // set blank mode to start
-    4096,             // USB block size
-    16);              // number of blocks for async transfers
+  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
 
   if(!d_urx) {
-    std::cout << "[usrp_server] Failed to open RX\n";
+    if (verbose)
+      std::cout << "[usrp_server] Failed to open RX\n";
     reply_data = pmt_list2(invocation_handle, PMT_F);
     d_cs->send(s_response_usrp_open, reply_data);
     return;
   }
 
-  if(!d_urx->set_rx_freq (0,0)) {  // try setting center freq to 0
-    std::cout << "[usrp_server] Failed to set center frequency on RX\n";
+  if(!d_urx->set_rx_freq (0, 10e6)) {
+    if (verbose)
+      std::cout << "[usrp_server] Failed to set center frequency on RX\n";
     reply_data = pmt_list2(invocation_handle, PMT_F);
     d_cs->send(s_response_usrp_open, reply_data);
     return;
   }
 
-  d_urx->start();   // FIXME: currently causing a hang
+  d_urx->start();
   
-  std::cout << "[USRP_USB_INTERFACE] Setup RX channel\n";
+  if (verbose)
+    std::cout << "[USRP_USB_INTERFACE] Setup RX channel\n";
 
   d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T));
 }
@@ -179,23 +195,28 @@
   pmt_t invocation_handle = pmt_nth(0, data);
   long channel = pmt_to_long(pmt_nth(1, data));
   pmt_t v_packets = pmt_nth(2, data);
-  long n_bytes = pmt_to_long(pmt_nth(3, data));
   
-  size_t psize;
+  size_t n_bytes;
   bool underrun;  // this will need to go, as it is taken care of in the 
packet headers
   
-  transport_pkt *pkts = (transport_pkt *) 
pmt_u8vector_writeable_elements(v_packets, psize);
+  transport_pkt *pkts = (transport_pkt *) 
pmt_u8vector_writeable_elements(v_packets, n_bytes);
 
   int ret = d_utx->write (pkts, n_bytes, &underrun);
 
-  if (ret == n_bytes) {
-    std::cout << "[usrp_server] Write of " << n_bytes << " successful\n";
+  if (0 && underrun)
+    fprintf(stderr, "uU");
+
+  if (ret == (int) n_bytes) {
+    if (verbose)
+      std::cout << "[usrp_server] Write of " << n_bytes << " successful\n";
     // need to respond with the channel so the USRP server knows who to 
forward the result of
     // the write to by looking up the owner of the channel
-    d_cs->send(s_response_usrp_write, pmt_list3(invocation_handle, 
pmt_from_long(channel), PMT_T));
+    d_cs->send(s_response_usrp_write,
+              pmt_list3(invocation_handle, pmt_from_long(channel), PMT_T));
   }
   else {
-    std::cout << "[usrp_server] Error writing " << n_bytes << " bytes to USB 
bus\n";
+    if (verbose)
+      std::cout << "[usrp_server] Error writing " << n_bytes << " bytes to USB 
bus\n";
     // need to respond with the channel so the USRP server knows who to 
forward the result of
     // the write to by looking up the owner of the channel
     d_cs->send(s_response_usrp_write, pmt_list3(invocation_handle, 
pmt_from_long(channel), PMT_F));
@@ -209,11 +230,14 @@
 {
   pmt_t invocation_handle = pmt_nth(0, data);
   
-  std::cout << "[usrp_usb_interface] Handling close request for USRP\n";
+  if (verbose)
+    std::cout << "[usrp_usb_interface] Handling close request for USRP\n";
 
   delete d_utx;
+  d_utx = 0;
 
   delete d_urx;
+  d_urx = 0;
 
   d_cs->send(s_response_usrp_close, pmt_list2(invocation_handle, PMT_T));
 

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface_stub.cc
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface_stub.cc
       2007-06-03 20:13:15 UTC (rev 5642)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface_stub.cc
       2007-06-03 20:32:36 UTC (rev 5643)
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 #include <iostream>
+#include <fstream>
 #include <vector>
 #include <usb.h>
 #include <mb_class_registry.h>
@@ -43,9 +44,12 @@
 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 const bool verbose = false;
+
 // need to take number of TX and RX channels as parameter
 usrp_usb_interface_stub::usrp_usb_interface_stub(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-interface-cs", true, mb_port::EXTERNAL);      
   
@@ -55,11 +59,17 @@
 
   d_utx = NULL;
   d_urx = NULL;
+
+  // d_disk_write=true;
+
+  if(d_disk_write)
+    ofile.open("pdump.dat",std::ios::binary|std::ios::out);
 }
 
 usrp_usb_interface_stub::~usrp_usb_interface_stub() 
 { 
-
+  if(d_disk_write)
+    ofile.close();
 }
 
 void 
@@ -116,9 +126,10 @@
   pmt_t rx_mode = pmt_nth(2, data);
   pmt_t reply_data;
 
-  std::cout << "[USRP_USB_INTERFACE_STUB] Handling open request for USRP " << 
which_usrp << "\n";
+  if (verbose)
+    std::cout << "[USRP_USB_INTERFACE_STUB] Handling open request for USRP " 
<< which_usrp << "\n";
 
-  usleep(2 * 1000000);  // artificial time to open the interface
+  usleep(2 * 1000);  // artificial time to open the interface
 
   d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T));
 }
@@ -127,12 +138,29 @@
 usrp_usb_interface_stub::handle_cmd_write(pmt_t data)
 {
   pmt_t invocation_handle = pmt_nth(0, data);
-  pmt_t channel = pmt_nth(1, data);
+  long channel = pmt_to_long(pmt_nth(1, data));
+  pmt_t v_packets = pmt_nth(2, data);
+
+  size_t n_bytes;
   
-  d_cs->send(s_response_usrp_write, pmt_list3(invocation_handle, channel, 
PMT_T));
+  size_t psize;
+  bool underrun;  // this will need to go, as it is taken care of in the 
packet headers
+  
+  d_cs->send(s_response_usrp_write, pmt_list3(invocation_handle, 
pmt_from_long(channel), PMT_T));
 
-  std::cout << "[USRP_USB_INTERFACE_STUB] Successful write\n";
+  if (verbose)
+    std::cout << "[USRP_USB_INTERFACE_STUB] Successful write\n";
 
+  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_payload()));
+
+    for(int i=0; i<(int)n_packets; i++) 
+      ofile.write((const char*) pkts[i].payload(), pkts[i].payload_len());
+    
+  }
+
   return;
 }
 
@@ -141,7 +169,8 @@
 {
   pmt_t invocation_handle = pmt_nth(0, data);
   
-  std::cout << "[USRP_USB_INTERFACE_STUB] Handling close request for USRP\n";
+  if (verbose)
+    std::cout << "[USRP_USB_INTERFACE_STUB] Handling close request for USRP\n";
 
   d_cs->send(s_response_usrp_close, pmt_list2(invocation_handle, PMT_T));
 

Modified: 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface_stub.h
===================================================================
--- 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface_stub.h
        2007-06-03 20:13:15 UTC (rev 5642)
+++ 
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_usb_interface_stub.h
        2007-06-03 20:32:36 UTC (rev 5643)
@@ -23,6 +23,7 @@
 
 #include <mb_mblock.h>
 #include <vector>
+#include <fstream>
 #include "usrp_standard.h"
 
 /*!
@@ -40,6 +41,9 @@
   long d_ntx_chan;
   long d_nrx_chan;
 
+  long d_disk_write;
+  std::ofstream ofile;
+
  public:
   usrp_usb_interface_stub(mb_runtime *rt, const std::string &instance_name, 
pmt_t user_arg);
   ~usrp_usb_interface_stub();





reply via email to

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