PORTS Forum

Ports and Interfaces => USB => Topic started by: lcpoon on August 27, 2012, 09:46:29 pm

Title: access WinUSB device - same serial number, different product name
Post 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)
Title: Re: access WinUSB device - same serial number, different product name
Post by: Jan Axelson on August 27, 2012, 10:30:47 pm
Open a handle to the first device, then keep looking for another one.
Title: Re: access WinUSB device - same serial number, different product name
Post by: lcpoon on August 27, 2012, 10:37:39 pm
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.
Title: Re: access WinUSB device - same serial number, different product name
Post by: Jan Axelson on August 28, 2012, 10:33:36 pm
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.

Title: Re: access WinUSB device - same serial number, different product name
Post by: lcpoon on August 28, 2012, 10:52:57 pm
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.
Title: Re: access WinUSB device - same serial number, different product name
Post by: lcpoon on September 04, 2012, 11:08:52 am
It works, thanks for your info about the memberIndex
Title: Re: access WinUSB device - same serial number, different product name
Post by: Pat Crowe on September 04, 2012, 02:52:58 pm
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.