summaryrefslogtreecommitdiffstats
path: root/host/lib/transport
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2013-07-15 15:57:53 -0700
committerJosh Blum <josh@joshknows.com>2013-07-15 15:57:53 -0700
commit719569ffbbf03ec62e14cb8527b254d77bfdfc43 (patch)
tree9b62f16c6d293d81e3bc0214d29e9aee6d0bcf0b /host/lib/transport
parentb1397e1f48d5966238a409ceb44798dc6c22e80b (diff)
downloaduhd-719569ffbbf03ec62e14cb8527b254d77bfdfc43.tar.gz
uhd-719569ffbbf03ec62e14cb8527b254d77bfdfc43.tar.bz2
uhd-719569ffbbf03ec62e14cb8527b254d77bfdfc43.zip
usb: added timeout param and additional queries
Diffstat (limited to 'host/lib/transport')
-rw-r--r--host/lib/transport/libusb1_base.cpp23
-rw-r--r--host/lib/transport/libusb1_base.hpp4
-rw-r--r--host/lib/transport/libusb1_control.cpp5
3 files changed, 22 insertions, 10 deletions
diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp
index d4ec874f1..fde96f385 100644
--- a/host/lib/transport/libusb1_base.cpp
+++ b/host/lib/transport/libusb1_base.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010-2011 Ettus Research LLC
+// Copyright 2010-2013 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
@@ -137,8 +137,13 @@ public:
return _desc;
}
- std::string get_ascii_serial(void) const{
- if (this->get().iSerialNumber == 0) return "";
+ std::string get_ascii_property(const std::string &what) const
+ {
+ boost::uint8_t off = 0;
+ if (what == "serial") off = this->get().iSerialNumber;
+ if (what == "product") off = this->get().iProduct;
+ if (what == "manufacturer") off = this->get().iManufacturer;
+ if (off == 0) return "";
libusb::device_handle::sptr handle(
libusb::device_handle::get_cached_handle(_dev)
@@ -146,7 +151,7 @@ public:
unsigned char buff[512];
ssize_t ret = libusb_get_string_descriptor_ascii(
- handle->get(), this->get().iSerialNumber, buff, sizeof(buff)
+ handle->get(), off, buff, sizeof(buff)
);
if (ret < 0) return ""; //on error, just return empty string
@@ -240,7 +245,15 @@ public:
}
std::string get_serial(void) const{
- return libusb::device_descriptor::make(this->get_device())->get_ascii_serial();
+ return libusb::device_descriptor::make(this->get_device())->get_ascii_property("serial");
+ }
+
+ std::string get_manufacturer() const{
+ return libusb::device_descriptor::make(this->get_device())->get_ascii_property("manufacturer");
+ }
+
+ std::string get_product() const{
+ return libusb::device_descriptor::make(this->get_device())->get_ascii_property("product");
}
boost::uint16_t get_vendor_id(void) const{
diff --git a/host/lib/transport/libusb1_base.hpp b/host/lib/transport/libusb1_base.hpp
index 04c1d6574..7dab07fda 100644
--- a/host/lib/transport/libusb1_base.hpp
+++ b/host/lib/transport/libusb1_base.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2013 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
@@ -102,7 +102,7 @@ namespace libusb {
//! get the underlying device descriptor
virtual const libusb_device_descriptor &get(void) const = 0;
- virtual std::string get_ascii_serial(void) const = 0;
+ virtual std::string get_ascii_property(const std::string &what) const = 0;
};
/*!
diff --git a/host/lib/transport/libusb1_control.cpp b/host/lib/transport/libusb1_control.cpp
index 3d9b38785..c1b8fe6df 100644
--- a/host/lib/transport/libusb1_control.cpp
+++ b/host/lib/transport/libusb1_control.cpp
@@ -21,8 +21,6 @@
using namespace uhd::transport;
-const int libusb_timeout = 0;
-
/***********************************************************************
* libusb-1.0 implementation of USB control transport
**********************************************************************/
@@ -39,7 +37,8 @@ public:
boost::uint16_t value,
boost::uint16_t index,
unsigned char *buff,
- boost::uint16_t length
+ boost::uint16_t length,
+ boost::int32_t libusb_timeout = 0
){
boost::mutex::scoped_lock lock(_mutex);
return libusb_control_transfer(_handle->get(),