使用 Linux 控制 USB 电源(开/关) [英] Controlling a USB power supply (on/off) with Linux

查看:62
本文介绍了使用 Linux 控制 USB 电源(开/关)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 Linux 手动打开/关闭 USB 电源?

Is it possible to turn on/off power supplies from USB manually with Linux?

有这个外部 USB 冷却风扇(你用来冷却自己的那种,而不是 PC),能够从终端控制它会很好,因为我想把风扇放在很远的地方.

There's this external USB cooling fan (the kind you use to cool yourself off, not the PC), and it would be nice to be able to control it from the terminal, because I want to position the fan somewhere far away.

我想这对其他各种事情也很有用,因为那里有很多 USB 玩具.也许是空气净化器等(我听说它们实际上不起作用).

I suppose this could also be useful for a variety of other things as well, because there's a lot of USB toys out there. Maybe air purifiers, etc. (I heard they don't really work though).

推荐答案

注意. 此答案中的信息与较旧的内核(最高 2.6.32)相关.有关较新内核的信息,请参阅 tlwhitec 的回答.

Note. The information in this answer is relevant for the older kernels (up to 2.6.32). See tlwhitec's answer for the information on the newer kernels.

# disable external wake-up; do this only once
echo disabled > /sys/bus/usb/devices/usb1/power/wakeup 

echo on > /sys/bus/usb/devices/usb1/power/level       # turn on
echo suspend > /sys/bus/usb/devices/usb1/power/level  # turn off

(您可能需要将 usb1 更改为 usb n)

(You may need to change usb1 to usb n)

来源:文档/usb/power-management.txt.gz

Source: Documentation/usb/power-management.txt.gz

这篇关于使用 Linux 控制 USB 电源(开/关)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆