[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5099 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5099 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Tue, 24 Apr 2007 19:42:29 -0600 (MDT) |
Author: gnychis
Date: 2007-04-24 19:42:29 -0600 (Tue, 24 Apr 2007)
New Revision: 5099
Added:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.mbh
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
Log:
adding in a first round test for channel allocation, not convinced a sink is
needed as responses are received from the usrp server on the same port
caught a bug in determining tx or rx channel in the usrp server, was accessing
a vector never initialized rather than the d_rx and d_tx vectors
the usrp server is not sending proper signals back, fixed up partially the
allocate channel signals, will fix the other signals as i write more tests
added a new static method to the usrp server to retrieve the maximum channel
capacity which is good for writing tests, though it could have use elsewhere
also
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
2007-04-24 21:35:07 UTC (rev 5098)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
2007-04-25 01:42:29 UTC (rev 5099)
@@ -42,7 +42,6 @@
usrp_server_mbh.cc : usrp_server.mbh
$(COMPILE_MBH) usrp_server.mbh usrp_server_mbh.cc
-
libusrp_inband_la_SOURCES = \
$(BUILT_SOURCES) \
usrp_server.cc
@@ -65,10 +64,15 @@
# ------------------------------------------------------------------------
# Build the qa code in its own library
+qa_inband_usrp_server_mbh.cc : qa_inband_usrp_server.mbh
+ $(COMPILE_MBH) qa_inband_usrp_server.mbh qa_inband_usrp_server_mbh.cc
+
+
libusrp_inband_qa_la_SOURCES = \
qa_inband.cc \
qa_inband_packet_prims.cc \
- qa_inband_usrp_server.cc
+ qa_inband_usrp_server.cc \
+ qa_inband_usrp_server_mbh.cc
# magic flags
libusrp_inband_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid-version
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-04-24 21:35:07 UTC (rev 5098)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-04-25 01:42:29 UTC (rev 5099)
@@ -32,13 +32,190 @@
#include <mb_protocol_class.h>
#include <mb_class_registry.h>
+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");
+
+//
----------------------------------------------------------------------------------------------
+
+class qa_alloc_src : public mb_mblock
+{
+ mb_port_sptr d_cs_top;
+ mb_port_sptr d_cs;
+
+ mb_port_sptr d_out;
+
+ long d_capacity_rqstd;
+ pmt_t d_expected_result;
+
+ public:
+ qa_alloc_src(mb_runtime *runtime, const std::string &instance_name, pmt_t
user_arg);
+ void handle_message(mb_message_sptr msg);
+
+ protected:
+ void request_capacity();
+};
+
+qa_alloc_src::qa_alloc_src(mb_runtime *runtime, const std::string
&instance_name, pmt_t user_arg)
+ : mb_mblock(runtime, instance_name, user_arg)
+{
+ d_cs_top = define_port("cs_top", "qa-alloc-cs", true, mb_port::EXTERNAL);
+ d_cs = define_port("cs", "qa-alloc-cs", true, mb_port::EXTERNAL);
+
+ d_out = define_port("out", "usrp-tx", false, mb_port::EXTERNAL);
+}
+
+void
+qa_alloc_src::handle_message(mb_message_sptr msg)
+{
+ pmt_t data = msg->data();
+
+ if ((pmt_eq(msg->port_id(), d_cs_top->port_symbol())
+ || pmt_eq(msg->port_id(), d_cs->port_symbol()))
+ && pmt_eq(msg->signal(), s_send_allocate_channel)){
+
+ d_capacity_rqstd = pmt_to_long(pmt_nth(0, data));
+ d_expected_result = pmt_nth(1, data);
+
+ request_capacity();
+ }
+
+ if (pmt_eq(msg->port_id(), d_out->port_symbol())
+ && pmt_eq(msg->signal(), s_response_allocate_channel)){
+
+ d_cs->send(msg->signal(), data);
+ }
+}
+
+void
+qa_alloc_src::request_capacity()
+{
+ std::cout << "Sending capacity request of " << d_capacity_rqstd << "\n";
+ d_out->send(s_cmd_allocate_channel, pmt_list2(d_expected_result,
pmt_from_long(d_capacity_rqstd)));
+}
+
+REGISTER_MBLOCK_CLASS(qa_alloc_src);
+
+//
----------------------------------------------------------------------------------------------
+
+class qa_alloc_sink : public mb_mblock
+{
+ static const size_t MAX_MSGS = 1 * 1024 * 1024;
+
+ mb_port_sptr d_in0;
+
+ long d_nmsgs_to_recv;
+ long d_nrecvd;
+
+ public:
+ qa_alloc_sink(mb_runtime *runtime, const std::string &instance_name, pmt_t
user_arg);
+ void handle_message(mb_message_sptr msg);
+
+ protected:
+ void check_message(mb_message_sptr msg);
+};
+
+qa_alloc_sink::qa_alloc_sink(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 = pmt_to_long(pmt_nth(0, user_arg));
+
+
+ if (d_nmsgs_to_recv > (long) MAX_MSGS)
+ throw std::out_of_range("qa_alloc_sink: nmsgs_to_recv is too big");
+
+ d_in0 = define_port("in", "qa-alloc-cs", false, mb_port::EXTERNAL);
+}
+
+void
+qa_alloc_sink::handle_message(mb_message_sptr msg)
+{
+ if (pmt_eq(msg->port_id(), d_in0->port_symbol())
+ && pmt_eq(msg->signal(), s_response_allocate_channel)){
+
+ check_message(msg);
+ }
+}
+
+void
+qa_alloc_sink::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_eq(expected_result, result))
+ shutdown_all(PMT_F);
+ else
+ std::cout << "Received expected response for message " << d_nrecvd << "\n";
+
+ if(d_nrecvd == d_nmsgs_to_recv)
+ shutdown_all(PMT_T);
+}
+
+REGISTER_MBLOCK_CLASS(qa_alloc_sink);
+
+//
----------------------------------------------------------------------------------------------
+
+class qa_alloc_top : public mb_mblock
+{
+ mb_port_sptr d_cs;
+
+ 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);
+};
+
+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_cs = define_port("cs", "qa-alloc-cs", false, mb_port::INTERNAL);
+
+ define_component("server", "usrp_server", PMT_F);
+ define_component("src", "qa_alloc_src", PMT_F);
+ define_component("sink", "qa_alloc_sink", pmt_list1(pmt_from_long(2))); //
number of expected responses
+
+ connect("self", "cs", "src", "cs_top");
+ connect("src", "out", "server", "tx0");
+ connect("src", "cs", "sink", "in");
+}
+
+qa_alloc_top::~qa_alloc_top(){}
+
+void
+qa_alloc_top::initial_transition()
+{
+ // should be able to allocate 100 bytes
+ d_cs->send(s_send_allocate_channel, pmt_list2(pmt_from_long(100), PMT_T));
+ // should not be able to allocate max capacity after 100 bytes were allocated
+ d_cs->send(s_send_allocate_channel,
pmt_list2(pmt_from_long(usrp_server::max_capacity()), PMT_F));
+}
+
+void
+qa_alloc_top::handle_message(mb_message_sptr msg)
+{
+}
+
+REGISTER_MBLOCK_CLASS(qa_alloc_top);
+
+
+//
----------------------------------------------------------------------------------------------
+
void
qa_inband_usrp_server::test_chan_allocation()
{
mb_runtime_sptr rt = mb_make_runtime();
pmt_t result = PMT_T;
- rt->run("top", "usrp_server", PMT_F, &result);
+ rt->run("top", "qa_alloc_top", PMT_F, &result);
+
+ CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
}
void
Added:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.mbh
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.mbh
(rev 0)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.mbh
2007-04-25 01:42:29 UTC (rev 5099)
@@ -0,0 +1,33 @@
+;; -*- scheme -*- ; not really, but tells emacs how to format this
+;;
+;; 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.
+;;
+
+;; ----------------------------------------------------------------
+;; qa-alloc -- interface to usrp server QA code
+;;
+
+(define-protocol-class qa-alloc-cs
+
+ (:outgoing
+
+ (send-allocate-channel)
+
+ )
+ )
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-04-24 21:35:07 UTC (rev 5098)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-04-25 01:42:29 UTC (rev 5099)
@@ -75,8 +75,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"+str(port), "usrp-tx", true,
mb_port::EXTERNAL));
- d_rx.push_back(define_port("tx"+str(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
@@ -171,10 +171,8 @@
// Return -1 if it is not an RX port, or an index
int usrp_server::tx_port_index(pmt_t port_id) {
- std::vector<mb_port_sptr>::iterator tx;
-
for(int i=0; i < (int) d_tx.size(); i++)
- if(pmt_eq(tx[i]->port_symbol(), port_id))
+ if(pmt_eq(d_tx[i]->port_symbol(), port_id))
return i;
return -1;
@@ -183,10 +181,8 @@
// Return -1 if it is not an RX port, or an index
int usrp_server::rx_port_index(pmt_t port_id) {
- std::vector<mb_port_sptr>::iterator rx;
-
for(int i=0; i < (int) d_rx.size(); i++)
- if(pmt_eq(rx[i]->port_symbol(), port_id))
+ if(pmt_eq(d_rx[i]->port_symbol(), port_id))
return i;
return -1;
@@ -220,7 +216,7 @@
// 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);
+ d_tx[port]->send(s_response_allocate_channel, reply_data);
return;
}
@@ -230,7 +226,7 @@
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;
}
}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
2007-04-24 21:35:07 UTC (rev 5098)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
2007-04-25 01:42:29 UTC (rev 5099)
@@ -59,6 +59,7 @@
void initial_transition();
void handle_message(mb_message_sptr msg);
+ static int max_capacity() { return D_USB_CAPACITY; }
private:
void handle_cmd_allocate_channel(pmt_t port_id, pmt_t data);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5099 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=