6

I am trying to write an application in C++ which lists Information obtained from a USB device. I am following USBView (Github) utility's code for it.

When device is in D0 power state (fully powered), I am able to get string descriptors, but when device goes to a low power state (D2), I am not.

The IOCTL IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION returns with the error "A device attached to the system is not functioning." USBView utility shows that string descriptors are not available when device is in a low power state.

enter image description here

This behaviour is odd, and nowhere in the USB spec did I find reference to it. I have checked with 2 devices, and I get the same behaviour. I am able to get other descriptors such as Device Descriptor, BOS Descriptor, etc. even in D2 state.

Is there a way to get string descriptors when USB device is in low power state? If not, is there a way to momentarily turn it to D0 power state? Probably ACPI is the answer, but it is a very low level API which I am finding overwhelming to understand. Does Windows provide any high level API to set power states?

Sahil Singh
  • 3,352
  • 39
  • 62

1 Answers1

2

The USB 2.0 specification defines suspend mode, a state where there is no traffic on the bus and devices go to sleep to save power. Since there is no traffic, you cannot request string descriptors from a device in suspend mode. You'd have to wake it up with special signalling before you can do that.

The only thing I can think of that might help you is disabling the "USB selective suspend setting", a feature of Windows that generally puts devices into suspend mode when they are not being used. It's pretty deep in the power settings part of the Control Panel so let me know if you have trouble finding it.

It seems to me that you ought to be able to wake the device up even if it is in selective suspend so that you can get information from it, but I am not sure exactly how to do that and it probably depends on what drivers your device uses.

David Grayson
  • 84,103
  • 24
  • 152
  • 189
  • "Allow computer to turn of this device" -> if this is the option you mean by selective suspend, I have turned it off for all ancestor hubs of my device, and the corresponding USB controller. – Sahil Singh Jun 25 '18 at 18:28
  • The thing that's strange is while other descriptors are available, why only string descriptors are not. Do they consume the most power for transfer? – Sahil Singh Jun 25 '18 at 18:29
  • The other descriptors were read out of necessity by Windows, since it needs them to figure out which driver to load. It probably caches them somewhere. There is no real energy difference. – David Grayson Jun 25 '18 at 18:30
  • In Windows 10, the global selective suspend setting can be found by: Windows key -> type "power" -> select "Power & Sleep Settings" -> "Additional power settings" -> "Change plan settings" -> "Change advanced power settings" -> "USB settings" -> "USB selective suspend setting". I don't know if this will work. Normally Windows does the right thing if your device has a driver installed and I don't need to mess with these settings. – David Grayson Jun 25 '18 at 18:34
  • I am using Microsoft Surfacebook, this option is not available in "Change advanced power settings". The problem still remains that either I want to change the device state to D0, or figure out why string descriptors cannot be fetched in low power states. The qeustion, and my application is more about trying to understand USB. – Sahil Singh Jun 25 '18 at 19:14
  • Ok, well, from the perspective of USB itself, I think I have r already explained sufficiently why you cannot fetch USB descriptors from a device in suspend mode. It's just a straightforward implication of the definition of suspend mode. So I think I answered that aspect of your question but let me know if I am missing something. – David Grayson Jun 25 '18 at 23:20
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/173795/discussion-between-sahil-singh-and-david-grayson). – Sahil Singh Jun 26 '18 at 06:59
  • @I have the same problem here. I have designed an INTERRUPPED Driven USB Device and on DELL INSPIRON 15 3000 with WIN 10 1903 the device goes to power state D3 where I can not retrieve the string descriptor. BUT it is not my USB device, as on othere Laptop with WIN 10 (1903) it works fine. The DELL Inspiron 15 has the Intel USB 3.0 eXtensible Host Controller USB Host Adapter on board. I saw that this part and its driver is buggy. Is there a workaournd? THanks – Walter Schrabmair Oct 09 '19 at 06:03