[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8575 - usrp2/trunk/host-ng/lib
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r8575 - usrp2/trunk/host-ng/lib |
Date: |
Tue, 10 Jun 2008 16:31:54 -0600 (MDT) |
Author: jcorgan
Date: 2008-06-10 16:31:49 -0600 (Tue, 10 Jun 2008)
New Revision: 8575
Added:
usrp2/trunk/host-ng/lib/copy_handler.cc
usrp2/trunk/host-ng/lib/copy_handler.h
Modified:
usrp2/trunk/host-ng/lib/Makefile.am
usrp2/trunk/host-ng/lib/eth_buffer.h
Log:
work-in-progress. Needs refactoring of namespace
Modified: usrp2/trunk/host-ng/lib/Makefile.am
===================================================================
--- usrp2/trunk/host-ng/lib/Makefile.am 2008-06-10 21:24:49 UTC (rev 8574)
+++ usrp2/trunk/host-ng/lib/Makefile.am 2008-06-10 22:31:49 UTC (rev 8575)
@@ -23,6 +23,7 @@
libusrp2ng.la
libusrp2ng_la_SOURCES = \
+ copy_handler.cc \
eth_buffer.cc \
ethernet.cc \
find.cc \
Added: usrp2/trunk/host-ng/lib/copy_handler.cc
===================================================================
--- usrp2/trunk/host-ng/lib/copy_handler.cc (rev 0)
+++ usrp2/trunk/host-ng/lib/copy_handler.cc 2008-06-10 22:31:49 UTC (rev
8575)
@@ -0,0 +1,57 @@
+/* -*- 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "copy_handler.h"
+
+namespace usrp2 {
+
+ copy_handler::copy_handler(uint8_t *dest, size_t len)
+ : d_dest(dest), d_space(len), d_bytes(0), d_times(0)
+ {
+ }
+
+ copy_handler::~copy_handler()
+ {
+ // NOP
+ }
+
+ uint32_t
+ copy_handler::operator()(const void *base, size_t len)
+ {
+ if (len > d_space)
+ return eth_buffer::handler::KEEP |
+ eth_buffer::handler::BREAK; // can't do anything, retry later
+
+ memcpy(d_dest, base, len);
+ d_space -= len;
+ d_bytes += len;
+ d_times++;
+
+ if (d_space == 0)
+ return eth_buffer::handler::BREAK; // don't call me anymore
+ }
+
+} // namespace usrp2
+
Added: usrp2/trunk/host-ng/lib/copy_handler.h
===================================================================
--- usrp2/trunk/host-ng/lib/copy_handler.h (rev 0)
+++ usrp2/trunk/host-ng/lib/copy_handler.h 2008-06-10 22:31:49 UTC (rev
8575)
@@ -0,0 +1,45 @@
+/* -*- 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.
+ */
+#ifndef INCLUDED_COPY_HANDLER_H
+#define INCLUDED_COPY_HANDLER_H
+
+#include "eth_buffer.h"
+#include <boost/utility.hpp>
+
+namespace usrp2 {
+
+ class copy_handler : eth_buffer::handler, boost::noncopyable {
+
+ uint8_t *d_dest; // next write pointer
+ size_t d_space; // space left in destination buffer
+ size_t d_bytes; // total bytes copied
+ int d_times; // number of times invoked
+
+ public:
+ copy_handler(uint8_t *dest, size_t len);
+ ~copy_handler();
+
+ uint32_t operator()(const void *base, size_t len);
+ };
+
+} // namespace usrp2
+
+#endif /* INCLUDED_COPY_HANDLER_H */
Modified: usrp2/trunk/host-ng/lib/eth_buffer.h
===================================================================
--- usrp2/trunk/host-ng/lib/eth_buffer.h 2008-06-10 21:24:49 UTC (rev
8574)
+++ usrp2/trunk/host-ng/lib/eth_buffer.h 2008-06-10 22:31:49 UTC (rev
8575)
@@ -72,7 +72,7 @@
* \param base points to the beginning of the frame (the 14-byte
ethernet header).
* \param len is the length in bytes of the frame.
*/
- virtual result operator()(const uint8_t *base, size_t len) = 0;
+ virtual uint32_t operator()(const void *base, size_t len) = 0;
virtual ~handler();
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8575 - usrp2/trunk/host-ng/lib,
jcorgan <=