Author Topic: multiple usb device with one host  (Read 9742 times)

kittu

  • Member
  • ***
  • Posts: 16
multiple usb device with one host
« on: February 12, 2011, 06:14:33 am »
Hello,

i am working with multiple usb hid devices with same VID &PID

i want to run more than one lock with one pc for diffrent application.

but i cant differentiate them from each other as they are returning same handle.

is there anyway to differentiate this usb device from each other.


thanks.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: multiple usb device with one host
« Reply #1 on: February 12, 2011, 09:38:24 am »
Each device gets its own handle. That's all you need unless you need to keep track of which is which after removing and reattaching. Then you can use serial numbers.

Jan

kittu

  • Member
  • ***
  • Posts: 16
Re: multiple usb device with one host
« Reply #2 on: February 14, 2011, 12:12:12 am »
Hi..

if with every hid device we get different handle.
 
then how we will read that handle(through which function)

is any windows function provided for this?

in my program i use find hid function IN WHICH I got the same handle for every hid device including my mouse & keyboard with my own hid devices

so i can not be differentiate with each other.

my differentiation  is based on my VID & PID

because of this i can use only one device with CPU for one application

I compare my hard coded VID PID with the VID PID that i read from function -HidD_GetAttributes (DeviceHandle, &Attributes);

Thank You.
          

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: multiple usb device with one host
« Reply #3 on: February 14, 2011, 11:03:02 am »
After detecting the first HID, continue searching for additional HIDs and use CreateFIle to open a handle to each HID you want to communicate with.

Jan

mdlayt

  • Member
  • ***
  • Posts: 40
Re: multiple usb device with one host
« Reply #4 on: February 16, 2011, 04:07:44 pm »
It is hard to tell if your question is actually
  "How can I distinguish my devices from each other because they are the same?"
or
  "How do I keep track of multiple devices attached to one computer?"

Of course, Jan answered both.

If it is the first question, then you need to make them different, eg with serial numbers, or PIDs, or something you can query.

The devices show up differently depending on where they are in your USB topology and once you get a handle to one of them, that handle will always be for that same device.  (This is why Windows "reinstalls" your device each time you change the topology--eg plug it into a different port.)

« Last Edit: February 16, 2011, 04:15:48 pm by mdlayt »