Changeset 9210

Show
Ignore:
Timestamp:
08/08/08 08:52:32
Author:
jcorgan
Message:

Renamed test2_usrp2 to rx_streaming_samples, changed -N default to infinite stream, works now with streaming_fft.py

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • usrp2/trunk/host-ng/apps

    • Property svn:ignore changed from Makefile Makefile.in .libs .deps test_eth test_usrp2 test2_usrp2 gen_const find_usrps cerr *.sh tx_samples to Makefile Makefile.in .libs .deps test_eth test_usrp2 gen_const find_usrps cerr *.sh tx_samples rx_streaming_samples
  • usrp2/trunk/host-ng/apps/Makefile.am

    r9142 r9210  
    2929noinst_PROGRAMS = \ 
    3030        gen_const \ 
    31         test2_usrp2
     31        rx_streaming_samples
    3232        tx_samples 
    3333 
    3434find_usrps = find_usrps.cc 
    35 test2_usrp2_SOURCES = test2_usrp2.cc 
     35rx_streaming_samples_SOURCES = rx_streaming_samples.cc 
    3636gen_const_SOURCES = gen_const.cc 
    3737tx_samples_SOURCES = tx_samples.cc 
  • usrp2/trunk/host-ng/apps/rx_streaming_samples.cc

    r9209 r9210  
    6666  size_t        d_nframes; 
    6767 
     68protected: 
     69  bool         *d_err; 
     70   
    6871public: 
    6972   
    70   rx_nop_handler(size_t max_samples
    71     : d_max_samples(max_samples), d_nsamples(0), d_nframes(0) {} 
     73  rx_nop_handler(size_t max_samples, bool *err=0
     74    : d_max_samples(max_samples), d_nsamples(0), d_nframes(0), d_err(err) {} 
    7275       
    7376  ~rx_nop_handler(); 
     
    8689    d_nframes++; 
    8790 
    88     return d_nsamples < d_max_samples; 
     91    if (d_max_samples != 0) 
     92        return d_nsamples < d_max_samples; 
     93 
     94    return true;         
    8995  } 
    9096}; 
     
    103109  FILE         *d_fp; 
    104110  std::string   d_filename; 
    105  
     111   
    106112public: 
    107113 
    108   complex_16_file_writer(const std::string &filename, size_t max_samples
    109     : rx_nop_handler(max_samples), d_filename(filename) 
     114  complex_16_file_writer(const std::string &filename, size_t max_samples, bool *err=0
     115    : rx_nop_handler(max_samples, err), d_filename(filename) 
    110116  { 
    111117    d_fp = fopen(filename.c_str(), "wb"); 
     
    133139      n += r; 
    134140      if (r == 0){      // out of space? 
     141        if (d_err) 
     142            *d_err = true; 
    135143        perror(d_filename.c_str()); 
    136144        ok = false; 
     
    154162  FILE         *d_fp; 
    155163  std::string   d_filename; 
    156  
     164   
    157165public: 
    158166 
    159   complex_float_file_writer(const std::string &filename, size_t max_samples
    160     : rx_nop_handler(max_samples), d_filename(filename) 
     167  complex_float_file_writer(const std::string &filename, size_t max_samples, bool *err=0
     168    : rx_nop_handler(max_samples, err), d_filename(filename) 
    161169  { 
    162170    d_fp = fopen(filename.c_str(), "wb"); 
     
    184192      n += r; 
    185193      if (r == 0){      // out of space? 
     194        if (d_err) 
     195          *d_err = true; 
    186196        perror(d_filename.c_str()); 
    187197        ok = false; 
     
    222232  fprintf(stderr, "  -d DECIM             specify receive decimation rate [default=5]\n"); 
    223233  fprintf(stderr, "  -g GAIN              specify receive daughterboard gain [default=0]\n"); 
    224   fprintf(stderr, "  -N NSAMPLES          specify number of samples to receive [default=250e6]\n"); 
     234  fprintf(stderr, "  -N NSAMPLES          specify number of samples to receive [default=infinite]\n"); 
    225235  fprintf(stderr, "  -o OUTPUT_FILENAME   specify file to receive samples [default=none]\n"); 
    226236  fprintf(stderr, "  -s                   write complex<short> [default=complex<float>]\n"); 
     
    237247  int rx_decim = 5; 
    238248  double rx_gain = 0.0; 
    239   size_t nsamples = static_cast<size_t>(250e6)
     249  size_t nsamples = 0
    240250  bool output_shorts = false; 
    241251  char *output_filename = 0; 
     
    244254  int ch; 
    245255 
    246   while ((ch = getopt(argc, argv, "he:m:f:d:g:N:o:sv")) != EOF){ 
     256  while ((ch = getopt(argc, argv, "he:m:f:d:g:No:sv")) != EOF){ 
    247257    double tmp; 
    248258    switch (ch){ 
     
    327337  handler_sptr handler; 
    328338 
     339  bool file_err = false; 
    329340  if (output_filename){ 
    330341    if (output_shorts) 
    331       handler = handler_sptr(new complex_16_file_writer(output_filename, nsamples)); 
     342      handler = handler_sptr(new complex_16_file_writer(output_filename, nsamples, &file_err)); 
    332343    else 
    333       handler = handler_sptr(new complex_float_file_writer(output_filename, nsamples)); 
     344      handler = handler_sptr(new complex_float_file_writer(output_filename, nsamples, &file_err)); 
    334345  } 
    335346  else 
     
    379390  } 
    380391 
    381   if (verbose) 
    382     printf("Receiving %zd samples\n\n", nsamples); 
     392  if (verbose) { 
     393    if (nsamples > 0) 
     394        printf("Receiving %zd samples\n\n", nsamples); 
     395    else 
     396        printf("Receiving infinite samples\n\n"); 
     397  } 
    383398   
    384399  struct timeval start, end; 
    385400  gettimeofday(&start, 0); 
    386401 
    387  
    388   while(!signaled && handler->nsamples() < handler->max_samples()){ 
     402  while(!signaled && !file_err &&  
     403        (handler->max_samples() == 0 || handler->nsamples() < handler->max_samples())){ 
    389404    bool ok = u2->rx_samples(0, handler.get()); 
    390405    if (!ok){ 
  • usrp2/trunk/host-ng/apps/streaming_fft.py

    r9142 r9210  
    6464        gain_clause = '-g ' + options.gain 
    6565 
    66     cmd = "sudo %s/rx_streaming_samples -e %s -f %g -d %d -F %d %s -o /proc/self/fd/1 | %s/stdin_int32_fft.py %s -f %g -d %d" % ( 
    67         path, options.eth, options.freq, options.decim, options.samples_per_frame, gain_clause, 
     66    # FIXME: restore -F 
     67    cmd = "sudo %s/rx_streaming_samples -e %s -f %g -d %d %s -o /proc/self/fd/1 | %s/stdin_int32_fft.py %s -f %g -d %d" % ( 
     68        path, options.eth, options.freq, options.decim, gain_clause, 
    6869        path, display_type, options.freq, options.decim) 
    6970 
  • usrp2/trunk/host-ng/apps/test.sh

    r9142 r9210  
    11#!/bin/sh 
    22 
    3 sudo ./test_usrp2 -d 4 
    4  
    5  
     3sudo ./rx_streaming_samples -d 4 -v