diff options
author | Josh Blum <josh@joshknows.com> | 2010-02-25 17:44:12 +0000 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-02-25 17:44:12 +0000 |
commit | c95a158548e93d1ea37061e0b937e78ab0486b57 (patch) | |
tree | 50531279c454f3b2d07e52dd8eb2562b7fabbbc7 /host/include | |
parent | 3cd7bc9be6420623eb7803e490b39ecc75d83ed9 (diff) | |
parent | 5715b2c4937ca094ca8f1d9d9b55c4edcc959981 (diff) | |
download | uhd-c95a158548e93d1ea37061e0b937e78ab0486b57.tar.gz uhd-c95a158548e93d1ea37061e0b937e78ab0486b57.tar.bz2 uhd-c95a158548e93d1ea37061e0b937e78ab0486b57.zip |
Merge branch 'master' into u1e_uhd
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/CMakeLists.txt | 2 | ||||
-rw-r--r-- | host/include/uhd/device.hpp | 37 | ||||
-rw-r--r-- | host/include/uhd/device_addr.hpp | 4 | ||||
-rw-r--r-- | host/include/uhd/metadata.hpp | 51 | ||||
-rw-r--r-- | host/include/uhd/shared_iovec.hpp | 54 | ||||
-rw-r--r-- | host/include/uhd/transport/udp.hpp | 39 | ||||
-rw-r--r-- | host/include/uhd/usrp/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/usrp/usrp1e.hpp | 48 | ||||
-rw-r--r-- | host/include/uhd/usrp/usrp2.hpp | 6 |
9 files changed, 155 insertions, 87 deletions
diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index 006c54f22..f4fb96786 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -24,8 +24,8 @@ INSTALL(FILES device_addr.hpp dict.hpp gain_handler.hpp + metadata.hpp props.hpp - shared_iovec.hpp time_spec.hpp utils.hpp wax.hpp diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp index dfbfbd7c0..ba5337d33 100644 --- a/host/include/uhd/device.hpp +++ b/host/include/uhd/device.hpp @@ -20,13 +20,12 @@ #include <uhd/device_addr.hpp> #include <uhd/props.hpp> +#include <uhd/metadata.hpp> #include <uhd/wax.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> #include <boost/function.hpp> #include <boost/asio/buffer.hpp> -#include <uhd/shared_iovec.hpp> -#include <vector> namespace uhd{ @@ -39,10 +38,6 @@ class device : boost::noncopyable, public wax::obj{ public: typedef boost::shared_ptr<device> sptr; - //structors - device(void); - virtual ~device(void); - /*! * \brief Discover usrp devices attached to the host. * @@ -72,9 +67,33 @@ public: */ device_addr_t get_device_addr(void); - //the io interface - virtual void send_raw(const std::vector<boost::asio::const_buffer> &) = 0; - virtual uhd::shared_iovec recv_raw(void) = 0; + /*! + * Send a buffer containing IF data with its metadata. + * + * \param buff a buffer pointing to some read-only memory + * \param metadata data describing the buffer's contents + * \param the type of data loaded in the buffer (32fc, 16sc) + * \return the number of samples sent + */ + virtual size_t send( + const boost::asio::const_buffer &buff, + const metadata_t &metadata, + const std::string &type = "32fc" + ) = 0; + + /*! + * Receive a buffer containing IF data and its metadata. + * + * \param buff the buffer to fill with IF data + * \param metadata data to fill describing the buffer + * \param the type of data to fill into the buffer (32fc, 16sc) + * \return the number of samples received + */ + virtual size_t recv( + const boost::asio::mutable_buffer &buff, + metadata_t &metadata, + const std::string &type = "32fc" + ) = 0; }; } //namespace uhd diff --git a/host/include/uhd/device_addr.hpp b/host/include/uhd/device_addr.hpp index 8ea580321..d02febd6c 100644 --- a/host/include/uhd/device_addr.hpp +++ b/host/include/uhd/device_addr.hpp @@ -56,7 +56,9 @@ namespace uhd{ * \param device_addr a device address instance * \return the string representation */ - std::string device_addr_to_string(const device_addr_t &device_addr); + struct device_addr{ + static std::string to_string(const device_addr_t &device_addr); + }; } //namespace uhd diff --git a/host/include/uhd/metadata.hpp b/host/include/uhd/metadata.hpp new file mode 100644 index 000000000..70842e7bc --- /dev/null +++ b/host/include/uhd/metadata.hpp @@ -0,0 +1,51 @@ +// +// 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/>. +// + +#ifndef INCLUDED_UHD_METADATA_HPP +#define INCLUDED_UHD_METADATA_HPP + +#include <uhd/time_spec.hpp> + +namespace uhd{ + +/*! + * Metadata structure for describing the IF data. + * Includes stream ID, time specification, and burst flags. + * The receive routines will convert IF data headers into metadata. + * The send routines will convert the metadata to IF data headers. + */ +struct metadata_t{ + uint32_t stream_id; + bool has_stream_id; + time_spec_t time_spec; + bool has_time_spec; + bool start_of_burst; + bool end_of_burst; + + metadata_t(void){ + stream_id = 0; + has_stream_id = false; + time_spec = time_spec_t(); + has_time_spec = false; + start_of_burst = false; + end_of_burst = false; + } +}; + +} //namespace uhd + +#endif /* INCLUDED_UHD_METADATA_HPP */ diff --git a/host/include/uhd/shared_iovec.hpp b/host/include/uhd/shared_iovec.hpp deleted file mode 100644 index a120e55d5..000000000 --- a/host/include/uhd/shared_iovec.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// -// 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/>. -// - -#ifndef INCLUDED_UHD_SHARED_IOVEC_HPP -#define INCLUDED_UHD_SHARED_IOVEC_HPP - -#include <boost/shared_array.hpp> -#include <stdint.h> - -namespace uhd{ - -/*! - * A shared iovec contains a shared array and its length. - * Creating a new shared iovec allocates new memory. - * This memory is freed when all copies are destroyed. - */ -class shared_iovec{ -public: - /*! - * Create a shared iovec and allocate memory. - * \param len the length in bytes - */ - shared_iovec(size_t len=0); - - /*! - * Destroy a shared iovec. - * Will not free the memory unless this is the last copy. - */ - ~shared_iovec(void); - - void *base; - size_t len; - -private: - boost::shared_array<uint8_t> _shared_array; -}; - -} //namespace uhd - -#endif /* INCLUDED_UHD_SHARED_IOVEC_HPP */ diff --git a/host/include/uhd/transport/udp.hpp b/host/include/uhd/transport/udp.hpp index 6db6bd377..8c6fb096f 100644 --- a/host/include/uhd/transport/udp.hpp +++ b/host/include/uhd/transport/udp.hpp @@ -18,7 +18,6 @@ #include <boost/asio.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> -#include <uhd/shared_iovec.hpp> #ifndef INCLUDED_UHD_TRANSPORT_UDP_HPP #define INCLUDED_UHD_TRANSPORT_UDP_HPP @@ -30,44 +29,46 @@ public: typedef boost::shared_ptr<udp> sptr; /*! - * Constructor. + * Make a new udp transport. * 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); + static sptr make(const std::string &addr, const std::string &port, bool bcast = false); /*! * Send a vector of buffer (like send_msg). + * Blocks until the data is sent. * \param buffs a vector of asio buffers + * \return the number of bytes sent */ - void send(const std::vector<boost::asio::const_buffer> &buffs); + virtual size_t send(const std::vector<boost::asio::const_buffer> &buffs) = 0; /*! * Send a single buffer. + * Blocks until the data is sent. * \param buff single asio buffer + * \return the number of bytes sent */ - void send(const boost::asio::const_buffer &buff); + virtual size_t send(const boost::asio::const_buffer &buff) = 0; /*! - * Receive a buffer. The memory is managed internally. - * Calling recv will invalidate the buffer of the previous recv. - * \return a shared iovec with allocated memory + * Receive a buffer. Write into the memory provided. + * Returns empty when data is not available. + * \param buffs a vector of asio buffers + * \return the number of bytes received. */ - uhd::shared_iovec recv(void); + virtual size_t recv(const std::vector<boost::asio::mutable_buffer> &buffs) = 0; -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; + /*! + * Receive a buffer. Write into the memory provided. + * Returns empty when data is not available. + * \param buff a mutable buffer to receive into + * \return the number of bytes received. + */ + virtual size_t recv(const boost::asio::mutable_buffer &buff) = 0; }; }} //namespace diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt index e7bdc1784..4e0a92365 100644 --- a/host/include/uhd/usrp/CMakeLists.txt +++ b/host/include/uhd/usrp/CMakeLists.txt @@ -21,6 +21,7 @@ INSTALL(FILES dboard_id.hpp dboard_interface.hpp dboard_manager.hpp + usrp1e.hpp usrp2.hpp DESTINATION ${HEADER_DIR}/uhd/usrp ) diff --git a/host/include/uhd/usrp/usrp1e.hpp b/host/include/uhd/usrp/usrp1e.hpp new file mode 100644 index 000000000..00748e55f --- /dev/null +++ b/host/include/uhd/usrp/usrp1e.hpp @@ -0,0 +1,48 @@ +// +// 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/>. +// + +#ifndef INCLUDED_UHD_USRP_USRP1E_HPP +#define INCLUDED_UHD_USRP_USRP1E_HPP + +#include <uhd/device.hpp> + +namespace uhd{ namespace usrp{ + +/*! + * The usrp1e device class. + */ +class usrp1e : public device{ +public: + /*! + * Discover usrp1e devices on the system via the device node. + * This static method will be called by the device::discover. + * \param hint a device addr with the usrp1e address filled in + * \return a vector of device addresses for all usrp1es found + */ + static device_addrs_t discover(const device_addr_t &hint); + + /*! + * Make a usrp1e from a device address. + * \param addr the device address + * \return a device sptr to a new usrp1e + */ + static device::sptr make(const device_addr_t &addr); +}; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_USRP1E_HPP */ diff --git a/host/include/uhd/usrp/usrp2.hpp b/host/include/uhd/usrp/usrp2.hpp index f6e49cbd6..da7ec595a 100644 --- a/host/include/uhd/usrp/usrp2.hpp +++ b/host/include/uhd/usrp/usrp2.hpp @@ -15,8 +15,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // -#ifndef INCLUDED_UHD_USRP_MBOARD_USRP2_HPP -#define INCLUDED_UHD_USRP_MBOARD_USRP2_HPP +#ifndef INCLUDED_UHD_USRP_USRP2_HPP +#define INCLUDED_UHD_USRP_USRP2_HPP #include <uhd/device.hpp> @@ -45,4 +45,4 @@ public: }} //namespace -#endif /* INCLUDED_UHD_USRP_MBOARD_USRP2_HPP */ +#endif /* INCLUDED_UHD_USRP_USRP2_HPP */ |