commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11065 - in gnuradio/branches/developers/eb/vrt: gr-vr


From: eb
Subject: [Commit-gnuradio] r11065 - in gnuradio/branches/developers/eb/vrt: gr-vrt/src vrt/apps vrt/include/vrt vrt/lib
Date: Wed, 20 May 2009 00:29:59 -0600 (MDT)

Author: eb
Date: 2009-05-20 00:29:58 -0600 (Wed, 20 May 2009)
New Revision: 11065

Added:
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h
Modified:
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/Makefile.am
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.cc
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.h
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_base.cc
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_base.h
   gnuradio/branches/developers/eb/vrt/vrt/apps/simple_rx_samples.cc
   gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h
   gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc
Log:
checkpoint

Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/Makefile.am  2009-05-20 
01:09:24 UTC (rev 11064)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/Makefile.am  2009-05-20 
06:29:58 UTC (rev 11065)
@@ -52,10 +52,12 @@
 lib_LTLIBRARIES = libgnuradio-vrt.la
 
 libgnuradio_vrt_la_SOURCES = \
-       vrt_base.cc \
+       vrt_gr_rx_common.cc \
        vrt_source_base.cc \
-       vrt_source_32fc.cc
+       vrt_source_32fc.cc \
+       vrt_quadradio_source_32fc.cc
 
+
 #libgnuradio_vrt_la_SOURCES = \
 #      rx_16sc_handler.cc \
 #      rx_32fc_handler.cc \
@@ -73,11 +75,11 @@
        $(GNURADIO_CORE_LA) 
 
 grinclude_HEADERS = \
-       vrt_base.h \
-       vrt_ctrl_base.h \
+       vrt_gr_rx_common.h \
        vrt_source_base.h \
        vrt_source_32fc.h \
-       vrt_source_16sc.h
+       vrt_source_16sc.h \
+       vrt_quadradio_source_32fc.h
 
 #      vrt_sink_base.h \
 #      vrt_sink_16sc.h \

Added: 
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc 
                        (rev 0)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc 
2009-05-20 06:29:58 UTC (rev 11065)
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 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 3, 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 <vrt_quadradio_source_32fc.h>
+#include <vrt/quadradio.h>
+
+vrt_quadradio_source_32fc::vrt_quadradio_source_32fc(const std::string &ip, 
size_t rx_bufsize)
+  : vrt_source_32fc("quadradio_source_32fc"),
+    d_qr(vrt::quadradio::sptr(new vrt::quadradio(ip, rx_bufsize))),
+    d_samples_per_pkt(0)
+{
+}
+
+vrt_quadradio_source_32fc::~vrt_quadradio_source_32fc()
+{
+  d_qr->stop_streaming();
+}
+
+vrt::rx::sptr 
+vrt_quadradio_source_32fc::vrt_rx() const
+{
+  return d_qr->vrt_rx();
+}
+
+bool 
+vrt_quadradio_source_32fc::start()
+{
+  return d_qr->start_streaming(d_samples_per_pkt);
+}  
+
+bool
+vrt_quadradio_source_32fc::stop()
+{
+  return d_qr->stop_streaming();
+}


Property changes on: 
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h  
                        (rev 0)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h  
2009-05-20 06:29:58 UTC (rev 11065)
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 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 3, 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_VRT_QUADRADIO_SOURCE_32FC_H
+#define INCLUDED_VRT_QUADRADIO_SOURCE_32FC_H
+
+#include <vrt_source_32fc.h>
+
+namespace vrt {
+  class quadradio;
+};
+
+class vrt_quadradio_source_32fc;
+typedef boost::shared_ptr<vrt_quadradio_source_32fc> 
vrt_quadradio_source_32fc_sptr;
+
+vrt_quadradio_source_32fc_sptr
+vrt_make_quadradio_source_32fc(const std::string &ip, size_t rx_bufsize = 0);
+
+class vrt_quadradio_source_32fc : public vrt_source_32fc
+{
+  boost::shared_ptr<vrt::quadradio>    d_qr;
+  int                                  d_samples_per_pkt;
+
+  vrt_quadradio_source_32fc(const std::string &ip, size_t rx_bufsize);
+  bool my_stop();
+
+public:
+  virtual ~vrt_quadradio_source_32fc();
+  virtual vrt::rx::sptr vrt_rx() const;
+
+  /*!
+   * \brief Called by scheduler when starting flowgraph
+   */
+  virtual bool start();
+  
+  /*!
+   * \brief Called by scheduler when stopping flowgraph
+   */
+  virtual bool stop();
+};
+
+
+
+#endif /* INCLUDED_VRT_QUADRADIO_SOURCE_32FC_H */


Property changes on: 
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.cc   
2009-05-20 01:09:24 UTC (rev 11064)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.cc   
2009-05-20 06:29:58 UTC (rev 11065)
@@ -83,14 +83,10 @@
 
 // ------------------------------------------------------------------------
 
-vrt_source_32fc::vrt_source_32fc(const char *name,
-                                vrt_ctrl_base::sptr ctrl,
-                                int data_socket_fd,
-                                size_t rx_bufsize)
-  throw (std::runtime_error)
+vrt_source_32fc::vrt_source_32fc(const char *name)
+
   : vrt_source_base(name,
-                   gr_make_io_signature(1, 1, sizeof(gr_complex)),
-                   ctrl, data_socket_fd, rx_bufsize)
+                   gr_make_io_signature(1, 1, sizeof(gr_complex)))
 {
 }
 
@@ -119,7 +115,7 @@
   
   // While we've got room, and there are packets, handle them
   rx_32fc_handler h(noutput_items, out, &oo, d_remainder);
-  bool ok = d_rx->rx_packets(&h);
+  bool ok = vrt_rx()->rx_packets(&h);
 
   if (!ok){
     std::cerr << "vrt_source_32fc: vrt::rx_packets() failed" << std::endl;

Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.h    
2009-05-20 01:09:24 UTC (rev 11064)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.h    
2009-05-20 06:29:58 UTC (rev 11065)
@@ -28,11 +28,7 @@
 class vrt_source_32fc : public vrt_source_base
 {
 protected:
-  vrt_source_32fc(const char *name,
-                 vrt_ctrl_base::sptr ctrl,
-                 int data_socket_fd,
-                 size_t rx_bufsize = 0)
-    throw (std::runtime_error);
+  vrt_source_32fc(const char *name);
 
   std::vector< std::complex<float> >   d_remainder;
 

Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_base.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_base.cc   
2009-05-20 01:09:24 UTC (rev 11064)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_base.cc   
2009-05-20 06:29:58 UTC (rev 11065)
@@ -29,16 +29,10 @@
 #include <iostream>
 
 vrt_source_base::vrt_source_base(const char *name,
-                                gr_io_signature_sptr output_signature,
-                                vrt_ctrl_base::sptr ctrl,
-                                int data_socket_fd,
-                                size_t rx_bufsize
-                                ) throw (std::runtime_error)
-  : vrt_base(name,
-            gr_make_io_signature(0, 0, 0),
-            output_signature,
-            ctrl),
-    d_rx(vrt::rx::make(data_socket_fd, rx_bufsize))
+                                gr_io_signature_sptr output_signature)
+  : gr_sync_block(name,
+                 gr_make_io_signature(0, 0, 0),
+                 output_signature)
 {
 }
 

Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_base.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_base.h    
2009-05-20 01:09:24 UTC (rev 11064)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_base.h    
2009-05-20 06:29:58 UTC (rev 11065)
@@ -25,25 +25,22 @@
 
 #include <vrt_base.h>
 #include <vrt/rx.h>
+#include <vrt_gr_rx_common.h>
+#include <gr_io_signature.h>
 
 /*!
  * Base class for all VRT source blocks
  */
-class vrt_source_base : public vrt_base
+class vrt_source_base : public gr_sync_block
 {
 protected:
   vrt_source_base(const char *name,
-                 gr_io_signature_sptr output_signature,
-                 vrt_ctrl_base::sptr ctrl,
-                 int data_socket_fd,
-                 size_t rx_bufsize = 0)
-    throw (std::runtime_error);
+                 gr_io_signature_sptr output_signature);
 
-  vrt::rx::sptr        d_rx;
-
 public:
   ~vrt_source_base();
 
+  virtual vrt::rx::sptr vrt_rx() const = 0;
 };
 
 #endif /* INCLUDED_VRT_SOURCE_BASE_H */

Modified: gnuradio/branches/developers/eb/vrt/vrt/apps/simple_rx_samples.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/apps/simple_rx_samples.cc   
2009-05-20 01:09:24 UTC (rev 11064)
+++ gnuradio/branches/developers/eb/vrt/vrt/apps/simple_rx_samples.cc   
2009-05-20 06:29:58 UTC (rev 11065)
@@ -341,18 +341,18 @@
   if (rt != gruel::RT_OK)
     std::cerr << "Failed to enable realtime scheduling" << std::endl;
 
-  
-  vrt::quadradio qr;
-  if (!qr.open(quad_radio_ip)){
-    std::cerr << "Failed to open quadradio\n";
+    
+  vrt::quadradio::sptr qr;
+  try {
+    qr = vrt::quadradio::sptr(new vrt::quadradio(quad_radio_ip, rx_bufsize));
+  }
+  catch (...){
+    std::cerr << "Failed to create vrt::quadradio\n";
     return 1;
   }
 
-  vrt::rx::sptr vrt_receiver = vrt::rx::make(qr.data_socket_fd(), rx_bufsize);
 
-
   rx_nop_handler::sptr handler;
-
   if (output_filename){
     if (output_shorts)
       handler = rx_nop_handler::sptr(new file_writer_16sc(output_filename, 
nsamples));
@@ -363,7 +363,7 @@
     handler = rx_nop_handler::sptr(new rx_nop_handler(nsamples));
 
 
-  if (!qr.start_streaming(samples_per_pkt)){
+  if (!qr->start_streaming(samples_per_pkt)){
     fprintf(stderr, "failed to send_rx_command\n");
     return 1;
   }
@@ -374,14 +374,14 @@
        && !signaled
        && !handler->has_errored_p()
        && !handler->has_finished_p()){
-    bool ok = vrt_receiver->rx_packets(handler.get());
+    bool ok = qr->vrt_rx()->rx_packets(handler.get());
     if (!ok){
       fprintf(stderr, "vrt->rx_packets failed\n");
       break;
     }
   }
 
-  qr.stop_streaming();
+  qr->stop_streaming();
 
   printf("%llu packets received, %llu bad pkt_cnt field values, %llu 
samples\n",
         handler->npackets(), handler->nwrong_pkt_cnt(), handler->nsamples());

Modified: gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h     
2009-05-20 01:09:24 UTC (rev 11064)
+++ gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h     
2009-05-20 06:29:58 UTC (rev 11065)
@@ -21,23 +21,27 @@
 #ifndef INCLUDED_VRT_QUADRADIO_H
 #define INCLUDED_VRT_QUADRADIO_H
 
+#include <vrt/rx.h>
+
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 
-/*
- * We're not committing to this interface.  It's just here so we can make 
progress...
- */
-
 namespace vrt {
 
+  /*
+   * We're not committing to this interface.  It's just here so we can make 
progress...
+   *
+   * This implements the ad-hoc control for bringup and has-a vrt::rx
+   */
   class quadradio
   {
     int                   d_ctrl_fd;          // socket for control
     struct in_addr d_ctrl_port_inaddr; // our ip addr
-    int                   d_data_fd;          // socket for data
+    int                   d_data_fd;          // socket for data (owned by 
d_rx)
     int                   d_data_port;        // our data port number
+    vrt::rx::sptr  d_rx;              // has-a rx
 
     static bool
     open_sockets(const char *quad_radio_ip, int quad_radio_ctrl_port,
@@ -52,18 +56,21 @@
     send_stop_rx_command(int ctrl_fd);
     
     static int control_port() { return 790; }
+    int data_socket_fd() const { return d_data_fd; }
 
+    bool open(const char *ip);
+
   public:
-    quadradio();
+    typedef boost::shared_ptr<quadradio> sptr;
+
+    quadradio(const std::string &ip, size_t rx_bufsize = 0);
     ~quadradio();
 
-    bool open(const char *ip);
-    bool close();
+    vrt::rx::sptr vrt_rx() const { return d_rx; }
 
     bool start_streaming(int samples_per_pkt = 0);
     bool stop_streaming();
-    
-    int data_socket_fd() const { return d_data_fd; }
+
   };
 
 };

Modified: gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc    2009-05-20 
01:09:24 UTC (rev 11064)
+++ gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc    2009-05-20 
06:29:58 UTC (rev 11065)
@@ -31,33 +31,29 @@
 #define        MAX_IP_LOCAL_PORT       61000
 
 
-vrt::quadradio::quadradio()
+vrt::quadradio::quadradio(const std::string &ip, size_t rx_bufsize)
   : d_ctrl_fd(0), d_data_fd(0), d_data_port(0)
 {
+  if (!open(ip.c_str()))
+    throw std::runtime_error("vrt::quadradio: failed to open " + ip + "\n");
+
+  d_rx = vrt::rx::make(data_socket_fd(), rx_bufsize);
 }
 
 vrt::quadradio::~quadradio()
 {
-  close();
+  ::close(d_ctrl_fd);
 }
 
 bool
 vrt::quadradio::open(const char *ip)
 {
-  return vrt::quadradio::open_sockets(ip, control_port(),
-                                     &d_ctrl_fd, &d_ctrl_port_inaddr,
-                                     &d_data_fd, &d_data_port);
+  return open_sockets(ip, control_port(),
+                     &d_ctrl_fd, &d_ctrl_port_inaddr,
+                     &d_data_fd, &d_data_port);
 }
 
 bool
-vrt::quadradio::close()
-{
-  ::close(d_ctrl_fd);
-  ::close(d_data_fd);
-  return true;
-}
-
-bool
 vrt::quadradio::start_streaming(int samples_per_pkt)
 {
   return send_rx_command(d_ctrl_fd, true, d_ctrl_port_inaddr,





reply via email to

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