commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9427 - usrp2/branches/developers/jcorgan/wip/host-ng/


From: jcorgan
Subject: [Commit-gnuradio] r9427 - usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2
Date: Tue, 26 Aug 2008 20:36:27 -0600 (MDT)

Author: jcorgan
Date: 2008-08-26 20:36:26 -0600 (Tue, 26 Aug 2008)
New Revision: 9427

Added:
   usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test.sh
Modified:
   usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/Makefile.am
   usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test_gr_usrp2.cc
Log:
Add gr-usrp2 test program.

Modified: usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/Makefile.am
===================================================================
--- usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/Makefile.am  
2008-08-27 02:15:39 UTC (rev 9426)
+++ usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/Makefile.am  
2008-08-27 02:36:26 UTC (rev 9427)
@@ -20,14 +20,14 @@
 AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
 
 lib_LTLIBRARIES = \
-       libgr_usrp2.la
+       libgr-usrp2.la
 
 bin_PROGRAMS = \
         test_gr_usrp2
         
 test_gr_usrp2_SOURCES = test_gr_usrp2.cc
 test_gr_usrp2_LDADD = \
-    libgr_usrp2.la \
+    libgr-usrp2.la \
     $(top_builddir)/lib/libusrp2ng.la
 
 libgr_usrp2_la_SOURCES = \

Added: usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test.sh
===================================================================
--- usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test.sh              
                (rev 0)
+++ usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test.sh      
2008-08-27 02:36:26 UTC (rev 9427)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sudo ./test_gr_usrp2 -v -m 31:66


Property changes on: 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: 
usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test_gr_usrp2.cc
===================================================================
--- usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test_gr_usrp2.cc     
2008-08-27 02:15:39 UTC (rev 9426)
+++ usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test_gr_usrp2.cc     
2008-08-27 02:36:26 UTC (rev 9427)
@@ -1,34 +1,195 @@
 /* -*- 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
+ *
+ * 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, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
+ * 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 GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include "usrp2_source_c.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");
+#if 0
+  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");
+  fprintf(stderr, "  -g GAIN              specify receive daughterboard gain 
[default=0]\n");
+  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(char *argc, char **argv)
+main(int argc, char **argv)
 {
-  usrp2_source_c_sptr u2 = usrp2_make_source_c();
-  printf("Using USRP2 at %s\n", u2->mac_addr().c_str());
+  // options and their defaults
+  const char *interface = "eth0";
+  const char *mac_addr_str = "";
+#if 0
+  double rx_freq = 0.0;
+  int rx_decim = 5;
+  double rx_gain = 0.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:v")) != EOF){
+    //double tmp;
+    switch (ch){
+
+    case 'e':
+      interface = optarg;
+      break;
+      
+    case 'm':
+      mac_addr_str = optarg;
+      break;
+#if 0
+    case 'f':
+      if (!strtod_si(optarg, &rx_freq)) {
+        std::cerr << "invalid number: " << optarg << std::endl;
+       usage(argv[0]);
+       exit(1);
+      }
+      break;
+
+    case 'g':
+      if (!strtod_si(optarg, &rx_gain)) {
+        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;
+
+    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 0
+  if (!u2->set_rx_gain(rx_gain)){
+    fprintf(stderr, "set_rx_gain(%f) failed\n", rx_gain);
+    exit(1);
+  }
+
+  usrp2::tune_result tr;
+  if (!u2->set_rx_center_freq(rx_freq, &tr)){
+    fprintf(stderr, "set_rx_center_freq(%g) failed\n", rx_freq);
+    exit(1);
+  }
+#endif
+
+  if (verbose){
+    printf("USRP2 MAC address: %s\n\n", u2->mac_addr().c_str());
+#if 0
+    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");
+#endif
+  }
+#if 0
+  if (!u2->set_rx_decim(rx_decim)) {
+    fprintf(stderr, "set_rx_decim(%d) failed\n", rx_decim);
+    exit(1);
+  }
+
+  if (verbose)
+    printf("USRP2 using decimation rate of %d\n", rx_decim);
+    
+  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;
 }





reply via email to

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