[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5513 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5513 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Mon, 21 May 2007 23:01:55 -0600 (MDT) |
Author: gnychis
Date: 2007-05-21 23:01:54 -0600 (Mon, 21 May 2007)
New Revision: 5513
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.mbh
Log:
Adding write and close functionality to the low level USRP interface. These
are currently *untested* in hardware.
Raw frame transmits cause writes that are passed to the low level USRP m-block.
Based on the response from the low level block the response is generated for
the frame transmit. To determine the port to send the response on, the channel
that the transmit occured on is used.
This is also true about the USRP server open and closes, the USRP server
responses are based on the responses from the low level USRP m-block.
Also added in correct numbers for the current block size and number of blocks
for async transfer.
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-05-22 00:56:13 UTC (rev 5512)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-05-22 05:01:54 UTC (rev 5513)
@@ -66,12 +66,17 @@
static pmt_t s_response_current_capacity_allocation =
pmt_intern("response-current-capacity-allocation");
// USRP signal set
-static pmt_t s_cmd_usrp_ntx_chan = pmt_intern("cmd-usrp-ntx-chan");
-static pmt_t s_cmd_usrp_nrx_chan = pmt_intern("cmd-usrp-nrx-chan");
+static pmt_t s_cmd_usrp_open = pmt_intern("cmd-usrp-open");
+static pmt_t s_cmd_usrp_close = pmt_intern("cmd-usrp-close");
+static pmt_t s_cmd_usrp_write = pmt_intern("cmd-usrp-write");
+static pmt_t s_cmd_usrp_ntx_chan = pmt_intern("cmd-usrp-ntx-chan");
+static pmt_t s_cmd_usrp_nrx_chan = pmt_intern("cmd-usrp-nrx-chan");
static pmt_t s_response_usrp_ntx_chan = pmt_intern("response-usrp-ntx-chan");
static pmt_t s_response_usrp_nrx_chan = pmt_intern("response-usrp-nrx-chan");
+static pmt_t s_response_usrp_open = pmt_intern("response-usrp-open");
+static pmt_t s_response_usrp_close = pmt_intern("response-usrp-close");
+static pmt_t s_response_usrp_write = pmt_intern("response-usrp-write");
-
static std::string
str(long x)
{
@@ -231,10 +236,19 @@
invocation_handle = pmt_nth(0, data);
long which_usrp = pmt_to_long(pmt_nth(1, data)); // integer usrp id,
usually 0
+#ifdef FAKE_USRP_TESTS
+ // When we are testing a fake USRP we don't need to open the interface
and just
+ // send a correct response
reply_data = pmt_list2(invocation_handle, PMT_T);
d_cs->send(s_response_open, reply_data);
+ #else
+
+ d_cs_usrp->send(s_cmd_open, pmt_list2(PMT_NIL,
pmt_from_long(which_usrp)));
+
+ #endif
+
return;
}
else if (pmt_eq(event, s_cmd_close)){
@@ -267,6 +281,33 @@
goto unhandled;
}
+ // A message from the USRP CS, which should *only* be responses
+ if (pmt_eq(port_id, d_cs_usrp->port_symbol())) {
+
+ if(pmt_eq(event, s_response_usrp_open)) {
+ // pass the response back over the regular CS port
+ invocation_handle = pmt_nth(0, data);
+ pmt_t status = pmt_nth(1, data);
+ d_cs->send(s_response_open, pmt_list2(invocation_handle, status));
+ }
+ else if (pmt_eq(event, s_response_usrp_close)) {
+ invocation_handle = pmt_nth(0, data);
+ pmt_t status = pmt_nth(1, data);
+ d_cs->send(s_response_open, pmt_list2(invocation_handle, status));
+ }
+ else if (pmt_eq(event, s_response_usrp_write)) {
+
+ invocation_handle = pmt_nth(0, data);
+ long channel = pmt_to_long(pmt_nth(1, data));
+ pmt_t status = pmt_nth(2, data);
+
+ // Find the port through the owner of the channel
+ long port = tx_port_index(d_chaninfo_tx[channel].owner);
+ d_tx[port]->send(s_response_xmit_raw_frame, pmt_list2(invocation_handle,
status));
+
+ }
+ }
+
if (pmt_eq(event, s_cmd_allocate_channel)){
handle_cmd_allocate_channel(port_id, data);
return;
@@ -460,13 +501,13 @@
if(channel >= d_ntx_chan) {
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);
+ d_tx[port]->send(s_response_xmit_raw_frame, reply_data);
return;
}
if(d_chaninfo_tx[channel].owner != port_id) {
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);
+ d_tx[port]->send(s_response_xmit_raw_frame, reply_data);
return;
}
@@ -495,21 +536,24 @@
pkts[n_packets-1].set_end_of_burst(); // set the last packet's end of
burst
- // interface with the USRP to send the USB packet, since the memory is
- // contiguous, this should be a serious of memory copies to the bus, each
being
- // USB_PKT_SIZE * MAX_PACKET_BURST bytes worth of data (given a full burst)
-
std::cout << "[USRP_SERVER] Received raw frame for invocation " <<
pmt_to_long(invocation_handle) << " --> " << n_packets << " packets\n";
- reply_data = pmt_list2(invocation_handle, PMT_T);
#ifdef FAKE_USRP_TESTS
fake_usrp usrp;
if(!usrp.write_bus(pkts, n_packets))
reply_data = pmt_list2(invocation_handle, PMT_F);
+ else
+ reply_data = pmt_list2(invocation_handle, PMT_T);
+
+ d_tx[port]->send(s_response_xmit_raw_frame, reply_data);
+#else
+
+ // The actual response to the write will be generated by a
s_response_usrp_write
+ d_cs_usrp->send(s_cmd_usrp_write, pmt_list3(PMT_NIL, channel, v_packets,
pmt_from_long(n_bytes)));
+
#endif
- d_tx[port]->send(s_response_xmit_raw_frame, reply_data);
}
}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
2007-05-22 00:56:13 UTC (rev 5512)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
2007-05-22 05:01:54 UTC (rev 5513)
@@ -30,12 +30,18 @@
#include <usrp_inband_usb_packet.h>
#include "usrp_standard.h"
+typedef usrp_inband_usb_packet transport_pkt;
+
static pmt_t s_cmd_usrp_open = pmt_intern("cmd-usrp-open");
+static pmt_t s_cmd_usrp_close = pmt_intern("cmd-usrp-close");
+static pmt_t s_cmd_usrp_write = pmt_intern("cmd-usrp-write");
static pmt_t s_cmd_usrp_ntx_chan = pmt_intern("cmd-usrp-ntx-chan");
static pmt_t s_cmd_usrp_nrx_chan = pmt_intern("cmd-usrp-nrx-chan");
static pmt_t s_response_usrp_ntx_chan = pmt_intern("response-usrp-ntx-chan");
static pmt_t s_response_usrp_nrx_chan = pmt_intern("response-usrp-nrx-chan");
static pmt_t s_response_usrp_open = pmt_intern("response-usrp-open");
+static pmt_t s_response_usrp_close = pmt_intern("response-usrp-close");
+static pmt_t s_response_usrp_write = pmt_intern("response-usrp-write");
// need to take number of TX and RX channels as parameter
usrp_usb_interface::usrp_usb_interface(mb_runtime *rt, const std::string
&instance_name, pmt_t user_arg)
@@ -74,12 +80,17 @@
pmt_t data = msg->data();
pmt_t invocation_handle;
- if (pmt_eq(port_id, d_cs->port_symbol())){ // message came in on our
control/status port
+ // message came in on our control/status port
+ if (pmt_eq(port_id, d_cs->port_symbol())) {
if (pmt_eq(event, s_cmd_usrp_open)){
- open(data);
+ handle_cmd_open(data);
return;
}
+ else if (pmt_eq(event, s_cmd_usrp_close)) {
+ handle_cmd_close(data);
+ return;
+ }
else if (pmt_eq(event, s_cmd_usrp_ntx_chan)) {
invocation_handle = pmt_nth(0, data);
d_cs->send(s_response_usrp_ntx_chan, pmt_list2(invocation_handle,
pmt_from_long(d_ntx_chan)));
@@ -90,6 +101,10 @@
d_cs->send(s_response_usrp_nrx_chan, pmt_list2(invocation_handle,
pmt_from_long(d_nrx_chan)));
return;
}
+ else if(pmt_eq(event, s_cmd_usrp_write)) {
+ handle_cmd_write(data);
+ return;
+ }
goto unhandled;
}
@@ -98,13 +113,13 @@
}
void
-usrp_usb_interface::open(pmt_t data)
+usrp_usb_interface::handle_cmd_open(pmt_t data)
{
pmt_t invocation_handle = pmt_nth(0, data);
long which_usrp = pmt_to_long(pmt_nth(1, data));
pmt_t reply_data;
- std::cout << "[usrp_usb_interface] handling open request for USRP " <<
which_usrp << "\n";
+ std::cout << "[usrp_usb_interface] Handling open request for USRP " <<
which_usrp << "\n";
// Open up a standard RX and TX for communication with the USRP
@@ -115,8 +130,8 @@
16, // interp = 32.0MB/s
chan,
-1, // mux
- USB_PKT_SIZE, // USB block size should be our USB packet size?
- 1); // number of blocks in a burst, I need to search for
this exact number
+ 4096, // USB block size
+ 16); // number of blocks for async transfers
if(!d_utx[chan]) {
std::cout << "[usrp_server] Failed to open channel " << chan << "\n";
@@ -139,8 +154,8 @@
16, // interp = 32.0MB/s
chan,
-1, // mux
- USB_PKT_SIZE, // USB block size should be our USB packet size?
- 1); // number of blocks in a burst, I need to search for
this exact number
+ 4096, // USB block size
+ 16); // number of blocks for async transfers
if(!d_urx[chan]) {
std::cout << "[usrp_server] Failed to open channel " << chan << "\n";
@@ -160,5 +175,54 @@
}
}
+void
+usrp_usb_interface::handle_cmd_write(pmt_t data)
+{
+ pmt_t invocation_handle = pmt_nth(0, data);
+ long channel = pmt_to_long(pmt_nth(1, data));
+ pmt_t v_packets = pmt_nth(2, data);
+ long n_bytes = pmt_to_long(pmt_nth(3, data));
+
+ size_t psize;
+ bool underrun; // this will need to go, as it is taken care of in the
packet headers
+
+ transport_pkt *pkts = (transport_pkt *)
pmt_u8vector_writeable_elements(v_packets, psize);
+ int ret = d_utx[channel]->write (pkts, n_bytes, &underrun);
+
+ if (ret == n_bytes) {
+ std::cout << "[usrp_server] 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_write, pmt_list3(invocation_handle,
pmt_from_long(channel), PMT_T));
+ return;
+ }
+ else {
+ std::cout << "[usrp_server] Error writing " << n_bytes << " bytes to USB
bus\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_write, pmt_list3(invocation_handle,
pmt_from_long(channel), PMT_F));
+ return;
+ }
+}
+
+void
+usrp_usb_interface::handle_cmd_close(pmt_t data)
+{
+ pmt_t invocation_handle = pmt_nth(0, data);
+
+ std::cout << "[usrp_usb_interface] Handling close request for USRP\n";
+
+ // Go through and close all of the channels by deleting them
+
+ for(int chan=0; chan < d_ntx_chan; chan++)
+ delete d_utx[chan];
+
+ for(int chan=0; chan < d_nrx_chan; chan++)
+ delete d_urx[chan];
+
+ d_cs->send(s_response_usrp_close, pmt_list2(invocation_handle, PMT_T));
+}
+
+
REGISTER_MBLOCK_CLASS(usrp_usb_interface);
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
2007-05-22 00:56:13 UTC (rev 5512)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
2007-05-22 05:01:54 UTC (rev 5513)
@@ -47,7 +47,9 @@
void handle_message(mb_message_sptr msg);
private:
- void open(pmt_t data);
+ void handle_cmd_open(pmt_t data);
+ void handle_cmd_close(pmt_t data);
+ void handle_cmd_write(pmt_t data);
};
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.mbh
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.mbh
2007-05-22 00:56:13 UTC (rev 5512)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.mbh
2007-05-22 05:01:54 UTC (rev 5513)
@@ -38,6 +38,7 @@
(cmd-usrp-close invocation-handle)
(cmd-usrp-ntx-chan invocation-handle)
(cmd-usrp-nrx-chan invocation-handle)
+ (cmd-usrp-write invocation-handle channel data n-bytes)
)
(:incoming
@@ -45,5 +46,6 @@
(response-usrp-close invocation-handle status)
(response-usrp-ntx-chan invocation-handle ntx-chan)
(response-usrp-nrx-chan invocation-handle nrx-chan)
+ (response-usrp-write invocation-handle channel status)
)
)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5513 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=