Author Topic: Access to multiple devices with same VID and PID  (Read 13637 times)

vineetrvce

  • Member
  • ***
  • Posts: 2
Access to multiple devices with same VID and PID
« on: May 23, 2012, 08:16:48 am »
Hello,
  I am able to access my embedded PIC device with the .NET app. But when I connect 2 devices, then there are issues accessing the 2 USB devices.

The problem is that whenever the 2nd device is inserted, i notice an addition in the device path name.

But how to ensure the the handle i get for the second device should be from the 2 device path name and not the first.
The call to get the handle is below:

hidHandle[hid_index] = FileIO.CreateFile(myDevicePathName, FileIO.GENERIC_READ | FileIO.GENERIC_WRITE, FileIO.FILE_SHARE_READ | FileIO.FILE_SHARE_WRITE, IntPtr.Zero, FileIO.OPEN_EXISTING, 0, 0);


Please suggest!

Thanks,
Vineet.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Access to multiple devices with same VID and PID
« Reply #1 on: May 23, 2012, 10:36:07 am »
Open the handle with exclusive access and you won't be able to get a handle the next time around.

Jan

vineetrvce

  • Member
  • ***
  • Posts: 2
Re: Access to multiple devices with same VID and PID
« Reply #2 on: May 25, 2012, 12:51:17 am »
 Thanks Jan, it worked!