TRAHOMOTO / javahidapi

Automatically exported from code.google.com/p/javahidapi
Other
0 stars 0 forks source link

Two devices with identical VID & PID returns same HIDDevice when opened simultaneously #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Insert two USB HID devices with same VID & PID
2. Call HIDManager.list_Devices() and call HIDDeviceInfo.open on each object 
that matches the VID & PID;
3. The two returned HIDDevice objects are equal, the peer is the same.

What is the expected output? What do you see instead?
Expected to see two different HIDObjects with different peers. But instead they 
have identical peers and both are working when reading/writing, but they reach 
the same device (as far as i can see the first that is enumerated). 

What version of the product are you using? On what operating system?
2011-12-21 build.
Windows 7 32 bit.

Please provide any additional information below.
Please tell me if you need more information or if this is a design choice. Some 
API's cannot handle multiple identical devices.

Original issue reported on code.google.com by i...@stokerkontrol.dk on 25 Apr 2012 at 10:08

GoogleCodeExporter commented 9 years ago
The problem is in get_hid_device_path().
It looks up only on VID & PID. But that is identical on two identical devices 
that are connected simultaneouly, and only the first in the list is returned, 
even though the path given is different on the two devices.

A solution, that proves this, but is not at all a full solution is this:
hid.c -> hid_open_path():
Outcomment this line: 
dev = get_hid_device_path(path);
Add this line instead:
dev = NULL;

Now you can open two different devices, and communicate them, but ofcourse this 
is not the full solution, just added it to make sure what was wrong.

The elegant solution is to lookup in the table given the path instead of the 
VID and PID only, and return the correct device.

Original comment by i...@stokerkontrol.dk on 25 Apr 2012 at 1:15

GoogleCodeExporter commented 9 years ago
I have implemented the solution where path is used to look up in the 
device_list instead of vid & pid, and now it works perfectly with multiple 
devices with same vid & pid. I hope this fix can be included in the official 
code.

Original comment by i...@stokerkontrol.dk on 26 Apr 2012 at 4:23

GoogleCodeExporter commented 9 years ago
Hello, we are facing a similar problem with out solution.

Would you be able to share your code snippet?

Thank you.

Original comment by mashkal...@gmail.com on 8 Jun 2012 at 1:38