Dan*_*our 14 linux usb power usb-storage usb-flash-drive
有没有办法可以完全使用 Linux 机器上的软件关闭(特定)USB 设备的电源?
我想用它来关闭(使 LED 熄灭)一个(单个)USB 记忆棒。
你知道任何方法来实现这一目标吗?例如使用 /sys/bus/usb 或类似的?
ala*_*and 12
如果您的机器运行旧内核,您可以发出echo suspend > /sys/bus/usb/devices/X-X/power/level强制暂停设备的命令。
但是,从 2.6.32 开始,这不再可能:
我们可以将电源管理事件分为两大类:外部和内部。外部事件是由 USB 堆栈之外的某个代理触发的事件:系统挂起/恢复(由用户空间触发)、手动动态恢复(也由用户空间触发)和远程唤醒(由设备触发)。 内部事件是在 USB 堆栈中触发的事件:自动挂起和自动恢复。请注意,所有动态挂起事件都是内部的;不允许外部代理发出动态暂停。
power/control
This file contains one of two words: "on" or "auto".
You can write those words to the file to change the
device's setting.
"on" means that the device should be resumed and
autosuspend is not allowed. (Of course, system
suspends are still allowed.)
"auto" is the normal state in which the kernel is
allowed to autosuspend and autoresume the device.
(In kernels up to 2.6.32, you could also specify
"suspend", meaning that the device should remain
suspended and autoresume was not allowed. This
setting is no longer supported.
Run Code Online (Sandbox Code Playgroud)
(来自http://www.kernel.org/doc/Documentation/usb/power-management.txt)
我想你能做的最好的事情是解除设备与驱动程序的绑定,所以它不会有任何活动,然后尽快将设备配置为自动挂起(echo auto > /sys/bus/usb/devices/X-X/power/control && echo 0 > /sys/bus/usb/devices/X-X/power/autosuspend_delay_ms)。
但是,据我了解USB 规格,即使您暂停设备,端口上的一些电源仍会保留,因此如果通过“哑”方案供电(即直接连接到 +5V 和 GND),则可能无法禁用 LED销)。
| 归档时间: |
|
| 查看次数: |
23280 次 |
| 最近记录: |