Author Topic: access WinUSB device - same serial number, different product name  (Read 18645 times)

lcpoon

  • Frequent Contributor
  • ****
  • Posts: 58
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)

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: access WinUSB device - same serial number, different product name
« Reply #1 on: August 27, 2012, 10:30:47 pm »
Open a handle to the first device, then keep looking for another one.

lcpoon

  • Frequent Contributor
  • ****
  • Posts: 58
Re: access WinUSB device - same serial number, different product name
« Reply #2 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.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: access WinUSB device - same serial number, different product name
« Reply #3 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.


lcpoon

  • Frequent Contributor
  • ****
  • Posts: 58
Re: access WinUSB device - same serial number, different product name
« Reply #4 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.

lcpoon

  • Frequent Contributor
  • ****
  • Posts: 58
Re: access WinUSB device - same serial number, different product name
« Reply #5 on: September 04, 2012, 11:08:52 am »
It works, thanks for your info about the memberIndex

Pat Crowe

  • Member
  • ***
  • Posts: 39
Re: access WinUSB device - same serial number, different product name
« Reply #6 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.