Changeset 9210
- Timestamp:
- 08/08/08 08:52:32
- Files:
-
- usrp2/trunk/host-ng/apps (modified) (1 prop)
- usrp2/trunk/host-ng/apps/Makefile.am (modified) (1 diff)
- usrp2/trunk/host-ng/apps/rx_streaming_samples.cc (moved) (moved from usrp2/trunk/host-ng/apps/test2_usrp2.cc) (11 diffs)
- usrp2/trunk/host-ng/apps/streaming_fft.py (modified) (1 diff)
- usrp2/trunk/host-ng/apps/test.sh (modified) (1 diff)
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 29 29 noinst_PROGRAMS = \ 30 30 gen_const \ 31 test2_usrp2\31 rx_streaming_samples \ 32 32 tx_samples 33 33 34 34 find_usrps = find_usrps.cc 35 test2_usrp2_SOURCES = test2_usrp2.cc35 rx_streaming_samples_SOURCES = rx_streaming_samples.cc 36 36 gen_const_SOURCES = gen_const.cc 37 37 tx_samples_SOURCES = tx_samples.cc usrp2/trunk/host-ng/apps/rx_streaming_samples.cc
r9209 r9210 66 66 size_t d_nframes; 67 67 68 protected: 69 bool *d_err; 70 68 71 public: 69 72 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) {} 72 75 73 76 ~rx_nop_handler(); … … 86 89 d_nframes++; 87 90 88 return d_nsamples < d_max_samples; 91 if (d_max_samples != 0) 92 return d_nsamples < d_max_samples; 93 94 return true; 89 95 } 90 96 }; … … 103 109 FILE *d_fp; 104 110 std::string d_filename; 105 111 106 112 public: 107 113 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) 110 116 { 111 117 d_fp = fopen(filename.c_str(), "wb"); … … 133 139 n += r; 134 140 if (r == 0){ // out of space? 141 if (d_err) 142 *d_err = true; 135 143 perror(d_filename.c_str()); 136 144 ok = false; … … 154 162 FILE *d_fp; 155 163 std::string d_filename; 156 164 157 165 public: 158 166 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) 161 169 { 162 170 d_fp = fopen(filename.c_str(), "wb"); … … 184 192 n += r; 185 193 if (r == 0){ // out of space? 194 if (d_err) 195 *d_err = true; 186 196 perror(d_filename.c_str()); 187 197 ok = false; … … 222 232 fprintf(stderr, " -d DECIM specify receive decimation rate [default=5]\n"); 223 233 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"); 225 235 fprintf(stderr, " -o OUTPUT_FILENAME specify file to receive samples [default=none]\n"); 226 236 fprintf(stderr, " -s write complex<short> [default=complex<float>]\n"); … … 237 247 int rx_decim = 5; 238 248 double rx_gain = 0.0; 239 size_t nsamples = static_cast<size_t>(250e6);249 size_t nsamples = 0; 240 250 bool output_shorts = false; 241 251 char *output_filename = 0; … … 244 254 int ch; 245 255 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){ 247 257 double tmp; 248 258 switch (ch){ … … 327 337 handler_sptr handler; 328 338 339 bool file_err = false; 329 340 if (output_filename){ 330 341 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)); 332 343 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)); 334 345 } 335 346 else … … 379 390 } 380 391 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 } 383 398 384 399 struct timeval start, end; 385 400 gettimeofday(&start, 0); 386 401 387 388 while(!signaled && handler->nsamples() < handler->max_samples()){402 while(!signaled && !file_err && 403 (handler->max_samples() == 0 || handler->nsamples() < handler->max_samples())){ 389 404 bool ok = u2->rx_samples(0, handler.get()); 390 405 if (!ok){ usrp2/trunk/host-ng/apps/streaming_fft.py
r9142 r9210 64 64 gain_clause = '-g ' + options.gain 65 65 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, 68 69 path, display_type, options.freq, options.decim) 69 70 usrp2/trunk/host-ng/apps/test.sh
r9142 r9210 1 1 #!/bin/sh 2 2 3 sudo ./test_usrp2 -d 4 4 5 3 sudo ./rx_streaming_samples -d 4 -v
