Changeset 9145
- Timestamp:
- 08/01/08 15:35:50
- Files:
-
- usrp2/trunk/host-ng/apps/test2_usrp2.cc (modified) (12 diffs)
- usrp2/trunk/host-ng/apps/tx_samples.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
usrp2/trunk/host-ng/apps/test2_usrp2.cc
r9142 r9145 31 31 #include <boost/shared_ptr.hpp> 32 32 #include <stdexcept> 33 #include <signal.h> 34 35 static volatile bool signaled = false; 36 37 static void 38 sig_handler(int sig) 39 { 40 signaled = true; 41 } 42 43 static void 44 install_sig_handler(int signum, 45 void (*new_handler)(int)) 46 { 47 struct sigaction new_action; 48 memset (&new_action, 0, sizeof (new_action)); 49 50 new_action.sa_handler = new_handler; 51 sigemptyset (&new_action.sa_mask); 52 new_action.sa_flags = 0; 53 54 if (sigaction (signum, &new_action, 0) < 0){ 55 perror ("sigaction (install new)"); 56 throw std::runtime_error ("sigaction"); 57 } 58 } 33 59 34 60 // ------------------------------------------------------------------------ … … 197 223 fprintf(stderr, " -g GAIN specify receive daughterboard gain [default=0]\n"); 198 224 fprintf(stderr, " -N NSAMPLES specify number of samples to receive [default=250e6]\n"); 199 //fprintf(stderr, " -b BUFSIZE specify size of receive buffer [default=64k]\n");200 225 fprintf(stderr, " -o OUTPUT_FILENAME specify file to receive samples [default=none]\n"); 201 226 fprintf(stderr, " -s write complex<short> [default=complex<float>]\n"); 227 fprintf(stderr, " -v verbose output\n"); 202 228 } 203 229 … … 214 240 bool output_shorts = false; 215 241 char *output_filename = 0; 242 bool verbose = false; 216 243 217 244 int ch; 218 245 219 while ((ch = getopt(argc, argv, "he:m:f:d:g:N:o:s ")) != EOF){246 while ((ch = getopt(argc, argv, "he:m:f:d:g:N:o:sv")) != EOF){ 220 247 double tmp; 221 248 switch (ch){ … … 282 309 break; 283 310 311 case 'v': 312 verbose = true; 313 break; 314 284 315 case 'h': 285 316 default: … … 288 319 } 289 320 } 321 322 323 install_sig_handler(SIGINT, sig_handler); 290 324 291 325 … … 302 336 handler = handler_sptr(new rx_nop_handler(nsamples)); 303 337 304 305 338 gruel::rt_status_t rt = gruel::enable_realtime_scheduling(); 306 339 if (rt != gruel::RT_OK) … … 325 358 } 326 359 327 printf("Daughterboard configuration:\n"); 328 printf(" baseband_freq=%f\n", tr.baseband_freq); 329 printf(" ddc_freq=%f\n", tr.dxc_freq); 330 printf(" residual_freq=%f\n", tr.residual_freq); 331 printf(" inverted=%s\n\n", tr.spectrum_inverted ? "yes" : "no"); 360 if (verbose){ 361 printf("Daughterboard configuration:\n"); 362 printf(" baseband_freq=%f\n", tr.baseband_freq); 363 printf(" ddc_freq=%f\n", tr.dxc_freq); 364 printf(" residual_freq=%f\n", tr.residual_freq); 365 printf(" inverted=%s\n\n", tr.spectrum_inverted ? "yes" : "no"); 366 } 332 367 333 368 if (!u2->set_rx_decim(rx_decim)) { … … 336 371 } 337 372 338 printf("USRP2 using decimation rate of %d\n", rx_decim); 373 if (verbose) 374 printf("USRP2 using decimation rate of %d\n", rx_decim); 339 375 340 376 if (!u2->start_rx_streaming(0)){ … … 343 379 } 344 380 345 printf("Receiving %zd samples\n\n", nsamples); 381 if (verbose) 382 printf("Receiving %zd samples\n\n", nsamples); 346 383 347 384 struct timeval start, end; … … 349 386 350 387 351 while( handler->nsamples() < handler->max_samples()){388 while(!signaled && handler->nsamples() < handler->max_samples()){ 352 389 bool ok = u2->rx_samples(0, handler.get()); 353 390 if (!ok){ … … 356 393 } 357 394 } 358 359 395 360 396 gettimeofday(&end, 0); … … 367 403 u2->stop_rx_streaming(); 368 404 369 printf("\nCopy handler called %zd times.\n", handler->nframes()); 370 printf("Copy handler called with %zd bytes.\n\n", handler->nsamples()*sizeof(uint32_t)); 371 printf("Elapsed time was %5.3f seconds.\n", elapsed); 372 printf("Packet rate was %1.0f pkts/sec.\n", pps); 373 printf("Approximate throughput was %5.2f MB/sec.\n", mbs); 374 printf("Total instances of overruns was %d.\n", u2->rx_overruns()); 375 printf("Total missing frames was %d.\n", u2->rx_missing()); 405 if (verbose){ 406 printf("\nCopy handler called %zd times.\n", handler->nframes()); 407 printf("Copy handler called with %zd bytes.\n\n", handler->nsamples()*sizeof(uint32_t)); 408 printf("Elapsed time was %5.3f seconds.\n", elapsed); 409 printf("Packet rate was %1.0f pkts/sec.\n", pps); 410 printf("Approximate throughput was %5.2f MB/sec.\n", mbs); 411 printf("Total instances of overruns was %d.\n", u2->rx_overruns()); 412 printf("Total missing frames was %d.\n", u2->rx_missing()); 413 } 376 414 377 415 return 0; usrp2/trunk/host-ng/apps/tx_samples.cc
r9142 r9145 26 26 #include <getopt.h> 27 27 #include <gruel/realtime.h> 28 #include <signal.h> 29 #include <stdexcept> 30 28 31 29 32 typedef std::complex<float> fcomplex; 33 34 static volatile bool signaled = false; 35 36 static void 37 sig_handler(int sig) 38 { 39 signaled = true; 40 } 41 42 static void 43 install_sig_handler(int signum, 44 void (*new_handler)(int)) 45 { 46 struct sigaction new_action; 47 memset (&new_action, 0, sizeof (new_action)); 48 49 new_action.sa_handler = new_handler; 50 sigemptyset (&new_action.sa_mask); 51 new_action.sa_flags = 0; 52 53 if (sigaction (signum, &new_action, 0) < 0){ 54 perror ("sigaction (install new)"); 55 throw std::runtime_error ("sigaction"); 56 } 57 } 58 30 59 31 60 static const char * … … 162 191 } 163 192 193 install_sig_handler(SIGINT, sig_handler); 194 164 195 165 196 gruel::rt_status_t rt = gruel::enable_realtime_scheduling(); … … 205 236 md.send_now = 1; 206 237 207 while ( 1){238 while (!signaled){ 208 239 209 240 std::complex<int16_t> samples[MAX_SAMPLES];
