Revision b96088b6 host/lib/usrp/usrp1/usrp1_impl.cpp

b/host/lib/usrp/usrp1/usrp1_impl.cpp
34 34
using namespace uhd::usrp;
35 35
using namespace uhd::transport;
36 36

  
37
const boost::uint16_t USRP1_VENDOR_ID  = 0xfffe;
38
const boost::uint16_t USRP1_PRODUCT_ID = 0x0002;
39
const boost::uint16_t FX2_VENDOR_ID    = 0x04b4;
40
const boost::uint16_t FX2_PRODUCT_ID   = 0x8613;
41

  
37 42
const std::vector<usrp1_impl::dboard_slot_t> usrp1_impl::_dboard_slots = boost::assign::list_of
38 43
    (usrp1_impl::DBOARD_SLOT_A)(usrp1_impl::DBOARD_SLOT_B)
39 44
;
......
54 59
    );
55 60
    std::cout << "USRP1 firmware image: " << usrp1_fw_image << std::endl;
56 61

  
62
    boost::uint16_t vid = hint.has_key("uninit") ? FX2_VENDOR_ID : USRP1_VENDOR_ID;
63
    boost::uint16_t pid = hint.has_key("uninit") ? FX2_PRODUCT_ID : USRP1_PRODUCT_ID;
64

  
57 65
    //see what we got on the USB bus
58 66
    std::vector<usb_device_handle::sptr> device_list =
59
        usb_device_handle::get_device_list();
67
        usb_device_handle::get_device_list(vid, pid);
68

  
69
    if(device_list.size() == 0) return usrp1_addrs; //return nothing if no USRPs found
60 70

  
61 71
    //find the usrps and load firmware
62 72
    BOOST_FOREACH(usb_device_handle::sptr handle, device_list) {
63
        if (handle->get_vendor_id() == 0xfffe &&
64
            handle->get_product_id() == 0x0002) {
65

  
66 73
            usb_control::sptr ctrl_transport = usb_control::make(handle);
67 74
            usrp_ctrl::sptr usrp_ctrl = usrp_ctrl::make(ctrl_transport);
68 75
            usrp_ctrl->usrp_load_firmware(usrp1_fw_image);
69
        }
70 76
    }
71 77

  
72
    //get descriptors again with serial number
73
    device_list = usb_device_handle::get_device_list();
78
    //get descriptors again with serial number, but using the initialized VID/PID now since we have firmware
79
    vid = USRP1_VENDOR_ID;
80
    pid = USRP1_PRODUCT_ID;
81
    device_list = usb_device_handle::get_device_list(vid, pid);
74 82

  
75 83
    BOOST_FOREACH(usb_device_handle::sptr handle, device_list) {
76
        if (handle->get_vendor_id() == 0xfffe &&
77
            handle->get_product_id() == 0x0002) {
78

  
79 84
            device_addr_t new_addr;
80 85
            new_addr["type"] = "usrp1";
81 86
            new_addr["serial"] = handle->get_serial();
82 87
            usrp1_addrs.push_back(new_addr);
83
        }
84 88
    }
85 89

  
86 90
    return usrp1_addrs;
......
99 103

  
100 104
    //try to match the given device address with something on the USB bus
101 105
    std::vector<usb_device_handle::sptr> device_list =
102
        usb_device_handle::get_device_list();
106
        usb_device_handle::get_device_list(USRP1_VENDOR_ID, USRP1_PRODUCT_ID);
103 107

  
104 108
    //create data and control transports
105 109
    usb_zero_copy::sptr data_transport;
106 110
    usrp_ctrl::sptr usrp_ctrl;
107 111

  
108
    BOOST_FOREACH(usb_device_handle::sptr handle, device_list) {
109
        if (handle->get_vendor_id() == 0xfffe &&
110
            handle->get_product_id() == 0x0002 &&
111
            handle->get_serial() == device_addr["serial"]) {
112 112

  
113
    BOOST_FOREACH(usb_device_handle::sptr handle, device_list) {
114
        if (handle->get_serial() == device_addr["serial"]) {
113 115
            usb_control::sptr ctrl_transport = usb_control::make(handle);
114 116
            usrp_ctrl = usrp_ctrl::make(ctrl_transport);
115 117
            usrp_ctrl->usrp_load_fpga(usrp1_fpga_image);

Also available in: Unified diff