commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8647 - in usrp2/branches/features/host-ng/host-ng: in


From: eb
Subject: [Commit-gnuradio] r8647 - in usrp2/branches/features/host-ng/host-ng: include/usrp2 lib
Date: Sat, 21 Jun 2008 15:23:40 -0600 (MDT)

Author: eb
Date: 2008-06-21 15:23:40 -0600 (Sat, 21 Jun 2008)
New Revision: 8647

Added:
   usrp2/branches/features/host-ng/host-ng/lib/data_handler.cc
Modified:
   usrp2/branches/features/host-ng/host-ng/include/usrp2/copy_handler.h
   usrp2/branches/features/host-ng/host-ng/include/usrp2/data_handler.h
   usrp2/branches/features/host-ng/host-ng/lib/Makefile.am
   usrp2/branches/features/host-ng/host-ng/lib/control.cc
   usrp2/branches/features/host-ng/host-ng/lib/control.h
   usrp2/branches/features/host-ng/host-ng/lib/copy_handler.cc
   usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc
   usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
   usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
Log:
s/unsigned int len/size_t len/g.
Added typedef for data_handler::result to clarify intentions.
Moved default dtor for data_handler to its own file.  
(These probably should have gone in as separate commits...)



Modified: usrp2/branches/features/host-ng/host-ng/include/usrp2/copy_handler.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/include/usrp2/copy_handler.h        
2008-06-21 20:40:02 UTC (rev 8646)
+++ usrp2/branches/features/host-ng/host-ng/include/usrp2/copy_handler.h        
2008-06-21 21:23:40 UTC (rev 8647)
@@ -26,18 +26,18 @@
 
 namespace usrp2 {
 
-  class copy_handler : data_handler, boost::noncopyable 
+  class copy_handler : public data_handler, boost::noncopyable 
   {
     uint8_t *d_dest;      // next write pointer
-    unsigned int d_space; // space left in destination buffer
-    unsigned int d_bytes; // total bytes copied
-    unsigned int d_times; // number of times invoked
+    size_t   d_space;     // space left in destination buffer
+    size_t   d_bytes;     // total bytes copied
+    size_t   d_times;     // number of times invoked
 
   public:
-    copy_handler(void *dest, unsigned int len);
+    copy_handler(void *dest, size_t len);
     ~copy_handler();
  
-    virtual uint32_t operator()(const void *base, unsigned int len);
+    virtual data_handler::result operator()(const void *base, size_t len);
   };
     
 } // namespace usrp2

Modified: usrp2/branches/features/host-ng/host-ng/include/usrp2/data_handler.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/include/usrp2/data_handler.h        
2008-06-21 20:40:02 UTC (rev 8646)
+++ usrp2/branches/features/host-ng/host-ng/include/usrp2/data_handler.h        
2008-06-21 21:23:40 UTC (rev 8647)
@@ -22,24 +22,31 @@
 #define INCLUDED_DATA_HANDLER_H
 
 #include <stdint.h>
+#include <stddef.h>
 
 namespace usrp2 {
 
   /*!
-   * \brief abstract function object called to handle received data blocks
+   * \brief Abstract function object called to handle received data blocks.
    */
   class data_handler 
   {
   public:
-    static const unsigned int KEEP = 0x0001; // do not discard data
-    static const unsigned int DONE = 0x0002; // do not call this object again
+
+    enum result_bits {
+      DONE     = 0x0001,       //< do not call this object again
+      KEEP     = 0x0002,       //< do not discard data
+    };
     
+    typedef int result;                //< bitmask of result_bits
+
     /*!
      * \param base points to the beginning of the data
      * \param len is the length in bytes of the data
+     * \returns bitmask composed of DONE, KEEP
      */
-      virtual unsigned int operator()(const void *base, unsigned int len) = 0;
-      virtual ~data_handler();
+    virtual result operator()(const void *base, size_t len) = 0;
+    virtual ~data_handler();
   };
 
 } // namespace usrp2

Modified: usrp2/branches/features/host-ng/host-ng/lib/Makefile.am
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/Makefile.am     2008-06-21 
20:40:02 UTC (rev 8646)
+++ usrp2/branches/features/host-ng/host-ng/lib/Makefile.am     2008-06-21 
21:23:40 UTC (rev 8647)
@@ -26,6 +26,7 @@
 libusrp2ng_la_SOURCES = \
        control.cc \
        copy_handler.cc \
+       data_handler.cc \
        eth_buffer.cc \
        ethernet.cc \
        find.cc \

Modified: usrp2/branches/features/host-ng/host-ng/lib/control.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/control.cc      2008-06-21 
20:40:02 UTC (rev 8646)
+++ usrp2/branches/features/host-ng/host-ng/lib/control.cc      2008-06-21 
21:23:40 UTC (rev 8647)
@@ -28,7 +28,7 @@
 
 namespace usrp2 {
 
-  pending_reply::pending_reply(unsigned int rid, void *buffer, unsigned int 
len)
+  pending_reply::pending_reply(unsigned int rid, void *buffer, size_t len)
     : d_rid(rid), d_mutex(), d_cond(&d_mutex), d_buffer(buffer), d_len(len)
   {
   }

Modified: usrp2/branches/features/host-ng/host-ng/lib/control.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/control.h       2008-06-21 
20:40:02 UTC (rev 8646)
+++ usrp2/branches/features/host-ng/host-ng/lib/control.h       2008-06-21 
21:23:40 UTC (rev 8647)
@@ -61,14 +61,14 @@
     omni_mutex      d_mutex;
     omni_condition  d_cond;
     void           *d_buffer;
-    unsigned int    d_len;
+    size_t         d_len;
 
   public:  
     /*!
      * Construct a pending reply from the reply ID, response packet
      * buffer, and buffer length.
      */
-    pending_reply(unsigned int rid, void *buffer, unsigned int len);
+    pending_reply(unsigned int rid, void *buffer, size_t len);
 
     /*!
      * Destructor. Signals creating thread.
@@ -100,7 +100,7 @@
     /*!
      * Retrieve destinateion buffer length
      */
-    unsigned int len() const { return d_len; }
+    size_t len() const { return d_len; }
   };
   
 } // namespace usrp2

Modified: usrp2/branches/features/host-ng/host-ng/lib/copy_handler.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/copy_handler.cc 2008-06-21 
20:40:02 UTC (rev 8646)
+++ usrp2/branches/features/host-ng/host-ng/lib/copy_handler.cc 2008-06-21 
21:23:40 UTC (rev 8647)
@@ -27,7 +27,7 @@
 
 namespace usrp2 {
   
-  copy_handler::copy_handler(void *dest, unsigned int len)
+  copy_handler::copy_handler(void *dest, size_t len)
     : d_dest((uint8_t *)dest), d_space(len), d_bytes(0), d_times(0)
   {
   }
@@ -37,8 +37,8 @@
     // NOP
   }
   
-  uint32_t
-  copy_handler::operator()(const void *base, unsigned int len)
+  data_handler::result
+  copy_handler::operator()(const void *base, size_t len)
   {
     if (len > d_space)
       return KEEP|DONE; // can't do anything, retry later

Added: usrp2/branches/features/host-ng/host-ng/lib/data_handler.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/data_handler.cc                 
        (rev 0)
+++ usrp2/branches/features/host-ng/host-ng/lib/data_handler.cc 2008-06-21 
21:23:40 UTC (rev 8647)
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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.
+ */
+
+#include <usrp2/data_handler.h>
+
+namespace usrp2 {
+  
+  data_handler::~data_handler()
+  {
+    // default nop destructor
+  }
+
+}
+  


Property changes on: usrp2/branches/features/host-ng/host-ng/lib/data_handler.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc   2008-06-21 
20:40:02 UTC (rev 8646)
+++ usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc   2008-06-21 
21:23:40 UTC (rev 8647)
@@ -47,11 +47,6 @@
 
 namespace usrp2 {
 
-  data_handler::~data_handler()
-  {
-    // default nop destructor
-  }
-  
   eth_buffer::eth_buffer(size_t rx_bufsize)
     : d_fd(0), d_using_tpring(false), d_buflen(0), d_buf(0), d_frame_nr(0),
       d_head(0), d_ring(0), d_ethernet(new ethernet())
@@ -210,11 +205,10 @@
       // Get start of ethernet frame and length
       tpacket_hdr *hdr = (tpacket_hdr *)d_ring[d_head];
       void *base = (uint8_t *)hdr+hdr->tp_mac;
-      unsigned int len = hdr->tp_len;
+      size_t len = hdr->tp_len;
       
       // Invoke data handler
-      unsigned int r = 0;
-      r = (*f)(base, len);
+      data_handler::result r = (*f)(base, len);
       
       // data_handler::KEEP not yet implemented
       hdr->tp_status = TP_STATUS_KERNEL; // mark it free

Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc   2008-06-21 
20:40:02 UTC (rev 8646)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc   2008-06-21 
21:23:40 UTC (rev 8647)
@@ -364,8 +364,8 @@
     }
   }
   
-  unsigned int
-  usrp2::impl::operator()(const void *base, unsigned int len)
+  data_handler::result
+  usrp2::impl::operator()(const void *base, size_t len)
   {
     u2_eth_samples_t *pkt = (u2_eth_samples_t *)base;
     int chan = u2p_chan(&pkt->hdrs.fixed);
@@ -399,8 +399,8 @@
     return true;
   }
 
-  unsigned int
-  usrp2::impl::handle_control_packet(const void *base, unsigned int len)
+  data_handler::result
+  usrp2::impl::handle_control_packet(const void *base, size_t len)
   {
     // point to beginning of payload (subpackets)
     unsigned char *p = (unsigned char *)base + sizeof(u2_eth_packet_t);
@@ -434,8 +434,8 @@
     return 0; // release packet
   }
   
-  unsigned int
-  usrp2::impl::handle_data_packet(const void *base, unsigned int len)
+  data_handler::result
+  usrp2::impl::handle_data_packet(const void *base, size_t len)
   {
     u2_eth_samples_t *pkt = (u2_eth_samples_t *)base;
     d_num_rx_frames++;

Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h    2008-06-21 
20:40:02 UTC (rev 8646)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h    2008-06-21 
21:23:40 UTC (rev 8647)
@@ -60,9 +60,9 @@
     void stop_bg();
     void init_config_rx_v2_cmd(op_config_rx_v2_cmd *cmd);
     bool transmit_cmd(void *cmd, int len, pending_reply *p, unsigned int 
msecs=0);
-    virtual unsigned int operator()(const void *base, unsigned int len);
-    unsigned int handle_control_packet(const void *base, unsigned int len);
-    unsigned int handle_data_packet(const void *base, unsigned int len);
+    virtual data_handler::result operator()(const void *base, size_t len);
+    data_handler::result handle_control_packet(const void *base, size_t len);
+    data_handler::result handle_data_packet(const void *base, size_t len);
 
   public:
     impl(const std::string &ifc, const std::string &addr);





reply via email to

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