关闭单个 USB 设备...再次 [英] Turning off a single usb device... again
问题描述
我知道这个话题已经讨论过很多次了,但没有一个答案对我有帮助.作为记录,我正在运行 Debian.
I know that this topic has been discussed many times, but none of the answers helped me. For the record, i'm running Debian.
交易是:我买了一个 USB 供电的 LED 灯,它非常简单,甚至没有开/关开关(它可以工作并且一直亮着).我希望能够通过命令行打开/关闭它.这是我尝试过的:
The deal is: I bought an usb powered led lamp, which is very simple and doesn't even have an on/off switch (it works and is always on). I want to be able to turn it on/off via command line. Here's what i tried:
echo on > /sys/bus/usb/devices/usb1/power/level # turn on
echo suspend > /sys/bus/usb/devices/usb1/power/level # turn off
这是我在许多论坛上发现的.打开打开"有效,但暂停"产生
which is what i've found on many forums. Turning "on" works, but "suspending" yields
-su: echo: write error: Invalid argument
适用于每个 USBN.我也试过了
for every usbN. I also tried
echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend_delay_ms"
它不会给出错误,但也不会做任何事情(同样,对于每个 usbN)
which doesn't give an error, but also doesn't do anything (again, for every usbN)
尝试
echo "usb1" > /sys/bus/usb/drivers/usb/unbind
仅适用于更智能"的设备,例如键盘、鼠标或 USB wifi 卡.我的意思是只有tyhose设备被关闭,其他usbN不会出错,但灯永远不会熄灭.
works only for more "inteligent" devices, like the keyboard, the mouse, or the usb wifi card. What i mean is that only tyhose devices are turned off, other usbN don't give an error, but the lamp never goes off.
/sys/bus/usb/devices/的内容是
the contents of /sys/bus/usb/devices/ are
1-0:1.0 1-1:1.0 1-2:1.0 1-2:1.2 2-0:1.0 4-0:1.0 4-1:1.0 6-0:1.0 8-0:1.0 8-2:1.0 usb2 usb4 usb6 usb8
1-1 1-2 1-2:1.1 1-2:1.3 3-0:1.0 4-1 5-0:1.0 7-0:1.0 8-2 usb1 usb3 usb5 usb7
我试过了
echo device_name > /sys/bus/usb/drivers/usb/unbind
对它们中的每一个,但只有设备 usbN 和 N-M 做出反应,形式为 n-m:x.y 的设备产率
with every single one of them, but only the devices usbN and N-M react, the ones of the form n-m:x.y yield
tee: /sys/bus/usb/drivers/usb/bind: No such device
(例如,我尝试输入1-0:1.0"、1-0:1.0"和1-0:1.0",都给出了相同的结果).
(i tried putting in, for instance, "1-0:1.0", "1-0:1.0" and "1-0:1.0", all gave the same result).
最后一件事,执行后显示什么
One last thing, what is shown after executing
lsusb -t
当我插入或拔下灯时不会改变.
does not change when i plug or unplug the lamp.
有什么想法吗?
推荐答案
关闭设备ID 2-1:
Turn off device ID 2-1:
echo '2-1' |sudo tee/sys/bus/usb/drivers/usb/unbind
重新打开设备 ID 2-1:
Turn device ID 2-1 back on:
echo '2-1' |sudo tee/sys/bus/usb/drivers/usb/bind
在我的例子中,使用设备 ID 2-1 控制我的 USB 记忆棒的电源,从而控制灯.
In my case, using device ID 2-1 controls power to my usb stick, and as a consequence controls the light.
- 提示:如果他们在 Debian 中为您工作,请为他们创建一个别名,以便您以后的生活更轻松.
希望这会有所帮助,苏
这篇关于关闭单个 USB 设备...再次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!