commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9027 - usrp2/branches/features/host-ng/host-ng/apps


From: jcorgan
Subject: [Commit-gnuradio] r9027 - usrp2/branches/features/host-ng/host-ng/apps
Date: Sun, 27 Jul 2008 14:15:05 -0600 (MDT)

Author: jcorgan
Date: 2008-07-27 14:15:04 -0600 (Sun, 27 Jul 2008)
New Revision: 9027

Modified:
   usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc
Log:
Parameterize copy test.

Modified: usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc  2008-07-27 
14:53:22 UTC (rev 9026)
+++ usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc  2008-07-27 
20:15:04 UTC (rev 9027)
@@ -48,6 +48,8 @@
   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 SAMPLES           specify number of samples to receive 
[default=250e6]\n");
+  fprintf(stderr, "  -b BUFSIZE           specify size of receive buffer 
[default=64k]\n");
 }
 
 int
@@ -59,10 +61,12 @@
   double rx_freq = 0.0;
   int rx_decim = 5;
   double rx_gain = 0.0;
-  
+  double samples = 250e6;
+  double bufsize = 65536;
+      
   int ch;
 
-  while ((ch = getopt(argc, argv, "he:m:f:d:g:")) != EOF){
+  while ((ch = getopt(argc, argv, "he:m:f:d:g:n:b:")) != EOF){
     switch (ch){
 
     case 'e':
@@ -89,7 +93,7 @@
       }
       break;
 
-   case 'd':
+    case 'd':
       rx_decim = strtol(optarg, 0, 0);
       if (rx_decim < 4 or rx_decim > 512) { 
         std::cerr << "invalid decimation rate: " << optarg << std::endl;
@@ -98,6 +102,22 @@
       }
       break;
 
+    case 'n':
+      if (!strtod_si(optarg, &samples)) {
+        std::cerr << "invalid number: " << optarg << std::endl;
+       usage(argv[0]);
+       exit(1);
+      }
+      break;
+      
+    case 'b':
+      if (!strtod_si(optarg, &bufsize)) {
+        std::cerr << "invalid number: " << optarg << std::endl;
+       usage(argv[0]);
+       exit(1);
+      }
+      break;
+      
     case 'h':
     default:
       usage(argv[0]);
@@ -145,22 +165,22 @@
     exit(1);
   }
 
-  size_t bufsize = static_cast<size_t>(100e6);
-  boost::scoped_ptr<unsigned char> buf(new unsigned char[bufsize]);
+  size_t nsamples = static_cast<size_t>(samples);
+  size_t buflen = static_cast<size_t>(bufsize);
+  boost::scoped_ptr<unsigned char> buf(new unsigned char[buflen]);
 
-  printf("Receiving data ten times into buffer of length %li bytes.\n\n", 
bufsize);
-
+  printf("Receiving %li samples into buffer of length %li bytes.\n\n", 
nsamples, buflen);
+  
   struct timeval start, end;
   gettimeofday(&start, 0);
 
   printf("Each '.' is 100 packets:\n");
 
-  int count = 0;
   unsigned long bytes = 0;
   unsigned long times = 0;
-  
+
   do {
-    usrp2::copy_handler h(buf.get(), bufsize);
+    usrp2::copy_handler h(buf.get(), buflen);
     bool ok;
     unsigned int n = 0;
     do {
@@ -170,14 +190,14 @@
         n = n+100;
       }
     }
-    while (ok && !h.full());
+    while (ok && !h.full() && (bytes+h.bytes()) <= nsamples*4);
     if (!ok)
       break;
 
     bytes += h.bytes();
     times += h.times();
   }
-  while (++count < 10);    
+  while (bytes <= nsamples*4);  // FIXME will vary by sample format    
 
   gettimeofday(&end, 0);
   long n_usecs = end.tv_usec-start.tv_usec;





reply via email to

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