Changeset 8955
- Timestamp:
- 07/20/08 14:47:16
- Files:
-
- usrp2/branches/features/host-ng/host-ng/apps/test.sh (modified) (1 diff)
- usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc (modified) (4 diffs)
- usrp2/branches/features/host-ng/host-ng/include/usrp2/copy_handler.h (modified) (1 diff)
- usrp2/branches/features/host-ng/host-ng/include/usrp2/usrp2.h (modified) (1 diff)
- usrp2/branches/features/host-ng/host-ng/lib/copy_handler.cc (modified) (2 diffs)
- usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc (modified) (1 diff)
- usrp2/branches/features/host-ng/host-ng/lib/usrp2.cc (modified) (1 diff)
- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc (modified) (6 diffs)
- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
usrp2/branches/features/host-ng/host-ng/apps/test.sh
r8749 r8955 1 1 #!/bin/sh 2 2 3 sudo ./test_usrp2 -d 5 1>cerr 2>&13 sudo ./test_usrp2 -d 4 4 4 5 5 usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc
r8856 r8955 24 24 #include <usrp2/tune_result.h> 25 25 #include <usrp2/strtod_si.h> 26 #include <usrp2/copy_handler.h> 26 27 #include <gruel/realtime.h> 28 #include <sys/time.h> 27 29 #include <iostream> 28 30 #include <string.h> … … 120 122 } 121 123 122 printf("baseband_freq=%f\n", tr.baseband_freq); 123 printf(" ddc_freq=%f\n", tr.dxc_freq); 124 printf("residual_freq=%f\n", tr.residual_freq); 125 printf(" inverted=%s\n", tr.spectrum_inverted ? "yes" : "no"); 124 printf("Daughterboard configuration:\n"); 125 printf(" baseband_freq=%f\n", tr.baseband_freq); 126 printf(" ddc_freq=%f\n", tr.dxc_freq); 127 printf(" residual_freq=%f\n", tr.residual_freq); 128 printf(" inverted=%s\n\n", tr.spectrum_inverted ? "yes" : "no"); 126 129 127 130 if (!u2->set_rx_decim(rx_decim)) { … … 129 132 exit(1); 130 133 } 134 135 printf("USRP2 using decimation rate of %d\n", rx_decim); 131 136 132 137 if (!u2->start_rx_streaming()){ … … 135 140 } 136 141 137 // Temporary to allow program to finish 138 int n = 0; 139 while(n++ < 100000) 140 u2->rx_samples(0, NULL); 142 size_t bufsize = 100e6; 143 unsigned char *buf = (unsigned char *)malloc(bufsize); 144 usrp2::copy_handler h(buf, bufsize); 141 145 146 printf("Receiving data into buffer of length %li bytes.\n\n", bufsize); 147 148 struct timeval start, end; 149 gettimeofday(&start, 0); 150 151 152 printf("Each '.' is 100 packets:\n"); 153 bool ok; 154 unsigned int n = 0; 155 do { 156 ok = u2->rx_samples(0, &h); 157 if (h.times() > n) { 158 printf("."); fflush(stdout); 159 n = n+100; 160 } 161 } 162 while (ok && !h.full()); 163 164 gettimeofday(&end, 0); 165 long n_usecs = end.tv_usec-start.tv_usec; 166 long n_secs = end.tv_sec-start.tv_sec; 167 double elapsed = (double)n_secs + (double)n_usecs*1e-6; 168 double mbs = h.bytes()/elapsed/1e6; 169 double pps = h.times()/elapsed; 170 142 171 u2->stop_rx_streaming(); 172 173 printf("\nCopy handler called %li times.\n", h.times()); 174 printf("Copy handler called with %li bytes.\n\n", h.bytes()); 175 printf("Elapsed time was %5.3f seconds.\n", elapsed); 176 printf("Packet rate was %1.0f pkts/sec.\n", pps); 177 printf("Approximate throughput was %5.2f MB/sec.\n", mbs); 178 printf("Total instances of overruns was %d.\n", u2->rx_overruns()); 179 printf("Total missing frames was %d.\n", u2->rx_missing()); 180 181 free(buf); 143 182 return 0; 144 183 } usrp2/branches/features/host-ng/host-ng/include/usrp2/copy_handler.h
r8647 r8955 39 39 40 40 virtual data_handler::result operator()(const void *base, size_t len); 41 42 size_t bytes() const { return d_bytes; } 43 size_t times() const { return d_times; } 44 45 static const size_t MIN_COPY_LEN = 1484; // FIXME: calculate eth packet - thdr 46 bool full() const { return d_space < MIN_COPY_LEN; } 41 47 }; 42 48 usrp2/branches/features/host-ng/host-ng/include/usrp2/usrp2.h
r8749 r8955 125 125 bool stop_rx_streaming(unsigned int channel=0); 126 126 127 /*! 128 * Returns number of times receive overruns have occurred 129 */ 130 unsigned int rx_overruns(); 131 132 /*! 133 * Returns total number of missing frames from overruns. 134 */ 135 unsigned int rx_missing(); 136 127 137 /* Ignore :-) */ 128 138 class impl; usrp2/branches/features/host-ng/host-ng/lib/copy_handler.cc
r8647 r8955 25 25 26 26 #include <usrp2/copy_handler.h> 27 #include <iostream> 27 28 28 29 namespace usrp2 { … … 48 49 d_bytes += len; 49 50 d_times++; 51 52 if (d_space < MIN_COPY_LEN) 53 return DONE; // don't call me anymore 50 54 51 if (d_space == 0)52 return DONE; // don't call me anymore53 54 55 return 0; 55 56 } usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc
r8848 r8955 35 35 #include <errno.h> 36 36 37 #define ETH_BUFFER_DEBUG 1// define to 0 or 137 #define ETH_BUFFER_DEBUG 0 // define to 0 or 1 38 38 #if ETH_BUFFER_DEBUG 39 39 #define DEBUG_LOG(x) ::write(2, (x), 1) usrp2/branches/features/host-ng/host-ng/lib/usrp2.cc
r8749 r8955 88 88 } 89 89 90 unsigned int 91 usrp2::rx_overruns() 92 { 93 return d_impl->rx_overruns(); 94 } 95 96 unsigned int 97 usrp2::rx_missing() 98 { 99 return d_impl->rx_missing(); 100 } 101 90 102 } // namespace usrp2 usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
r8856 r8955 35 35 #include <stdio.h> 36 36 37 #define USRP2_IMPL_DEBUG 137 #define USRP2_IMPL_DEBUG 0 38 38 #if USRP2_IMPL_DEBUG 39 39 #define DEBUG_LOG(x) ::write(2, x, 1) … … 79 79 : d_buffer(new eth_buffer()), d_pf(0), d_bg_thread(0), d_bg_running(false), 80 80 d_rx_decim(0), d_rx_seqno(-1), d_tx_seqno(0), d_next_rid(0), 81 d_num_rx_frames(0), d_num_rx_ lost(0), d_num_rx_bytes(0), d_num_enqueued(0),82 d_ enqueued_mutex(), d_bg_pending_cond(&d_enqueued_mutex)81 d_num_rx_frames(0), d_num_rx_missing(0), d_num_rx_overruns(0), d_num_rx_bytes(0), 82 d_num_enqueued(0), d_enqueued_mutex(), d_bg_pending_cond(&d_enqueued_mutex) 83 83 { 84 84 props_vector_t u2s = find(ifc, addr); … … 116 116 std::cerr << std::endl 117 117 << "usrp2 destructor: received " << d_num_rx_frames 118 << " frames, with " << d_num_rx_ lost<< " lost ("119 << (d_num_rx_frames == 0 ? 0 : (int)(100.0*d_num_rx_ lost/d_num_rx_frames))118 << " frames, with " << d_num_rx_missing << " lost (" 119 << (d_num_rx_frames == 0 ? 0 : (int)(100.0*d_num_rx_missing/d_num_rx_frames)) 120 120 << "%), totaling " << d_num_rx_bytes 121 121 << " bytes" << std::endl; … … 483 483 missing += 256; 484 484 485 d_num_rx_lost += missing; 485 d_num_rx_overruns++; 486 d_num_rx_missing += missing; 486 487 } 487 488 } … … 495 496 } 496 497 497 if (d_channel_rings[chan]->enqueue(&pkt->samples, 0)) { 498 size_t offset = (uint8_t *)(&pkt->samples) - (uint8_t *)base; 499 if (d_channel_rings[chan]->enqueue(&pkt->samples, len-offset)) { 498 500 inc_enqueued(); 499 501 DEBUG_LOG("+"); … … 539 541 size_t len; 540 542 while (rp->dequeue(&p, &len)) { 541 542 // TODO: Invoke user callback, handle KEEP and DONE 543 544 // Release frame543 result r = (*handler)(p, len); 544 545 // Callers are always required to accept a frame, but then to signal when 546 // they are done. 545 547 d_buffer->release_frame(p); 546 548 DEBUG_LOG("-"); 547 549 dec_enqueued(); 550 551 if (r && data_handler::DONE) 552 break; 548 553 } 549 554 usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
r8850 r8955 51 51 int d_next_rid; 52 52 unsigned int d_num_rx_frames; 53 unsigned int d_num_rx_lost; 53 unsigned int d_num_rx_missing; 54 unsigned int d_num_rx_overruns; 54 55 unsigned int d_num_rx_bytes; 55 56 … … 95 96 bool rx_samples(unsigned int channel, data_handler *handler); 96 97 bool stop_rx_streaming(unsigned int channel); 98 unsigned int rx_overruns() const { return d_num_rx_overruns; } 99 unsigned int rx_missing() const { return d_num_rx_missing; } 97 100 }; 98 101
