commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9496 - in usrp2/trunk/host: . apps config include/usr


From: eb
Subject: [Commit-gnuradio] r9496 - in usrp2/trunk/host: . apps config include/usrp2 lib
Date: Thu, 4 Sep 2008 00:27:32 -0600 (MDT)

Author: eb
Date: 2008-09-04 00:27:32 -0600 (Thu, 04 Sep 2008)
New Revision: 9496

Added:
   usrp2/trunk/host/apps/usrp2_burn_mac_addr.cc
   usrp2/trunk/host/config/acx_pthread.m4
Removed:
   usrp2/trunk/host/apps/u2_burn_mac_addr.cc
Modified:
   usrp2/trunk/host/Makefile.common
   usrp2/trunk/host/apps/
   usrp2/trunk/host/apps/Makefile.am
   usrp2/trunk/host/config/Makefile.am
   usrp2/trunk/host/configure.ac
   usrp2/trunk/host/include/usrp2/usrp2.h
   usrp2/trunk/host/lib/Makefile.am
   usrp2/trunk/host/lib/control.h
   usrp2/trunk/host/lib/usrp2.cc
   usrp2/trunk/host/lib/usrp2_impl.cc
   usrp2/trunk/host/lib/usrp2_impl.h
Log:
Reimplemented usrp2_burn_mac_addr; removed dependency on gnuradio-core.


Modified: usrp2/trunk/host/Makefile.common
===================================================================
--- usrp2/trunk/host/Makefile.common    2008-09-04 05:04:58 UTC (rev 9495)
+++ usrp2/trunk/host/Makefile.common    2008-09-04 06:27:32 UTC (rev 9496)
@@ -21,7 +21,8 @@
 STD_DEFINES_AND_INCLUDES = \
   -I$(top_srcdir)/include \
   -I$(top_srcdir)/../firmware/include \
-  $(GNURADIO_CORE_CFLAGS)
+  $(GRUEL_CFLAGS) \
+  $(GR_OMNITHREAD_CFLAGS)
 
 
 # includes


Property changes on: usrp2/trunk/host/apps
___________________________________________________________________
Name: svn:ignore
   - Makefile
Makefile.in
.libs
.deps
test_eth
test_usrp2
gen_const
find_usrps
cerr
*.sh
tx_samples
rx_streaming_samples

   + Makefile
Makefile.in
.libs
.deps
test_eth
test_usrp2
gen_const
find_usrps
cerr
*.sh
tx_samples
rx_streaming_samples
u2_burn_mac_addr
usrp2_burn_mac_addr


Modified: usrp2/trunk/host/apps/Makefile.am
===================================================================
--- usrp2/trunk/host/apps/Makefile.am   2008-09-04 05:04:58 UTC (rev 9495)
+++ usrp2/trunk/host/apps/Makefile.am   2008-09-04 06:27:32 UTC (rev 9496)
@@ -24,14 +24,16 @@
        -lgruel
 
 bin_PROGRAMS = \
-       find_usrps
+       find_usrps \
+       usrp2_burn_mac_addr
 
 noinst_PROGRAMS = \
        gen_const \
        rx_streaming_samples \
        tx_samples
 
-find_usrps = find_usrps.cc
+find_usrps_SOURCES = find_usrps.cc
+usrp2_burn_mac_addr_SOURCES = usrp2_burn_mac_addr.cc
 rx_streaming_samples_SOURCES = rx_streaming_samples.cc
 gen_const_SOURCES = gen_const.cc
 tx_samples_SOURCES = tx_samples.cc

Deleted: usrp2/trunk/host/apps/u2_burn_mac_addr.cc

Copied: usrp2/trunk/host/apps/usrp2_burn_mac_addr.cc (from rev 9495, 
usrp2/trunk/host/apps/u2_burn_mac_addr.cc)
===================================================================
--- usrp2/trunk/host/apps/usrp2_burn_mac_addr.cc                                
(rev 0)
+++ usrp2/trunk/host/apps/usrp2_burn_mac_addr.cc        2008-09-04 06:27:32 UTC 
(rev 9496)
@@ -0,0 +1,176 @@
+/* -*- c++ -*- */
+/*
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <usrp2/usrp2.h>
+#include <iostream>
+#include <getopt.h>
+#include <string.h>
+#include <time.h>
+#include <stdio.h>
+#include <signal.h>
+#include <stdexcept>
+
+
+static volatile bool signaled = false;
+
+static void 
+sig_handler(int sig)
+{
+  signaled = true;
+}
+
+static void
+install_sig_handler(int signum,
+                   void (*new_handler)(int))
+{
+  struct sigaction new_action;
+  memset (&new_action, 0, sizeof (new_action));
+
+  new_action.sa_handler = new_handler;
+  sigemptyset (&new_action.sa_mask);
+  new_action.sa_flags = 0;
+
+  if (sigaction (signum, &new_action, 0) < 0){
+    perror ("sigaction (install new)");
+    throw std::runtime_error ("sigaction");
+  }
+}
+
+
+static void
+usage(const char *progname)
+{
+  fprintf(stderr, "usage: %s [-e ethN] [-m old_mac_addr] new_mac_addr\n",
+         progname);
+  fprintf(stderr, "  old_mac_addr defaults to 00:50:c2:85:3f:ff\n");
+  fprintf(stderr, "  new_mac_address must be HH:HH or HH:HH:HH:HH:HH:HH\n");
+}
+
+static bool
+check_mac_addr_syntax(const std::string &s)
+{
+  unsigned char addr[6];
+
+  addr[0] = 0x00;              // Matt's IAB
+  addr[1] = 0x50;
+  addr[2] = 0xC2;
+  addr[3] = 0x85;
+  addr[4] = 0x30;
+  addr[5] = 0x00;
+    
+  int len = s.size();
+    
+  switch (len){
+      
+  case 5:
+    return sscanf(s.c_str(), "%hhx:%hhx", &addr[4], &addr[5]) == 2;
+      
+  case 17:
+    return sscanf(s.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+                 &addr[0], &addr[1], &addr[2],
+                 &addr[3], &addr[4], &addr[5]) == 6;
+  default:
+    return false;
+  }
+
+  return true;
+}
+
+
+int
+main(int argc, char **argv)
+{
+  int ch;
+  const char *interface = "eth0";
+  const char *old_mac_addr = "00:50:c2:85:3f:ff";
+  const char *new_mac_addr = 0;
+
+  while ((ch = getopt(argc, argv, "he:m:")) != EOF){
+    switch (ch){
+    case 'e':
+      interface = optarg;
+      break;
+      
+    case 'm':
+      old_mac_addr = optarg;
+      break;
+      
+    case 'h':
+    default:
+      usage(argv[0]);
+      exit(1);
+    }
+  }
+
+  if (argc - optind != 1){
+    usage(argv[0]);
+    exit(1);
+  }
+
+  new_mac_addr = argv[optind];
+
+  if (!check_mac_addr_syntax(old_mac_addr)){
+    fprintf(stderr, "invalid mac address: %s\n", old_mac_addr);
+    exit(1);
+  }
+  if (!check_mac_addr_syntax(new_mac_addr)){
+    fprintf(stderr, "invalid mac address: %s\n", new_mac_addr);
+    exit(1);
+  }
+  
+  install_sig_handler(SIGINT, sig_handler);
+
+  usrp2::usrp2::sptr u2;
+
+  try {
+    u2 = usrp2::usrp2::make(interface, old_mac_addr);
+  }
+  catch (std::exception const &e){
+    std::cerr << e.what() << std::endl;
+    return 1;
+  }
+
+  if (!u2->burn_mac_addr(new_mac_addr)){
+    std::cerr << "Failed to burn mac address: "
+             << new_mac_addr << std::endl;
+    return 1;
+  }
+
+  u2.reset();  // close
+
+  // wait 250 ms
+  struct timespec ts;
+  ts.tv_sec = 0;
+  ts.tv_nsec = 250000000;
+  nanosleep(&ts, 0);
+
+  try {
+    u2 = usrp2::usrp2::make(interface, new_mac_addr);
+  }
+  catch (std::exception const &e){
+    std::cerr << "Failed to connect to USRP2 using new addr: "
+             << new_mac_addr << std::endl;
+    std::cerr << e.what() << std::endl;
+    return 1;
+  }
+
+  return 0;
+}

Modified: usrp2/trunk/host/config/Makefile.am
===================================================================
--- usrp2/trunk/host/config/Makefile.am 2008-09-04 05:04:58 UTC (rev 9495)
+++ usrp2/trunk/host/config/Makefile.am 2008-09-04 06:27:32 UTC (rev 9496)
@@ -19,6 +19,7 @@
 #
 
 M4FILES = \
+       acx_pthread.m4 \
        ax_boost_base.m4 \
        ax_boost_date_time.m4 \
        ax_boost_filesystem.m4 \

Copied: usrp2/trunk/host/config/acx_pthread.m4 (from rev 9494, 
gnuradio/trunk/config/acx_pthread.m4)
===================================================================
--- usrp2/trunk/host/config/acx_pthread.m4                              (rev 0)
+++ usrp2/trunk/host/config/acx_pthread.m4      2008-09-04 06:27:32 UTC (rev 
9496)
@@ -0,0 +1,275 @@
+# ===========================================================================
+#              http://autoconf-archive.cryp.to/acx_pthread.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+#   This macro figures out how to build C programs using POSIX threads. It
+#   sets the PTHREAD_LIBS output variable to the threads library and linker
+#   flags, and the PTHREAD_CFLAGS output variable to any special C compiler
+#   flags that are needed. (The user can also force certain compiler
+#   flags/libs to be tested by setting these environment variables.)
+#
+#   Also sets PTHREAD_CC to any special C compiler that is needed for
+#   multi-threaded programs (defaults to the value of CC otherwise). (This
+#   is necessary on AIX to use the special cc_r compiler alias.)
+#
+#   NOTE: You are assumed to not only compile your program with these flags,
+#   but also link it with them as well. e.g. you should link with
+#   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
+#
+#   If you are only building threads programs, you may wish to use these
+#   variables in your default LIBS, CFLAGS, and CC:
+#
+#          LIBS="$PTHREAD_LIBS $LIBS"
+#          CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+#          CC="$PTHREAD_CC"
+#
+#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
+#   has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
+#   (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+#
+#   ACTION-IF-FOUND is a list of shell commands to run if a threads library
+#   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
+#   is not found. If ACTION-IF-FOUND is not specified, the default action
+#   will define HAVE_PTHREAD.
+#
+#   Please let the authors know if this macro fails on any platform, or if
+#   you have any other suggestions or comments. This macro was based on work
+#   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
+#   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
+#   Alejandro Forero Cuervo to the autoconf macro repository. We are also
+#   grateful for the helpful feedback of numerous users.
+#
+# LAST MODIFICATION
+#
+#   2008-04-12
+#
+# COPYLEFT
+#
+#   Copyright (c) 2008 Steven G. Johnson <address@hidden>
+#
+#   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/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Macro Archive. When you make and
+#   distribute a modified version of the Autoconf Macro, you may extend this
+#   special exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([ACX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_LANG_SAVE
+AC_LANG_C
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with 
CFLAGS=$PTHREAD_CFLAGS])
+        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
+        AC_MSG_RESULT($acx_pthread_ok)
+        if test x"$acx_pthread_ok" = xno; then
+                PTHREAD_LIBS=""
+                PTHREAD_CFLAGS=""
+        fi
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try.  Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads 
-mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important.  Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+#       other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+#      doesn't hurt to check since this sometimes defines pthreads too;
+#      also defines -D_REENTRANT)
+#      ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+        *solaris*)
+
+        # On Solaris (at least, for some versions), libc contains stubbed
+        # (non-functional) versions of the pthreads routines, so link-based
+        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
+        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
+        # a function called by this macro, so we could check for that, but
+        # who knows whether they'll stub that too in a future libc.)  So,
+        # we'll just look for -pthreads and -lpthread first:
+
+        acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+        ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+        case $flag in
+                none)
+                AC_MSG_CHECKING([whether pthreads work without any flags])
+                ;;
+
+                -*)
+                AC_MSG_CHECKING([whether pthreads work with $flag])
+                PTHREAD_CFLAGS="$flag"
+                ;;
+
+               pthread-config)
+               AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
+               if test x"$acx_pthread_config" = xno; then continue; fi
+               PTHREAD_CFLAGS="`pthread-config --cflags`"
+               PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config 
--libs`"
+               ;;
+
+                *)
+                AC_MSG_CHECKING([for the pthreads library -l$flag])
+                PTHREAD_LIBS="-l$flag"
+                ;;
+        esac
+
+        save_LIBS="$LIBS"
+        save_CFLAGS="$CFLAGS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Check for various functions.  We must include pthread.h,
+        # since some functions may be macros.  (On the Sequent, we
+        # need a special flag -Kthread to make this header compile.)
+        # We check for pthread_join because it is in -lpthread on IRIX
+        # while pthread_create is in libc.  We check for pthread_attr_init
+        # due to DEC craziness with -lpthreads.  We check for
+        # pthread_cleanup_push because it is one of the few pthread
+        # functions on Solaris that doesn't have a non-functional libc stub.
+        # We try pthread_create on general principles.
+        AC_TRY_LINK([#include <pthread.h>],
+                    [pthread_t th; pthread_join(th, 0);
+                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
+                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+                    [acx_pthread_ok=yes])
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        AC_MSG_RESULT($acx_pthread_ok)
+        if test "x$acx_pthread_ok" = xyes; then
+                break;
+        fi
+
+        PTHREAD_LIBS=""
+        PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+       AC_MSG_CHECKING([for joinable pthread attribute])
+       attr_name=unknown
+       for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+           AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
+                        [attr_name=$attr; break])
+       done
+        AC_MSG_RESULT($attr_name)
+        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+                               [Define to necessary symbol if this constant
+                                uses a non-standard name on your system.])
+        fi
+
+        AC_MSG_CHECKING([if more special flags are required for pthreads])
+        flag=no
+        case "${host_cpu}-${host_os}" in
+            *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+            *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+        esac
+        AC_MSG_RESULT(${flag})
+        if test "x$flag" != xno; then
+            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+        fi
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        # More AIX lossage: must compile with xlc_r or cc_r
+       if test x"$GCC" != xyes; then
+          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
+        else
+          PTHREAD_CC=$CC
+       fi
+else
+        PTHREAD_CC="$CC"
+fi
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX 
threads libraries and header files.]),[$1])
+        :
+else
+        acx_pthread_ok=no
+        $2
+fi
+AC_LANG_RESTORE
+])dnl ACX_PTHREAD

Modified: usrp2/trunk/host/configure.ac
===================================================================
--- usrp2/trunk/host/configure.ac       2008-09-04 05:04:58 UTC (rev 9495)
+++ usrp2/trunk/host/configure.ac       2008-09-04 06:27:32 UTC (rev 9496)
@@ -89,7 +89,7 @@
 dnl GR_FORTRAN
 
 GR_NO_UNDEFINED                dnl do we need the -no-undefined linker flag
-GR_SCRIPTING
+dnl GR_SCRIPTING
 
 dnl AC_CHECK_PROG([XMLTO],[xmlto],[yes],[])
 dnl AM_CONDITIONAL([HAS_XMLTO], [test x$XMLTO = xyes])
@@ -187,10 +187,8 @@
 dnl CFLAGS="${CFLAGS} $PTHREAD_CFLAGS"
 dnl CXXFLAGS="${CXXFLAGS} $PTHREAD_CFLAGS"
 
-
 dnl conditional build stuff
 GR_CHECK_DOXYGEN
-GR_SET_MD_CPU
 
 dnl Define where to look for cppunit includes and libs
 dnl sets CPPUNIT_CFLAGS and CPPUNIT_LIBS
@@ -208,9 +206,12 @@
 dnl calls AC_SUBST(BOOST_CPPFLAGS), AC_SUBST(BOOST_LDFLAGS) and defines 
HAVE_BOOST
 AX_BOOST_BASE([1.35])
 
-dnl so we can use some utilities. FIXME hoist them out
-PKG_CHECK_MODULES(GNURADIO_CORE, gnuradio-core >= 3)
+dnl calls AC_SUBST(BOOST_THREAD_LIB), AC_SUBST(BOOST_CXXFLAGS) and defines 
HAVE_BOOST_THREAD
+AX_BOOST_THREAD
+CXXFLAGS="$CXXFLAGS $BOOST_CXXFLAGS"       dnl often picks up a -pthread or 
something similar
+CFLAGS="$CFLAGS $BOOST_CXXFLAGS"           dnl often picks up a -pthread or 
something similar
 
+
 # If this is being done from a subversion tree, create variables
 GR_SUBVERSION
 

Modified: usrp2/trunk/host/include/usrp2/usrp2.h
===================================================================
--- usrp2/trunk/host/include/usrp2/usrp2.h      2008-09-04 05:04:58 UTC (rev 
9495)
+++ usrp2/trunk/host/include/usrp2/usrp2.h      2008-09-04 06:27:32 UTC (rev 
9496)
@@ -73,7 +73,7 @@
      * Static function to return an instance of usrp2 as a shared pointer
      *
      * \param ifc   Network interface name, e.g., "eth0"
-     * \param addr  Network mac address, e.g., "01:02:03:04:05:06", "05:06" or 
"".
+     * \param addr  Network mac address, e.g., "01:23:45:67:89:ab", "89:ab" 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.
      */
@@ -89,6 +89,14 @@
      */
     std::string mac_addr();
 
+    /*!
+     * Burn new mac address into EEPROM on USRP2
+     *
+     * \param new_addr  Network mac address, e.g., "01:23:45:67:89:ab" or 
"89:ab".
+     *                  If \p addr is HH:HH, it's treated as if it were 
00:50:c2:85:HH:HH
+     */
+    bool burn_mac_addr(const std::string &new_addr);
+
     /*
      * ----------------------------------------------------------------
      * Rx configuration and control

Modified: usrp2/trunk/host/lib/Makefile.am
===================================================================
--- usrp2/trunk/host/lib/Makefile.am    2008-09-04 05:04:58 UTC (rev 9495)
+++ usrp2/trunk/host/lib/Makefile.am    2008-09-04 06:27:32 UTC (rev 9496)
@@ -18,7 +18,7 @@
 include $(top_srcdir)/Makefile.common
 
 #AM_CXXFLAGS = -Wall -Werror (handle this with: $ ./configure CXXFLAGS="-Wall 
-Werror -O2 -g")
-AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(GRUEL_CFLAGS) 
$(BOOST_CFLAGS)
+AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(STD_DEFINES_AND_INCLUDES) 
$(CPPUNIT_INCLUDES) $(GRUEL_CFLAGS) 
 
 lib_LTLIBRARIES = \
        libusrp2.la
@@ -42,7 +42,8 @@
 
 libusrp2_la_LIBADD = \
        $(GR_OMNITHREAD_LIBS) \
-       $(GRUEL_LIBS)
+       $(GRUEL_LIBS) \
+       $(BOOST_LDFLAGS) $(BOOST_THREAD_LIB)
 
 # Private headers not needed for above the API development
 noinst_HEADERS = \

Modified: usrp2/trunk/host/lib/control.h
===================================================================
--- usrp2/trunk/host/lib/control.h      2008-09-04 05:04:58 UTC (rev 9495)
+++ usrp2/trunk/host/lib/control.h      2008-09-04 06:27:32 UTC (rev 9496)
@@ -53,6 +53,12 @@
     op_generic_t      eop;
   };
 
+  struct op_burn_mac_addr_cmd 
+  {
+    u2_eth_packet_t    h;
+    op_burn_mac_addr_t op;
+    op_generic_t       eop;
+  };
 
   /*!
    * Control mechanism to allow API calls to block waiting for reply packets

Modified: usrp2/trunk/host/lib/usrp2.cc
===================================================================
--- usrp2/trunk/host/lib/usrp2.cc       2008-09-04 05:04:58 UTC (rev 9495)
+++ usrp2/trunk/host/lib/usrp2.cc       2008-09-04 06:27:32 UTC (rev 9496)
@@ -130,9 +130,9 @@
 
     if (n == 0) {
       if (addr == "")
-       throw std::runtime_error("No USRPs found on interface.");
+       throw std::runtime_error("No USRPs found on interface " + ifc);
       else
-       throw std::runtime_error("Specified USRP2 not found on interface.");
+       throw std::runtime_error("No USRP found with addr " + addr + " on 
interface " + ifc);
     }
 
     if (n > 1)
@@ -160,6 +160,13 @@
     return d_impl->mac_addr();
   }
 
+  bool
+  usrp2::burn_mac_addr(const std::string &new_addr)
+  {
+    return d_impl->burn_mac_addr(new_addr);
+  }
+
+
   // Receive
 
   bool 

Modified: usrp2/trunk/host/lib/usrp2_impl.cc
===================================================================
--- usrp2/trunk/host/lib/usrp2_impl.cc  2008-09-04 05:04:58 UTC (rev 9495)
+++ usrp2/trunk/host/lib/usrp2_impl.cc  2008-09-04 06:27:32 UTC (rev 9496)
@@ -410,7 +410,35 @@
     return data_handler::RELEASE;
   }
 
+
   // ----------------------------------------------------------------
+  //                      misc commands
+  // ----------------------------------------------------------------
+
+  bool
+  usrp2::impl::burn_mac_addr(const std::string &new_addr)
+  {
+    op_burn_mac_addr_cmd cmd;
+    op_generic_t reply;
+
+    memset(&cmd, 0, sizeof(cmd));
+    init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, -1);
+    cmd.op.opcode = OP_BURN_MAC_ADDR;
+    cmd.op.len = sizeof(cmd.op);
+    cmd.op.rid = d_next_rid++;
+    if (!parse_mac_addr(new_addr, &cmd.op.addr))
+      return false;
+
+    pending_reply p(cmd.op.rid, &reply, sizeof(reply));
+    if (!transmit_cmd(&cmd, sizeof(cmd), &p, 4*DEF_CMD_TIMEOUT))
+      return false;
+
+    bool success = (ntohx(reply.ok) == 1);
+    return success;
+  }
+
+
+  // ----------------------------------------------------------------
   //                          Receive
   // ----------------------------------------------------------------
 

Modified: usrp2/trunk/host/lib/usrp2_impl.h
===================================================================
--- usrp2/trunk/host/lib/usrp2_impl.h   2008-09-04 05:04:58 UTC (rev 9495)
+++ usrp2/trunk/host/lib/usrp2_impl.h   2008-09-04 06:27:32 UTC (rev 9496)
@@ -95,6 +95,8 @@
     void bg_loop();
 
     std::string mac_addr() const { return d_addr; } // FIXME: convert from 
u2_mac_addr_t
+    bool burn_mac_addr(const std::string &new_addr);
+
     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]