PORTS Forum

Ports and Interfaces => USB => Topic started by: vineetrvce on May 23, 2012, 08:16:48 am

Title: Access to multiple devices with same VID and PID
Post by: vineetrvce 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.
Title: Re: Access to multiple devices with same VID and PID
Post by: Jan Axelson 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
Title: Re: Access to multiple devices with same VID and PID
Post by: vineetrvce on May 25, 2012, 12:51:17 am
 Thanks Jan, it worked!