commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r5675 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Mon, 4 Jun 2007 20:46:55 -0600 (MDT)

Author: gnychis
Date: 2007-06-04 20:46:55 -0600 (Mon, 04 Jun 2007)
New Revision: 5675

Added:
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.h
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.lo
Modified:
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_interface.mbh
   
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
Log:
Work-in-progress, adding in *untested* RX code


Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am    
    2007-06-05 02:16:27 UTC (rev 5674)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am    
    2007-06-05 02:46:55 UTC (rev 5675)
@@ -54,10 +54,11 @@
        $(COMPILE_MBH) usrp_interface.mbh usrp_interface_mbh.cc
 
 libusrp_inband_la_SOURCES =            \
-       $(BUILT_SOURCES)                \
-       usrp_server.cc                  \
-       usrp_usb_interface.cc           \
-       usrp_usb_interface_stub.cc
+       $(BUILT_SOURCES)                                                \
+       usrp_server.cc                                                  \
+       usrp_usb_interface.cc                           \
+       usrp_usb_interface_stub.cc      \
+       usrp_rx.cc
 
 libusrp_inband_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
 
@@ -70,7 +71,8 @@
        usrp_server.h                   \
        usrp_usb_interface.h            \
        usrp_inband_usb_packet.h        \
-       usrp_usb_interface_stub.h
+       usrp_usb_interface_stub.h       \
+       usrp_rx.h
 
 noinst_HEADERS =                       \
        qa_inband.h                     \

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_interface.mbh
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_interface.mbh
 2007-06-05 02:16:27 UTC (rev 5674)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_interface.mbh
 2007-06-05 02:46:55 UTC (rev 5675)
@@ -27,9 +27,9 @@
 ;; ----------------------------------------------------------------
 
 ;; ----------------------------------------------------------------
-;; tx-channels
+;; usrp-interface-cs
 ;;
-;; Handles a query for the number of tx-channels
+;; Handles interaction between the usrp_sever and the USB interface
 
 (define-protocol-class usrp-interface-cs
 
@@ -51,3 +51,37 @@
    (response-usrp-read invocation-handle channel)
    )
   )
+
+;; ----------------------------------------------------------------
+;; usrp-tx-cs
+;;
+;; Handles interaction between the USB interface and RX interface
+
+(define-protocol-class usrp-tx-cs
+
+  (:outgoing
+   (cmd-usrp-tx-write invocation-handle data)
+   )
+
+  (:incoming
+   (response-usrp-rx-write invocation-handle status)
+   )
+  )
+
+;; ----------------------------------------------------------------
+;; usrp-rx-cs
+;;
+;; Handles interaction between the USB interface and RX interface
+
+(define-protocol-class usrp-rx-cs
+
+  (:outgoing
+   (cmd-usrp-rx-start-reading invocation-handle rx-handle)
+   )
+
+  (:incoming
+   (response-usrp-rx-read invocation-handle data)
+
+   ;; There is currently no response to a stop reading
+   )
+  )

Added: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc 
                        (rev 0)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc 
2007-06-05 02:46:55 UTC (rev 5675)
@@ -0,0 +1,109 @@
+/* -*- 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_rx.h>
+#include <usrp_inband_usb_packet.h>
+#include <fpga_regs_common.h>
+#include "usrp_standard.h"
+#include <stdio.h>
+
+typedef usrp_inband_usb_packet transport_pkt;
+
+static const bool verbose = true;
+
+static pmt_t s_cmd_usrp_rx_start_reading = 
pmt_intern("cmd-usrp-rx-start-reading");
+static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read");
+
+usrp_rx::usrp_rx(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-rx-cs", true, mb_port::EXTERNAL);
+  
+}
+
+usrp_rx::~usrp_rx() 
+{
+}
+
+void 
+usrp_rx::initial_transition()
+{
+  
+}
+
+void
+usrp_rx::handle_message(mb_message_sptr msg)
+{
+  pmt_t event = msg->signal();
+  pmt_t port_id = msg->port_id();
+  pmt_t data = msg->data(); 
+
+  // Theoretically only have 1 message to ever expect, but
+  // want to make sure its at least what we want
+  if(pmt_eq(port_id, d_cs->port_symbol())) {
+    
+    if(pmt_eqv(event, s_cmd_usrp_rx_start_reading))
+      read_and_respond(data);
+  }
+}
+
+void
+usrp_rx::read_and_respond(pmt_t data)
+{
+  size_t ignore;
+  bool underrun;
+  unsigned int n_read;
+  unsigned int pkt_size = sizeof(transport_pkt);
+
+  pmt_t invocation_handle = pmt_nth(0, data);
+  d_urx = boost::any_cast<usrp_standard_rx *>(pmt_any_ref(pmt_nth(1, data)));
+
+  pmt_t v_pkt = pmt_make_u8vector(pkt_size, 0);
+  transport_pkt *pkt = (transport_pkt *) 
pmt_u8vector_writeable_elements(v_pkt, ignore);
+
+  if(verbose)
+    std::cout << "[usrp_rx] Waiting for packets..\n";
+  
+  // Read by 512 which is packet size and send them back up
+  while(1) {
+    n_read = d_urx->read(pkt, pkt_size, &underrun);
+
+    if(n_read != pkt_size) {
+      std::cerr << "[usrp_rx] Error reading packet, shutting down\n";
+      shutdown_all(PMT_F);
+      return;
+    }
+
+    d_cs->send(s_response_usrp_rx_read, pmt_list2(PMT_NIL, v_pkt));
+    if(verbose)
+      std::cout << "[usrp_rx] Read 1 packet\n";
+  }
+}
+
+REGISTER_MBLOCK_CLASS(usrp_rx);

Added: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.h
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.h  
                        (rev 0)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.h  
2007-06-05 02:46:55 UTC (rev 5675)
@@ -0,0 +1,52 @@
+/* -*- 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_RX_H
+#define INCLUDED_USRP_RX_H
+
+#include <mb_mblock.h>
+#include <vector>
+#include "usrp_standard.h"
+
+/*!
+ * \brief Implements the low level usb interface to the USRP
+ */
+class usrp_rx : public mb_mblock
+{
+ public:
+
+  mb_port_sptr d_cs;
+  usrp_standard_rx* d_urx;
+  
+ public:
+  usrp_rx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
+  ~usrp_rx();
+  void initial_transition();
+  void handle_message(mb_message_sptr msg);
+
+ private:
+  void read_and_respond(pmt_t data);
+  void read_data();
+ 
+};
+  
+
+#endif /* INCLUDED_USRP_RX_H */
+

Added: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.lo
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.lo 
                        (rev 0)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.lo 
2007-06-05 02:46:55 UTC (rev 5675)
@@ -0,0 +1,12 @@
+# usrp_rx.lo - a libtool object file
+# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 
22:14:06)
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/usrp_rx.o'
+
+# Name of the non-PIC object.
+non_pic_object=none
+

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-06-05 02:16:27 UTC (rev 5674)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
      2007-06-05 02:46:55 UTC (rev 5675)
@@ -29,6 +29,7 @@
 #include <usrp_usb_interface.h>
 #include <usrp_inband_usb_packet.h>
 #include <fpga_regs_common.h>
+#include "usrp_rx.h"
 #include "usrp_standard.h"
 #include <stdio.h>
 
@@ -46,6 +47,10 @@
 static pmt_t s_response_usrp_close = pmt_intern("response-usrp-close");
 static pmt_t s_response_usrp_write = pmt_intern("response-usrp-write");
 
+// TX and RX signals
+static pmt_t s_cmd_usrp_rx_start_reading = 
pmt_intern("cmd-usrp-rx-start-reading");
+static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read");
+
 static const bool verbose = true;
 
 // need to take number of TX and RX channels as parameter
@@ -54,6 +59,11 @@
   d_fpga_debug(false)
 {
   d_cs = define_port("cs", "usrp-interface-cs", true, mb_port::EXTERNAL);      
+  d_rx_cs = define_port("rx_cs", "usrp-rx-cs", false, mb_port::INTERNAL);      
+
+  // Connect to TX and RX
+  define_component("rx", "usrp-rx", PMT_F);
+  connect("self", "rx_cs", "usrp_rx", "cs");
   
   // FIX ME: the code should query the FPGA to retrieve the number of channels 
and such
   d_ntx_chan = 2;
@@ -140,8 +150,8 @@
 
   // Open up a standard RX and TX for communication with the USRP
    
-  std::string rbf = "usrp_inband_usb.rbf";
-  //std::string rbf = "";
+  //std::string rbf = "usrp_inband_usb.rbf";
+  std::string rbf = "";
 
   d_utx = usrp_standard_tx::make(which_usrp,
                                 32,            // 128/32 -> 4MS/s
@@ -198,8 +208,6 @@
     return;
   }
 
-  d_urx->start();
-
   if(d_fpga_debug) {
     d_utx->_write_fpga_reg(FR_DEBUG_EN,0xf);
     d_utx->_write_oe(0, 0xffff, 0xffff);
@@ -260,6 +268,15 @@
 {
   pmt_t invocation_handle = pmt_nth(0, data);
 
+  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));
+
+  if(verbose)
+    std::cout << "[usrp_usb_interface] Starting RX...\n";
+
   return;
 }
 

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-06-05 02:16:27 UTC (rev 5674)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
       2007-06-05 02:46:55 UTC (rev 5675)
@@ -36,6 +36,8 @@
   usrp_standard_rx* d_urx;
   
   mb_port_sptr d_cs;
+  mb_port_sptr  d_rx_cs;
+  mb_port_sptr  d_tx_cs;
   
   long d_ntx_chan;
   long d_nrx_chan;





reply via email to

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