[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5487 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5487 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Thu, 17 May 2007 11:56:19 -0600 (MDT) |
Author: gnychis
Date: 2007-05-17 11:56:18 -0600 (Thu, 17 May 2007)
New Revision: 5487
Added:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.h
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
Log:
Adding in fake USRP code for detailed packet testing.
The fake USRP testing is currently run by defining FAKE_USRP_TESTS (enabled for
now).
Functionality tested:
- start of burst on first packet
- end of burst on last packet
- all other flags initialized to 0 on all packets
- timestamp set on first packet
- 'now' (0xffffffff) set on all other packets in the burst
- payload size sanity check when >1 packet
the code is also setup for testing control/status in the future, as it branches
the test cases based on the channel as the FPGA would.
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
2007-05-17 13:52:28 UTC (rev 5486)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
2007-05-17 17:56:18 UTC (rev 5487)
@@ -61,6 +61,7 @@
qa_inband.h \
qa_inband_packet_prims.h \
qa_inband_usrp_server.h \
+ fake_usrp.h
\
usrp_inband_usb_packet.h
@@ -70,7 +71,8 @@
libusrp_inband_qa_la_SOURCES = \
qa_inband.cc \
qa_inband_packet_prims.cc \
- qa_inband_usrp_server.cc
+ qa_inband_usrp_server.cc \
+ fake_usrp.cc
# magic flags
libusrp_inband_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid-version
@@ -92,4 +94,3 @@
MOSTLYCLEANFILES = \
$(BUILT_SOURCES) *~ *.pyc
-
Added:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.cc
(rev 0)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.cc
2007-05-17 17:56:18 UTC (rev 5487)
@@ -0,0 +1,130 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <fake_usrp.h>
+#include <iostream>
+#include <usrp_inband_usb_packet.h>
+#include <mb_class_registry.h>
+#include <vector>
+
+typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit
easy
+
+fake_usrp::fake_usrp()
+{
+ std::cout << "[fake_usrp] Initializing...\n";
+}
+
+fake_usrp::~fake_usrp() {}
+
+long
+fake_usrp::write_bus(transport_pkt *pkts, long n_pkts)
+{
+ std::cout << "[fake_usrp] Packets over bus: " << n_pkts << "\n";
+
+ // I'm assuming that a control packet cannot exist in a burst of data
packets,
+ // therefore i read only the first packet's channel in the current burst
+ if(pkts[0].chan() == 0x1f) {
+ return control_block(pkts, n_pkts);
+ } else {
+ return data_block(pkts, n_pkts);
+ }
+
+}
+
+long
+fake_usrp::data_block(transport_pkt *pkts, long n_pkts)
+{
+ std::cout << "[fake_usrp] Entering data block\n";
+
+ // The first packet should have the start of burst, and the last packet
should have end of burst
+ if(pkts[0].start_of_burst() && pkts[n_pkts-1].end_of_burst()) {
+ std::cout << "[fake_usrp] Correct burst flags set\n";
+ } else {
+ std::cout << "[fake_usrp] Incorrect burst flags set!\n";
+ return 0;
+ }
+
+ // All other flags should be set to 0 (e.g., overrun should not be set yet)
on ALL packets
+ for(int i=0; i < n_pkts; i++) {
+ if(pkts[i].overrun()) {
+ std::cout << "[fake_usrp] Incorrect set of overrun flag on transmit\n";
+ return 0;
+ } else if(pkts[i].underrun()) {
+ std::cout << "[fake_usrp] Incorrect set of underrun flag on transmit\n";
+ return 0;
+ } else if(pkts[i].dropped()) {
+ std::cout << "[fake_usrp] Incorrect set of drop flag on transmit\n";
+ return 0;
+ }
+ }
+ std::cout << "[fake_usrp] Correct overrun, underrun, and drop flags on
transmit (initialized to 0)\n";
+
+ // The first packet should have a timestamp, other packets should have "NOW"
+ if(pkts[0].timestamp() != 0xffffffff) {
+ std::cout << "[fake_usrp] Correct timestamp on first packet\n";
+ } else {
+ std::cout << "[fake_usrp] Initial packet should not have the 0xffffffff
timestamp\n";
+ return 0;
+ }
+
+ // Check that all of the other packets include the NOW timestamp
+ int check_stamps=1;
+ for(int i=1; i < n_pkts; i++) // start at 1 to skip the first
packet
+ if(pkts[i].timestamp() != 0xffffffff)
+ check_stamps=0;
+
+ if(check_stamps) {
+ std::cout << "[fake_usrp] Correct NOW timestamps (0xffffffff) on
intermediate burst packets\n";
+ } else {
+ std::cout << "[fake_usrp] Incorrect timestamps on intermediate burst
packets\n";
+ return 0;
+ }
+
+ // Since we are being transparent about samples, we do not ensure the
payload is correct, however
+ // it should be the case that if there are >1 packets, all packets except
the last packet should
+ // have a full payload size
+ if(n_pkts > 1) {
+ int check_size=1;
+ for(int i=0; i < n_pkts-1; i++)
+ if(pkts[i].payload_len() != transport_pkt::max_payload())
+ check_size=0;
+
+ if(check_size) {
+ std::cout << "[fake_usrp] Correct payload size sanity check on
packets\n";
+ } else {
+ std::cout << "[fake_usrp] Failed payload size sanity check\n";
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+long
+fake_usrp::control_block(transport_pkt *pkts, long n_pkts)
+{
+ std::cout << "[fake_usrp] Entering control block\n";
+
+ return 1;
+}
Property changes on:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.cc
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.h
(rev 0)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.h
2007-05-17 17:56:18 UTC (rev 5487)
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_FAKE_USRP_H
+#define INCLUDED_FAKE_USRP_H
+
+#include <usrp_inband_usb_packet.h>
+typedef usrp_inband_usb_packet transport_pkt;
+
+/*!
+ * \brief Implements a fake USRP for testing without hardware
+ */
+class fake_usrp
+{
+ public:
+ fake_usrp();
+ ~fake_usrp();
+ long write_bus(transport_pkt *pkts, long n_pkts);
+
+ protected:
+ long data_block(transport_pkt *pkts, long n_pkts);
+ long control_block(transport_pkt *pkts, long n_pkts);
+};
+
+#endif /* INCLUDED_FAKE_USRP_H */
+
Property changes on:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-05-17 13:52:28 UTC (rev 5486)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-05-17 17:56:18 UTC (rev 5487)
@@ -27,9 +27,12 @@
#include <usrp_inband_usb_packet.h>
#include <mb_class_registry.h>
#include <vector>
+#include <fake_usrp.h>
typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit
easy
+#define FAKE_USRP_TESTS
+
// FIXME We should machine generate these by a simple preprocessor run over
this file
//
// These are all the messages that we expect to receive.
@@ -408,10 +411,17 @@
// interface with the USRP to send the USB packet, since the memory is
// contiguous, this should be a serious of memory copies to the bus, each
being
// USB_PKT_SIZE * MAX_PACKET_BURST bytes worth of data (given a full burst)
-
+
std::cout << "[usrp_server] Received raw frame for invocation " <<
pmt_to_long(invocation_handle) << " --> " << n_packets << " packets\n";
-
+
reply_data = pmt_list2(invocation_handle, PMT_T);
+
+#ifdef FAKE_USRP_TESTS
+ fake_usrp usrp;
+ if(!usrp.write_bus(pkts, n_packets))
+ reply_data = pmt_list2(invocation_handle, PMT_F);
+#endif
+
d_tx[port]->send(s_response_xmit_raw_frame, reply_data);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5487 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=