[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5214 - in gnuradio/branches/features/inband-usb: . us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5214 - in gnuradio/branches/features/inband-usb: . usrp/host/apps usrp/host/lib usrp/host/lib/inband usrp/host/lib/legacy usrp/host/swig |
Date: |
Tue, 1 May 2007 19:04:52 -0600 (MDT) |
Author: gnychis
Date: 2007-05-01 19:04:52 -0600 (Tue, 01 May 2007)
New Revision: 5214
Added:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband.cc
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband.h
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_packet_prims.cc
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_packet_prims.h
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.h
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/test_inband.cc
Modified:
gnuradio/branches/features/inband-usb/Makefile.common
gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am
gnuradio/branches/features/inband-usb/usrp/host/lib/Makefile.am
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.mbh
gnuradio/branches/features/inband-usb/usrp/host/lib/legacy/Makefile.am
gnuradio/branches/features/inband-usb/usrp/host/swig/Makefile.am
Log:
Merged gnychis/inband -r5057:5213 in to features/inband-usb. Contains usrp
server code and QA code for channel allocation and deallocation.
Modified: gnuradio/branches/features/inband-usb/Makefile.common
===================================================================
--- gnuradio/branches/features/inband-usb/Makefile.common 2007-05-01
22:44:43 UTC (rev 5213)
+++ gnuradio/branches/features/inband-usb/Makefile.common 2007-05-02
01:04:52 UTC (rev 5214)
@@ -76,7 +76,7 @@
USRP_INCLUDES = -I$(top_srcdir)/usrp/host/lib/legacy \
-I$(top_srcdir)/usrp/host/lib/inband \
-I$(top_srcdir)/usrp/firmware/include
-USRP_LA = $(top_builddir)/usrp/host/lib/libusrp.la
+USRP_LA = $(top_builddir)/usrp/host/lib/legacy/libusrp.la
# How to link the PMT library from inside the tree
PMT_INCLUDES = -I$(top_srcdir)/pmt/src/lib
Modified: gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am
2007-05-01 22:44:43 UTC (rev 5213)
+++ gnuradio/branches/features/inband-usb/usrp/host/apps/Makefile.am
2007-05-02 01:04:52 UTC (rev 5214)
@@ -23,8 +23,6 @@
INCLUDES = $(USRP_INCLUDES) $(BOOST_CFLAGS)
-USRP_LIB = $(top_builddir)/usrp/host/lib/libusrp.la
-
bin_PROGRAMS = \
usrper \
usrp_cal_dc_offset
@@ -45,13 +43,13 @@
check_order_quickly_SOURCES = check_order_quickly.cc
test_usrp_standard_rx_SOURCES = test_usrp_standard_rx.cc time_stuff.c
-test_usrp_standard_rx_LDADD = $(USRP_LIB)
+test_usrp_standard_rx_LDADD = $(USRP_LA)
test_usrp_standard_tx_SOURCES = test_usrp_standard_tx.cc time_stuff.c
-test_usrp_standard_tx_LDADD = $(USRP_LIB)
+test_usrp_standard_tx_LDADD = $(USRP_LA)
usrper_SOURCES = usrper.cc
-usrper_LDADD = $(USRP_LIB)
+usrper_LDADD = $(USRP_LA)
usrp_cal_dc_offset_SOURCES = usrp_cal_dc_offset.cc
-usrp_cal_dc_offset_LDADD = $(USRP_LIB)
+usrp_cal_dc_offset_LDADD = $(USRP_LA)
Modified: gnuradio/branches/features/inband-usb/usrp/host/lib/Makefile.am
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/Makefile.am
2007-05-01 22:44:43 UTC (rev 5213)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/Makefile.am
2007-05-02 01:04:52 UTC (rev 5214)
@@ -20,27 +20,5 @@
include $(top_srcdir)/Makefile.common
-SUBDIRS = legacy inband .
+SUBDIRS = legacy inband
-INCLUDES = $(USRP_INCLUDES)
-
-EXTRA_DIST =
-BUILT_SOURCES =
-
-# generate libusrp.la from the convenience libraries in subdirs
-
-lib_LTLIBRARIES = libusrp.la
-
-libusrp_la_SOURCES =
-
-libusrp_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
-
-libusrp_la_LIBADD = \
- $(USB_LIBS) \
- ../misc/libmisc.la \
- legacy/liblegacy.la \
- inband/libinband.la
-
-MOSTLYCLEANFILES = \
- $(BUILT_SOURCES) *~ *.pyc
-
Modified: gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am
2007-05-01 22:44:43 UTC (rev 5213)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/Makefile.am
2007-05-02 01:04:52 UTC (rev 5214)
@@ -22,41 +22,71 @@
INCLUDES = \
$(DEFINES) $(OMNITHREAD_INCLUDES) $(PMT_INCLUDES) $(MBLOCK_INCLUDES) \
- $(USRP_INCLUDES) $(BOOST_CFLAGS)
+ $(USRP_INCLUDES) $(BOOST_CFLAGS) $(CPPUNIT_INCLUDES)
+TESTS = test_inband
-EXTRA_DIST = \
- usrp_server.mbh \
- dump_packets.py \
- usb_packet.py \
- gen_test_packets.py
+EXTRA_DIST =
+lib_LTLIBRARIES = \
+ libusrp_inband.la \
+ libusrp_inband-qa.la
-noinst_LTLIBRARIES = libinband.la
+# ------------------------------------------------------------------------
+# Build the inband library
BUILT_SOURCES = \
- usrp_server_mbh.cc
+ usrp_server_mbh.cc
usrp_server_mbh.cc : usrp_server.mbh
$(COMPILE_MBH) usrp_server.mbh usrp_server_mbh.cc
-
-libinband_la_SOURCES = \
+libusrp_inband_la_SOURCES = \
$(BUILT_SOURCES) \
- usrp_server.cc
+ usrp_server.cc
-libinband_la_LIBADD = \
- $(MBLOCK_LA)
+libusrp_inband_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
+libusrp_inband_la_LIBADD = \
+ $(MBLOCK_LA) \
+ -lstdc++
+
include_HEADERS = \
usrp_server.h
-noinst_HEADERS = \
- usrp_inband_usb_packet.h
+noinst_HEADERS = \
+ qa_inband.h \
+ qa_inband_packet_prims.h \
+ qa_inband_usrp_server.h
+# ------------------------------------------------------------------------
+# Build the qa code in its own library
+libusrp_inband_qa_la_SOURCES = \
+ qa_inband.cc \
+ qa_inband_packet_prims.cc \
+ qa_inband_usrp_server.cc
+
+# magic flags
+libusrp_inband_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid-version
+
+# link against c++ standard library
+libusrp_inband_qa_la_LIBADD = \
+ libusrp_inband.la \
+ $(CPPUNIT_LIBS) \
+ -lstdc++
+
+# ------------------------------------------------------------------------
+
+noinst_PROGRAMS = \
+ test_inband
+
+test_inband_SOURCES = test_inband.cc
+test_inband_LDADD = libusrp_inband-qa.la
+
+
MOSTLYCLEANFILES = \
$(BUILT_SOURCES) *~ *.pyc
Copied: gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband.cc
(from rev 5213,
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband.cc)
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband.cc
(rev 0)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband.cc
2007-05-02 01:04:52 UTC (rev 5214)
@@ -0,0 +1,35 @@
+/* -*- 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.
+ */
+
+#include <qa_inband.h>
+#include <qa_inband_packet_prims.h>
+#include <qa_inband_usrp_server.h>
+
+CppUnit::TestSuite *
+qa_inband::suite()
+{
+ CppUnit::TestSuite *s = new CppUnit::TestSuite("inband");
+
+ s->addTest (qa_inband_packet_prims::suite());
+ s->addTest (qa_inband_usrp_server::suite());
+
+ return s;
+}
Copied: gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband.h
(from rev 5213,
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband.h)
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband.h
(rev 0)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband.h
2007-05-02 01:04:52 UTC (rev 5214)
@@ -0,0 +1,35 @@
+/* -*- 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_QA_INBAND_H
+#define INCLUDED_QA_INBAND_H
+
+#include <cppunit/TestSuite.h>
+
+//! collect all the tests for the user server
+
+class qa_inband {
+ public:
+ //! return suite of tests for all of usrp server
+ static CppUnit::TestSuite *suite();
+};
+
+#endif /* INCLUDED_QA_INBAND_H */
Copied:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_packet_prims.cc
(from rev 5213,
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.cc)
===================================================================
---
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_packet_prims.cc
(rev 0)
+++
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_packet_prims.cc
2007-05-02 01:04:52 UTC (rev 5214)
@@ -0,0 +1,161 @@
+/* -*- 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 <qa_inband_packet_prims.h>
+#include <cppunit/TestAssert.h>
+#include <stdio.h>
+#include <usrp_inband_usb_packet.h> // will change on gigabit
crossover
+
+typedef usrp_inband_usb_packet transport_pkt;
+
+void
+qa_inband_packet_prims::test_flags()
+{
+ transport_pkt pkt;
+
+ // Test each one of the flags while ensuring no other fields become set in
the process
+ pkt.set_header(pkt.FL_START_OF_BURST,0,0,0);
+ CPPUNIT_ASSERT_EQUAL(1, pkt.start_of_burst());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+ pkt.set_header(pkt.FL_END_OF_BURST,0,0,0);
+ CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
+ CPPUNIT_ASSERT_EQUAL(1, pkt.end_of_burst());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+ pkt.set_header(pkt.FL_OVERRUN,0,0,0);
+ CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
+ CPPUNIT_ASSERT_EQUAL(1, pkt.overrun());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+ pkt.set_header(pkt.FL_UNDERRUN,0,0,0);
+ CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
+ CPPUNIT_ASSERT_EQUAL(1, pkt.underrun());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+ pkt.set_header(pkt.FL_DROPPED,0,0,0);
+ CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
+ CPPUNIT_ASSERT_EQUAL(1, pkt.dropped());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+ // test of all fields set
+ pkt.set_header(
+ pkt.FL_START_OF_BURST |
+ pkt.FL_END_OF_BURST |
+ pkt.FL_UNDERRUN |
+ pkt.FL_OVERRUN |
+ pkt.FL_DROPPED
+ ,0,0,0);
+ CPPUNIT_ASSERT_EQUAL(1, pkt.start_of_burst());
+ CPPUNIT_ASSERT_EQUAL(1, pkt.end_of_burst());
+ CPPUNIT_ASSERT_EQUAL(1, pkt.overrun());
+ CPPUNIT_ASSERT_EQUAL(1, pkt.underrun());
+ CPPUNIT_ASSERT_EQUAL(1, pkt.dropped());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+
+}
+//////////////////////////////////////////////////////////////////////
+
+void
+qa_inband_packet_prims::test_fields()
+{
+ transport_pkt pkt;
+ void * payload;
+
+ // test word0 field exclusiveness
+ //
+ // I want to test max values of each field to ensure field boundaries
+ // but these max values could change based on technology? The
+ // max payload is returned by a private method so the code is not
+ // technology dependent
+ pkt.set_header(0,16,0,0);
+ CPPUNIT_ASSERT_EQUAL(16, pkt.chan());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+ pkt.set_header(0,0,8,0);
+ CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+ CPPUNIT_ASSERT_EQUAL(8, pkt.tag());
+ CPPUNIT_ASSERT_EQUAL(0,pkt.payload_len());
+
+ pkt.set_header(0,0,0,pkt.max_payload());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+ CPPUNIT_ASSERT_EQUAL(pkt.max_payload(), pkt.payload_len());
+
+ // test timestamp, shouldn't have to test other fields since
+ // setting the timestamp only has the ability to affect one word
+ pkt.set_timestamp(54);
+ CPPUNIT_ASSERT_EQUAL(uint32_t(54), pkt.timestamp());
+
+ // test the payload, ensure no other fields overwritten
+ //
+ // is there a better test for this?
+ pkt.set_header(0,0,0,0);
+ payload = malloc(pkt.payload_len());
+ memset(payload, 'f', pkt.payload_len());
+ memcpy(pkt.payload(), payload, pkt.payload_len());
+ CPPUNIT_ASSERT_EQUAL(0, memcmp(pkt.payload(), payload, pkt.payload_len()));
+ CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+ CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+ free(payload);
+
+}
+//////////////////////////////////////////////////////////////////////
Copied:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_packet_prims.h
(from rev 5213,
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.h)
===================================================================
---
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_packet_prims.h
(rev 0)
+++
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_packet_prims.h
2007-05-02 01:04:52 UTC (rev 5214)
@@ -0,0 +1,41 @@
+/* -*- 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 QA_INBAND_PACKET_PRIMS_H
+#define QA_INBAND_PACKET_PRIMS_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_inband_packet_prims : public CppUnit::TestCase {
+
+ CPPUNIT_TEST_SUITE(qa_inband_packet_prims);
+ CPPUNIT_TEST(test_flags);
+ CPPUNIT_TEST(test_fields);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void test_flags();
+ void test_fields();
+
+};
+
+#endif /* INCLUDED_QA_INBAND_PACKET_PRIMS_H */
Copied:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
(from rev 5213,
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc)
===================================================================
---
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
(rev 0)
+++
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-05-02 01:04:52 UTC (rev 5214)
@@ -0,0 +1,455 @@
+/* -*- 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 <qa_inband_usrp_server.h>
+#include <cppunit/TestAssert.h>
+#include <stdio.h>
+#include <usrp_server.h>
+#include <mb_mblock.h>
+#include <mb_runtime.h>
+#include <mb_protocol_class.h>
+#include <mb_class_registry.h>
+#include <vector>
+#include <iostream>
+
+static pmt_t s_cmd_allocate_channel = pmt_intern("cmd-allocate-channel");
+static pmt_t s_response_allocate_channel =
pmt_intern("response-allocate-channel");
+static pmt_t s_send_allocate_channel = pmt_intern("send-allocate-channel");
+static pmt_t s_cmd_deallocate_channel = pmt_intern("cmd-deallocate-channel");
+static pmt_t s_response_deallocate_channel =
pmt_intern("response-deallocate-channel");
+static pmt_t s_send_deallocate_channel = pmt_intern("send-deallocate-channel");
+static pmt_t s_cmd_max_capacity = pmt_intern("cmd-max-capacity");
+static pmt_t s_response_max_capacity = pmt_intern("response-max-capacity");
+static pmt_t s_cmd_ntx_chan = pmt_intern("cmd-ntx-chan");
+static pmt_t s_cmd_nrx_chan = pmt_intern("cmd-nrx-chan");
+static pmt_t s_response_ntx_chan = pmt_intern("response-ntx-chan");
+static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan");
+static pmt_t s_cmd_current_capacity_allocation =
pmt_intern("cmd-current-capacity-allocation");
+static pmt_t s_response_current_capacity_allocation =
pmt_intern("response-current-capacity-allocation");
+
+
+//
----------------------------------------------------------------------------------------------
+
+class qa_alloc_top : public mb_mblock
+{
+ mb_port_sptr d_tx;
+ mb_port_sptr d_rx;
+ mb_port_sptr d_cs;
+
+ long d_nmsgs_to_recv;
+ long d_nrecvd;
+
+ long d_max_capacity;
+ long d_ntx_chan, d_nrx_chan;
+
+ long d_nstatus;
+ long d_nstatus_to_recv;
+
+ public:
+ qa_alloc_top(mb_runtime *runtime, const std::string &instance_name, pmt_t
user_arg);
+ ~qa_alloc_top();
+ void initial_transition();
+ void handle_message(mb_message_sptr msg);
+
+ protected:
+ void check_message(mb_message_sptr msg);
+ void run_tests();
+};
+
+qa_alloc_top::qa_alloc_top(mb_runtime *runtime, const std::string
&instance_name, pmt_t user_arg)
+ : mb_mblock(runtime, instance_name, user_arg)
+{
+ d_nrecvd=0;
+ d_nmsgs_to_recv = 7;
+ d_nstatus=0;
+ d_nstatus_to_recv = 3;
+
+ d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
+ d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
+ d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
+
+ // Test the TX side
+ define_component("server", "usrp_server", PMT_F);
+ connect("self", "tx0", "server", "tx0");
+ connect("self", "rx0", "server", "rx0");
+ connect("self", "cs", "server", "cs");
+
+}
+
+qa_alloc_top::~qa_alloc_top(){}
+
+void
+qa_alloc_top::initial_transition()
+{
+ // Retrieve information about the USRP, then run tests
+ d_cs->send(s_cmd_max_capacity, pmt_list1(PMT_F));
+ d_cs->send(s_cmd_ntx_chan, pmt_list1(PMT_F));
+ d_cs->send(s_cmd_nrx_chan, pmt_list1(PMT_F));
+}
+
+void
+qa_alloc_top::run_tests()
+{
+ std::cout << "[qa_alloc_top] Starting tests...\n";
+ // should be able to allocate 1 byte
+ d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
+
+ // should not be able to allocate max capacity after 100 bytes were allocated
+ d_tx->send(s_cmd_allocate_channel,
pmt_list2(pmt_from_long(usrp_server::RQSTD_CAPACITY_UNAVAIL),
pmt_from_long(d_max_capacity)));
+
+ // keep allocating a little more until all of the channels are used and test
the error response
+ // we start at 1 since we've already allocated 1 channel
+ for(int i=1; i < d_ntx_chan; i++) {
+ d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
+ d_nmsgs_to_recv++;
+ }
+ d_tx->send(s_cmd_allocate_channel,
pmt_list2(pmt_from_long(usrp_server::CHANNEL_UNAVAIL), pmt_from_long(1)));
+
+ // test out the same on the RX side
+ d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
+ d_rx->send(s_cmd_allocate_channel,
pmt_list2(pmt_from_long(usrp_server::RQSTD_CAPACITY_UNAVAIL),
pmt_from_long(d_max_capacity)));
+
+ for(int i=1; i < d_nrx_chan; i++) {
+ d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
+ d_nmsgs_to_recv++;
+ }
+ d_rx->send(s_cmd_allocate_channel,
pmt_list2(pmt_from_long(usrp_server::CHANNEL_UNAVAIL), pmt_from_long(1)));
+
+ // when all is said and done, there should be d_ntx_chan+d_ntx_chan bytes
allocated
+ d_cs->send(s_cmd_current_capacity_allocation,
pmt_list1(pmt_from_long(d_ntx_chan+d_nrx_chan)));
+}
+
+void
+qa_alloc_top::handle_message(mb_message_sptr msg)
+{
+ pmt_t data = msg->data();
+
+ if ((pmt_eq(msg->port_id(), d_tx->port_symbol())
+ || pmt_eq(msg->port_id(), d_rx->port_symbol()))
+ && pmt_eq(msg->signal(), s_response_allocate_channel))
+ check_message(msg);
+
+ if (pmt_eq(msg->port_id(), d_cs->port_symbol())) {
+
+ if(pmt_eq(msg->signal(), s_response_max_capacity)) {
+ d_max_capacity = pmt_to_long(pmt_nth(1, data));
+ std::cout << "[qa_alloc_top] USRP has max capacity of " <<
d_max_capacity << "\n";
+ }
+ else if(pmt_eq(msg->signal(), s_response_ntx_chan)) {
+ d_ntx_chan = pmt_to_long(pmt_nth(1, data));
+ std::cout << "[qa_alloc_top] USRP tx channels: " << d_ntx_chan << "\n";
+ }
+ else if(pmt_eq(msg->signal(), s_response_nrx_chan)) {
+ d_nrx_chan = pmt_to_long(pmt_nth(1, data));
+ std::cout << "[qa_alloc_top] USRP rx channels: " << d_nrx_chan << "\n";
+ }
+ else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) {
+ check_message(msg);
+ }
+
+ d_nstatus++;
+
+ if(d_nstatus==d_nstatus_to_recv)
+ run_tests();
+ }
+}
+
+void
+qa_alloc_top::check_message(mb_message_sptr msg)
+{
+ pmt_t data = msg->data();
+
+ pmt_t expected_result = pmt_nth(0, data);
+ pmt_t result = pmt_nth(1, data);
+
+ d_nrecvd++;
+
+
+ if(!pmt_eqv(expected_result, result)) {
+ std::cout << "Got: " << result << " Expected: " << expected_result << "\n";
+ shutdown_all(PMT_F);
+ } else {
+ std::cout << "[qa_alloc_top] Received expected response for message " <<
d_nrecvd << "\n";
+ }
+
+ if(d_nrecvd == d_nmsgs_to_recv)
+ shutdown_all(PMT_T);
+}
+
+REGISTER_MBLOCK_CLASS(qa_alloc_top);
+
+//
----------------------------------------------------------------------------------------------
+
+class qa_dealloc_top : public mb_mblock
+{
+ mb_port_sptr d_tx;
+ mb_port_sptr d_rx;
+ mb_port_sptr d_cs;
+
+ long d_max_capacity;
+ long d_ntx_chan, d_nrx_chan;
+
+ long d_nstatus;
+ long d_nstatus_to_recv;
+
+ long d_nalloc_to_recv;
+ long d_nalloc_recvd;
+
+ long d_ndealloc_to_recv;
+ long d_ndealloc_recvd;
+
+ std::vector<long> d_tx_chans;
+ std::vector<long> d_rx_chans;
+
+ public:
+ qa_dealloc_top(mb_runtime *runtime, const std::string &instance_name, pmt_t
user_arg);
+ ~qa_dealloc_top();
+ void initial_transition();
+ void handle_message(mb_message_sptr msg);
+
+ protected:
+ void check_allocation(mb_message_sptr msg);
+ void check_deallocation(mb_message_sptr msg);
+ void allocate_max();
+ void deallocate_all();
+};
+
+qa_dealloc_top::qa_dealloc_top(mb_runtime *runtime, const std::string
&instance_name, pmt_t user_arg)
+ : mb_mblock(runtime, instance_name, user_arg)
+{
+ d_ndealloc_recvd=0;
+ d_ndealloc_to_recv = 0;
+ d_nalloc_recvd=0;
+ d_nalloc_to_recv = 0;
+ d_nstatus=0;
+ d_nstatus_to_recv = 3;
+
+ d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
+ d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
+ d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
+
+ // Test the TX side
+ define_component("server", "usrp_server", PMT_F);
+ connect("self", "tx0", "server", "tx0");
+ connect("self", "rx0", "server", "rx0");
+ connect("self", "cs", "server", "cs");
+}
+
+qa_dealloc_top::~qa_dealloc_top(){}
+
+void
+qa_dealloc_top::initial_transition()
+{
+ // Retrieve information about the USRP, then run tests
+ d_cs->send(s_cmd_max_capacity, pmt_list1(PMT_F));
+ d_cs->send(s_cmd_ntx_chan, pmt_list1(PMT_F));
+ d_cs->send(s_cmd_nrx_chan, pmt_list1(PMT_F));
+}
+
+void
+qa_dealloc_top::allocate_max()
+{
+ std::cout << "[qa_dealloc_top] Max allocating...\n";
+
+ // Keep allocating until we hit the maximum number of channels
+ for(int i=0; i < d_ntx_chan; i++) {
+ d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
+ d_nalloc_to_recv++;
+ }
+ for(int i=0; i < d_nrx_chan; i++) {
+ d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
+ d_nalloc_to_recv++;
+ }
+}
+
+void
+qa_dealloc_top::deallocate_all() {
+
+ // Deallocate all of the channels that were allocated from allocate_max()
+ for(int i=0; i < (int)d_tx_chans.size(); i++) {
+ d_tx->send(s_cmd_deallocate_channel, pmt_list2(PMT_T,
pmt_from_long(d_tx_chans[i])));
+ d_ndealloc_to_recv++;
+ }
+ for(int i=0; i < (int)d_rx_chans.size(); i++) {
+ d_rx->send(s_cmd_deallocate_channel, pmt_list2(PMT_T,
pmt_from_long(d_rx_chans[i])));
+ d_ndealloc_to_recv++;
+ }
+
+ // Should get permission denied errors trying to re-dealloc the channels, as
we no
+ // longer have permission to them after deallocating
+ for(int i=0; i < (int)d_tx_chans.size(); i++) {
+ d_tx->send(s_cmd_deallocate_channel,
pmt_list2(pmt_from_long(usrp_server::PERMISSION_DENIED),
pmt_from_long(d_tx_chans[i])));
+ d_ndealloc_to_recv++;
+ }
+ for(int i=0; i < (int)d_rx_chans.size(); i++) {
+ d_rx->send(s_cmd_deallocate_channel,
pmt_list2(pmt_from_long(usrp_server::PERMISSION_DENIED),
pmt_from_long(d_rx_chans[i])));
+ d_ndealloc_to_recv++;
+ }
+
+ // Try to deallocate a channel that doesn't exist on both sides, the last
element in the vectors
+ // is the highest channel number, so we take that plus 1
+ d_ndealloc_to_recv+=2;
+ d_tx->send(s_cmd_deallocate_channel,
pmt_list2(pmt_from_long(usrp_server::CHANNEL_INVALID),
pmt_from_long(d_rx_chans.back()+1)));
+ d_rx->send(s_cmd_deallocate_channel,
pmt_list2(pmt_from_long(usrp_server::CHANNEL_INVALID),
pmt_from_long(d_rx_chans.back()+1)));
+
+
+ // The used capacity should be back to 0 now that we've deallocated
everything
+ d_cs->send(s_cmd_current_capacity_allocation, pmt_list1(pmt_from_long(0)));
+}
+
+void
+qa_dealloc_top::handle_message(mb_message_sptr msg)
+{
+ pmt_t data = msg->data();
+ if (pmt_eq(msg->port_id(), d_tx->port_symbol())
+ || pmt_eq(msg->port_id(), d_rx->port_symbol())) {
+
+ if(pmt_eq(msg->signal(), s_response_allocate_channel)) {
+ check_allocation(msg);
+ }
+
+ if(pmt_eq(msg->signal(), s_response_deallocate_channel)){
+ check_deallocation(msg);
+ }
+ }
+
+ if (pmt_eq(msg->port_id(), d_cs->port_symbol())) {
+
+ if(pmt_eq(msg->signal(), s_response_max_capacity)) {
+ d_max_capacity = pmt_to_long(pmt_nth(1, data));
+ std::cout << "[qa_dealloc_top] USRP has max capacity of " <<
d_max_capacity << "\n";
+ }
+ else if(pmt_eq(msg->signal(), s_response_ntx_chan)) {
+ d_ntx_chan = pmt_to_long(pmt_nth(1, data));
+ std::cout << "[qa_dealloc_top] USRP tx channels: " << d_ntx_chan << "\n";
+ }
+ else if(pmt_eq(msg->signal(), s_response_nrx_chan)) {
+ d_nrx_chan = pmt_to_long(pmt_nth(1, data));
+ std::cout << "[qa_dealloc_top] USRP rx channels: " << d_nrx_chan << "\n";
+ }
+ else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) {
+ // the final command is a capacity check which should be 0, then we
shutdown
+ pmt_t expected_result = pmt_nth(0, data);
+ pmt_t result = pmt_nth(1, data);
+
+ if(pmt_eqv(expected_result, result))
+ shutdown_all(PMT_T);
+ else
+ shutdown_all(PMT_F);
+ }
+
+ d_nstatus++;
+
+ if(d_nstatus==d_nstatus_to_recv)
+ allocate_max();
+ }
+}
+
+void
+qa_dealloc_top::check_deallocation(mb_message_sptr msg)
+{
+ pmt_t data = msg->data();
+
+ pmt_t expected_result = pmt_nth(0, data);
+ pmt_t result = pmt_nth(1, data);
+
+ d_ndealloc_recvd++;
+
+ if(!pmt_eqv(expected_result, result)) {
+ std::cout << "Got: " << result << " Expected: " << expected_result << "\n";
+ shutdown_all(PMT_F);
+ } else {
+ std::cout << "[qa_dealloc_top] Received expected deallocation response for
message " << d_ndealloc_recvd << "\n";
+ }
+}
+
+void
+qa_dealloc_top::check_allocation(mb_message_sptr msg)
+{
+ pmt_t data = msg->data();
+
+ pmt_t invocation_handle = pmt_nth(0, data);
+ pmt_t status = pmt_nth(1, data);
+ pmt_t channel = pmt_nth(2, data);
+
+ d_nalloc_recvd++;
+
+ if(pmt_eqv(status, PMT_F)) {
+ std::cout << "[qa_dealloc_top] Unexpected error response when allocating
channels\n";
+ shutdown_all(PMT_F);
+ } else {
+ // store all of the allocate channel numbers
+ if(pmt_eq(msg->port_id(), d_tx->port_symbol()))
+ d_tx_chans.push_back(pmt_to_long(channel));
+ if(pmt_eq(msg->port_id(), d_rx->port_symbol()))
+ d_rx_chans.push_back(pmt_to_long(channel));
+ }
+
+ if(d_nalloc_recvd == d_nalloc_to_recv) {
+
+ std::cout << "[qa_dealloc_top] Allocated TX channels: ";
+ for(int i=0; i < (int)d_tx_chans.size(); i++)
+ std::cout << d_tx_chans[i] << " ";
+
+ std::cout << "\n[qa_dealloc_top] Allocated RX channels: ";
+ for(int i=0; i < (int)d_rx_chans.size(); i++)
+ std::cout << d_rx_chans[i] << " ";
+ std::cout << "\n";
+
+ deallocate_all(); // once we've allocated all of our channels, try to
dealloc them
+ }
+}
+
+REGISTER_MBLOCK_CLASS(qa_dealloc_top);
+
+//
----------------------------------------------------------------------------------------------
+
+void
+qa_inband_usrp_server::test_chan_allocation()
+{
+ mb_runtime_sptr rt = mb_make_runtime();
+ pmt_t result = PMT_T;
+
+ rt->run("top", "qa_alloc_top", PMT_F, &result);
+
+ CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
+}
+
+void
+qa_inband_usrp_server::test_chan_deallocation()
+{
+ mb_runtime_sptr rt = mb_make_runtime();
+ pmt_t result = PMT_T;
+
+ rt->run("top", "qa_dealloc_top", PMT_F, &result);
+
+ CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
+}
+
+void
+qa_inband_usrp_server::test_fragmentation()
+{
+
+}
Copied:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.h
(from rev 5213,
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h)
===================================================================
---
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.h
(rev 0)
+++
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.h
2007-05-02 01:04:52 UTC (rev 5214)
@@ -0,0 +1,42 @@
+/* -*- 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 QA_INBAND_USRP_SERVER_H
+#define QA_INBAND_USRP_SERVER_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_inband_usrp_server : public CppUnit::TestCase {
+
+ CPPUNIT_TEST_SUITE(qa_inband_usrp_server);
+ CPPUNIT_TEST(test_chan_allocation);
+ CPPUNIT_TEST(test_chan_deallocation);
+ CPPUNIT_TEST(test_fragmentation);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void test_chan_allocation();
+ void test_chan_deallocation();
+ void test_fragmentation();
+};
+
+#endif /* INCLUDED_QA_INBAND_USRP_SERVER_H */
Copied:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/test_inband.cc (from
rev 5213,
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_inband.cc)
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/test_inband.cc
(rev 0)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/test_inband.cc
2007-05-02 01:04:52 UTC (rev 5214)
@@ -0,0 +1,36 @@
+/* -*- 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.
+ */
+
+#include <cppunit/TextTestRunner.h>
+#include <qa_inband.h>
+
+int
+main(int argc, char **argv)
+{
+
+ CppUnit::TextTestRunner runner;
+
+ runner.addTest(qa_inband::suite ());
+
+ bool was_successful = runner.run("", false);
+
+ return was_successful ? 0 : 1;
+}
Modified:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
2007-05-01 22:44:43 UTC (rev 5213)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
2007-05-02 01:04:52 UTC (rev 5214)
@@ -25,6 +25,7 @@
#include <usrp_server.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
@@ -44,6 +45,10 @@
static pmt_t s_cmd_stop_recv_raw_samples =
pmt_intern("cmd-stop-recv-raw-samples");
static pmt_t s_cmd_to_control_channel = pmt_intern("cmd-to-control-channel");
static pmt_t s_cmd_xmit_raw_frame = pmt_intern("cmd-xmit-raw-frame");
+static pmt_t s_cmd_max_capacity = pmt_intern("cmd-max-capacity");
+static pmt_t s_cmd_ntx_chan = pmt_intern("cmd-ntx-chan");
+static pmt_t s_cmd_nrx_chan = pmt_intern("cmd-nrx-chan");
+static pmt_t s_cmd_current_capacity_allocation =
pmt_intern("cmd-current-capacity-allocation");
static pmt_t s_response_allocate_channel =
pmt_intern("response-allocate-channel");
static pmt_t s_response_close = pmt_intern("response-close");
static pmt_t s_response_deallocate_channel =
pmt_intern("response-deallocate-channel");
@@ -51,7 +56,18 @@
static pmt_t s_response_open = pmt_intern("response-open");
static pmt_t s_response_recv_raw_samples =
pmt_intern("response-recv-raw-samples");
static pmt_t s_response_xmit_raw_frame = pmt_intern("response-xmit-raw-frame");
+static pmt_t s_response_max_capacity = pmt_intern("response-max-capacity");
+static pmt_t s_response_ntx_chan = pmt_intern("response-ntx-chan");
+static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan");
+static pmt_t s_response_current_capacity_allocation =
pmt_intern("response-current-capacity-allocation");
+static std::string
+str(long x)
+{
+ std::ostringstream s;
+ s << x;
+ return s.str();
+}
usrp_server::usrp_server(mb_runtime *rt, const std::string &instance_name,
pmt_t user_arg)
: mb_mblock(rt, instance_name, user_arg)
@@ -66,8 +82,8 @@
// (if/when we do replicated ports, these will be replaced by a
// single replicated port)
for(int port=0; port < N_PORTS; port++) {
- d_tx.push_back(define_port("rx"+port, "usrp-tx", true, mb_port::EXTERNAL));
- d_rx.push_back(define_port("tx"+port, "usrp-rx", true, mb_port::EXTERNAL));
+ d_tx.push_back(define_port("tx"+str(port), "usrp-tx", true,
mb_port::EXTERNAL));
+ d_rx.push_back(define_port("rx"+str(port), "usrp-rx", true,
mb_port::EXTERNAL));
}
// FIXME ... initializing to 2 channels on each for now, eventually we should
@@ -109,8 +125,8 @@
pmt_t status;
if (1){
- std::cout << "event: " << event << std::endl;
- std::cout << "port_id: " << port_id << std::endl;
+ std::cout << "[USRP_SERVER] event: " << event << std::endl;
+ std::cout << "[USRP_SERVER] port_id: " << port_id << std::endl;
}
// It would be nice if this were all table driven, and we could
@@ -137,6 +153,27 @@
else if (pmt_eq(event, s_cmd_close)){
// ...
}
+ else if (pmt_eq(event, s_cmd_max_capacity)) {
+ invocation_handle = pmt_nth(0, data);
+ reply_data = pmt_list2(invocation_handle, pmt_from_long(max_capacity()));
+ d_cs->send(s_response_max_capacity, reply_data);
+ return;
+ }
+ else if (pmt_eq(event, s_cmd_ntx_chan)) {
+ invocation_handle = pmt_nth(0, data);
+ reply_data = pmt_list2(invocation_handle, pmt_from_long(d_ntx_chan));
+ d_cs->send(s_response_ntx_chan, reply_data);
+ }
+ else if (pmt_eq(event, s_cmd_nrx_chan)) {
+ invocation_handle = pmt_nth(0, data);
+ reply_data = pmt_list2(invocation_handle, pmt_from_long(d_nrx_chan));
+ d_cs->send(s_response_nrx_chan, reply_data);
+ }
+ else if (pmt_eq(event, s_cmd_current_capacity_allocation)) {
+ invocation_handle = pmt_nth(0, data);
+ reply_data = pmt_list2(invocation_handle,
pmt_from_long(current_capacity_allocation()));
+ d_cs->send(s_response_current_capacity_allocation, reply_data);
+ }
goto unhandled;
}
@@ -156,28 +193,24 @@
}
unhandled:
- std::cout << "unhandled msg: " << msg << std::endl;
+ std::cout << "[USRP_SERVER] unhandled msg: " << msg << std::endl;
}
// Return -1 if it is not an RX port, or an index
-long usrp_server::tx_port_index(pmt_t port_id) {
+int usrp_server::tx_port_index(pmt_t port_id) {
- std::vector<mb_port_sptr>::iterator tx;
-
- for(int i=0; i < d_tx.size(); i++)
- if(pmt_eq(tx[i]->port_symbol(), port_id))
+ for(int i=0; i < (int) d_tx.size(); i++)
+ if(pmt_eq(d_tx[i]->port_symbol(), port_id))
return i;
return -1;
}
// Return -1 if it is not an RX port, or an index
-long usrp_server::rx_port_index(pmt_t port_id) {
+int usrp_server::rx_port_index(pmt_t port_id) {
- std::vector<mb_port_sptr>::iterator rx;
-
- for(int i=0; i < d_rx.size(); i++)
- if(pmt_eq(rx[i]->port_symbol(), port_id))
+ for(int i=0; i < (int) d_rx.size(); i++)
+ if(pmt_eq(d_rx[i]->port_symbol(), port_id))
return i;
return -1;
@@ -210,8 +243,8 @@
// Check capacity exists
if((D_USB_CAPACITY - current_capacity_allocation()) < rqstd_capacity) {
- reply_data = pmt_list3(invocation_handle, PMT_F, PMT_NIL); // no
capacity available
- d_tx[port]->send(invocation_handle, reply_data);
+ reply_data = pmt_list3(invocation_handle,
pmt_from_long(RQSTD_CAPACITY_UNAVAIL), PMT_NIL); // no capacity available
+ d_tx[port]->send(s_response_allocate_channel, reply_data);
return;
}
@@ -221,13 +254,15 @@
d_chaninfo_tx[chan].owner = port_id;
d_chaninfo_tx[chan].assigned_capacity = rqstd_capacity;
reply_data = pmt_list3(invocation_handle, PMT_T, pmt_from_long(chan));
- d_tx[port]->send(invocation_handle, reply_data);
+ d_tx[port]->send(s_response_allocate_channel, reply_data);
return;
}
}
- reply_data = pmt_list3(invocation_handle, PMT_F, PMT_NIL); // no free TX
chan found
- d_tx[port]->send(invocation_handle, reply_data);
+ std::cout << "[USRP_SERVER] Couldnt find a TX chan\n";
+
+ reply_data = pmt_list3(invocation_handle, pmt_from_long(CHANNEL_UNAVAIL),
PMT_NIL); // no free TX chan found
+ d_tx[port]->send(s_response_allocate_channel, reply_data);
return;
}
@@ -235,23 +270,24 @@
if((port = rx_port_index(port_id)) != -1) {
if((D_USB_CAPACITY - current_capacity_allocation()) < rqstd_capacity) {
- reply_data = pmt_list3(invocation_handle, PMT_F, PMT_NIL); // no
capacity available
- d_rx[port]->send(invocation_handle, reply_data);
+ reply_data = pmt_list3(invocation_handle,
pmt_from_long(RQSTD_CAPACITY_UNAVAIL), PMT_NIL); // no capacity available
+ d_rx[port]->send(s_response_allocate_channel, reply_data);
return;
}
- for(chan=0; chan < d_ntx_chan; chan++) {
- if(d_chaninfo_tx[chan].owner == PMT_NIL) {
- d_chaninfo_tx[chan].owner = port_id;
- d_chaninfo_tx[chan].assigned_capacity = rqstd_capacity;
+ for(chan=0; chan < d_nrx_chan; chan++) {
+ if(d_chaninfo_rx[chan].owner == PMT_NIL) {
+ d_chaninfo_rx[chan].owner = port_id;
+ d_chaninfo_rx[chan].assigned_capacity = rqstd_capacity;
reply_data = pmt_list3(invocation_handle, PMT_T, pmt_from_long(chan));
- d_rx[port]->send(invocation_handle, reply_data);
+ d_rx[port]->send(s_response_allocate_channel, reply_data);
return;
}
}
- reply_data = pmt_list3(invocation_handle, PMT_F, PMT_NIL); // no free RX
chan found
- d_rx[port]->send(invocation_handle, reply_data);
+ std::cout << "[USRP_SERVER] Couldnt find a RX chan\n";
+ reply_data = pmt_list3(invocation_handle, pmt_from_long(CHANNEL_UNAVAIL),
PMT_NIL); // no free RX chan found
+ d_rx[port]->send(s_response_allocate_channel, reply_data);
return;
}
}
@@ -271,14 +307,14 @@
if((port = tx_port_index(port_id)) != -1) {
if(channel >= d_ntx_chan) {
- reply_data = pmt_list2(invocation_handle, PMT_F); // not a legit
channel number
- d_tx[port]->send(invocation_handle, reply_data);
+ reply_data = pmt_list2(invocation_handle,
pmt_from_long(CHANNEL_INVALID)); // not a legit channel number
+ d_tx[port]->send(s_response_deallocate_channel, reply_data);
return;
}
if(d_chaninfo_tx[channel].owner != port_id) {
- reply_data = pmt_list2(invocation_handle, PMT_F); // not the owner of
the port
- d_tx[port]->send(invocation_handle, reply_data);
+ reply_data = pmt_list2(invocation_handle,
pmt_from_long(PERMISSION_DENIED)); // not the owner of the port
+ d_tx[port]->send(s_response_deallocate_channel, reply_data);
return;
}
@@ -286,7 +322,7 @@
d_chaninfo_tx[channel].owner = PMT_NIL;
reply_data = pmt_list2(invocation_handle, PMT_T);
- d_tx[port]->send(invocation_handle, reply_data);
+ d_tx[port]->send(s_response_deallocate_channel, reply_data);
return;
}
@@ -294,14 +330,14 @@
if((port = rx_port_index(port_id)) != -1) {
if(channel >= d_nrx_chan) {
- reply_data = pmt_list2(invocation_handle, PMT_F); // not a legit
channel number
- d_rx[port]->send(invocation_handle, reply_data);
+ reply_data = pmt_list2(invocation_handle,
pmt_from_long(CHANNEL_INVALID)); // not a legit channel number
+ d_rx[port]->send(s_response_deallocate_channel, reply_data);
return;
}
if(d_chaninfo_rx[channel].owner != port_id) {
- reply_data = pmt_list2(invocation_handle, PMT_F); // not the owner of
the port
- d_rx[port]->send(invocation_handle, reply_data);
+ reply_data = pmt_list2(invocation_handle,
pmt_from_long(PERMISSION_DENIED)); // not the owner of the port
+ d_rx[port]->send(s_response_deallocate_channel, reply_data);
return;
}
@@ -309,7 +345,7 @@
d_chaninfo_rx[channel].owner = PMT_NIL;
reply_data = pmt_list2(invocation_handle, PMT_T);
- d_rx[port]->send(invocation_handle, reply_data);
+ d_rx[port]->send(s_response_deallocate_channel, reply_data);
return;
}
@@ -327,13 +363,15 @@
// Determine the number of packets to allocate contiguous memory for
bursting over the
// USB and get a pointer to the memory to be used in building the packets
- long n_packets = std::ceil(n_bytes / (double)max_payload_len);
+ long n_packets = static_cast<long>(std::ceil(n_bytes /
(double)max_payload_len));
pmt_t v_packets = pmt_make_u8vector(sizeof(transport_pkt) * n_packets, 0);
- transport_pkt *pkts = (transport_pkt *)
pmt_u8vector_writeable_elements(v_packets, psize);
+ transport_pkt *pkts =
+ (transport_pkt *) pmt_u8vector_writeable_elements(v_packets, psize);
+
for(int n=0; n < n_packets; n++) {
- long payload_len = std::min((int)(n_bytes-(n*max_payload_len)),
(int)max_payload_len);
+ long payload_len = std::min((long)(n_bytes-(n*max_payload_len)),
(long)max_payload_len);
if(n == 0) { // first packet gets start of burst flag and timestamp
pkts[n].set_header(pkts[n].FL_START_OF_BURST, channel, 0, payload_len);
@@ -353,3 +391,4 @@
// USB_PKT_SIZE * MAX_PACKET_BURST bytes worth of data (given a full burst)
}
+REGISTER_MBLOCK_CLASS(usrp_server);
Modified:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h
2007-05-01 22:44:43 UTC (rev 5213)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h
2007-05-02 01:04:52 UTC (rev 5214)
@@ -31,6 +31,13 @@
{
public:
+ enum error_codes {
+ RQSTD_CAPACITY_UNAVAIL = 0,
+ CHANNEL_UNAVAIL = 1,
+ CHANNEL_INVALID = 2,
+ PERMISSION_DENIED = 3
+ };
+
// our ports
enum port_types {
RX_PORT = 0,
@@ -60,12 +67,15 @@
void initial_transition();
void handle_message(mb_message_sptr msg);
+protected:
+ static int max_capacity() { return D_USB_CAPACITY; }
+
private:
void handle_cmd_allocate_channel(pmt_t port_id, pmt_t data);
void handle_cmd_deallocate_channel(pmt_t port_id, pmt_t data);
void handle_cmd_xmit_raw_frame(pmt_t data);
- long rx_port_index(pmt_t port_id);
- long tx_port_index(pmt_t port_id);
+ int rx_port_index(pmt_t port_id);
+ int tx_port_index(pmt_t port_id);
long current_capacity_allocation();
};
Modified:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.mbh
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.mbh
2007-05-01 22:44:43 UTC (rev 5213)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.mbh
2007-05-02 01:04:52 UTC (rev 5214)
@@ -239,10 +239,18 @@
(:outgoing
(cmd-open invocation-handle which-usrp)
(cmd-close invocation-handle)
+ (cmd-max-capacity invocation-handle)
+ (cmd-ntx-chan invocation-handle)
+ (cmd-nrx-chan invocation-handle)
+ (cmd-current-capacity-allocation invocation-handle)
)
(:incoming
(response-open invocation-handle status)
(response-close invocation-handle status)
+ (response-max-capacity invocation-handle capacity)
+ (response-ntx-chan invocation-handle ntx-chan)
+ (response-nrx-chan invocation-handle nrx-chan)
+ (response-current-capacity-allocation invocation-handle capacity)
)
)
Modified: gnuradio/branches/features/inband-usb/usrp/host/lib/legacy/Makefile.am
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/legacy/Makefile.am
2007-05-01 22:44:43 UTC (rev 5213)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/legacy/Makefile.am
2007-05-02 01:04:52 UTC (rev 5214)
@@ -22,9 +22,14 @@
INCLUDES = $(USRP_INCLUDES)
-noinst_LTLIBRARIES = liblegacy.la
+lib_LTLIBRARIES = libusrp.la
+libusrp_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
+libusrp_la_LIBADD = \
+ $(USB_LIBS) \
+ ../../misc/libmisc.la
+
EXTRA_DIST = \
std_paths.h.in \
usrp_dbid.dat
@@ -72,7 +77,7 @@
#
# include each <foo>_CODE entry here...
#
-EXTRA_liblegacy_la_SOURCES = \
+EXTRA_libusrp_la_SOURCES = \
$(generic_CODE) \
$(darwin_CODE) \
$(win32_CODE) \
@@ -81,7 +86,7 @@
# work around automake deficiency
-liblegacy_la_common_SOURCES = \
+libusrp_la_common_SOURCES = \
fusb.cc \
md5.c \
usrp_basic.cc \
@@ -93,23 +98,23 @@
if FUSB_TECH_generic
-liblegacy_la_SOURCES = $(liblegacy_la_common_SOURCES) $(generic_CODE)
+libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(generic_CODE)
endif
if FUSB_TECH_darwin
-liblegacy_la_SOURCES = $(liblegacy_la_common_SOURCES) $(darwin_CODE)
+libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(darwin_CODE)
endif
if FUSB_TECH_win32
-liblegacy_la_SOURCES = $(liblegacy_la_common_SOURCES) $(win32_CODE)
+libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(win32_CODE)
endif
if FUSB_TECH_linux
-liblegacy_la_SOURCES = $(liblegacy_la_common_SOURCES) $(linux_CODE)
+libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(linux_CODE)
endif
if FUSB_TECH_ra_wb
-liblegacy_la_SOURCES = $(liblegacy_la_common_SOURCES) $(ra_wb_CODE)
+libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(ra_wb_CODE)
endif
include_HEADERS = \
Modified: gnuradio/branches/features/inband-usb/usrp/host/swig/Makefile.am
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/swig/Makefile.am
2007-05-01 22:44:43 UTC (rev 5213)
+++ gnuradio/branches/features/inband-usb/usrp/host/swig/Makefile.am
2007-05-02 01:04:52 UTC (rev 5214)
@@ -64,7 +64,7 @@
noinst_HEADERS =
-_usrp_prims_la_LIBADD = $(top_builddir)/usrp/host/lib/libusrp.la -lstdc++
$(PYTHON_LDFLAGS)
+_usrp_prims_la_LIBADD = $(USRP_LA) -lstdc++ $(PYTHON_LDFLAGS)
_usrp_prims_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5214 - in gnuradio/branches/features/inband-usb: . usrp/host/apps usrp/host/lib usrp/host/lib/inband usrp/host/lib/legacy usrp/host/swig,
gnychis <=