summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-09-28 11:08:41 -0700
committerJosh Blum <josh@joshknows.com>2010-09-28 11:08:41 -0700
commitf5bdb7ccb39ef23d4b2c0872fe410e9d5d031958 (patch)
treee981cb06d62ce6c939250fab3eb1dedbaee74a86 /host/lib/usrp/usrp1
parent137aa0ab1ed0b8f7f31a6c484fcf5a845682db80 (diff)
downloaduhd-f5bdb7ccb39ef23d4b2c0872fe410e9d5d031958.tar.gz
uhd-f5bdb7ccb39ef23d4b2c0872fe410e9d5d031958.tar.bz2
uhd-f5bdb7ccb39ef23d4b2c0872fe410e9d5d031958.zip
usrp1: move the get handles call into the for loop scope to facilitate decontruction
Diffstat (limited to 'host/lib/usrp/usrp1')
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index 627180b11..a56649305 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -74,14 +74,14 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
boost::uint16_t vid = hint.has_key("uninit") ? FX2_VENDOR_ID : USRP1_VENDOR_ID;
boost::uint16_t pid = hint.has_key("uninit") ? FX2_PRODUCT_ID : USRP1_PRODUCT_ID;
- //see what we got on the USB bus
- std::vector<usb_device_handle::sptr> device_list =
- usb_device_handle::get_device_list(vid, pid);
-
- if(device_list.size() == 0) return usrp1_addrs; //return nothing if no USRPs found
+ // Important note:
+ // The get device list calls are nested inside the for loop.
+ // This allows the usb guts to decontruct when not in use,
+ // so that re-enumeration after fw load can occur successfully.
+ // This requirement is a courtesy of libusb1.0 on windows.
//find the usrps and load firmware
- BOOST_FOREACH(usb_device_handle::sptr handle, device_list) {
+ BOOST_FOREACH(usb_device_handle::sptr handle, usb_device_handle::get_device_list(vid, pid)) {
usb_control::sptr ctrl_transport = usb_control::make(handle);
usrp_ctrl::sptr usrp_ctrl = usrp_ctrl::make(ctrl_transport);
usrp_ctrl->usrp_load_firmware(usrp1_fw_image);
@@ -90,9 +90,8 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
//get descriptors again with serial number, but using the initialized VID/PID now since we have firmware
vid = USRP1_VENDOR_ID;
pid = USRP1_PRODUCT_ID;
- device_list = usb_device_handle::get_device_list(vid, pid);
- BOOST_FOREACH(usb_device_handle::sptr handle, device_list) {
+ BOOST_FOREACH(usb_device_handle::sptr handle, usb_device_handle::get_device_list(vid, pid)) {
device_addr_t new_addr;
new_addr["type"] = "usrp1";
new_addr["serial"] = handle->get_serial();