commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10895 - in gnuradio/branches/developers/eb/vrt/vrt: i


From: eb
Subject: [Commit-gnuradio] r10895 - in gnuradio/branches/developers/eb/vrt/vrt: include/vrt lib
Date: Wed, 22 Apr 2009 21:12:46 -0600 (MDT)

Author: eb
Date: 2009-04-22 21:12:46 -0600 (Wed, 22 Apr 2009)
New Revision: 10895

Added:
   gnuradio/branches/developers/eb/vrt/vrt/include/vrt/expanded_headers.h
   gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_packet_handler.h
   gnuradio/branches/developers/eb/vrt/vrt/include/vrt/vrt_rx_udp.h
   gnuradio/branches/developers/eb/vrt/vrt/lib/expanded_header.cc
Log:
checkpoint

Added: gnuradio/branches/developers/eb/vrt/vrt/include/vrt/expanded_headers.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/include/vrt/expanded_headers.h      
                        (rev 0)
+++ gnuradio/branches/developers/eb/vrt/vrt/include/vrt/expanded_headers.h      
2009-04-23 03:12:46 UTC (rev 10895)
@@ -0,0 +1,77 @@
+/* -*- 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_EXPANDED_HEADERS_H
+#define INCLUDED_VRT_EXPANDED_HEADERS_H
+
+#include <stdint.h>
+#include <vrt/vrt_bits.h>
+
+namespace vrt {
+
+  /*!
+   * \brief All headers and trailer for VRT IF-Data, Extension-Data,
+   * IF-Context and Extension-Context packets.
+   *
+   * There are fields allocated for each possible header.  Their content may
+   * or may not be valid.  Check the header field to confirm their validity.
+   * All values are in host-endian format.
+   */
+  struct expanded_headers {
+    uint32_t   header;                 // first word of all packets
+    uint32_t   stream_id;              // optional stream identifier
+    uint64_t   class_id;               // optional class identifier
+    uint32_t   integer_secs;           // optional integer seconds timestamp
+    uint64_t   fractional_secs;        // optional fractional seconds timestamp
+    uint32_t   trailer;                // optional trailer (only possible in 
data pkts)
+
+    expanded_headers()
+      : header(0), stream_id(0), class_id(0),
+       integer_secs(0), fractional_secs(0), trailer(0) {}
+
+    int pkt_type(){
+      return (header & VRTH_PT_MASK) >> 28;
+    }
+    
+    // packet type predicates
+    bool if_data_p() { return s_if_data[pkt_type()]; }
+    bool ext_data_p() { return s_ext_data[pkt_type()]; }
+    bool if_context_p() { return (header & VRTH_PT_MASK) == 
VRTH_PT_IF_CONTEXT; }
+    bool ext_context_p() {return (header & VRTH_PT_MASK) == 
VRTH_PT_EXT_CONTEXT; }
+
+    bool data_p() { return if_data_p() || ext_data_p(); }
+    bool context_p() { return if_context_p() || ext_context_p(); }
+
+    // optional info predicates
+    bool stream_id_p() { return s_stream_id[pkt_type()]; }
+    bool class_id_p() { return (header & VRTH_HAS_CLASSID) != 0; }
+    bool trailer_p() { return data_p() && (header & VRTH_HAS_TRAILER) != 0; }
+
+  private:
+    static unsigned char s_if_data[16];
+    static unsigned char s_ext_data[16];
+    static unsigned char s_stream_id[16];
+
+  };
+
+}; // vrt
+
+
+#endif /* INCLUDED_VRT_EXPANDED_HEADERS_H */


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

Added: gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_packet_handler.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_packet_handler.h     
                        (rev 0)
+++ gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_packet_handler.h     
2009-04-23 03:12:46 UTC (rev 10895)
@@ -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_RX_PACKET_HANDLER_H
+#define INCLUDED_VRT_RX_PACKET_HANDLER_H
+
+#include <vrt/expanded_headers.h>
+
+namespace vrt {
+
+  /*!
+   * \brief Abstract function object called to handle received VRT packets.
+   *
+   * An object derived from this class is passed to vrt_rx_udp::rx_packets
+   * to process the received packets.
+   */
+  class rx_packet_handler {
+  public:
+    virtual ~rx_sample_handler();
+
+    /*!
+     * \param payload points to the first 32-bit word of the payload field.
+     * \param n32_bit_words is the number of 32-bit words in the payload field.
+     * \param hdrs is the expanded version of the mandatory and optional 
headers (& trailer).
+     *
+     * \p payload points to the raw payload section of the packet received off
+     * the wire. The data is network-endian (aka big-endian) 32-bit integers.
+     *
+     * This is the general purpose, low level interface and relies on other
+     * functions to handle all required endian-swapping and format conversion
+     * of the payload.  \sa FIXME.
+     *
+     * \returns true if the object wants to be called again with new data;
+     * false if no additional data is wanted.
+     */
+    virtual bool operator()(const uint32_t *payload,
+                           size_t n32_bit_words,
+                           const expanded_headers *hdrs);
+  };
+
+};  // vrt
+
+
+#endif /* INCLUDED_VRT_RX_PACKET_HANDLER_H */


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

Added: gnuradio/branches/developers/eb/vrt/vrt/include/vrt/vrt_rx_udp.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/include/vrt/vrt_rx_udp.h            
                (rev 0)
+++ gnuradio/branches/developers/eb/vrt/vrt/include/vrt/vrt_rx_udp.h    
2009-04-23 03:12:46 UTC (rev 10895)
@@ -0,0 +1,82 @@
+/* -*- 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_VRT_RX_UDP_H
+#define INCLUDED_VRT_VRT_RX_UDP_H
+
+#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
+
+namespace vrt {
+
+  /*!
+   * Relatively low-level interface to receive VRT packets over UDP.
+   *
+   * (We'll refactor this if/when we use a non-UDP transport.)
+   * No VRT control issues are addressed here.
+   */
+  class rx_udp : boost::nocopyable
+  {
+    int                d_socket_fd;
+
+  public:
+    /*!
+     * Shared pointer to this class
+     */ 
+    typedef boost::shared_ptr<usrp2> sptr;
+
+    /*! 
+     * \brief Static function to return an instance of rx_udp as a shared 
pointer.
+     *
+     * \param socket_fd file descriptor that data grams will be received from.
+     *                 It is assumed that some higher-level control software
+     *                 opened the appropriate UDP socket for us.  This object
+     *                 assumes management of the socket's lifetime.  The
+     *                 socket will be closed when our destructor fires.
+     */
+    static sptr make(int socket_fd);
+
+    /*! 
+     * \param socket_fd file descriptor that data grams will be received from.
+     *                 It is assumed that some higher-level control software
+     *                 opened the appropriate UDP socket for us.  This object
+     *                 assumes management of the socket's lifetime.  The
+     *                 socket will be closed when our destructor fires.
+     */
+    rx_udp(int socket_fd);
+    ~rx_udp();
+
+    /*!
+     * \brief Receive packets from the given socket file descriptor.
+     *
+     * Handler will be invoked for all available packets.
+     * This function blocks until at least one packet has been processed.
+     */
+    bool rx_packets(rx_sample_handler *handler);
+
+    /*
+     * \returns the socket_fd.   Useful for select or poll.
+     */
+    int socket_fd() const { return d_socket_fd; }
+  };
+
+}
+
+#endif /* INCLUDED_VRT_VRT_RX_UDP_H */


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

Added: gnuradio/branches/developers/eb/vrt/vrt/lib/expanded_header.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/lib/expanded_header.cc              
                (rev 0)
+++ gnuradio/branches/developers/eb/vrt/vrt/lib/expanded_header.cc      
2009-04-23 03:12:46 UTC (rev 10895)
@@ -0,0 +1,42 @@
+/* -*- 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/expanded_headers.h>
+
+namespace vrt {
+
+  static unsigned char expanded_headers::s_if_data[16] = {
+    1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+  };
+
+  static unsigned char expanded_headers::s_ext_data[16] = {
+    0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+  };
+
+  static unsigned char expanded_headers::s_stream_id[16] = {
+    0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+  };
+
+
+}; // vrt


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





reply via email to

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