Changeset 9461
- Timestamp:
- 08/30/08 13:49:25
- Files:
-
- usrp2/trunk/host/apps/rx_streaming_samples.cc (modified) (7 diffs)
- usrp2/trunk/host/include/usrp2/Makefile.am (modified) (2 diffs)
- usrp2/trunk/host/include/usrp2/rx_nop_handler.h (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
usrp2/trunk/host/apps/rx_streaming_samples.cc
r9430 r9461 24 24 #include <usrp2/strtod_si.h> 25 25 #include <usrp2/copiers.h> 26 #include <usrp2/rx_nop_handler.h> 26 27 #include <gruel/realtime.h> 27 28 #include <sys/time.h> … … 60 61 // ------------------------------------------------------------------------ 61 62 62 class rx_nop_handler : public usrp2::rx_sample_handler63 {64 uint64_t d_max_samples;65 uint64_t d_nsamples;66 uint64_t d_nframes;67 68 protected:69 bool d_err;70 71 public:72 73 rx_nop_handler(uint64_t max_samples)74 : d_max_samples(max_samples), d_nsamples(0), d_nframes(0), d_err(false) {}75 76 ~rx_nop_handler();77 78 uint64_t nframes() const { return d_nframes; }79 uint64_t nsamples() const { return d_nsamples; }80 uint64_t max_samples() const { return d_max_samples; }81 bool has_errored_p() const { return d_err; }82 bool has_finished_p() const83 { return d_max_samples == 0 ? false : d_nsamples >= d_max_samples; }84 85 bool86 operator()(const uint32_t *items, size_t nitems, const usrp2::rx_metadata *metadata)87 {88 // printf("W0: %08x TS: %08x\n", metadata->word0, metadata->timestamp);89 // printf("I0: %08x\n", items[0]);90 91 d_nsamples += nitems;92 d_nframes++;93 94 return !has_finished_p();95 }96 };97 98 rx_nop_handler::~rx_nop_handler()99 {100 // nop101 }102 103 typedef boost::shared_ptr<rx_nop_handler> handler_sptr;104 105 // ------------------------------------------------------------------------106 107 63 // FIXME make this a template 108 64 109 class complex_16_file_writer : public rx_nop_handler65 class complex_16_file_writer : public usrp2::rx_nop_handler 110 66 { 111 67 FILE *d_fp; … … 115 71 116 72 complex_16_file_writer(const std::string &filename, uint64_t max_samples) 117 : rx_nop_handler(max_samples), d_filename(filename)73 : usrp2::rx_nop_handler(max_samples), d_filename(filename) 118 74 { 119 75 d_fp = fopen(filename.c_str(), "wb"); … … 159 115 // ------------------------------------------------------------------------ 160 116 161 class complex_float_file_writer : public rx_nop_handler117 class complex_float_file_writer : public usrp2::rx_nop_handler 162 118 { 163 119 FILE *d_fp; … … 167 123 168 124 complex_float_file_writer(const std::string &filename, uint64_t max_samples) 169 : rx_nop_handler(max_samples), d_filename(filename)125 : usrp2::rx_nop_handler(max_samples), d_filename(filename) 170 126 { 171 127 d_fp = fopen(filename.c_str(), "wb"); … … 210 166 211 167 // ------------------------------------------------------------------------ 212 213 214 215 168 216 169 static void … … 322 275 install_sig_handler(SIGINT, sig_handler); 323 276 324 handler_sptr handler;277 usrp2::rx_nop_handler::sptr handler; 325 278 326 279 if (output_filename){ 327 280 if (output_shorts) 328 handler = handler_sptr(new complex_16_file_writer(output_filename, nsamples));281 handler = usrp2::rx_nop_handler::sptr(new complex_16_file_writer(output_filename, nsamples)); 329 282 else 330 handler = handler_sptr(new complex_float_file_writer(output_filename, nsamples));283 handler = usrp2::rx_nop_handler::sptr(new complex_float_file_writer(output_filename, nsamples)); 331 284 } 332 285 else 333 handler = handler_sptr(newrx_nop_handler(nsamples));286 handler = usrp2::rx_nop_handler::sptr(new usrp2::rx_nop_handler(nsamples)); 334 287 335 288 gruel::rt_status_t rt = gruel::enable_realtime_scheduling(); usrp2/trunk/host/include/usrp2/Makefile.am
r9447 r9461 26 26 copy_handler.h \ 27 27 metadata.h \ 28 rx_nop_handler.h \ 28 29 rx_sample_handler.h \ 29 30 strtod_si.h \ … … 31 32 usrp2.h \ 32 33 usrp2_cdefs.h 33
