Changeset 8958
- Timestamp:
- 07/20/08 15:55:40
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc
r8955 r8958 142 142 size_t bufsize = 100e6; 143 143 unsigned char *buf = (unsigned char *)malloc(bufsize); 144 usrp2::copy_handler h(buf, bufsize);145 144 146 printf("Receiving data into buffer of length %li bytes.\n\n", bufsize);145 printf("Receiving data ten times into buffer of length %li bytes.\n\n", bufsize); 147 146 148 147 struct timeval start, end; 149 148 gettimeofday(&start, 0); 150 149 150 printf("Each '.' is 100 packets:\n"); 151 151 152 printf("Each '.' is 100 packets:\n"); 153 bool ok; 154 unsigned int n = 0; 152 int count = 0; 153 unsigned long bytes = 0; 154 unsigned long times = 0; 155 155 156 do { 156 ok = u2->rx_samples(0, &h); 157 if (h.times() > n) { 158 printf("."); fflush(stdout); 159 n = n+100; 157 usrp2::copy_handler h(buf, bufsize); 158 bool ok; 159 unsigned int n = 0; 160 do { 161 ok = u2->rx_samples(0, &h); 162 if (h.times() > n) { 163 printf("."); fflush(stdout); 164 n = n+100; 165 } 160 166 } 167 while (ok && !h.full()); 168 if (!ok) 169 break; 170 171 bytes += h.bytes(); 172 times += h.times(); 161 173 } 162 while ( ok && !h.full());174 while (++count < 10); 163 175 164 176 gettimeofday(&end, 0); … … 166 178 long n_secs = end.tv_sec-start.tv_sec; 167 179 double elapsed = (double)n_secs + (double)n_usecs*1e-6; 168 double mbs = h.bytes()/elapsed/1e6;169 double pps = h.times()/elapsed;180 double mbs = bytes/elapsed/1e6; 181 double pps = times/elapsed; 170 182 171 183 u2->stop_rx_streaming(); 172 184 173 printf("\nCopy handler called %li times.\n", h.times());174 printf("Copy handler called with %li bytes.\n\n", h.bytes());185 printf("\nCopy handler called %li times.\n", times); 186 printf("Copy handler called with %li bytes.\n\n", bytes); 175 187 printf("Elapsed time was %5.3f seconds.\n", elapsed); 176 188 printf("Packet rate was %1.0f pkts/sec.\n", pps);
