aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-02-09 17:45:35 -0800
committerJosh Blum <josh@joshknows.com>2010-02-09 17:45:35 -0800
commite2044e13ec4ad94e9739402257134abd92cf1521 (patch)
treee642baa20cb194b38d1b3f0c9d4d0b93e32f868d /include
parentc5480830c6e8e8e862523b3ebf3117fda8a100df (diff)
downloaduhd-e2044e13ec4ad94e9739402257134abd92cf1521.tar.gz
uhd-e2044e13ec4ad94e9739402257134abd92cf1521.tar.bz2
uhd-e2044e13ec4ad94e9739402257134abd92cf1521.zip
added transport directory and udp transport
Diffstat (limited to 'include')
-rw-r--r--include/uhd/Makefile.am2
-rw-r--r--include/uhd/device.hpp13
-rw-r--r--include/uhd/transport/.gitignore2
-rw-r--r--include/uhd/transport/Makefile.am24
-rw-r--r--include/uhd/transport/udp.hpp77
-rw-r--r--include/uhd/usrp/usrp.hpp9
6 files changed, 111 insertions, 16 deletions
diff --git a/include/uhd/Makefile.am b/include/uhd/Makefile.am
index 00691d920..772d1e4b9 100644
--- a/include/uhd/Makefile.am
+++ b/include/uhd/Makefile.am
@@ -17,7 +17,7 @@
include $(top_srcdir)/Makefile.common
-SUBDIRS = usrp quadradio
+SUBDIRS = quadradio transport usrp
this_includedir = $(includedir)/uhd
this_include_HEADERS = \
diff --git a/include/uhd/device.hpp b/include/uhd/device.hpp
index 63f897f97..84d1c1bfb 100644
--- a/include/uhd/device.hpp
+++ b/include/uhd/device.hpp
@@ -38,12 +38,6 @@ class device : boost::noncopyable, public wax::obj{
public:
typedef boost::shared_ptr<device> sptr;
- //argument types for send and recv raw methods
- //the send args is a vector of the boost asio buffers
- //the recv args is a callback that takes a boost asio buffer
- typedef std::vector<boost::asio::const_buffer> send_args_t;
- typedef boost::function<bool(const boost::asio::const_buffer &)> recv_args_t;
-
//structors
device(void);
virtual ~device(void);
@@ -78,11 +72,8 @@ public:
device_addr_t get_device_addr(void);
//the io interface
- virtual void send_raw(const send_args_t &) = 0;
- virtual void recv_raw(const recv_args_t &) = 0;
-
- //connect dsps and subdevs
- void connect(const wax::obj &src, const wax::obj &sink);
+ virtual void send_raw(const std::vector<boost::asio::const_buffer> &) = 0;
+ virtual const boost::asio::const_buffer recv_raw(void) = 0;
};
} //namespace uhd
diff --git a/include/uhd/transport/.gitignore b/include/uhd/transport/.gitignore
new file mode 100644
index 000000000..b336cc7ce
--- /dev/null
+++ b/include/uhd/transport/.gitignore
@@ -0,0 +1,2 @@
+/Makefile
+/Makefile.in
diff --git a/include/uhd/transport/Makefile.am b/include/uhd/transport/Makefile.am
new file mode 100644
index 000000000..7a62e3051
--- /dev/null
+++ b/include/uhd/transport/Makefile.am
@@ -0,0 +1,24 @@
+#
+# Copyright 2010 Ettus Research LLC
+#
+# This program 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 of the License, or
+# (at your option) any later version.
+#
+# This program 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, see <http://www.gnu.org/licenses/>.
+#
+
+include $(top_srcdir)/Makefile.common
+
+SUBDIRS =
+
+this_includedir = $(includedir)/uhd/transport
+this_include_HEADERS = \
+ udp.hpp
diff --git a/include/uhd/transport/udp.hpp b/include/uhd/transport/udp.hpp
new file mode 100644
index 000000000..67979afac
--- /dev/null
+++ b/include/uhd/transport/udp.hpp
@@ -0,0 +1,77 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program 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 of the License, or
+// (at your option) any later version.
+//
+// This program 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, see <http://www.gnu.org/licenses/>.
+//
+
+#include <boost/asio.hpp>
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+#include <stdio.h>
+
+#ifndef INCLUDED_UHD_TRANSPORT_UDP_HPP
+#define INCLUDED_UHD_TRANSPORT_UDP_HPP
+
+namespace uhd{ namespace transport{
+
+class udp : boost::noncopyable{
+public:
+ typedef boost::shared_ptr<udp> sptr;
+
+ /*!
+ * Constructor.
+ * The address will be resolved, it can be a host name or ipv4.
+ * The port will be resolved, it can be a port type or number.
+ * \param addr a string representing the destination address
+ * \param port a string representing the destination port
+ * \param bcast if true, enable the broadcast option on the socket
+ */
+ udp(const std::string &addr, const std::string &port, bool bcast = false);
+
+ /*!
+ * Destructor
+ */
+ ~udp(void);
+
+ /*!
+ * Send a vector of buffer (like send_msg).
+ * \param buffs a vector of asio buffers
+ */
+ void send(const std::vector<boost::asio::const_buffer> &buffs);
+
+ /*!
+ * Send a single buffer.
+ * \param buff a pointer into memory
+ * \param len the length in bytes
+ */
+ void send(const void *buff, size_t len);
+
+ /*!
+ * Receive a buffer. The memory is managed internally.
+ * Calling recv will invalidate the buffer of the previous recv.
+ * \return an asio const buffer with internal memory
+ */
+ const boost::asio::const_buffer recv(void);
+
+private:
+ boost::asio::ip::udp::socket *_socket;
+ boost::asio::ip::udp::endpoint _receiver_endpoint;
+ boost::asio::ip::udp::endpoint _sender_endpoint;
+ boost::asio::io_service _io_service;
+ uint8_t _recv_buff[1500]; //max mtu
+};
+
+}} //namespace
+
+#endif /* INCLUDED_UHD_TRANSPORT_UDP_HPP */
diff --git a/include/uhd/usrp/usrp.hpp b/include/uhd/usrp/usrp.hpp
index eda8f5fc1..84890b8fe 100644
--- a/include/uhd/usrp/usrp.hpp
+++ b/include/uhd/usrp/usrp.hpp
@@ -35,16 +35,17 @@ public:
usrp(const device_addr_t & device_addr);
~usrp(void);
- void send_raw(const send_args_t &);
- void recv_raw(const recv_args_t &);
+ //the io interface
+ void send_raw(const std::vector<boost::asio::const_buffer> &);
+ const boost::asio::const_buffer recv_raw(void);
private:
void get(const wax::obj &, wax::obj &);
void set(const wax::obj &, const wax::obj &);
std::map<std::string, mboard::base::sptr> _mboards;
- boost::function<void(const device::send_args_t &)> _send_raw_cb;
- boost::function<void(const device::recv_args_t &)> _recv_raw_cb;
+ boost::function<void(const std::vector<boost::asio::const_buffer> &)> _send_raw_cb;
+ boost::function<const boost::asio::const_buffer(void)> _recv_raw_cb;
};
}} //namespace