[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5176 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5176 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Fri, 27 Apr 2007 20:15:03 -0600 (MDT) |
Author: gnychis
Date: 2007-04-27 20:15:03 -0600 (Fri, 27 Apr 2007)
New Revision: 5176
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.h
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
Log:
adding in the base code for the deallocate channel test and added a layout of
one of the tests
fixed the improper signals of the deallocate channel, but need to add the error
responses
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-28 02:00:15 UTC (rev 5175)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-04-28 02:15:03 UTC (rev 5176)
@@ -35,6 +35,9 @@
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");
//
----------------------------------------------------------------------------------------------
@@ -59,6 +62,7 @@
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;
}
qa_alloc_top::~qa_alloc_top(){}
@@ -67,9 +71,11 @@
qa_alloc_top::initial_transition()
{
d_nmsgs_to_recv = 8;
+
+ d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
+ d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
// Test the TX side
- d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
define_component("server", "usrp_server", PMT_F);
connect("self", "tx0", "server", "tx0");
@@ -84,7 +90,6 @@
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 = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
connect("self", "rx0", "server", "rx0");
d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(100)));
d_rx->send(s_cmd_allocate_channel,
pmt_list2(pmt_from_long(usrp_server::RQSTD_CAPACITY_UNAVAIL),
pmt_from_long(usrp_server::max_capacity())));
@@ -128,7 +133,96 @@
REGISTER_MBLOCK_CLASS(qa_alloc_top);
+//
----------------------------------------------------------------------------------------------
+class qa_dealloc_top : public mb_mblock
+{
+ mb_port_sptr d_tx;
+ mb_port_sptr d_rx;
+
+ long d_nmsgs_to_recv;
+ long d_nrecvd;
+
+ 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_message(mb_message_sptr msg);
+};
+
+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_nrecvd=0;
+}
+
+qa_dealloc_top::~qa_dealloc_top(){}
+
+void
+qa_dealloc_top::initial_transition()
+{
+ d_nmsgs_to_recv = 2;
+
+ d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
+ d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
+
+ // Test the TX side
+ define_component("server", "usrp_server", PMT_F);
+ connect("self", "tx0", "server", "tx0");
+
+ // should be able to allocate 100 bytes
+ d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(100)));
// FIXME: extract the returned channel
+
+ // Should not be able to allocate max capacity
+ d_tx->send(s_cmd_allocate_channel,
pmt_list2(pmt_from_long(usrp_server::RQSTD_CAPACITY_UNAVAIL),
pmt_from_long(usrp_server::max_capacity())));
+
+
+ // If we give up the 100 byte allocation, we should then be able to allocate
max
+// d_tx->send(s_cmd_deallocate_channel, pmt_list2(PMT_T)); // FIXME: pass the
channel
+// d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T,
pmt_from_long(usrp_server::max_capacity())));
+
+}
+
+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()))
+ && (pmt_eq(msg->signal(), s_response_allocate_channel)
+ || pmt_eq(msg->signal(), s_response_deallocate_channel))){
+ check_message(msg);
+ }
+
+}
+
+void
+qa_dealloc_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 << "Received expected response for message " << d_nrecvd << "\n";
+ }
+
+ if(d_nrecvd == d_nmsgs_to_recv)
+ shutdown_all(PMT_T);
+}
+
+REGISTER_MBLOCK_CLASS(qa_dealloc_top);
+
//
----------------------------------------------------------------------------------------------
void
@@ -143,6 +237,17 @@
}
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()
{
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
2007-04-28 02:00:15 UTC (rev 5175)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
2007-04-28 02:15:03 UTC (rev 5176)
@@ -29,11 +29,13 @@
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();
};
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-28 02:00:15 UTC (rev 5175)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-04-28 02:15:03 UTC (rev 5176)
@@ -280,13 +280,13 @@
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);
+ 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);
+ d_tx[port]->send(s_response_deallocate_channel, reply_data);
return;
}
@@ -294,7 +294,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;
}
@@ -303,13 +303,13 @@
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);
+ 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);
+ d_rx[port]->send(s_response_deallocate_channel, reply_data);
return;
}
@@ -317,7 +317,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;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5176 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=