diff options
| -rw-r--r-- | host/include/uhd/transport/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | host/include/uhd/transport/usb_control.hpp | 17 | ||||
| -rw-r--r-- | host/include/uhd/transport/usb_device_handle.hpp | 79 | ||||
| -rw-r--r-- | host/include/uhd/transport/usb_zero_copy.hpp | 8 | ||||
| -rw-r--r-- | host/include/uhd/types/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | host/include/uhd/types/usb_descriptor.hpp | 49 | 
6 files changed, 86 insertions, 69 deletions
| diff --git a/host/include/uhd/transport/CMakeLists.txt b/host/include/uhd/transport/CMakeLists.txt index dd1a20eed..0f1cbf2a2 100644 --- a/host/include/uhd/transport/CMakeLists.txt +++ b/host/include/uhd/transport/CMakeLists.txt @@ -27,6 +27,7 @@ INSTALL(FILES      udp_zero_copy.hpp      usb_control.hpp      usb_zero_copy.hpp +    usb_device_handle.hpp      vrt_if_packet.hpp      zero_copy.hpp      DESTINATION ${INCLUDE_DIR}/uhd/transport diff --git a/host/include/uhd/transport/usb_control.hpp b/host/include/uhd/transport/usb_control.hpp index 6b5591a21..6137ecf84 100644 --- a/host/include/uhd/transport/usb_control.hpp +++ b/host/include/uhd/transport/usb_control.hpp @@ -18,11 +18,7 @@  #ifndef INCLUDED_UHD_TRANSPORT_USB_CONTROL_HPP  #define INCLUDED_UHD_TRANSPORT_USB_CONTROL_HPP -#include <uhd/config.hpp> -#include <uhd/types/usb_descriptor.hpp> -#include <boost/utility.hpp> -#include <boost/shared_ptr.hpp> -#include <vector> +#include "usb_device_handle.hpp"  namespace uhd { namespace transport { @@ -35,9 +31,9 @@ public:       * This transport is for sending and receiving control information from       * the host to device using the Default Control Pipe.       * -     * \param descriptor a descriptor that identifies a USB device +     * \param handle a device handle that uniquely identifies a USB device       */ -    static sptr make(usb_descriptor_t descriptor); +    static sptr make(usb_device_handle::sptr handle);      /*!       * Submit a USB device request: @@ -62,13 +58,6 @@ public:                            boost::uint16_t index,                             unsigned char *buff,                            boost::uint16_t length) = 0;  - -    /*! -     * Get a vector of USB device descriptors  -     * -     * \return a vector of usb_descriptors -     */ -    static usb_descriptors_t get_device_list();  };  }} //namespace diff --git a/host/include/uhd/transport/usb_device_handle.hpp b/host/include/uhd/transport/usb_device_handle.hpp new file mode 100644 index 000000000..78c78f6b5 --- /dev/null +++ b/host/include/uhd/transport/usb_device_handle.hpp @@ -0,0 +1,79 @@ +// +// 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_TRANSPORT_USB_DEVICE_HANDLE_HPP +#define INCLUDED_UHD_TRANSPORT_USB_DEVICE_HANDLE_HPP + +#include <uhd/config.hpp> +#include <boost/utility.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/cstdint.hpp> +#include <vector> + +namespace uhd { namespace transport { + +/*! + * Device handle class that represents a USB device + * Used for identifying devices on the USB bus and selecting which device is + * used when creating a  USB transport. A minimal subset of USB descriptor + * fields are used. Fields can be found in the USB 2.0 specification Table + * 9-8 (Standard Device Descriptor). In addition to fields of the device + * descriptor, the interface returns the device's USB device address. + * + * Note: The USB 2.0 Standard Device Descriptor contains an index rather then + *       a true descriptor serial number string. This interface returns the + *       actual string descriptor. + */ +class UHD_API usb_device_handle : boost::noncopyable { +public: +    typedef boost::shared_ptr<usb_device_handle> sptr; + +    /*! +     * Return the device's serial number  +     * \return a string describing the device's serial number +     */ +    virtual UHD_API std::string get_serial() const = 0; + +    /*! +     * Return the device's Vendor ID (usually assigned by the USB-IF) +     * \return a Vendor ID +     */ +    virtual UHD_API boost::uint16_t get_vendor_id() const = 0; + +    /*! +     * Return the device's Product ID (usually assigned by manufacturer) +     * \return a Product ID +     */ +    virtual UHD_API boost::uint16_t get_product_id() const = 0; + +    /*! +     * Return the device's USB address +     * \return a Product ID +     */ +    virtual UHD_API boost::uint16_t get_device_addr() const = 0; + +    /*! +     * Return a vector of USB devices on this host  +     * \return a vector of USB device handles +     */ +    static UHD_API std::vector<usb_device_handle::sptr> get_device_list(); + +}; //namespace usb + +}} //namespace + +#endif /* INCLUDED_UHD_TRANSPORT_USB_DEVICE_HANDLE_HPP */ diff --git a/host/include/uhd/transport/usb_zero_copy.hpp b/host/include/uhd/transport/usb_zero_copy.hpp index 7b9692fa5..2edd6d91d 100644 --- a/host/include/uhd/transport/usb_zero_copy.hpp +++ b/host/include/uhd/transport/usb_zero_copy.hpp @@ -18,10 +18,8 @@  #ifndef INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP  #define INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP -#include <uhd/config.hpp> -#include <uhd/types/usb_descriptor.hpp> +#include "usb_device_handle.hpp"  #include <uhd/transport/zero_copy.hpp> -#include <boost/shared_ptr.hpp>  namespace uhd { namespace transport { @@ -46,13 +44,13 @@ public:       * The primary usage for this transport is data transactions.       * The underlying implementation may be platform specific.       * -     * \param descriptor a USB descriptor identifying the device +     * \param handle a device handle that uniquely identifying the device       * \param rx_endpoint an integer specifiying an IN endpoint number        * \param tx_endpoint an integer specifiying an OUT endpoint number       * \param buff_size total number of bytes of buffer space to allocate        * \param block_size number of bytes allocated for each I/O transaction        */ -    static sptr make(usb_descriptor_t descriptor, +    static sptr make(usb_device_handle::sptr handle,                       unsigned int rx_endpoint,                       unsigned int tx_endpoint,  		     size_t buff_size = 0,  diff --git a/host/include/uhd/types/CMakeLists.txt b/host/include/uhd/types/CMakeLists.txt index 8e302eed2..dbce21c98 100644 --- a/host/include/uhd/types/CMakeLists.txt +++ b/host/include/uhd/types/CMakeLists.txt @@ -29,6 +29,5 @@ INSTALL(FILES      stream_cmd.hpp      time_spec.hpp      tune_result.hpp -    usb_descriptor.hpp      DESTINATION ${INCLUDE_DIR}/uhd/types  ) diff --git a/host/include/uhd/types/usb_descriptor.hpp b/host/include/uhd/types/usb_descriptor.hpp deleted file mode 100644 index 0e4c8c369..000000000 --- a/host/include/uhd/types/usb_descriptor.hpp +++ /dev/null @@ -1,49 +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_TYPES_USB_DESCRIPTOR_HPP -#define INCLUDED_UHD_TYPES_USB_DESCRIPTOR_HPP - -#include <uhd/config.hpp> -#include <boost/cstdint.hpp> -#include <vector> -#include <string> - -namespace uhd{ - -    /*! -     * The USB descriptor struct holds identity information for a USB device -     */ -    struct UHD_API usb_descriptor_t{ -        std::string serial; -        boost::uint16_t vendor_id; -        boost::uint16_t product_id; -        boost::uint16_t device_addr; - -        /*! -         * Create a pretty print string for this USB descriptor struct. -         * \return the printable string -         */ -        std::string to_pp_string(void) const; -    }; - -    //handy typde for a vector of usb descriptors -    typedef std::vector<usb_descriptor_t> usb_descriptors_t; - -} //namespace uhd - -#endif /* INCLUDED_UHD_TYPES_USB_DESCRIPTOR_HPP */ | 
