Revision 38746242

b/host/include/uhd/transport/CMakeLists.txt
25 25
    if_addrs.hpp
26 26
    udp_simple.hpp
27 27
    udp_zero_copy.hpp
28
    usb_control.hpp
29
    usb_zero_copy.hpp
28 30
    vrt_if_packet.hpp
29 31
    zero_copy.hpp
30 32
    DESTINATION ${INCLUDE_DIR}/uhd/transport
b/host/include/uhd/transport/usb_control.hpp
1
//
2
// Copyright 2010 Ettus Research LLC
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
//
17

  
18
#ifndef INCLUDED_UHD_TRANSPORT_USB_CONTROL_HPP
19
#define INCLUDED_UHD_TRANSPORT_USB_CONTROL_HPP
20

  
21
#include <uhd/config.hpp>
22
#include <uhd/types/usb_descriptor.hpp>
23
#include <boost/utility.hpp>
24
#include <boost/shared_ptr.hpp>
25
#include <vector>
26

  
27
namespace uhd { namespace transport {
28

  
29
class UHD_API usb_control : boost::noncopyable {
30
public:
31
    typedef boost::shared_ptr<usb_control> sptr;
32

  
33
    /*!
34
     * Create a new usb control transport:
35
     * This transport is for sending and receiving control information from
36
     * the host to device using the Default Control Pipe.
37
     *
38
     * \param descriptor a descriptor that identifies a USB device
39
     */
40
    static sptr make(usb_descriptor_t descriptor);
41

  
42
    /*!
43
     * Submit a USB device request:
44
     * Blocks until the request returns
45
     *
46
     * For format and corresponding USB request fields
47
     * see USB Specification Revision 2.0 - 9.3 USB Device Requests
48
     *
49
     * Usage is device specific
50
     *
51
     * \param request_type 1-byte bitmask (bmRequestType)
52
     * \param request      1-byte (bRequest)
53
     * \param value        2-byte (wValue)
54
     * \param index        2-byte (wIndex)
55
     * \param buff         buffer to hold send or receive data
56
     * \param length       2-byte (wLength)
57
     * \return             number of bytes submitted
58
     */
59
    virtual size_t submit(boost::uint8_t request_type,
60
                          boost::uint8_t request,
61
                          boost::uint16_t value,
62
                          boost::uint16_t index, 
63
                          unsigned char *buff,
64
                          boost::uint16_t length) = 0; 
65

  
66
    /*!
67
     * Get a vector of USB device descriptors 
68
     *
69
     * \return a vector of usb_descriptors
70
     */
71
    static usb_descriptors_t get_device_list();
72
};
73

  
74
}} //namespace
75

  
76
#endif /* INCLUDED_UHD_TRANSPORT_USB_CONTROL_HPP */
b/host/include/uhd/transport/usb_zero_copy.hpp
1
//
2
// Copyright 2010 Ettus Research LLC
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
//
17

  
18
#ifndef INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP
19
#define INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP
20

  
21
#include <uhd/config.hpp>
22
#include <uhd/types/usb_descriptor.hpp>
23
#include <uhd/transport/zero_copy.hpp>
24
#include <boost/shared_ptr.hpp>
25

  
26
namespace uhd { namespace transport {
27

  
28
/*!
29
 * A zero copy usb transport provides an efficient way to handle data.
30
 * by avoiding the extra copy when recv() or send() is called on the handle.
31
 * Rather, the zero copy transport gives the caller memory references.
32
 * The caller informs the transport when it is finished with the reference.
33
 *
34
 * On linux systems, the zero copy transport can use a kernel packet ring.
35
 * If no platform specific solution is available, make returns a boost asio
36
 * implementation that wraps functionality around standard send/recv calls.
37
 */
38
class UHD_API usb_zero_copy : public virtual zero_copy_if {
39
public:
40
    typedef boost::shared_ptr<usb_zero_copy> sptr;
41

  
42
    /*!
43
     * Make a new zero copy usb transport:
44
     * This transport is for sending and receiving between the host
45
     * and a pair of USB bulk transfer endpoints.
46
     * The primary usage for this transport is data transactions.
47
     * The underlying implementation may be platform specific.
48
     *
49
     * \param descriptor a USB descriptor identifying the device
50
     * \param rx_endpoint an integer specifiying an IN endpoint number 
51
     * \param tx_endpoint an integer specifiying an OUT endpoint number
52
     * \param buff_size total number of bytes of buffer space to allocate 
53
     * \param block_size number of bytes allocated for each I/O transaction 
54
     */
55
    static sptr make(usb_descriptor_t descriptor,
56
                     unsigned int rx_endpoint,
57
                     unsigned int tx_endpoint,
58
		     size_t buff_size = 0, 
59
                     size_t block_size = 0);
60
};
61

  
62
}} //namespace
63

  
64
#endif /* INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP */
b/host/include/uhd/types/CMakeLists.txt
29 29
    stream_cmd.hpp
30 30
    time_spec.hpp
31 31
    tune_result.hpp
32
    usb_descriptor.hpp
32 33
    DESTINATION ${INCLUDE_DIR}/uhd/types
33 34
)
b/host/include/uhd/types/usb_descriptor.hpp
1
//
2
// Copyright 2010 Ettus Research LLC
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
//
17

  
18
#ifndef INCLUDED_UHD_TYPES_USB_DESCRIPTOR_HPP
19
#define INCLUDED_UHD_TYPES_USB_DESCRIPTOR_HPP
20

  
21
#include <uhd/config.hpp>
22
#include <boost/cstdint.hpp>
23
#include <vector>
24
#include <string>
25

  
26
namespace uhd{
27

  
28
    /*!
29
     * The USB descriptor struct holds identity information for a USB device
30
     */
31
    struct UHD_API usb_descriptor_t{
32
        std::string serial;
33
        boost::uint16_t vendor_id;
34
        boost::uint16_t product_id;
35
        boost::uint16_t device_addr;
36

  
37
        /*!
38
         * Create a pretty print string for this USB descriptor struct.
39
         * \return the printable string
40
         */
41
        std::string to_pp_string(void) const;
42
    };
43

  
44
    //handy typde for a vector of usb descriptors
45
    typedef std::vector<usb_descriptor_t> usb_descriptors_t;
46

  
47
} //namespace uhd
48

  
49
#endif /* INCLUDED_UHD_TYPES_USB_DESCRIPTOR_HPP */

Also available in: Unified diff