PORTS Forum
Ports and Interfaces => USB => Topic started by: lcpoon on August 27, 2012, 09:46:29 pm
-
Hi,
I have two devices with same PID, same VID, same serial number (MY12345678) but different product name. How to access each individually?
The problem is that the DevicePathName is the same for both:
DevicePathName = "\\?\usb#vid_0957&pid_a118#MY123454678#{400b501e-5a37-472d-b4a7-998bf4e9a7cd}"
success = SetupDiGetDeviceInterfaceDetail _
(deviceInfoSet, _
myDeviceInterfaceData, _
detailDataBuffer, _
bufferSize, _
bufferSize, _
IntPtr.Zero)
'Skip over cbsize (4 bytes) to get the address of the devicePathName.
pdevicePathName = New IntPtr(detailDataBuffer.ToInt32 + 4)
'Get the String containing the devicePathName.
DevicePathName = Marshal.PtrToStringAuto(pdevicePathName)
-
Open a handle to the first device, then keep looking for another one.
-
I am using myWinUsbDevice.GetDeviceHandle(devicePathName) to open the handle to the first device. How to open the handle for the second device because devicePathName is the same as the first one? If I am using myWinUsbDevice.GetDeviceHandle(devicePathName), it always connected to the first device and not the second ones.
-
In SetupDiEnumDeviceInterfaces, do you use a different memberIndex to get a different deviceInfoSet the second time?
As an aside, the purpose of a serial number is to identify a unique device so multiple devices shouldn't share a serial number.
-
We have two product models - A and B, loaded with the same microcontroller f/w codes.
A and B are using different hardware circuitries on board, enabled by the microcontroller f/w codes.
That's the reason we have same serial number, same PID and same VID but different product name.
-
It works, thanks for your info about the memberIndex
-
I'm glad it works for you. You can, of course, do want you want in your own laboratory. I just hope you know you should not sell two different products with the same vid/pid/sn to other people. Or even two identical products with the same vid/pid/sn.