commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r5501 - gnuradio/branches/developers/gnychis/inband/us


From: gnychis
Subject: [Commit-gnuradio] r5501 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Sun, 20 May 2007 00:37:38 -0600 (MDT)

Author: gnychis
Date: 2007-05-20 00:37:37 -0600 (Sun, 20 May 2007)
New Revision: 5501

Added:
   
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
Modified:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
Log:
usrp_standard is no longer needed by usrp_server

Also adding in initialize low level USRP usb interface code.  The signals 
between the USRP server and the low level USRP code are general such that the 
Gigabit ethernet switch should be simple, the defined component in 
usrp_server.cc should only need to change from usrp_usb_interface to 
usrp_giga_interface, for example.  This could be based on the configuration 
stating the USRP version.


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-20 06:28:20 UTC (rev 5500)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-05-20 06:37:37 UTC (rev 5501)
@@ -28,7 +28,6 @@
 #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
@@ -494,7 +493,7 @@
 
     pkts[n_packets-1].set_end_of_burst();   // set the last packet's end of 
burst
 
-    // usb_interface with the USRP to send the USB packet, since the memory is
+    // 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)
     

Added: 
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
                              (rev 0)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
      2007-05-20 06:37:37 UTC (rev 5501)
@@ -0,0 +1,164 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <iostream>
+#include <vector>
+#include <usb.h>
+#include <mb_class_registry.h>
+#include <usrp_usb_interface.h>
+#include <usrp_inband_usb_packet.h>
+#include "usrp_standard.h"
+
+static pmt_t s_cmd_usrp_open = pmt_intern("cmd-usrp-open");
+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");
+
+// 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)
+  : mb_mblock(rt, instance_name, user_arg)
+{
+  d_cs = define_port("cs", "usrp-usb-interface-cs", true, mb_port::EXTERNAL);  
+  
+  // FIX ME: the code should query the FPGA to retrieve the number of channels 
and such
+  d_ntx_chan = 2;
+  d_nrx_chan = 2;
+
+  // Initialize NULLs for the channel pointers
+  for(int i=0; i < d_ntx_chan; i++)
+    d_utx.push_back(NULL);
+
+  for(int i=0; i < d_nrx_chan; i++)
+    d_urx.push_back(NULL);
+}
+
+usrp_usb_interface::~usrp_usb_interface() 
+{ 
+
+}
+
+void 
+usrp_usb_interface::initial_transition()
+{
+
+}
+
+void
+usrp_usb_interface::handle_message(mb_message_sptr msg)
+{
+  pmt_t event = msg->signal();         // the "name" of the message
+  pmt_t port_id = msg->port_id();      // which port it came in on
+  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
+
+    if (pmt_eq(event, s_cmd_usrp_open)){
+      open(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)));
+      return;
+    }
+    else if (pmt_eq(event, s_cmd_usrp_nrx_chan)) {
+      invocation_handle = pmt_nth(0, data);
+      d_cs->send(s_response_usrp_nrx_chan, pmt_list2(invocation_handle, 
pmt_from_long(d_nrx_chan)));
+      return;
+    }
+    goto unhandled;
+  }
+
+ unhandled:
+  std::cout << "[usrp_usb_interface] unhandled msg: " << msg << std::endl;
+}
+
+void
+usrp_usb_interface::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";
+
+  // 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_usrp_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_usrp_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++) {
+    d_urx[chan] = usrp_standard_rx::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_urx[chan]) {
+      std::cout << "[usrp_server] Failed to open channel " << chan << "\n";
+      reply_data = pmt_list2(invocation_handle, PMT_F);
+      d_cs->send(s_response_usrp_open, reply_data);
+      return;
+    }
+
+    if(!d_urx[chan]->set_rx_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_usrp_open, reply_data);
+      return;
+    }
+
+    d_urx[chan]->start();  // not sure if this is the appropriate place to 
start yet
+  }
+}
+
+
+REGISTER_MBLOCK_CLASS(usrp_usb_interface);


Property changes on: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
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
                               (rev 0)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
       2007-05-20 06:37:37 UTC (rev 5501)
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_USRP_USB_INTERFACE_H
+#define INCLUDED_USRP_USB_INTERFACE_H
+
+#include <mb_mblock.h>
+#include <vector>
+#include "usrp_standard.h"
+
+/*!
+ * \brief Implements the low level usb interface to the USRP
+ */
+class usrp_usb_interface : public mb_mblock
+{
+ public:
+
+  std::vector<usrp_standard_tx*> d_utx;
+  std::vector<usrp_standard_rx*> d_urx;
+  
+  mb_port_sptr d_cs;
+  
+  long d_ntx_chan;
+  long d_nrx_chan;
+
+ public:
+  usrp_usb_interface(mb_runtime *rt, const std::string &instance_name, pmt_t 
user_arg);
+  ~usrp_usb_interface();
+  void initial_transition();
+  void handle_message(mb_message_sptr msg);
+
+ private:
+  void open(pmt_t data);
+ 
+};
+  
+
+#endif /* INCLUDED_USRP_USB_INTERFACE_H */


Property changes on: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
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
                             (rev 0)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.mbh
     2007-05-20 06:37:37 UTC (rev 5501)
@@ -0,0 +1,49 @@
+;; -*- scheme -*- ; not really, but tells emacs how to format this
+;;
+;; Copyright 2007 Free Software Foundation, Inc.
+;; 
+;; This file is part of GNU Radio
+;; 
+;; GNU Radio is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;; 
+;; GNU Radio is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;; 
+;; You should have received a copy of the GNU General Public License along
+;; with this program; if not, write to the Free Software Foundation, Inc.,
+;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+;;
+
+;; ----------------------------------------------------------------
+;;              This is an mblock header file
+;;
+;; The format is very much a work-in-progress.
+;; It'll be compiled to C++.
+;; ----------------------------------------------------------------
+
+;; ----------------------------------------------------------------
+;; tx-channels
+;;
+;; Handles a query for the number of tx-channels
+
+(define-protocol-class usrp-usb-interface-cs
+
+  (:outgoing
+   (cmd-usrp-open invocation-handle which-usrp)
+   (cmd-usrp-close invocation-handle)
+   (cmd-usrp-ntx-chan invocation-handle)
+   (cmd-usrp-nrx-chan invocation-handle)
+   )
+
+  (:incoming
+   (response-usrp-open invocation-handle status)
+   (response-usrp-close invocation-handle status)
+   (response-usrp-ntx-chan invocation-handle ntx-chan)
+   (response-usrp-nrx-chan invocation-handle nrx-chan)
+   )
+  )





reply via email to

[Prev in Thread] Current Thread [Next in Thread]