[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8955 - in usrp2/branches/features/host-ng/host-ng: ap
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r8955 - in usrp2/branches/features/host-ng/host-ng: apps include/usrp2 lib |
Date: |
Sun, 20 Jul 2008 14:47:16 -0600 (MDT) |
Author: jcorgan
Date: 2008-07-20 14:47:16 -0600 (Sun, 20 Jul 2008)
New Revision: 8955
Modified:
usrp2/branches/features/host-ng/host-ng/apps/test.sh
usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc
usrp2/branches/features/host-ng/host-ng/include/usrp2/copy_handler.h
usrp2/branches/features/host-ng/host-ng/include/usrp2/usrp2.h
usrp2/branches/features/host-ng/host-ng/lib/copy_handler.cc
usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc
usrp2/branches/features/host-ng/host-ng/lib/usrp2.cc
usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
Log:
Receiving data now flowing through top-level rx_samples with raw copy handler.
Modified: usrp2/branches/features/host-ng/host-ng/apps/test.sh
===================================================================
--- usrp2/branches/features/host-ng/host-ng/apps/test.sh 2008-07-20
18:01:33 UTC (rev 8954)
+++ usrp2/branches/features/host-ng/host-ng/apps/test.sh 2008-07-20
20:47:16 UTC (rev 8955)
@@ -1,5 +1,5 @@
#!/bin/sh
-sudo ./test_usrp2 -d 5 1>cerr 2>&1
+sudo ./test_usrp2 -d 4
Modified: usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc 2008-07-20
18:01:33 UTC (rev 8954)
+++ usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc 2008-07-20
20:47:16 UTC (rev 8955)
@@ -23,7 +23,9 @@
#include <usrp2/usrp2.h>
#include <usrp2/tune_result.h>
#include <usrp2/strtod_si.h>
+#include <usrp2/copy_handler.h>
#include <gruel/realtime.h>
+#include <sys/time.h>
#include <iostream>
#include <string.h>
@@ -119,26 +121,63 @@
exit(1);
}
- printf("baseband_freq=%f\n", tr.baseband_freq);
- printf(" ddc_freq=%f\n", tr.dxc_freq);
- printf("residual_freq=%f\n", tr.residual_freq);
- printf(" inverted=%s\n", tr.spectrum_inverted ? "yes" : "no");
+ printf("Daughterboard configuration:\n");
+ printf(" baseband_freq=%f\n", tr.baseband_freq);
+ printf(" ddc_freq=%f\n", tr.dxc_freq);
+ printf(" residual_freq=%f\n", tr.residual_freq);
+ printf(" inverted=%s\n\n", tr.spectrum_inverted ? "yes" : "no");
if (!u2->set_rx_decim(rx_decim)) {
fprintf(stderr, "set_rx_decim(%d) failed\n", rx_decim);
exit(1);
}
+
+ printf("USRP2 using decimation rate of %d\n", rx_decim);
if (!u2->start_rx_streaming()){
fprintf(stderr, "start_rx_streaming failed\n");
exit(1);
}
- // Temporary to allow program to finish
- int n = 0;
- while(n++ < 100000)
- u2->rx_samples(0, NULL);
+ size_t bufsize = 100e6;
+ unsigned char *buf = (unsigned char *)malloc(bufsize);
+ usrp2::copy_handler h(buf, bufsize);
+ printf("Receiving data into buffer of length %li bytes.\n\n", bufsize);
+
+ struct timeval start, end;
+ gettimeofday(&start, 0);
+
+
+ printf("Each '.' is 100 packets:\n");
+ bool ok;
+ unsigned int n = 0;
+ do {
+ ok = u2->rx_samples(0, &h);
+ if (h.times() > n) {
+ printf("."); fflush(stdout);
+ n = n+100;
+ }
+ }
+ while (ok && !h.full());
+
+ gettimeofday(&end, 0);
+ long n_usecs = end.tv_usec-start.tv_usec;
+ long n_secs = end.tv_sec-start.tv_sec;
+ double elapsed = (double)n_secs + (double)n_usecs*1e-6;
+ double mbs = h.bytes()/elapsed/1e6;
+ double pps = h.times()/elapsed;
+
u2->stop_rx_streaming();
+
+ printf("\nCopy handler called %li times.\n", h.times());
+ printf("Copy handler called with %li bytes.\n\n", h.bytes());
+ printf("Elapsed time was %5.3f seconds.\n", elapsed);
+ printf("Packet rate was %1.0f pkts/sec.\n", pps);
+ printf("Approximate throughput was %5.2f MB/sec.\n", mbs);
+ printf("Total instances of overruns was %d.\n", u2->rx_overruns());
+ printf("Total missing frames was %d.\n", u2->rx_missing());
+
+ free(buf);
return 0;
}
Modified: usrp2/branches/features/host-ng/host-ng/include/usrp2/copy_handler.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/include/usrp2/copy_handler.h
2008-07-20 18:01:33 UTC (rev 8954)
+++ usrp2/branches/features/host-ng/host-ng/include/usrp2/copy_handler.h
2008-07-20 20:47:16 UTC (rev 8955)
@@ -38,6 +38,12 @@
~copy_handler();
virtual data_handler::result operator()(const void *base, size_t len);
+
+ size_t bytes() const { return d_bytes; }
+ size_t times() const { return d_times; }
+
+ static const size_t MIN_COPY_LEN = 1484; // FIXME: calculate eth packet -
thdr
+ bool full() const { return d_space < MIN_COPY_LEN; }
};
} // namespace usrp2
Modified: usrp2/branches/features/host-ng/host-ng/include/usrp2/usrp2.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/include/usrp2/usrp2.h
2008-07-20 18:01:33 UTC (rev 8954)
+++ usrp2/branches/features/host-ng/host-ng/include/usrp2/usrp2.h
2008-07-20 20:47:16 UTC (rev 8955)
@@ -124,6 +124,16 @@
*/
bool stop_rx_streaming(unsigned int channel=0);
+ /*!
+ * Returns number of times receive overruns have occurred
+ */
+ unsigned int rx_overruns();
+
+ /*!
+ * Returns total number of missing frames from overruns.
+ */
+ unsigned int rx_missing();
+
/* Ignore :-) */
class impl;
Modified: usrp2/branches/features/host-ng/host-ng/lib/copy_handler.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/copy_handler.cc 2008-07-20
18:01:33 UTC (rev 8954)
+++ usrp2/branches/features/host-ng/host-ng/lib/copy_handler.cc 2008-07-20
20:47:16 UTC (rev 8955)
@@ -24,6 +24,7 @@
#endif
#include <usrp2/copy_handler.h>
+#include <iostream>
namespace usrp2 {
@@ -47,10 +48,10 @@
d_space -= len;
d_bytes += len;
d_times++;
+
+ if (d_space < MIN_COPY_LEN)
+ return DONE; // don't call me anymore
- if (d_space == 0)
- return DONE; // don't call me anymore
-
return 0;
}
Modified: usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc 2008-07-20
18:01:33 UTC (rev 8954)
+++ usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc 2008-07-20
20:47:16 UTC (rev 8955)
@@ -34,7 +34,7 @@
#include <cmath>
#include <errno.h>
-#define ETH_BUFFER_DEBUG 1 // define to 0 or 1
+#define ETH_BUFFER_DEBUG 0 // define to 0 or 1
#if ETH_BUFFER_DEBUG
#define DEBUG_LOG(x) ::write(2, (x), 1)
#else
Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2.cc 2008-07-20
18:01:33 UTC (rev 8954)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2.cc 2008-07-20
20:47:16 UTC (rev 8955)
@@ -87,4 +87,16 @@
return d_impl->stop_rx_streaming(channel);
}
+ unsigned int
+ usrp2::rx_overruns()
+ {
+ return d_impl->rx_overruns();
+ }
+
+ unsigned int
+ usrp2::rx_missing()
+ {
+ return d_impl->rx_missing();
+ }
+
} // namespace usrp2
Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc 2008-07-20
18:01:33 UTC (rev 8954)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc 2008-07-20
20:47:16 UTC (rev 8955)
@@ -34,7 +34,7 @@
#include <iostream>
#include <stdio.h>
-#define USRP2_IMPL_DEBUG 1
+#define USRP2_IMPL_DEBUG 0
#if USRP2_IMPL_DEBUG
#define DEBUG_LOG(x) ::write(2, x, 1)
#else
@@ -78,8 +78,8 @@
usrp2::impl::impl(const std::string &ifc, const std::string &addr)
: d_buffer(new eth_buffer()), d_pf(0), d_bg_thread(0), d_bg_running(false),
d_rx_decim(0), d_rx_seqno(-1), d_tx_seqno(0), d_next_rid(0),
- d_num_rx_frames(0), d_num_rx_lost(0), d_num_rx_bytes(0),
d_num_enqueued(0),
- d_enqueued_mutex(), d_bg_pending_cond(&d_enqueued_mutex)
+ d_num_rx_frames(0), d_num_rx_missing(0), d_num_rx_overruns(0),
d_num_rx_bytes(0),
+ d_num_enqueued(0), d_enqueued_mutex(),
d_bg_pending_cond(&d_enqueued_mutex)
{
props_vector_t u2s = find(ifc, addr);
if (u2s.size() != 1)
@@ -115,8 +115,8 @@
if (USRP2_IMPL_DEBUG) {
std::cerr << std::endl
<< "usrp2 destructor: received " << d_num_rx_frames
- << " frames, with " << d_num_rx_lost << " lost ("
- << (d_num_rx_frames == 0 ? 0 :
(int)(100.0*d_num_rx_lost/d_num_rx_frames))
+ << " frames, with " << d_num_rx_missing << " lost ("
+ << (d_num_rx_frames == 0 ? 0 :
(int)(100.0*d_num_rx_missing/d_num_rx_frames))
<< "%), totaling " << d_num_rx_bytes
<< " bytes" << std::endl;
}
@@ -482,7 +482,8 @@
if (missing < 0)
missing += 256;
- d_num_rx_lost += missing;
+ d_num_rx_overruns++;
+ d_num_rx_missing += missing;
}
}
@@ -494,7 +495,8 @@
return 0; // discard packet, no channel handler
}
- if (d_channel_rings[chan]->enqueue(&pkt->samples, 0)) {
+ size_t offset = (uint8_t *)(&pkt->samples) - (uint8_t *)base;
+ if (d_channel_rings[chan]->enqueue(&pkt->samples, len-offset)) {
inc_enqueued();
DEBUG_LOG("+");
return KEEP; // channel ring runner will mark frame done
@@ -538,13 +540,16 @@
void *p;
size_t len;
while (rp->dequeue(&p, &len)) {
+ result r = (*handler)(p, len);
- // TODO: Invoke user callback, handle KEEP and DONE
-
- // Release frame
+ // Callers are always required to accept a frame, but then to signal when
+ // they are done.
d_buffer->release_frame(p);
DEBUG_LOG("-");
dec_enqueued();
+
+ if (r && data_handler::DONE)
+ break;
}
return true;
Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h 2008-07-20
18:01:33 UTC (rev 8954)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h 2008-07-20
20:47:16 UTC (rev 8955)
@@ -50,7 +50,8 @@
int d_tx_seqno;
int d_next_rid;
unsigned int d_num_rx_frames;
- unsigned int d_num_rx_lost;
+ unsigned int d_num_rx_missing;
+ unsigned int d_num_rx_overruns;
unsigned int d_num_rx_bytes;
unsigned int d_num_enqueued;
@@ -94,6 +95,8 @@
bool start_rx_streaming(unsigned int channel, unsigned int
items_per_frame);
bool rx_samples(unsigned int channel, data_handler *handler);
bool stop_rx_streaming(unsigned int channel);
+ unsigned int rx_overruns() const { return d_num_rx_overruns; }
+ unsigned int rx_missing() const { return d_num_rx_missing; }
};
} // namespace usrp2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8955 - in usrp2/branches/features/host-ng/host-ng: apps include/usrp2 lib,
jcorgan <=