[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5500 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5500 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Sun, 20 May 2007 00:28:21 -0600 (MDT) |
Author: gnychis
Date: 2007-05-20 00:28:20 -0600 (Sun, 20 May 2007)
New Revision: 5500
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
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.mbh
Log:
Created a new m-block for the low level interface which usrp_server contains.
Pulled the low level code out of usrp_server so that reads/writes, which have
the possibility of blocking the usrp server
The USRP server now queries the low level interface (which should query the
FPGA) for the number of TX and RX channels. This creates problems that
messages may come in before the number of TX and RX chans have been received
back from querying the low level interface for which they are needed. Rather
than discard these messages, or force the client to send an initialize signal
and block on a response, the usrp_server creates a queue of messages received
while being initialized. Once usrp_server becomes fully initialized, the
messages in the queue are parsed and then normal operation ensues.
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
2007-05-19 03:43:53 UTC (rev 5499)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
2007-05-20 06:28:20 UTC (rev 5500)
@@ -27,7 +27,8 @@
TESTS = test_inband
EXTRA_DIST = \
- usrp_server.mbh
+ usrp_server.mbh \
+ usrp_usb_interface.mbh
lib_LTLIBRARIES = \
@@ -39,14 +40,19 @@
# Build the inband library
BUILT_SOURCES = \
- usrp_server_mbh.cc
+ usrp_server_mbh.cc \
+ usrp_usb_interface_mbh.cc
usrp_server_mbh.cc : usrp_server.mbh
$(COMPILE_MBH) usrp_server.mbh usrp_server_mbh.cc
+usrp_usb_interface_mbh.cc : usrp_usb_interface.mbh
+ $(COMPILE_MBH) usrp_usb_interface.mbh usrp_usb_interface_mbh.cc
+
libusrp_inband_la_SOURCES = \
$(BUILT_SOURCES) \
- usrp_server.cc
+ usrp_server.cc \
+ usrp_usb_interface.cc
libusrp_inband_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
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-05-19 03:43:53 UTC (rev 5499)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-05-20 06:28:20 UTC (rev 5500)
@@ -576,6 +576,9 @@
mb_runtime_sptr rt = mb_make_runtime();
pmt_t result = PMT_T;
+ std::cout << "\n\n----------------------------\n";
+ std::cout << " RUNNING ALLOCATION TESTS \n";
+
rt->run("top", "qa_alloc_top", PMT_F, &result);
CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
@@ -587,6 +590,9 @@
mb_runtime_sptr rt = mb_make_runtime();
pmt_t result = PMT_T;
+ std::cout << "\n\n----------------------------\n";
+ std::cout << " RUNNING DEALLOCATION TESTS \n";
+
rt->run("top", "qa_dealloc_top", PMT_F, &result);
CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
@@ -598,6 +604,9 @@
mb_runtime_sptr rt = mb_make_runtime();
pmt_t result = PMT_T;
+ std::cout << "\n\n----------------------------\n";
+ std::cout << " RUNNING PACKET TESTS \n";
+
rt->run("top", "qa_packets_top", PMT_F, &result);
CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
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-19 03:43:53 UTC (rev 5499)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-05-20 06:28:20 UTC (rev 5500)
@@ -24,12 +24,12 @@
#endif
#include <usrp_server.h>
#include <iostream>
-#include <usb.h>
#include <usrp_inband_usb_packet.h>
#include <mb_class_registry.h>
#include <vector>
#include <fake_usrp.h>
#include "usrp_standard.h"
+#include <usrp_usb_interface.h>
typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit
easy
@@ -66,6 +66,13 @@
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");
+// 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_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 std::string
str(long x)
{
@@ -78,9 +85,11 @@
: mb_mblock(rt, instance_name, user_arg)
{
// define our ports
+
// control & status port
d_cs = define_port("cs", "usrp-server-cs", true, mb_port::EXTERNAL);
+ d_cs_usrp = define_port("cs_usrp", "usrp-usb-interface-cs", false,
mb_port::INTERNAL);
// ports
//
@@ -91,36 +100,87 @@
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
- // query the FPGA to get these values
- d_ntx_chan = 2;
- d_nrx_chan = 2;
+ // connect to the USRP low level interface, usb can easily be changed to
gigabit
+ define_component("usrp", "usrp_usb_interface", PMT_F);
+ connect("self", "cs_usrp", "usrp", "cs");
+ // Request the number of TX and RX channels from the USRP for initialization
+ d_cs_usrp->send(s_cmd_usrp_ntx_chan, pmt_list1(PMT_NIL));
+ d_cs_usrp->send(s_cmd_usrp_nrx_chan, pmt_list1(PMT_NIL));
+
+ // Set everything to uninitialized
+ d_init.tx=0;
+ d_init.rx=0;
+ d_init.fully_initialized=0;
+
+}
+
+usrp_server::~usrp_server()
+{
+}
+
+
+void
+usrp_server::initial_transition()
+{
+ // the initial transition
+}
+
+void
+usrp_server::initialize_tx_chans(pmt_t data)
+{
+
+ pmt_t invocation_handle = pmt_nth(0, data);
+ pmt_t chans = pmt_nth(1, data);
+
+ d_ntx_chan = pmt_to_long(chans);
+
// Initialize capacity on each channel to 0 and to no owner
// Also initialize the USRP standard tx/rx pointers to NULL
for(int chan=0; chan < d_ntx_chan; chan++) {
d_chaninfo_tx[chan].assigned_capacity = 0;
d_chaninfo_tx[chan].owner = PMT_NIL;
- d_utx.push_back(NULL);
}
+
+ std::cout << "[USRP_SERVER] Initialized " << chans << " TX chans\n";
+
+ d_init.tx=1;
+ check_initialization();
+}
+
+void
+usrp_server::initialize_rx_chans(pmt_t data)
+{
+
+ pmt_t invocation_handle = pmt_nth(0, data);
+ pmt_t chans = pmt_nth(1, data);
+
+ d_nrx_chan = pmt_to_long(chans);
+
for(int chan=0; chan < d_nrx_chan; chan++) {
d_chaninfo_rx[chan].assigned_capacity = 0;
d_chaninfo_rx[chan].owner = PMT_NIL;
- d_urx.push_back(NULL);
}
-}
+
+ std::cout << "[USRP_SERVER] Initialized " << chans << " RX chans\n";
-usrp_server::~usrp_server()
-{
+ d_init.rx=1;
+ check_initialization();
}
-
void
-usrp_server::initial_transition()
+usrp_server::check_initialization()
{
- // the initial transition
+ if(d_init.rx && d_init.tx) {
+ d_init.fully_initialized=1; // used by the message handler
+
+ // Parse the messages that were queued while unitialized
+ for(int i=0; i < (int)d_init_queue.size(); i++)
+ handle_message(d_init_queue[i]);
+ }
}
+
void
usrp_server::handle_message(mb_message_sptr msg)
{
@@ -140,6 +200,29 @@
// It would be nice if this were all table driven, and we could
// compute our state transition as f(current_state, port_id, signal)
+ // Check for messages that lead to full initialization of the USRP server
+ if(!d_init.fully_initialized) {
+
+ std::cout << "[USRP_SERVER] Received msg while uninitialized\n";
+
+ if (pmt_eq(port_id, d_cs_usrp->port_symbol())) {
+ if(pmt_eq(event, s_response_usrp_ntx_chan)) {
+ initialize_tx_chans(data);
+ return;
+ }
+ else if (pmt_eq(event, s_response_usrp_nrx_chan)) {
+ initialize_rx_chans(data);
+ return;
+ }
+ }
+
+ // If we're not initialized and the message is not understood to be part
of the
+ // initialization, we queue it
+ d_init_queue.push_back(msg);
+
+ return;
+ }
+
if (pmt_eq(port_id, d_cs->port_symbol())){ // message came in on our
control/status port
if (pmt_eq(event, s_cmd_open)){
@@ -147,41 +230,7 @@
invocation_handle = pmt_nth(0, data);
long which_usrp = pmt_to_long(pmt_nth(1, data)); // integer usrp id,
usually 0
- // Open up a standard RX and TX for communication with the USRP
- //
- // I'm not sure if i should be opening up all RX and TX channels, but
given that
- // one is not specified in the signal, I am assuming so.
- for(int chan=0; chan < d_ntx_chan; chan++) {
- d_utx[chan] = usrp_standard_tx::make (which_usrp,
- 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
-
- if(!d_utx[chan]) {
- std::cout << "[usrp_server] Failed to open channel " << chan << "\n";
- reply_data = pmt_list2(invocation_handle, PMT_F);
- d_cs->send(s_response_open, reply_data);
- return;
- }
-
- if(!d_utx[chan]->set_tx_freq (0,0)) { // try setting center freq to 0
- std::cout << "[usrp_server] Failed to set center frequency on
channel " << chan << "\n";
- reply_data = pmt_list2(invocation_handle, PMT_F);
- d_cs->send(s_response_open, reply_data);
- return;
- }
-
- d_utx[chan]->start(); // not sure if this is the appropriate place to
start yet
- }
- for(int chan=0; chan < d_nrx_chan; chan++) {
-
- }
- // Do the right thing....
- // build a reply
-
reply_data = pmt_list2(invocation_handle, PMT_T);
d_cs->send(s_response_open, reply_data);
@@ -200,16 +249,19 @@
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);
+ return;
}
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);
+ return;
}
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);
+ return;
}
goto unhandled;
}
@@ -442,11 +494,11 @@
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
+ // usb_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";
+ 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);
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-05-19 03:43:53 UTC (rev 5499)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
2007-05-20 06:28:20 UTC (rev 5500)
@@ -23,18 +23,13 @@
#include <mb_mblock.h>
#include <vector>
-#include "usrp_standard.h"
/*!
- * \brief Implements the lowest-level mblock interface to the USRP
+ * \brief Implements the lowest-level mblock usb_interface to the USRP
*/
class usrp_server : public mb_mblock
{
public:
-
- std::vector<usrp_standard_tx*> d_utx;
- std::vector<usrp_standard_rx*> d_urx;
-
enum error_codes {
RQSTD_CAPACITY_UNAVAIL = 0,
CHANNEL_UNAVAIL = 1,
@@ -50,6 +45,7 @@
static const int N_PORTS = 4;
std::vector<mb_port_sptr> d_tx, d_rx;
mb_port_sptr d_cs;
+ mb_port_sptr d_cs_usrp;
static const int D_USB_CAPACITY = 32 * 1024 * 1024;
static const int D_MAX_CHANNELS = 16;
@@ -64,6 +60,19 @@
struct channel_info d_chaninfo_tx[D_MAX_CHANNELS];
struct channel_info d_chaninfo_rx[D_MAX_CHANNELS];
+ std::vector<mb_message_sptr> d_init_queue;
+
+ // components we need information about from the FPGA
+ // that we will block service on until we get responses.
+ // All messages are queued until then.
+ struct initialized {
+ long tx;
+ long rx;
+ long fully_initialized;
+ };
+
+ struct initialized d_init;
+
public:
usrp_server(mb_runtime *rt, const std::string &instance_name, pmt_t
user_arg);
~usrp_server();
@@ -81,6 +90,9 @@
int rx_port_index(pmt_t port_id);
int tx_port_index(pmt_t port_id);
long current_capacity_allocation();
+ void initialize_tx_chans(pmt_t data);
+ void initialize_rx_chans(pmt_t data);
+ void check_initialization();
};
#endif /* INCLUDED_USRP_SERVER_H */
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.mbh
===================================================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5500 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=