Author Topic: Using WMI to detect HID. Getting a pair of insert notifications  (Read 10761 times)

crezyoz

  • Member
  • ***
  • Posts: 2
Using WMI to detect HID. Getting a pair of insert notifications
« on: February 25, 2014, 10:40:14 am »
I had been using WMI in an app I am writing to detect USB serial devices with good results. The firmware for the device was moved to HID. I noticed that the app now receives a pair of identical insert notifications and a pair of detach notifications from HID devices. I tested with a joystick as well. So I ran the latest HID app from Jan and indeed, it also receives a pair of insert notifications as well. I am somewhat confused by this and I am at a loss as to how I might find a solution.

Coding with VS2010 in Win7 64. Unit under test is a PIC 18Fxx. Though the same duplicate notifications occur when testing with a joystick as well. Is this normal? If so, how does one get around this to provide only a single, exclusive attach notification to an app?



Thank you in advance!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Using WMI to detect HID. Getting a pair of insert notifications
« Reply #1 on: February 25, 2014, 11:37:41 am »
HIDs will often have one listing in Device Manager under Human Input Devices and another under the function (keyboard, etc.) Each likely results in a notification. Without looking into it I can't say, but perhaps the notifications aren't 100% identical. At any rate, you can ignore the duplicates.   

crezyoz

  • Member
  • ***
  • Posts: 2
Re: Using WMI to detect HID. Getting a pair of insert notifications
« Reply #2 on: February 25, 2014, 12:23:37 pm »
Agreed. I am trying to use WMI queries to determine what the differences might be (haven't been able to yet) so I can easily ignore the one I don't want. I am assuming I want the one under the function, which in my case is the "USB Input Device".

Your .62 app seems to ignore the dupe, yet they show up in the ListBox. I only have VS2010 so I can't load the project.. but I am trying to figure it out by looking at the source. I use the same WMI instance detection that you used in .62.  I am guessing this is because you use a GUID to find the device. So perhaps I need to add that step to my code.

It was interesting because each notification contains the pair , Human Interface Device and USB Input Device.
Is Windows likely re-enumerating this device upon attachment, and both interfaces arrive on each enumeration?

I am not sure what differences to look for but I think you're correct, as usual.

Thank you for taking the time to answer my post.
« Last Edit: February 25, 2014, 12:26:02 pm by crezyoz »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Using WMI to detect HID. Getting a pair of insert notifications
« Reply #3 on: February 25, 2014, 12:30:06 pm »
Sometimes a driver will request descriptors from a device that has already been enumerated.

If you want to load the application, I think you can do so with the free Express edition:

http://www.visualstudio.com/en-US/products/visual-studio-express-vs