[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5199 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5199 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Mon, 30 Apr 2007 17:49:40 -0600 (MDT) |
Author: gnychis
Date: 2007-04-30 17:49:40 -0600 (Mon, 30 Apr 2007)
New Revision: 5199
Modified:
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
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.mbh
Log:
full test code for channel allocation and deallocation
tests that all channels can be allocated, logically checks the capacity
requested with the capacity used via a message
tests that all channels can then be deallocated and that the capacity returns
to 0
tests all error conditions:
- requesting more than the available capacity
- requesting a channel when they're all in use
- attempting a deallocation on a channel that doesn't exist
- attempting a deallocation on a channel you have no permission to
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-30 22:39:23 UTC (rev 5198)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-04-30 23:49:40 UTC (rev 5199)
@@ -31,6 +31,7 @@
#include <mb_runtime.h>
#include <mb_protocol_class.h>
#include <mb_class_registry.h>
+#include <vector>
static pmt_t s_cmd_allocate_channel = pmt_intern("cmd-allocate-channel");
static pmt_t s_response_allocate_channel =
pmt_intern("response-allocate-channel");
@@ -38,17 +39,33 @@
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();
@@ -57,12 +74,27 @@
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(){}
@@ -70,31 +102,42 @@
void
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);
+ // 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));
+}
- // 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)));
+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(usrp_server::max_capacity())));
+ d_tx->send(s_cmd_allocate_channel,
pmt_list2(pmt_from_long(usrp_server::RQSTD_CAPACITY_UNAVAIL),
pmt_from_long(d_max_capacity)));
- // allocate a little more until all of the channels are used and
- d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(100)));
+ // 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
- 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())));
- 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_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
@@ -104,8 +147,31 @@
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_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();
}
}
@@ -124,7 +190,7 @@
std::cout << "Got: " << result << " Expected: " << expected_result << "\n";
shutdown_all(PMT_F);
} else {
- std::cout << "Received expected response for message " << d_nrecvd << "\n";
+ std::cout << "[qa_alloc_top] Received expected response for message " <<
d_nrecvd << "\n";
}
if(d_nrecvd == d_nmsgs_to_recv)
@@ -139,10 +205,23 @@
{
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_nmsgs_to_recv;
- long d_nrecvd;
+ 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();
@@ -150,13 +229,31 @@
void handle_message(mb_message_sptr msg);
protected:
- void check_message(mb_message_sptr msg);
+ 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_nrecvd=0;
+ 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(){}
@@ -164,61 +261,164 @@
void
qa_dealloc_top::initial_transition()
{
- d_nmsgs_to_recv = 2;
+ // 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() {
- d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
- d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
+ // 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++;
+ }
- // Test the TX side
- define_component("server", "usrp_server", PMT_F);
- connect("self", "tx0", "server", "tx0");
+ // 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++;
+ }
- // 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
+ // 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)));
- // 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())));
-
+ // 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()))
- && (pmt_eq(msg->signal(), s_response_allocate_channel)
- || pmt_eq(msg->signal(), s_response_deallocate_channel))){
- check_message(msg);
+ 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_message(mb_message_sptr msg)
+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_nrecvd++;
+ d_ndealloc_recvd++;
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";
+ std::cout << "[qa_dealloc_top] Received expected deallocation response for
message " << d_ndealloc_recvd << "\n";
}
+}
- if(d_nrecvd == d_nmsgs_to_recv)
- shutdown_all(PMT_T);
+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);
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-30 22:39:23 UTC (rev 5198)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-04-30 23:49:40 UTC (rev 5199)
@@ -45,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");
@@ -52,8 +56,11 @@
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)
{
@@ -118,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
@@ -146,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;
}
@@ -165,7 +193,7 @@
}
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
@@ -231,7 +259,7 @@
}
}
- std::cout << "Couldnt find a TX chan\n";
+ 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);
@@ -257,7 +285,7 @@
}
}
- std::cout << "Couldnt find a RX chan\n";
+ 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;
@@ -279,13 +307,13 @@
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
+ 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
+ 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;
}
@@ -302,13 +330,13 @@
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
+ 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
+ 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;
}
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-30 22:39:23 UTC (rev 5198)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
2007-04-30 23:49:40 UTC (rev 5199)
@@ -33,7 +33,9 @@
enum error_codes {
RQSTD_CAPACITY_UNAVAIL = 0,
- CHANNEL_UNAVAIL = 1
+ CHANNEL_UNAVAIL = 1,
+ CHANNEL_INVALID = 2,
+ PERMISSION_DENIED = 3
};
// our ports
@@ -64,6 +66,8 @@
void initial_transition();
void handle_message(mb_message_sptr msg);
+
+protected:
static int max_capacity() { return D_USB_CAPACITY; }
private:
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.mbh
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.mbh
2007-04-30 22:39:23 UTC (rev 5198)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.mbh
2007-04-30 23:49:40 UTC (rev 5199)
@@ -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)
)
)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5199 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=