|
Hi,
I'm trying to Open 2 USB HID devices with the same Prod ID and Vendor ID SN is different off course . I'm getting 2 devices on the list , but I always seem to open the same device I see it by a function to get the device SN . part of the code : HIDInterface* hid; struct usb_bus *usb_bus; struct usb_device *dev; usb_init(); usb_find_busses(); usb_find_devices(); HIDInterfaceMatcher matcher = { VENDOR_ID, PRODUCT_ID, NULL, NULL, 0 }; for (usb_bus = usb_busses; usb_bus; usb_bus = usb_bus->next) // 2 devices are available { for (dev = usb_bus->devices; dev; dev = dev->next) { if ((dev->descriptor.idVendor == VENDOR_ID) && (dev->descriptor.idProduct == PRODUCT_ID)) { ret = hid_init(); hid1 = hid_new_HIDInterface(); ret = hid_force_open(hid, 0, &matcher, 3); Get_SN(SNreceive,hid); // a function to retrieve the device SN } } } any idea? thanks T.Z |
|
TZ2002 wrote:
> I'm trying to Open 2 USB HID devices with the same Prod ID and Vendor ID > SN is different off course . > I'm getting 2 devices on the list , but I always seem to open the same > device That's not your exact code; you have a confusion between "hid" and "hid1" as the names of the structure. Also, this is a libhid question, not a libusb question. hid_force_open does its own search. It opens the first match it finds that is not already open. Thus, there is no point in having you loop through the devices -- let libhid do it. So, this should work: hid_init(); hid1 = hid_new_HIDInterface(); hid_force_open( hid1, 0, &matcher, 3 ); hid2 = hid_new_HIDInterface(); hid_force_open( hid2, 0, &matcher, 3 ); -- Tim Roberts, [hidden email] Providenza & Boekelheide, Inc. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
Thanks, What you suggest is not working -So I will check libhid. |
|
In reply to this post by TZ2002
On 06/11/2012 06:08 AM, TZ2002 wrote:
> Hi, > I'm trying to Open 2 USB HID devices with the same Prod ID and Vendor ID > SN is different off course . > I'm getting 2 devices on the list , but I always seem to open the same > device > I see it by a function to get the device SN . > > part of the code : > > HIDInterface* hid; > struct usb_bus *usb_bus; > struct usb_device *dev; > usb_init(); > usb_find_busses(); > usb_find_devices(); > HIDInterfaceMatcher matcher = { VENDOR_ID, PRODUCT_ID, NULL, NULL, 0 }; > for (usb_bus = usb_busses; usb_bus; usb_bus = usb_bus->next) // 2 > devices are available > { > for (dev = usb_bus->devices; dev; dev = dev->next) > { > if ((dev->descriptor.idVendor == VENDOR_ID) && > (dev->descriptor.idProduct == PRODUCT_ID)) > { > ret = hid_init(); > hid1 = hid_new_HIDInterface(); > ret = hid_force_open(hid, 0, &matcher, 3); > Get_SN(SNreceive,hid); // a function to retrieve the device > SN > } > } > } > > > any idea? You may want to take a look at HIDAPI [1]. Libhid is based on the long-deprecated libusb-0.1 (at least according to the current website). Opening devices based on serial number is a use case that was designed into HIDAPI from the start. Judge for yourself though; I'm biased :) Alan. [1] http://www.signal11.us/oss/hidapi/ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
| Powered by Nabble | Edit this page |
