web-dev-qa-db-ja.com

ソフトウェアを使用してUSBデバイスの電源を切る方法はありますか?

Linuxマシンのソフトウェアを使用して(特定の)USBデバイスの電源を完全に切る方法はありますか?

これを使用して(LEDがオフになるように)(単一の)USBスティックの電源をオフにします。

これを達成するための方法を知っていますか?例えば。/sys/bus/usbなどを使用していますか?

11
Daniel Jour

マシンで古いカーネルを実行している場合は、echo suspend > /sys/bus/usb/devices/X-X/power/levelデバイスの一時停止を強制します。

ただし、2.6.32以降、これは不可能になりました。

電源管理イベントは、外部と内部の2つの大きなクラスに分類できます。外部イベントは、USBスタックの外部のエージェントによってトリガーされるイベントです。システムの一時停止/再開(ユーザースペースによってトリガーされます)、手動の動的再開(ユーザースペースによってトリガーされます)、およびリモートウェイクアップ(デバイスによってトリガーされます)。 内部イベントは、USBスタック内でトリガーされるイベントです:autosuspendおよびautoresume。 すべての動的な中断イベントは内部であることに注意してください;外部エージェントは動的中断を発行できません。

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.

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)。

ただし、私が理解している限り SB仕様 、デバイスを一時停止しても、ポートの一部の電源が残っているため、「ダム」スキーム(つまり、 + 5VピンとGNDピンに直接接続されています)。

10
aland

イジェクトコマンドを使用する必要があります。

eject /dev/<devicename>を実行すると、電源が切れます。

3
soandos