commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r5691 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Tue, 5 Jun 2007 11:02:02 -0600 (MDT)

Author: gnychis
Date: 2007-06-05 11:02:01 -0600 (Tue, 05 Jun 2007)
New Revision: 5691

Added:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.h
Modified:
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
Log:
Checking in basic RX stub, trying to fix TX stub


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 15:43:50 UTC (rev 5690)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am    
    2007-06-05 17:02:01 UTC (rev 5691)
@@ -59,7 +59,8 @@
        usrp_usb_interface.cc                           \
        usrp_tx.cc                                                              
        \
        usrp_tx_stub.cc                                                 \
-       usrp_rx.cc
+       usrp_rx.cc                                                              
        \
+       usrp_rx_stub.cc
 
 libusrp_inband_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
 
@@ -73,6 +74,7 @@
        usrp_usb_interface.h            \
        usrp_inband_usb_packet.h        \
        usrp_tx_stub.h                                          \
+       usrp_rx_stub.h                                          \
        usrp_tx.h                                                               
        \
        usrp_rx.h
 

Added: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
                            (rev 0)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
    2007-06-05 17:02:01 UTC (rev 5691)
@@ -0,0 +1,110 @@
+/* -*- 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_stub.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 = false;
+
+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_stub::usrp_rx_stub(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_stub::~usrp_rx_stub() 
+{
+}
+
+void 
+usrp_rx_stub::initial_transition()
+{
+  
+}
+
+void
+usrp_rx_stub::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_stub::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_stub] 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_stub] Error reading packet, shutting down\n";
+      d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_F, PMT_NIL));
+      return;
+    }
+
+    d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_T, v_pkt));
+    if(verbose)
+      std::cout << "[usrp_rx_stub] Read 1 packet\n";
+  }
+}
+
+REGISTER_MBLOCK_CLASS(usrp_rx_stub);

Added: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.h 
                            (rev 0)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.h 
    2007-06-05 17:02:01 UTC (rev 5691)
@@ -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_STUB_H
+#define INCLUDED_USRP_RX_STUB_H
+
+#include <mb_mblock.h>
+#include <vector>
+#include "usrp_standard.h"
+
+/*!
+ * \brief Implements the low level usb interface to the USRP
+ */
+class usrp_rx_stub : public mb_mblock
+{
+ public:
+
+  mb_port_sptr d_cs;
+  usrp_standard_rx* d_urx;
+  
+ public:
+  usrp_rx_stub(mb_runtime *rt, const std::string &instance_name, pmt_t 
user_arg);
+  ~usrp_rx_stub();
+  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 */
+





reply via email to

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