Linux USB: turning the power on and off?

后端 未结 13 1365
遥遥无期
遥遥无期 2020-12-07 10:41

How can I programmatically enable and disable the power to a particular USB port on Linux? Is such a thing even possible? Mac answers appreciated as well!

I was tryi

13条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 11:04

    You could use uhubctl - command line utility to control USB power per port for compatible USB hubs.

    It works only on hubs that support per-port power switching, but note that many modern motherboards have USB hubs that support this feature. Also, last version of uhubctl supports USB 3.0 hubs, and good news is that quite a few new USB 3.0 hubs are supporting this feature.

    To compile:

    git clone https://github.com/mvp/uhubctl
    cd uhubctl
    make
    

    To list status of all hubs and ports that can be controlled by uhubctl:

    uhubctl
    

    To turn off power on port 5 of single compatible hub:

    uhubctl -a 0 -p 5
    

    To turn on power for all ports of all compatible hubs:

    uhubctl -a 1
    

    To toggle power off then on:

    uhubctl -a 2 -p 5
    

    Read more here.

    Disclosure - I am the author of uhubctl.

提交回复
热议问题