64 std::vector<struct usb_device *>
find_devices(uint16_t vendor, uint16_t product)
67 struct usb_device *dev;
68 struct usb_bus *busses;
69 std::vector<struct usb_device *> ret_vec;
75 busses = usb_get_busses();
77 for (bus = busses; bus; bus = bus->next)
78 for (dev = bus->devices; dev; dev = dev->next)
79 if ((dev->descriptor.idVendor == vendor) && (dev->descriptor.idProduct == product))
80 ret_vec.push_back(dev);
109 if(
devices.empty() )
return -1;
114 for (
unsigned int i=0; i<
devices.size(); i++) {
115 struct usb_device *dev =
devices[i];
116 usb_dev_handle *h = usb_open(dev);
117 if ( h == NULL )
continue;
119 std::map<std::string, std::string> M_desc;
120 if ( usb_get_string_simple(h, dev->descriptor.iSerialNumber, buff, 128) < 0 )
continue;
121 M_desc[
"serial_number"] = std::string(buff);
123 if ( usb_get_string_simple(h, dev->descriptor.iManufacturer, buff, 128) < 0 )
continue;
124 M_desc[
"manufacturer"] = std::string(buff);
126 if ( usb_get_string_simple(h, dev->descriptor.iProduct, buff, 128) < 0 )
continue;
127 M_desc[
"product"] = std::string(buff);
143 int get_serial_id(
unsigned int index, std::string &serial_id) {
173 int get_product (
unsigned int index, std::string &product) {
214 if(
scan() < 0 )
return -1;
217 struct usb_device *dev =
devices[0];
218 usb_dev_handle *h = usb_open(dev);
222 int ret_val = usb_reset(h);
229 std::vector<struct usb_device *>
devices;
230 std::vector<std::map<std::string, std::string> >
descriptions;