Hi again, some more improvements, this time for the tx part only. This patch saves about 10% CPU for the test_usrp_inband_tx example.
-- Stefan Brüns / Bergstraße 21 / 52062 Aachen phone: +49 241 53809034 mobile: +49 151 50412019
=== modified file 'usrp/host/lib/inband/symbols_usrp_rx_cs.h'
--- usrp/host/lib/inband/symbols_usrp_rx_cs.h 2007-09-05 00:43:43 +0000
+++ usrp/host/lib/inband/symbols_usrp_rx_cs.h 2009-01-26 01:54:15 +0000
@@ -25,6 +25,7 @@
// Outgoing
static pmt_t s_cmd_usrp_rx_start_reading = pmt_intern("cmd-usrp-rx-start-reading");
+static pmt_t s_cmd_usrp_rx_handle = pmt_intern("cmd-usrp-rx-handle");
// Incoming
static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read");
=== modified file 'usrp/host/lib/inband/symbols_usrp_tx_cs.h'
--- usrp/host/lib/inband/symbols_usrp_tx_cs.h 2007-09-05 00:43:43 +0000
+++ usrp/host/lib/inband/symbols_usrp_tx_cs.h 2009-01-26 01:54:15 +0000
@@ -25,6 +25,7 @@
// Outgoing
static pmt_t s_cmd_usrp_tx_write = pmt_intern("cmd-usrp-tx-write");
+static pmt_t s_cmd_usrp_tx_handle = pmt_intern("cmd-usrp-tx-handle");
// Incoming
static pmt_t s_response_usrp_tx_write = pmt_intern("response-usrp-tx-write");
=== modified file 'usrp/host/lib/inband/usrp_rx.cc'
--- usrp/host/lib/inband/usrp_rx.cc 2009-01-12 21:31:44 +0000
+++ usrp/host/lib/inband/usrp_rx.cc 2009-01-26 01:54:15 +0000
@@ -93,6 +93,8 @@
if(pmt_eqv(event, s_cmd_usrp_rx_start_reading))
read_and_respond(data);
+ if(pmt_eqv(event, s_cmd_usrp_rx_handle))
+ d_urx = boost::any_cast<usrp_standard_rx_sptr>(pmt_any_ref(data));
}
}
@@ -115,13 +117,12 @@
unsigned int n_read;
unsigned int pkt_size = sizeof(transport_pkt);
- pmt_t invocation_handle = pmt_nth(0, data);
-
- // Need the handle to the RX port to send responses, this is passed
- // by the USRP interface m-block
- pmt_t handle = pmt_nth(1, data);
- d_urx =
- boost::any_cast<usrp_standard_rx_sptr>(pmt_any_ref(handle));
+ if(!d_urx) {
+ std::cerr << "[usrp_rx] USRP RX Handle not set, shutting down\n";
+ d_cs->send(s_response_usrp_rx_read,
+ pmt_list3(PMT_NIL, PMT_F, PMT_NIL));
+ return;
+ }
if(verbose)
std::cout << "[usrp_rx] Waiting for packets..\n";
=== modified file 'usrp/host/lib/inband/usrp_tx.cc'
--- usrp/host/lib/inband/usrp_tx.cc 2009-01-26 01:06:02 +0000
+++ usrp/host/lib/inband/usrp_tx.cc 2009-01-26 01:54:15 +0000
@@ -83,6 +83,8 @@
if(pmt_eqv(event, s_cmd_usrp_tx_write))
write(data);
+ if(pmt_eqv(event, s_cmd_usrp_tx_handle))
+ d_utx = boost::any_cast<usrp_standard_tx_sptr>(pmt_any_ref(data));
}
}
@@ -100,7 +102,13 @@
pmt_t invocation_handle = pmt_nth(0, data);
pmt_t channel = pmt_nth(1, data);
pmt_t v_packets = pmt_nth(2, data);
- d_utx = boost::any_cast<usrp_standard_tx_sptr>(pmt_any_ref(pmt_nth(3, data)));
+
+ if(!d_utx) {
+ std::cerr << "[usrp_tx] USRP TX Handle not set, shutting down\n";
+ d_cs->send(s_response_usrp_tx_write,
+ pmt_list3(PMT_NIL, PMT_F, PMT_NIL));
+ return;
+ }
size_t n_bytes;
bool underrun; // this will need to go, as it is taken care of in the packet headers
@@ -114,7 +122,7 @@
if (ret == (int) n_bytes) {
if (verbose)
- std::cout << "[usrp_server] Write of " << n_bytes << " successful\n";
+ std::cout << "[usrp_tx] Write of " << n_bytes << " successful\n";
// need to respond with the channel so the USRP server knows who to forward the result of
// the write to by looking up the owner of the channel
d_cs->send(s_response_usrp_tx_write,
@@ -122,7 +130,7 @@
}
else {
if (verbose)
- std::cout << "[usrp_server] Error writing " << n_bytes << " bytes to USB bus\n";
+ std::cout << "[usrp_tx] Error writing " << n_bytes << " bytes to USB bus\n";
d_cs->send(s_response_usrp_tx_write,
pmt_list3(invocation_handle, PMT_F, channel));
}
=== modified file 'usrp/host/lib/inband/usrp_usb_interface.cc'
--- usrp/host/lib/inband/usrp_usb_interface.cc 2009-01-26 01:06:02 +0000
+++ usrp/host/lib/inband/usrp_usb_interface.cc 2009-01-26 01:54:15 +0000
@@ -412,6 +412,11 @@
// d_utx->_write_oe(1, 0xffff, 0xffff);
// d_urx->_write_oe(1, 0xffff, 0xffff);
+ pmt_t tx_handle = pmt_make_any(d_utx);
+ pmt_t rx_handle = pmt_make_any(d_urx);
+ d_tx_cs->send(s_cmd_usrp_tx_handle, tx_handle);
+ d_rx_cs->send(s_cmd_usrp_rx_handle, rx_handle);
+
d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T));
}
@@ -426,17 +431,7 @@
void
usrp_usb_interface::handle_cmd_write(pmt_t data)
{
- pmt_t invocation_handle = pmt_nth(0, data);
- pmt_t channel = pmt_nth(1, data);
- pmt_t pkts = pmt_nth(2, data);
-
- pmt_t tx_handle = pmt_make_any(d_utx);
-
- d_tx_cs->send(s_cmd_usrp_tx_write,
- pmt_list4(invocation_handle,
- channel,
- pkts,
- tx_handle));
+ d_tx_cs->send(s_cmd_usrp_tx_write, data);
}
/*!
@@ -455,9 +450,7 @@
if(!d_fake_usrp)
d_urx->start();
- pmt_t rx_handle = pmt_make_any(d_urx);
-
- d_rx_cs->send(s_cmd_usrp_rx_start_reading, pmt_list2(PMT_NIL, rx_handle));
+ d_rx_cs->send(s_cmd_usrp_rx_start_reading, PMT_NIL);
d_rx_reading = true;
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Discuss-gnuradio mailing list [email protected] http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
