简体   繁体   English

如何从处于低功耗状态的USB设备获取字符串描述符?

[英]How to get string descriptor from a USB device which is in low power state?

I am trying to write an application in C++ which lists Information obtained from a USB device. 我正在尝试用C ++编写一个应用程序,其中列出了从USB设备获取的信息。 I am following USBView ( Github ) utility's code for it. 我正在关注USBView( Github )实用程序的代码。

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. 当设备处于D0电源状态(完全供电)时,我能够获得字符串描述符,但是当设备进入低功耗状态(D2) ,我不是。

The IOCTL IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION returns with the error "A device attached to the system is not functioning." IOCTL IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION返回错误“连接到系统的设备无法正常运行”。 USBView utility shows that string descriptors are not available when device is in a low power state. USBView实用程序显示当设备处于低功耗状态时,字符串描述符不可用。

在此输入图像描述

This behaviour is odd, and nowhere in the USB spec did I find reference to it. 这种行为是奇怪的,在USB规范中没有找到它的参考。 I have checked with 2 devices, and I get the same behaviour. 我已经检查了2个设备,我得到了相同的行为。 I am able to get other descriptors such as Device Descriptor, BOS Descriptor, etc. even in D2 state. 即使在D2状态下,我也可以获得其他描述符,例如设备描述符,BOS描述符等。

Is there a way to get string descriptors when USB device is in low power state? 当USB设备处于低功耗状态时,有没有办法获取字符串描述符? If not, is there a way to momentarily turn it to D0 power state? 如果没有,有没有办法暂时将其转为D0电源状态? Probably ACPI is the answer, but it is a very low level API which I am finding overwhelming to understand. 可能ACPI就是答案,但它是一个非常低级别的API,我发现它无法理解。 Does Windows provide any high level API to set power states? Windows是否提供任何高级API来设置电源状态?

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. USB 2.0规范定义了挂起模式,即总线上没有流量且设备进入休眠以节省电量的状态。 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. 我能想到的唯一可以帮助你的是禁用“USB选择性挂起设置”,这是Windows的一项功能,通常会在不使用时将设备置于挂起模式。 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. 在我看来,你应该能够唤醒设备,即使它处于选择性暂停状态,以便你可以从中获取信息,但我不确定如何做到这一点,这可能取决于你的设备驱动程序使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM