Author Topic: Win7 suddenly informs device disconnection  (Read 22450 times)

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Win7 suddenly informs device disconnection
« Reply #15 on: December 04, 2014, 09:57:42 am »
HidD_GetAttributes should generate no USB traffic; it just returns information collected during enumeration. However, if the device has, for example, failed to respond (even with NAK) to interrupt IN token packets, Windows may stop trying to communicate or may reset and re-enumerate. When you get the error, if possible, see if the device is present in Device Manager.

Are you calling HidD_GetAttributes repeatedly for a different device each time or repeating the call for the same device? If it's the latter, why? If you increase the delay, does the problem go away?


tk

  • Member
  • ***
  • Posts: 10
Re: Win7 suddenly informs device disconnection
« Reply #16 on: December 05, 2014, 02:20:55 am »
I have confirmed that the USB hub driver does not lose sight of a device even when HidD_GetAttributes fails and GetLastError returns ERROR_DEVICE_NOT_CONNECTED.

I have a composite device that has two interfaces, one of them is keyboard and the other is vendor defined. If I get a handle for an interface of the keybord and repeat HidD_GetAttributes, every call of the API completes successfully. But if a handle is for the vendor defined one, the problem occurs.
The behaviour of HidD_GetAttributes is different depending on an interface.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Win7 suddenly informs device disconnection
« Reply #17 on: December 05, 2014, 10:14:27 am »
Why are you calling HidD_GetAttributes repeatedly for the same device? If you increase the delay, does the problem go away?

tk

  • Member
  • ***
  • Posts: 10
Re: Win7 suddenly informs device disconnection
« Reply #18 on: December 07, 2014, 07:17:53 pm »
It's just for my test in order to observe the behaviour of the host.
If I interleave enough delay after getting a handle, no problem occurs.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Win7 suddenly informs device disconnection
« Reply #19 on: December 09, 2014, 10:13:10 am »
If adding a short delay after getting a handle fixes it, maybe that is all you need to do, especially since you likely need to get a handle only once each time you run the application.