[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8542 - in usrp2/trunk/host-ng: apps lib
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r8542 - in usrp2/trunk/host-ng: apps lib |
Date: |
Mon, 2 Jun 2008 01:53:22 -0600 (MDT) |
Author: jcorgan
Date: 2008-06-02 01:53:14 -0600 (Mon, 02 Jun 2008)
New Revision: 8542
Added:
usrp2/trunk/host-ng/apps/test.sh
Modified:
usrp2/trunk/host-ng/apps/
usrp2/trunk/host-ng/apps/Makefile.am
usrp2/trunk/host-ng/apps/test_usrp2.cc
usrp2/trunk/host-ng/lib/usrp2.cc
Log:
wip, receiving at linespeed
Property changes on: usrp2/trunk/host-ng/apps
___________________________________________________________________
Name: svn:ignore
- Makefile
Makefile.in
.libs
.deps
test_usrp2
+ Makefile
Makefile.in
.libs
.deps
test_usrp2
cerr
Modified: usrp2/trunk/host-ng/apps/Makefile.am
===================================================================
--- usrp2/trunk/host-ng/apps/Makefile.am 2008-06-02 01:02:26 UTC (rev
8541)
+++ usrp2/trunk/host-ng/apps/Makefile.am 2008-06-02 07:53:14 UTC (rev
8542)
@@ -20,7 +20,8 @@
INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES)
LDADD = \
- ../lib/libusrp2ng.la
+ ../lib/libusrp2ng.la \
+ $(GNURADIO_CORE_LIBS)
noinst_PROGRAMS = \
test_usrp2
Added: usrp2/trunk/host-ng/apps/test.sh
===================================================================
--- usrp2/trunk/host-ng/apps/test.sh (rev 0)
+++ usrp2/trunk/host-ng/apps/test.sh 2008-06-02 07:53:14 UTC (rev 8542)
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+sudo ./test_usrp2 2>cerr
+
Property changes on: usrp2/trunk/host-ng/apps/test.sh
___________________________________________________________________
Name: svn:executable
+ *
Modified: usrp2/trunk/host-ng/apps/test_usrp2.cc
===================================================================
--- usrp2/trunk/host-ng/apps/test_usrp2.cc 2008-06-02 01:02:26 UTC (rev
8541)
+++ usrp2/trunk/host-ng/apps/test_usrp2.cc 2008-06-02 07:53:14 UTC (rev
8542)
@@ -21,11 +21,16 @@
#endif
#include <usrp2/usrp2.h>
+#include <gr_realtime.h>
#include <iostream>
int
main(int argc, char **argv)
{
+ gr_rt_status_t rt = gr_enable_realtime_scheduling();
+ if (rt != RT_OK)
+ std::cerr << "Failed to enable realtime scheduling" << std::endl;
+
// usrp2::usrp2::sptr u2 = usrp2::usrp2::make("eth0", "00:50:c2:85:31:67");
// usrp2::usrp2::sptr u2 = usrp2::usrp2::make("eth0", "BO:GU:SA:DD:RE:SS");
usrp2::usrp2::sptr u2 = usrp2::usrp2::make("eth0");
@@ -33,7 +38,7 @@
u2->start_rx_streaming();
struct timespec ts;
- ts.tv_sec = 1;
+ ts.tv_sec = 10;
nanosleep(&ts, 0);
std::cout << std::endl;
Modified: usrp2/trunk/host-ng/lib/usrp2.cc
===================================================================
--- usrp2/trunk/host-ng/lib/usrp2.cc 2008-06-02 01:02:26 UTC (rev 8541)
+++ usrp2/trunk/host-ng/lib/usrp2.cc 2008-06-02 07:53:14 UTC (rev 8542)
@@ -53,9 +53,11 @@
std::string d_addr;
usrp2_thread *d_thread;
bool d_tx_active;
- unsigned int d_rx_seqno;
- unsigned int d_tx_seqno;
-
+ int d_rx_seqno;
+ int d_tx_seqno;
+ unsigned int d_num_rx_frames;
+ unsigned int d_num_rx_lost;
+
public:
impl(const std::string &ifc, const std::string &addr);
~impl();
@@ -113,7 +115,7 @@
usrp2::impl::impl(const std::string &ifc, const std::string &addr)
: d_ethernet(new ethernet()), d_pf(0), d_thread(0),
- d_rx_seqno(0), d_tx_seqno(0)
+ d_rx_seqno(-1), d_tx_seqno(0), d_num_rx_frames(0), d_num_rx_lost(0)
{
props_vector_t u2s = find(ifc, addr);
if (u2s.size() != 1)
@@ -142,6 +144,13 @@
delete d_pf;
d_ethernet->close();
delete d_ethernet;
+
+ if (USRP2_DEBUG) {
+ std::cerr << "usrp2 destructor: received " << d_num_rx_frames
+ << " frames, with " << d_num_rx_lost << " gaps ("
+ << (int)(100.0*d_num_rx_lost/d_num_rx_frames)
+ << "%)" << std::endl;
+ }
}
bool
@@ -155,7 +164,6 @@
p->addr[5] = 0x00;
int len = s.size();
- std::cerr << len << std::endl;
switch (len){
@@ -232,6 +240,7 @@
bool
usrp2::impl::stop_rx_streaming()
{
+ return true;
}
void
@@ -279,12 +288,13 @@
void
usrp2::impl::rx_frames()
{
- uint8_t pktbuf[ethernet::MAX_PKTLEN];
- memset(pktbuf, 0, sizeof(pktbuf));
+ //uint8_t pktbuf[ethernet::MAX_PKTLEN];
+ //memset(pktbuf, 0, sizeof(pktbuf));
+ u2_eth_samples_t pkt;
int len;
while (1) {
- len = d_ethernet->read_packet_dont_block(pktbuf, sizeof(pktbuf));
+ len = d_ethernet->read_packet_dont_block(&pkt, sizeof(pkt));
if (len < 0) {
DEBUG_LOG("!"); // error
@@ -301,8 +311,27 @@
DEBUG_LOG("R"); // read ok
}
- // Do stuff with received packet...
+ d_num_rx_frames += 1;
+ if (d_rx_seqno != -1) {
+ int expected_seqno = (d_rx_seqno + 1) & 0xFF;
+ int seqno = pkt.hdrs.thdr.seqno;
+ if (seqno != expected_seqno) {
+ std::cerr << "\nL expected=" << expected_seqno
+ << " actual=" << seqno
+ << std::endl;
+
+ //DEBUG_LOG("L"); // missed packet
+ int missing = expected_seqno - seqno;
+ if (missing < 0)
+ missing += 256;
+
+ if (d_num_rx_frames > 256) // skip start up
+ d_num_rx_lost += missing;
+ }
+ }
+
+ d_rx_seqno = pkt.hdrs.thdr.seqno;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8542 - in usrp2/trunk/host-ng: apps lib,
jcorgan <=