commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9430 - in usrp2/trunk: host host-ng host-ng/apps host


From: jcorgan
Subject: [Commit-gnuradio] r9430 - in usrp2/trunk: host host-ng host-ng/apps host-ng/gr-usrp2 host-ng/include/usrp2 host-ng/lib
Date: Tue, 26 Aug 2008 21:47:01 -0600 (MDT)

Author: jcorgan
Date: 2008-08-26 21:47:00 -0600 (Tue, 26 Aug 2008)
New Revision: 9430

Added:
   usrp2/trunk/host-ng/gr-usrp2/
   usrp2/trunk/host-ng/gr-usrp2/Makefile.am
   usrp2/trunk/host-ng/gr-usrp2/test.sh
   usrp2/trunk/host-ng/gr-usrp2/test_gr_usrp2.cc
   usrp2/trunk/host-ng/gr-usrp2/usrp2.i
   usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.cc
   usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.h
   usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.cc
   usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.h
   usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.cc
   usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.h
   usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.cc
   usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.h
Removed:
   usrp2/trunk/host-ng/gr-usrp2/Makefile.am
   usrp2/trunk/host-ng/gr-usrp2/test.sh
   usrp2/trunk/host-ng/gr-usrp2/test_gr_usrp2.cc
   usrp2/trunk/host-ng/gr-usrp2/usrp2.i
   usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.cc
   usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.h
   usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.cc
   usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.h
   usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.cc
   usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.h
   usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.cc
   usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.h
   usrp2/trunk/host/gr-usrp2/
Modified:
   usrp2/trunk/host-ng/
   usrp2/trunk/host-ng/Makefile.am
   usrp2/trunk/host-ng/apps/rx_streaming_samples.cc
   usrp2/trunk/host-ng/configure.ac
   usrp2/trunk/host-ng/include/usrp2/usrp2.h
   usrp2/trunk/host-ng/lib/usrp2.cc
   usrp2/trunk/host-ng/lib/usrp2_impl.h
   usrp2/trunk/host/Makefile.am
   usrp2/trunk/host/configure.ac
Log:
Merged changeset -r9421:9429 from jcorgan/wip into trunk.  WIP on gr-usrp2 
classes.

Modified: usrp2/trunk/host/Makefile.am
===================================================================
--- usrp2/trunk/host/Makefile.am        2008-08-27 03:37:08 UTC (rev 9429)
+++ usrp2/trunk/host/Makefile.am        2008-08-27 03:47:00 UTC (rev 9430)
@@ -26,4 +26,4 @@
        configure \
        config.h.in
 
-SUBDIRS = config lib gr-usrp2 apps
+SUBDIRS = config lib apps

Modified: usrp2/trunk/host/configure.ac
===================================================================
--- usrp2/trunk/host/configure.ac       2008-08-27 03:37:08 UTC (rev 9429)
+++ usrp2/trunk/host/configure.ac       2008-08-27 03:47:00 UTC (rev 9430)
@@ -205,7 +205,6 @@
     Makefile \
     config/Makefile \
     apps/Makefile \
-    gr-usrp2/Makefile \
     lib/Makefile \
 ])
 


Property changes on: usrp2/trunk/host-ng
___________________________________________________________________
Name: svn:ignore
   - configure
Makefile.in
config.log
config.status
config.guess
stamp-h1
config.h
ltmain.sh
config.sub
config.h.in
libtool
autom4te.cache
missing
aclocal.m4
Makefile
install-sh
depcomp
usrp2*.tar.gz

   + configure
Makefile.in
config.log
config.status
config.guess
stamp-h1
config.h
ltmain.sh
config.sub
config.h.in
libtool
autom4te.cache
missing
aclocal.m4
Makefile
install-sh
depcomp
usrp2*.tar.gz
py-compile


Modified: usrp2/trunk/host-ng/Makefile.am
===================================================================
--- usrp2/trunk/host-ng/Makefile.am     2008-08-27 03:37:08 UTC (rev 9429)
+++ usrp2/trunk/host-ng/Makefile.am     2008-08-27 03:47:00 UTC (rev 9430)
@@ -26,4 +26,4 @@
        configure \
        config.h.in
 
-SUBDIRS = config include lib apps
+SUBDIRS = config include lib gr-usrp2 apps

Modified: usrp2/trunk/host-ng/apps/rx_streaming_samples.cc
===================================================================
--- usrp2/trunk/host-ng/apps/rx_streaming_samples.cc    2008-08-27 03:37:08 UTC 
(rev 9429)
+++ usrp2/trunk/host-ng/apps/rx_streaming_samples.cc    2008-08-27 03:47:00 UTC 
(rev 9430)
@@ -355,6 +355,7 @@
   }
 
   if (verbose){
+    printf("USRP2 MAC address: %s\n\n", u2->mac_addr().c_str());
     printf("Daughterboard configuration:\n");
     printf("  baseband_freq=%f\n", tr.baseband_freq);
     printf("       ddc_freq=%f\n", tr.dxc_freq);

Modified: usrp2/trunk/host-ng/configure.ac
===================================================================
--- usrp2/trunk/host-ng/configure.ac    2008-08-27 03:37:08 UTC (rev 9429)
+++ usrp2/trunk/host-ng/configure.ac    2008-08-27 03:47:00 UTC (rev 9430)
@@ -221,6 +221,7 @@
     config/Makefile \
     include/Makefile \
     include/usrp2/Makefile \
+    gr-usrp2/Makefile \
     lib/Makefile \
 ])
 

Copied: usrp2/trunk/host-ng/gr-usrp2 (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2)


Property changes on: usrp2/trunk/host-ng/gr-usrp2
___________________________________________________________________
Name: svn:ignore
   + .libs
.deps
Makefile
Makefile.in
*.pyc
usrp2.cc
usrp2.py
test_gr_usrp2


Deleted: usrp2/trunk/host-ng/gr-usrp2/Makefile.am

Copied: usrp2/trunk/host-ng/gr-usrp2/Makefile.am (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/Makefile.am)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/Makefile.am                            (rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/Makefile.am    2008-08-27 03:47:00 UTC (rev 
9430)
@@ -0,0 +1,94 @@
+#
+# Copyright 2007,2008 Free Software Foundation, Inc.
+#
+# This program 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 3 of the License, or
+# (at your option) any later version.
+#
+# This program 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, see <http://www.gnu.org/licenses/>.
+#
+
+include $(top_srcdir)/Makefile.common
+
+AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
+
+lib_LTLIBRARIES = \
+       libgr-usrp2.la
+
+bin_PROGRAMS = \
+        test_gr_usrp2
+        
+test_gr_usrp2_SOURCES = test_gr_usrp2.cc
+test_gr_usrp2_LDADD = \
+    libgr-usrp2.la \
+    $(top_builddir)/lib/libusrp2ng.la
+
+libgr_usrp2_la_SOURCES = \
+       usrp2_source_base.cc \
+       usrp2_source_c.cc
+#      usrp2_sink_base.cc
+#      usrp2_sink_c.cc
+
+libgr_usrp2_la_LIBADD = \
+       $(top_builddir)/lib/libusrp2ng.la \
+        $(GNURADIO_CORE_LIBS)
+
+# These will get installed once this moves into GNU Radio trunk
+#include_HEADERS = \
+#      usrp2_sink_base.h \
+#      usrp2_sink_c.h \
+#      usrp2_source_base.h \
+#      usrp2_source_c.h
+
+# Export C++ GNU Radio driver to Python via SWIG
+#ourpythondir = $(grpythondir)
+#ourlibdir    = $(grpyexecdir)
+
+#SWIGPYTHONARGS = $(SWIGPYTHONFLAGS) $(SWIGGRFLAGS) $(WITH_SWIG_INCLUDES) \
+#      $(WITH_INCLUDES)
+
+#LOCAL_IFILES = \
+#      usrp2.i                         
+
+#BUILT_SOURCES =       \
+#      usrp2.cc \
+#      usrp2.py                        
+
+#ourpython_PYTHON = \
+#      usrp2.py
+
+#ourlib_LTLIBRARIES = \
+#      _usrp2.la
+
+#_usrp2_la_SOURCES = \
+#      usrp2.cc
+
+#_usrp2_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version
+
+#_usrp2_la_LIBADD = \
+#      $(PYTHON_LDFLAGS) \
+#      libgr_usrp2.la \
+#      $(GNURADIO_CORE_LIBS) \
+#      -lstdc++                        
+
+#_usrp2_la_CPPFLAGS = $(PYTHON_CPPFLAGS)
+
+#usrp2.cc usrp2.py: $(LOCAL_IFILES)
+#      $(SWIG) $(SWIGPYTHONARGS) -module usrp2 -o usrp2.cc $(LOCAL_IFILES)
+
+#swiginclude_HEADERS = \
+#      $(LOCAL_IFILES)
+
+# Don't distribute output of swig
+#dist-hook:
+#      @for file in $(BUILT_SOURCES); do echo $(RM) $(distdir)/$$file; done
+#      @for file in $(BUILT_SOURCES); do $(RM) $(distdir)/$$file; done
+
+MOSTLYCLEANFILES += $(BUILT_SOURCES) *.pyc *~

Deleted: usrp2/trunk/host-ng/gr-usrp2/test.sh

Copied: usrp2/trunk/host-ng/gr-usrp2/test.sh (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test.sh)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/test.sh                                (rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/test.sh        2008-08-27 03:47:00 UTC (rev 
9430)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sudo ./test_gr_usrp2 -d 4 -v

Deleted: usrp2/trunk/host-ng/gr-usrp2/test_gr_usrp2.cc

Copied: usrp2/trunk/host-ng/gr-usrp2/test_gr_usrp2.cc (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test_gr_usrp2.cc)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/test_gr_usrp2.cc                               
(rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/test_gr_usrp2.cc       2008-08-27 03:47:00 UTC 
(rev 9430)
@@ -0,0 +1,194 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <usrp2/strtod_si.h>
+#include <gruel/realtime.h>
+#include <usrp2_source_c.h>
+#include <string.h>
+#include <iostream>
+
+static void
+usage(const char *progname)
+{
+  const char *p = strrchr(progname, '/');      // drop leading directory path
+  if (p)
+    p++;
+
+  if (strncmp(p, "lt-", 3) == 0)               // drop lt- libtool prefix
+    p += 3;
+  
+  fprintf(stderr, "Usage: %s [options]\n\n", p);
+  fprintf(stderr, "Options:\n");
+  fprintf(stderr, "  -h                   show this message and exit\n");
+  fprintf(stderr, "  -e ETH_INTERFACE     specify ethernet interface 
[default=eth0]\n");
+  fprintf(stderr, "  -m MAC_ADDR          mac address of USRP2 HH:HH 
[default=first one found]\n");
+  fprintf(stderr, "  -g GAIN              specify receive daughterboard gain 
[default=0]\n");
+  fprintf(stderr, "  -f FREQUENCY         specify receive center frequency in 
Hz [default=0.0]\n");
+  fprintf(stderr, "  -d DECIM             specify receive decimation rate 
[default=5]\n");
+#if 0
+  fprintf(stderr, "  -N NSAMPLES          specify number of samples to receive 
[default=infinite]\n");
+  fprintf(stderr, "  -o OUTPUT_FILENAME   specify file to receive samples 
[default=none]\n");
+  fprintf(stderr, "  -s                   write complex<short> 
[default=complex<float>]\n");
+#endif
+  fprintf(stderr, "  -v                   verbose output\n");
+}
+
+int
+main(int argc, char **argv)
+{
+  // options and their defaults
+  const char *interface = "eth0";
+  const char *mac_addr_str = "";
+  double rx_gain = 0.0;
+  double rx_freq = 0.0;
+  int rx_decim = 5;
+#if 0
+  uint64_t nsamples = 0;
+  bool output_shorts = false;
+  char *output_filename = 0;
+#endif
+  bool verbose = false;
+
+  int ch;
+
+  //while ((ch = getopt(argc, argv, "he:m:f:d:g:N:o:sv")) != EOF){
+  while ((ch = getopt(argc, argv, "he:m:g:f:d:v")) != EOF){
+    //double tmp;
+    switch (ch){
+
+    case 'e':
+      interface = optarg;
+      break;
+      
+    case 'm':
+      mac_addr_str = optarg;
+      break;
+
+    case 'g':
+      if (!strtod_si(optarg, &rx_gain)) {
+        std::cerr << "invalid number: " << optarg << std::endl;
+       usage(argv[0]);
+       exit(1);
+      }
+      break;
+
+    case 'f':
+      if (!strtod_si(optarg, &rx_freq)) {
+        std::cerr << "invalid number: " << optarg << std::endl;
+       usage(argv[0]);
+       exit(1);
+      }
+      break;
+
+    case 'd':
+      rx_decim = strtol(optarg, 0, 0);
+      if (rx_decim < 4 or rx_decim > 512) { 
+        std::cerr << "invalid decimation rate: " << optarg << std::endl;
+       usage(argv[0]);
+       exit(1);
+      }
+      break;
+
+#if 0
+    case 'N':
+      if (!strtod_si(optarg, &tmp)) {
+        std::cerr << "invalid number: " << optarg << std::endl;
+       usage(argv[0]);
+       exit(1);
+      }
+      nsamples = static_cast<uint64_t>(tmp);
+      break;
+      
+    case 's':
+      output_shorts = true;
+      break;
+
+    case 'o':
+      output_filename = optarg;
+      break;
+#endif      
+    case 'v':
+      verbose = true;
+      break;
+
+    case 'h':
+    default:
+      usage(argv[0]);
+      exit(1);
+    }
+  }
+
+  gruel::rt_status_t rt = gruel::enable_realtime_scheduling();
+  if (rt != gruel::RT_OK)
+    std::cerr << "Failed to enable realtime scheduling" << std::endl;
+
+  usrp2_source_c_sptr u2 = usrp2_make_source_c(interface, mac_addr_str);
+
+  if (!u2->set_gain(rx_gain)){
+    fprintf(stderr, "set_gain(%f) failed\n", rx_gain);
+    exit(1);
+  }
+
+  usrp2::tune_result tr;
+  if (!u2->set_center_freq(rx_freq, &tr)){
+    fprintf(stderr, "set_center_freq(%g) failed\n", rx_freq);
+    exit(1);
+  }
+
+  if (verbose){
+    printf("USRP2 MAC address: %s\n\n", u2->mac_addr().c_str());
+    printf("Daughterboard configuration:\n");
+    printf("  baseband_freq=%f\n", tr.baseband_freq);
+    printf("       ddc_freq=%f\n", tr.dxc_freq);
+    printf("  residual_freq=%f\n", tr.residual_freq);
+    printf("       inverted=%s\n\n", tr.spectrum_inverted ? "yes" : "no");
+  }
+
+  if (!u2->set_decim(rx_decim)) {
+    fprintf(stderr, "set_decim(%d) failed\n", rx_decim);
+    exit(1);
+  }
+
+  if (verbose)
+    printf("USRP2 using decimation rate of %d\n", rx_decim);
+
+#if 0    
+  if (verbose) {
+    if (nsamples > 0)
+        printf("Receiving %zd samples\n\n", nsamples);
+    else
+        printf("Receiving infinite samples\n\n");
+  }
+  
+  struct timeval start, end;
+  gettimeofday(&start, 0);
+
+  // Run flowgraph here
+
+  gettimeofday(&end, 0);
+  long n_usecs = end.tv_usec-start.tv_usec;
+  long n_secs = end.tv_sec-start.tv_sec;
+  double elapsed = (double)n_secs + (double)n_usecs*1e-6;
+#endif
+
+  return 0;
+}

Deleted: usrp2/trunk/host-ng/gr-usrp2/usrp2.i

Copied: usrp2/trunk/host-ng/gr-usrp2/usrp2.i (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2.i)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/usrp2.i                                (rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/usrp2.i        2008-08-27 03:47:00 UTC (rev 
9430)
@@ -0,0 +1,97 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 3, 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.
+ */
+
+%feature("autodoc", "1");              // generate python docstrings
+
+%include "exception.i"
+%import "gnuradio.i"                           // the common stuff
+
+%{
+#include "gnuradio_swig_bug_workaround.h"      // mandatory bug fix
+#include "usrp2_sink_c.h"
+#include "usrp2_source_c.h"
+%}
+
+// ----------------------------------------------------------------
+
+class usrp2_sink_base : public gr_sync_block {
+
+protected:
+  usrp2_sink_base(const std::string &name,
+                 gr_io_signature_sptr input_signature) 
+    throw (std::runtime_error);
+
+public:
+  ~usrp2_sink_base();
+
+};
+
+// ----------------------------------------------------------------
+
+class usrp2_source_base : public gr_sync_block {
+
+protected:
+  usrp2_source_base(const std::string &name,
+                   gr_io_signature_sptr output_signature) 
+    throw (std::runtime_error);
+
+public:
+  ~usrp2_source_base();
+
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(usrp2,sink_c)
+
+usrp2_sink_c_sptr
+usrp2_make_sink_c() throw (std::runtime_error);
+
+class usrp2_sink_c : public usrp2_sink_base {
+
+protected:
+  usrp2_sink_c();
+
+public:
+  ~usrp2_sink_c();
+
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(usrp2,source_c)
+
+usrp2_source_c_sptr
+usrp2_make_source_c(const std::string &ifc="eth0",
+                   const std::string &mac="") 
+  throw (std::runtime_error);
+
+class usrp2_source_c : public usrp2_source_base {
+
+protected:
+  usrp2_source_c(const std::string &ifc,
+                const std::string &mac);
+
+public:
+  ~usrp2_source_c();
+
+};

Deleted: usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.cc

Copied: usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.cc (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_sink_base.cc)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.cc                             
(rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.cc     2008-08-27 03:47:00 UTC 
(rev 9430)
@@ -0,0 +1,49 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 3, 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
+
+#include <usrp2_sink_base.h>
+#include <gr_io_signature.h>
+
+usrp2_sink_base::usrp2_sink_base(const std::string &name,
+                                gr_io_signature_sptr input_signature) 
+  throw (std::runtime_error)
+  : gr_sync_block(name,
+                 input_signature,
+                 gr_make_io_signature(0, 0, 0))
+{
+}
+
+usrp2_sink_base::~usrp2_sink_base ()
+{
+}
+
+int
+usrp2_sink_base::work(int noutput_items,
+                     gr_vector_const_void_star &input_items,
+                     gr_vector_void_star &output_items)
+{
+  return noutput_items;
+}

Deleted: usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.h

Copied: usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.h (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_sink_base.h)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.h                              
(rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.h      2008-08-27 03:47:00 UTC 
(rev 9430)
@@ -0,0 +1,46 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 3, 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_USRP2_SINK_BASE_H
+#define INCLUDED_USRP2_SINK_BASE_H
+
+#include <gr_sync_block.h>
+#include <stdexcept>
+
+class usrp2_sink_base : public gr_sync_block {
+
+private:
+
+protected:
+  usrp2_sink_base(const std::string &name,
+                 gr_io_signature_sptr input_signature) 
+    throw (std::runtime_error);
+  
+public:
+  ~usrp2_sink_base();
+  
+  int work(int noutput_items,
+          gr_vector_const_void_star &input_items,
+          gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_USRP2_SINK_BASE_H */

Deleted: usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.cc

Copied: usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.cc (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_sink_c.cc)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.cc                                
(rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.cc        2008-08-27 03:47:00 UTC 
(rev 9430)
@@ -0,0 +1,46 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 3, 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
+
+#include <usrp2_sink_c.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <usrp_bytesex.h>
+
+usrp2_sink_c_sptr
+usrp2_make_sink_c() throw (std::runtime_error)
+{
+  return usrp2_sink_c_sptr(new usrp2_sink_c());
+}
+
+usrp2_sink_c::usrp2_sink_c() throw (std::runtime_error)
+  : usrp2_sink_base("usrp2_sink_c",
+                   gr_make_io_signature(1, 1, sizeof(gr_complex)))
+{
+}
+
+usrp2_sink_c::~usrp2_sink_c()
+{
+}

Deleted: usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.h

Copied: usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.h (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_sink_c.h)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.h                         (rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.h 2008-08-27 03:47:00 UTC (rev 
9430)
@@ -0,0 +1,47 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 3, 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_USRP2_SINK_C_H
+#define INCLUDED_USRP2_SINK_C_H
+
+#include <usrp2_sink_base.h>
+
+class usrp2_sink_c;
+typedef boost::shared_ptr<usrp2_sink_c> usrp2_sink_c_sptr;
+
+usrp2_sink_c_sptr
+usrp2_make_sink_c() throw (std::runtime_error);
+
+class usrp2_sink_c : public usrp2_sink_base {
+private:
+
+  friend usrp2_sink_c_sptr
+  usrp2_make_sink_c() throw (std::runtime_error);
+
+protected:
+  usrp2_sink_c() throw (std::runtime_error);
+
+public:
+  ~usrp2_sink_c();
+};
+
+#endif /* INCLUDED_USRP2_SINK_C_H */

Deleted: usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.cc

Copied: usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.cc (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_source_base.cc)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.cc                           
(rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.cc   2008-08-27 03:47:00 UTC 
(rev 9430)
@@ -0,0 +1,76 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 3, 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
+
+#include <usrp2_source_base.h>
+#include <gr_io_signature.h>
+#include <iostream>
+
+#define USRP2_SOURCE_BASE_DEBUG 0
+
+usrp2_source_base::usrp2_source_base(const std::string &name,
+                                    gr_io_signature_sptr output_signature,
+                                    const std::string &interface,
+                                    const std::string &mac) 
+  throw (std::runtime_error)
+  : gr_sync_block(name,
+                 gr_make_io_signature(0, 0, 0),
+                 output_signature),
+    d_u2(usrp2::usrp2::sptr())
+{
+  d_u2 = usrp2::usrp2::make(interface, mac);
+  if (!d_u2)
+    throw std::runtime_error("Unable to initialize USRP2!");
+}
+
+usrp2_source_base::~usrp2_source_base ()
+{
+}
+
+bool
+usrp2_source_base::set_gain(double gain)
+{
+  return d_u2->set_rx_gain(gain);
+}
+
+bool
+usrp2_source_base::set_center_freq(double frequency, usrp2::tune_result *tr)
+{
+  return d_u2->set_rx_center_freq(frequency, tr);
+}
+
+bool
+usrp2_source_base::set_decim(int decimation_factor)
+{
+  return d_u2->set_rx_decim(decimation_factor);
+}
+
+int
+usrp2_source_base::work(int noutput_items,
+                       gr_vector_const_void_star &input_items,
+                       gr_vector_void_star &output_items)
+{
+  return noutput_items;
+}

Deleted: usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.h

Copied: usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.h (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_source_base.h)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.h                            
(rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.h    2008-08-27 03:47:00 UTC 
(rev 9430)
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 3, 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_USRP2_SOURCE_BASE_H
+#define INCLUDED_USRP2_SOURCE_BASE_H
+
+#include <gr_sync_block.h>
+#include <usrp2/usrp2.h>
+#include <stdexcept>
+
+class usrp2_source_base : public gr_sync_block {
+  
+protected:
+  usrp2_source_base(const std::string &name,
+                   gr_io_signature_sptr output_signature,
+                   const std::string &ifc = "eth0",
+                   const std::string &mac = "")
+    throw (std::runtime_error);
+
+  usrp2::usrp2::sptr d_u2;
+
+public:
+  ~usrp2_source_base();
+
+  /*!
+   * \brief Return USRP2 MAC address
+   */
+  const std::string &mac_addr() const { return d_u2->mac_addr(); }
+
+  /*!
+   * \brief Set receiver gain
+   */
+  bool set_gain(double gain);
+
+  /*!
+   * \brief Set receiver center frequency
+   */
+  bool set_center_freq(double frequency, usrp2::tune_result *tr);
+   
+  /*!
+   * \brief Set receive decimation rate
+   */
+  bool set_decim(int decimation_factor);
+
+  int work(int noutput_items,
+          gr_vector_const_void_star &input_items,
+          gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_USRP2_SOURCE_BASE_H */

Deleted: usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.cc

Copied: usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.cc (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_source_c.cc)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.cc                              
(rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.cc      2008-08-27 03:47:00 UTC 
(rev 9430)
@@ -0,0 +1,49 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 3, 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
+
+#include <usrp2_source_c.h>
+#include <gr_io_signature.h>
+
+usrp2_source_c_sptr
+usrp2_make_source_c(const std::string &interface,
+                   const std::string &mac_addr) 
+  throw (std::runtime_error)
+{
+  return usrp2_source_c_sptr(new usrp2_source_c(interface, mac_addr));
+}
+
+usrp2_source_c::usrp2_source_c(const std::string &interface,
+                              const std::string &mac_addr) 
+  throw (std::runtime_error)
+  : usrp2_source_base("usrp2_source_c",
+                     gr_make_io_signature(1, 1, sizeof(gr_complex)),
+                     interface, mac_addr)
+{
+}
+
+usrp2_source_c::~usrp2_source_c()
+{
+}

Deleted: usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.h

Copied: usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.h (from rev 9429, 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_source_c.h)
===================================================================
--- usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.h                               
(rev 0)
+++ usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.h       2008-08-27 03:47:00 UTC 
(rev 9430)
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 3, 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_USRP2_SOURCE_C_H
+#define INCLUDED_USRP2_SOURCE_C_H
+
+#include <usrp2_source_base.h>
+
+class usrp2_source_c;
+typedef boost::shared_ptr<usrp2_source_c> usrp2_source_c_sptr;
+
+usrp2_source_c_sptr
+usrp2_make_source_c(const std::string &ifc="eth0",
+                   const std::string &mac="") 
+  throw (std::runtime_error);
+
+class usrp2_source_c : public usrp2_source_base {
+
+private:
+  friend usrp2_source_c_sptr
+  usrp2_make_source_c(const std::string &ifc,
+                     const std::string &mac) throw (std::runtime_error);
+
+protected:
+  usrp2_source_c(const std::string &ifc="eth0",
+                const std::string &mac="") throw (std::runtime_error);
+
+public:
+  ~usrp2_source_c();
+};
+
+#endif /* INCLUDED_USRP2_SOURCE_C_H */

Modified: usrp2/trunk/host-ng/include/usrp2/usrp2.h
===================================================================
--- usrp2/trunk/host-ng/include/usrp2/usrp2.h   2008-08-27 03:37:08 UTC (rev 
9429)
+++ usrp2/trunk/host-ng/include/usrp2/usrp2.h   2008-08-27 03:47:00 UTC (rev 
9430)
@@ -74,6 +74,7 @@
      *
      * \param ifc   Network interface name, e.g., "eth0"
      * \param addr  Network mac address, e.g., "01:02:03:04:05:06", "05:06" or 
"".
+     *              If \p addr is HH:HH, it's treated as if it were 
00:50:c2:85:HH:HH
      *              "" will autoselect a USRP2 if there is only a single one 
on the local ethernet.
      */
     static sptr make(const std::string &ifc, const std::string &addr="");
@@ -83,6 +84,11 @@
      */
     ~usrp2();  
 
+    /*!
+     * Returns the MAC address associated with this USRP
+     */
+    const std::string &mac_addr();
+
     /*
      * ----------------------------------------------------------------
      * Rx configuration and control
@@ -252,13 +258,14 @@
      */
     bool config_mimo(int flags);
 
-
-
     class impl;                // implementation details
 
   private:
-    // Only usrp2::make factory function can instantiate this class
-    usrp2(const std::string &ifc, const std::string &addr);
+    // Static function to retrieve or create usrp2 instance
+    static sptr find_existing_or_make_new(const std::string &ifc, props *p);
+
+    // Only class members can instantiate this class
+    usrp2(const std::string &ifc, props *p);
   
     // All private state is held in opaque pointer
     std::auto_ptr<impl> d_impl;

Modified: usrp2/trunk/host-ng/lib/usrp2.cc
===================================================================
--- usrp2/trunk/host-ng/lib/usrp2.cc    2008-08-27 03:37:08 UTC (rev 9429)
+++ usrp2/trunk/host-ng/lib/usrp2.cc    2008-08-27 03:47:00 UTC (rev 9430)
@@ -48,16 +48,11 @@
   static boost::mutex s_table_mutex;
   static usrp_table s_table;
 
-  static usrp2::sptr
-  find_existing_or_make_new(const std::string &ifc, const std::string 
&mac_addr)
+  usrp2::sptr
+  usrp2::find_existing_or_make_new(const std::string &ifc, props *pr)
   {
-    // FIXME normalize addr
+    std::string key = ifc + ":" + pr->addr;
 
-    if (mac_addr.size() != 17)
-      throw std::invalid_argument("invalid mac_addr: " + mac_addr);
-
-    std::string key = ifc + ":" + mac_addr;
-
     boost::mutex::scoped_lock  guard(s_table_mutex);
 
     for (usrp_table::iterator p = s_table.begin(); p != s_table.end();){
@@ -74,7 +69,7 @@
     // We don't have the USRP2 we're looking for
 
     // create a new one and stick it in the table.
-    usrp2::sptr r = usrp2::make(ifc, mac_addr);
+    usrp2::sptr r(new usrp2::usrp2(ifc, pr));
     usrp_table_entry t(key, r);
     s_table.push_back(t);
 
@@ -83,17 +78,63 @@
 
   // --- end of table code ---
 
+  static bool
+  parse_mac_addr(const std::string &s, std::string &ns)
+  {
+    u2_mac_addr_t p;
 
-  // Shared pointer factory function, wraps constructor call
+    p.addr[0] = 0x00;          // Matt's IAB
+    p.addr[1] = 0x50;
+    p.addr[2] = 0xC2;
+    p.addr[3] = 0x85;
+    p.addr[4] = 0x30;
+    p.addr[5] = 0x00;
+    
+    int len = s.size();
+    switch (len) {
+      
+    case 5:
+      if (sscanf(s.c_str(), "%hhx:%hhx", &p.addr[4], &p.addr[5]) != 2)
+       return false;
+      break;
+      
+    case 17:
+      if (sscanf(s.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+                &p.addr[0], &p.addr[1], &p.addr[2],
+                &p.addr[3], &p.addr[4], &p.addr[5]) != 6)
+       return false;
+      break;
+
+    default:
+      return false;
+    }
+    
+    char buf[128];
+    snprintf(buf, sizeof(buf),
+            "%02x:%02x:%02x:%02x:%02x:%02x",
+            p.addr[0],p.addr[1],p.addr[2],
+            p.addr[3],p.addr[4],p.addr[5]);
+    ns = std::string(buf);
+    return true;
+  }
+
   usrp2::sptr
   usrp2::make(const std::string &ifc, const std::string &addr)
   {
-    return usrp2::sptr(new usrp2(ifc, addr));
+    std::string naddr = "";
+    if (addr != "" && !parse_mac_addr(addr, naddr))
+      throw std::runtime_error("Invalid MAC address");
+
+    props_vector_t u2s = find(ifc, naddr);
+    if (u2s.size() != 1)
+      throw std::runtime_error("Unable to find requested USRP2.");
+
+    return find_existing_or_make_new(ifc, &u2s[0]);
   }
 
   // Private constructor.  Sole function is to create an impl.
-  usrp2::usrp2(const std::string &ifc, const std::string &addr)
-    : d_impl(new usrp2::impl(ifc, addr))
+  usrp2::usrp2(const std::string &ifc, props *p)
+    : d_impl(new usrp2::impl(ifc, p->addr))
   {
     // NOP
   }
@@ -104,6 +145,12 @@
     // NOP
   }
   
+  const std::string &
+  usrp2::mac_addr()
+  {
+    return d_impl->mac_addr();
+  }
+
   // Receive
 
   bool 

Modified: usrp2/trunk/host-ng/lib/usrp2_impl.h
===================================================================
--- usrp2/trunk/host-ng/lib/usrp2_impl.h        2008-08-27 03:37:08 UTC (rev 
9429)
+++ usrp2/trunk/host-ng/lib/usrp2_impl.h        2008-08-27 03:47:00 UTC (rev 
9430)
@@ -43,7 +43,7 @@
 
     eth_buffer    *d_eth_buf;
     pktfilter     *d_pf;
-    std::string    d_addr;
+    std::string    d_addr;       // FIXME: use u2_mac_addr_t instead
     usrp2_thread  *d_bg_thread;
     volatile bool  d_bg_running; // TODO: multistate if needed
     
@@ -94,6 +94,7 @@
     
     void bg_loop();
 
+    const std::string &mac_addr() const { return d_addr; } // FIXME: convert 
from u2_mac_addr_t
     bool set_rx_gain(double gain);
     bool set_rx_center_freq(double frequency, tune_result *result);
     bool set_rx_decim(int decimation_factor);





reply via email to

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