mirror of
https://github.com/mvp/uhubctl.git
synced 2026-06-24 11:07:02 +03:00
Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ee8260c71 | ||
|
|
8ba36bd8df | ||
|
|
aaf87accad | ||
|
|
58385b87e6 | ||
|
|
7bf80a08d1 | ||
|
|
b73213dd6d | ||
|
|
e327f5aeb1 | ||
|
|
9b824b5587 | ||
|
|
aa864285b1 | ||
|
|
fa524cf7df | ||
|
|
7fd3080f90 | ||
|
|
e3734e052f | ||
|
|
d576db98fb | ||
|
|
9e402917dc | ||
|
|
b0d321a041 | ||
|
|
0d2aa24bae | ||
|
|
bd92bcef2f | ||
|
|
ea70731854 | ||
|
|
6366aea0bd | ||
|
|
232dcc6f6d | ||
|
|
5691db3379 | ||
|
|
fae3da7e6f | ||
|
|
c79c9ac667 | ||
|
|
7f25162ed3 | ||
|
|
6f84663c6a | ||
|
|
4aae44ced0 | ||
|
|
9857849c0e | ||
|
|
821cdb8833 | ||
|
|
c387442b0c | ||
|
|
b690bd376a | ||
|
|
c220668adc | ||
|
|
3e10680f22 | ||
|
|
39b407a863 | ||
|
|
d227c8326f | ||
|
|
743ecf226b | ||
|
|
fd611df1e7 | ||
|
|
a6cdc3dc4b | ||
|
|
609d0bcae1 | ||
|
|
54365acb8d | ||
|
|
6e5782c3b7 | ||
|
|
59447ce431 | ||
|
|
05647714b6 | ||
|
|
4818eddc03 |
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
uhubctl – USB hub per-port power control.
|
||||
|
||||
Copyright (c) 2009-2019, Vadim Mikhailov
|
||||
Copyright (c) 2009-2020, Vadim Mikhailov
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
4
Makefile
4
Makefile
@@ -14,14 +14,14 @@ RM := rm -rf
|
||||
CC ?= gcc
|
||||
CFLAGS ?= -g -O0
|
||||
CFLAGS += -Wall -Wextra -std=c99 -pedantic
|
||||
GIT_VERSION := $(shell git describe --abbrev=8 --dirty --always --tags)
|
||||
GIT_VERSION := $(shell git describe --match "v[0-9]*" --abbrev=8 --dirty --always --tags | cut -c2-)
|
||||
ifeq ($(GIT_VERSION),)
|
||||
GIT_VERSION := $(shell cat VERSION)
|
||||
endif
|
||||
CFLAGS += -DPROGRAM_VERSION=\"$(GIT_VERSION)\"
|
||||
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
LDFLAGS += -Wl,-z,relro -lusb-1.0
|
||||
LDFLAGS += -Wl,-zrelro,-znow -lusb-1.0
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
|
||||
113
README.md
113
README.md
@@ -20,27 +20,38 @@ This is list of known compatible USB hubs:
|
||||
|:-------------------|:-----------------------------------------------------|:------|:----|:----------|:--------|:-----|
|
||||
| AmazonBasics | HU3641V1 ([RPi issue](https://goo.gl/CLt46M)) | 4 | 3.0 |`2109:2811`| 2013 | |
|
||||
| AmazonBasics | HU3770V1 ([RPi issue](https://goo.gl/CLt46M)) | 7 | 3.0 |`2109:2811`| 2013 | |
|
||||
| AmazonBasics | HU9002V1SBL ([RPi issue](https://goo.gl/CLt46M)) | 10 | 3.1 |`2109:2817`| 2018 | |
|
||||
| AmazonBasics | HUC9002V1ESL ([RPi issue](https://goo.gl/CLt46M)) | 10 | 3.1 |`2109:2817`| 2018 | |
|
||||
| Apple | Thunderbolt Display 27" (internal USB hub) | 6 | 2.0 | | 2011 | 2016 |
|
||||
| Apple | USB Keyboard With Numeric Pad (internal USB hub) | 3 | 2.0 | | 2011 | |
|
||||
| Asus | Z87-PLUS Motherboard (onboard USB hub) | 4 | 3.0 | | 2013 | 2016 |
|
||||
| B+B SmartWorx | UHR204 | 4 | 2.0 |`0856:DB00`| 2013 | |
|
||||
| B+B SmartWorx | USH304 | 4 | 3.0 |`04B4:6506`| 2017 | |
|
||||
| Basler | 2000036234 | 4 | 3.0 |`0451:8046`| 2016 | |
|
||||
| Belkin | F5U101 | 4 | 2.0 |`0451:2046`| 2005 | 2010 |
|
||||
| Belkin | F5U701-BLK | 7 | 2.0 | | 2008 | 2012 |
|
||||
| Buffalo | BSH4A05U3BK | 4 | 3.0 |`05E3:0610`| 2015 | |
|
||||
| Bytecc | BT-UH340 | 4 | 3.0 |`2109:8110`| 2010 | |
|
||||
| Circuitco | Beagleboard-xM (internal USB hub) | 4 | 2.0 |`0424:9514`| 2010 | |
|
||||
| Club3D | CSV-3242HD Dual Display Docking Station | 4 | 3.0 |`2109:2811`| 2015 | |
|
||||
| CyberPower | CP-H420P | 4 | 2.0 |`0409:0059`| 2004 | |
|
||||
| Cypress | CY4608 HX2VL development kit | 4 | 2.0 |`04B4:6570`| 2012 | |
|
||||
| D-Link | DUB-H4 rev D1 (black edition) | 4 | 2.0 |`05E3:0608`| 2012 | |
|
||||
| D-Link | DUB-H7 rev A (silver edition) | 7 | 2.0 |`2001:F103`| 2005 | 2010 |
|
||||
| D-Link | DUB-H7 rev D1 (black edition) | 7 | 2.0 |`05E3:0608`| 2012 | |
|
||||
| D-Link | DUB-H4 rev B (silver) | 4 | 2.0 |`05E3:0605`| 2005 | 2010 |
|
||||
| D-Link | DUB-H4 rev D,E (black). Note: rev A,C not supported | 4 | 2.0 |`05E3:0608`| 2012 | |
|
||||
| D-Link | DUB-H7 rev A (silver) | 7 | 2.0 |`2001:F103`| 2005 | 2010 |
|
||||
| D-Link | DUB-H7 rev D (black). Note: rev B,C not supported | 7 | 2.0 |`05E3:0608`| 2012 | |
|
||||
| Dell | P2416D 24" QHD Monitor | 4 | 2.0 | | 2017 | |
|
||||
| Dell | UltraSharp 1704FPT 17" LCD Monitor | 4 | 2.0 |`0424:A700`| 2005 | 2015 |
|
||||
| Dell | UltraSharp U2415 24" LCD Monitor | 5 | 3.0 | | 2014 | |
|
||||
| Elecom | U2H-G4S | 4 | 2.0 | | 2006 | 2011 |
|
||||
| GlobalScale | ESPRESSObin SBUD102 V5 | 1 | 3.0 |`1D6B:0003`| 2017 | |
|
||||
| Hawking Technology | UH214 | 4 | 2.0 | | 2003 | 2008 |
|
||||
| IOI | U3H415E1 | 4 | 3.0 | | 2012 | |
|
||||
| j5create | JUH470 (works only in USB2 mode) | 3 | 3.0 |`05E3:0610`| 2014 | |
|
||||
| Lenovo | ThinkPad EU Ultra Dockingstation (40A20090EU) | 6 | 2.0 |`17EF:100F`| 2015 | |
|
||||
| Juiced Systems | 6HUB-01 | 7 | 3.0 |`0BDA:0411`| 2014 | 2018 |
|
||||
| LG Electronics | 38WK95C-W monitor | 4 | 3.0 |`0451:8142`| 2018 | |
|
||||
| Lenovo | ThinkPad Ultra Docking Station (40A20090EU) | 6 | 2.0 |`17EF:100F`| 2015 | |
|
||||
| Lenovo | ThinkPad Ultra Docking Station (40AJ0135EU) | 7 | 3.1 |`17EF:3070`| 2018 | |
|
||||
| Lenovo | ThinkPad X200 Ultrabase 42X4963 | 3 | 2.0 |`17EF:1005`| 2008 | 2011 |
|
||||
| Lenovo | ThinkPad X6 Ultrabase 42W3107 | 4 | 2.0 |`17EF:1000`| 2006 | 2009 |
|
||||
| Lindy | USB serial converter 4 port | 4 | 1.1 |`058F:9254`| 2008 | |
|
||||
@@ -52,12 +63,13 @@ This is list of known compatible USB hubs:
|
||||
| Plugable | USB3-HUB7BC | 7 | 3.0 |`2109:0813`| 2015 | |
|
||||
| Plugable | USB3-HUB7C | 7 | 3.0 |`2109:0813`| 2015 | |
|
||||
| Plugable | USB3-HUB7-81X | 7 | 3.0 |`2109:0813`| 2012 | |
|
||||
| Plugable | USB2-HUB10S | 10 | 2.0 | | 2010 | |
|
||||
| Raspberry Pi | Model B+, 2 B, 3 B (port 2 only) | 4 | 2.0 | | 2011 | |
|
||||
| Raspberry Pi | Model 3 B+ | 6 | 2.0 |`0424:2514`| 2018 | |
|
||||
| Raspberry Pi | B+, 2B, 3B ([see below](#raspberry-pi-b2b3b)) | 4 | 2.0 | | 2011 | |
|
||||
| Raspberry Pi | 3B+ ([see below](#raspberry-pi-3b)) | 4 | 2.0 |`0424:2514`| 2018 | |
|
||||
| Raspberry Pi | 4B ([see below](#raspberry-pi-4b)) | 4 | 3.0 |`2109:3431`| 2019 | |
|
||||
| Renesas | uPD720202 PCIe USB 3.0 host controller | 2 | 3.0 | | 2013 | |
|
||||
| Rosewill | RHUB-210 | 4 | 2.0 |`0409:005A`| 2011 | 2014 |
|
||||
| Sanwa Supply | USB-HUB14GPH | 4 | 1.1 | | 2001 | 2003 |
|
||||
| Seagate | Backup Plus Hub STEL8000100 | 2 | 3.0 |`0BC2:AB44`| 2016 | |
|
||||
| StarTech | ST4200USBM | 4 | 2.0 |`0409:005A`| 2004 | |
|
||||
| Sunix | SHB4200MA | 4 | 2.0 |`0409:0058`| 2006 | 2009 |
|
||||
| Targus | PAUH212U | 7 | 2.0 | | 2004 | 2009 |
|
||||
@@ -67,12 +79,11 @@ This table is by no means complete.
|
||||
If your hub works with `uhubctl`, but is not listed above, please report it
|
||||
by opening new issue at https://github.com/mvp/uhubctl/issues,
|
||||
so we can add it to supported table. In your report, please provide
|
||||
exact product model and add output from `uhubctl`.
|
||||
exact product model and add output from `uhubctl`
|
||||
and please test VBUS off support as described below in FAQ.
|
||||
|
||||
Note that quite a few modern motherboards have built-in root hubs that
|
||||
do support this feature - you may not even need to buy any external hub.
|
||||
WARNING: turning off built-in USB ports may cut off your keyboard or mouse,
|
||||
so be careful what ports you are turning off!
|
||||
|
||||
|
||||
USB 3.0 duality note
|
||||
@@ -99,11 +110,18 @@ is using `winusb.sys` driver, which according to Microsoft does not support
|
||||
[necessary USB control requests](https://social.msdn.microsoft.com/Forums/sqlserver/en-US/f680b63f-ca4f-4e52-baa9-9e64f8eee101).
|
||||
This may be fixed if `libusb` starts supporting different driver on Windows.
|
||||
|
||||
First, you need to install library libusb-1.0 (version 1.0.12 or later):
|
||||
First, you need to install library libusb-1.0 (version 1.0.12 or later, 1.0.16 or later is recommended):
|
||||
|
||||
* Ubuntu: `sudo apt-get install libusb-1.0-0-dev`
|
||||
* Redhat: `sudo yum install libusb1-devel`
|
||||
* MacOSX: `brew install libusb`, or `sudo port install libusb-devel`
|
||||
> :warning: `libusb-1.0.23` is [broken](https://github.com/libusb/libusb/issues/707) on MacOS Catalina!
|
||||
You have to install `libusb-1.0.22` until [libusb issue 707](https://github.com/libusb/libusb/issues/707) is fixed,
|
||||
or use this workaround to force use of older Mojave build:
|
||||
|
||||
brew uninstall --ignore-dependencies libusb
|
||||
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/5314f1d/Formula/libusb.rb
|
||||
|
||||
* FreeBSD: libusb is included by default
|
||||
* NetBSD: `sudo pkgin install libusb1 gmake pkg-config`
|
||||
* Windows: TBD?
|
||||
@@ -134,6 +152,9 @@ on port 2 (`-p 2`). Supported actions are `off`/`on`/`cycle` (or `0`/`1`/`2`).
|
||||
`cycle` means turn power off, wait some delay (configurable with `-d`) and turn it back on.
|
||||
Ports can be comma separated list, and may use `-` for ranges e.g. `2`, or `2,4`, or `2-5`, or `1-2,5-8`.
|
||||
|
||||
> :warning: Turning off built-in USB ports may cut off your keyboard or mouse,
|
||||
so be careful which ports you are turning off!
|
||||
|
||||
If you have more than one smart USB hub connected, you should choose
|
||||
specific hub to control using `-l` (location) parameter.
|
||||
To find hub locations, simply run `uhubctl` without any parameters.
|
||||
@@ -240,12 +261,18 @@ You can use option `-r N` where N is some number from 10 to 1000 to fix this -
|
||||
`uhubctl` will try to turn power off many times in quick succession, and it should suppress that.
|
||||
This may be eventually fixed in kernel, see more discussion [here](https://bit.ly/2JzczjZ).
|
||||
|
||||
If your device is USB mass storage, invoking `udisksctl` before calling `uhubctl`
|
||||
might help to mitigate this issue:
|
||||
|
||||
sudo udisksctl power-off --block-device /dev/disk/...`
|
||||
sudo uhubctl -a off ...
|
||||
|
||||
|
||||
#### _Multiple 4-port hubs are detected, but I only have one 7-port hub connected_
|
||||
|
||||
Many hub manufacturers build their USB hubs using basic 4 port USB chips.
|
||||
E.g. to make 7 port hub, they daisy-chain two 4 port hubs - 1 port is lost to daisy-chaining,
|
||||
so it makes it 4+4-1=7 port hub. Simularly, 10 port hub could be built as 3 4-port hubs
|
||||
so it makes it 4+4-1=7 port hub. Similarly, 10 port hub could be built as 3 4-port hubs
|
||||
daisy-chained together, which gives 4+4+4-2=10 usable ports.
|
||||
|
||||
Note that you should never try to change power state for ports used to daisy-chain internal hubs together.
|
||||
@@ -255,20 +282,48 @@ Doing so will confuse internal hub circuitry and will cause unpredictable behavi
|
||||
#### _Raspberry Pi turns power off on all ports, not just the one I specified_
|
||||
|
||||
This is limitation of Raspberry Pi hardware design.
|
||||
For reference, Raspberry Pi models have following internal USB topology:
|
||||
|
||||
* B+/2B/3B: one USB hub `1-1`, with port `1` for Ethernet+wifi, and ports `2-5` ganged, controlled by port `2`.
|
||||
(Trying to control ports 3,4,5 won't do anything).
|
||||
* 3B+: 2 hubs - main hub `1-1`, all 4 ports ganged, all controlled by port `2`.
|
||||
Second hub `1-1.1` (daisy-chained to main): 3 independently controlled ports, `1` is used for Ethernet+wifi,
|
||||
and ports `2,3` are available with proper per-port power switching.
|
||||
In other words, 2 out of total 4 ports wired outside do support independent power switching on 3B+.
|
||||
* 4B: Hardware supports power switching, but current firmware is reporting broken USB descriptors.
|
||||
For more details see Raspberry Pi issue https://github.com/raspberrypi/linux/issues/3079.
|
||||
USB3 hub `2`, 4 ports, per-port power switching. BOS `ContainerID` not reported (required for USB3).
|
||||
USB2 hub `1`, 1 port, no usable ports, connects hub `1-1` below.
|
||||
USB2 hub `1-1`, 4 ports, dual to USB3 hub above. Hub descriptor incorrectly reports ganged power switching.
|
||||
USB2 hub `3`, 1 port, OTG controller, incorrectly reports ganged power switching.
|
||||
For reference, supported Raspberry Pi models have following internal USB topology:
|
||||
|
||||
##### Raspberry Pi B+,2B,3B
|
||||
|
||||
* Single hub `1-1`, ports 2-5 ganged, all controlled by port `2`:
|
||||
|
||||
uhubctl -l 1-1 -p 2 -a 0
|
||||
|
||||
Trying to control ports `3`,`4`,`5` will not do anything.
|
||||
Port `1` controls power for Ethernet+WiFi.
|
||||
|
||||
##### Raspberry Pi 3B+
|
||||
|
||||
* Main hub `1-1`, all 4 ports ganged, all controlled by port `2` (turns off secondary hub ports as well).
|
||||
Port `1` connects hub `1-1.1` below, ports `2` and `3` are wired outside, port `4` not wired.
|
||||
|
||||
uhubctl -l 1-1 -p 2 -a 0
|
||||
|
||||
* Secondary hub `1-1.1` (daisy-chained to main): 3 ports,
|
||||
port `1` is used for Ethernet+WiFi, and ports `2` and `3` are wired outside.
|
||||
|
||||
|
||||
##### Raspberry Pi 4B
|
||||
|
||||
> :warning: You may need to [update firmware](https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md)
|
||||
to vl805 00137ac or later to make power switching work on RPi 4B.
|
||||
|
||||
* USB2 hub `1`, 1 port, only connects hub `1-1` below.
|
||||
|
||||
* USB2 hub `1-1`, 4 ports ganged, dual to USB3 hub `2` below:
|
||||
|
||||
uhubctl -l 1-1 -a 0
|
||||
|
||||
* USB3 hub `2`, 4 ports ganged, dual to USB2 hub `1-1` above:
|
||||
|
||||
uhubctl -l 2 -a 0
|
||||
|
||||
* USB2 hub `3`, 1 port, OTG controller:
|
||||
|
||||
uhubctl -l 3 -p 1 -a 0
|
||||
|
||||
|
||||
As a workaround, you can buy any external USB hub from supported list,
|
||||
attach it to any USB port of Raspberry Pi, and control power on its ports independently.
|
||||
@@ -285,20 +340,22 @@ Notable projects using uhubctl
|
||||
| [Build Status Light](https://goo.gl/3GA82o) | Create a build status light in under 10 minutes |
|
||||
| [Buildenlights](https://git.io/fj1FC) | GitLab/GitHub project build status as green/red light |
|
||||
| [Weather Station](https://goo.gl/3b1FzC) | Reset Weather Station when it freezes |
|
||||
| [sysmoQMOD](https://goo.gl/8wvcKA) | Reset cellular modems when necessary |
|
||||
| [sysmoQMOD](https://bit.ly/2VtWrVt) | Reset cellular modems when necessary |
|
||||
| [Smog Sensor](https://bit.ly/2EMwgCk) | Raspberry Pi based smog sensor power reset |
|
||||
| [Terrible Cluster](https://goo.gl/XjiXFu) | Power on/off Raspberry Pi cluster nodes as needed |
|
||||
| [Ideal Music Server](https://bit.ly/2UJq6Z9) | Turn off unused USB ports to improve audio quality |
|
||||
| [Ideal Music Server](https://bit.ly/39MeVFQ) | Turn off unused USB ports to improve audio quality |
|
||||
| [USB drives with no phantom load](https://goo.gl/qfrmGK) | Power USB drives only when needed to save power |
|
||||
| [USB drive data recovery](https://goo.gl/4MddLr) | Recover data from failing USB hard drive |
|
||||
| [Control power to 3D printer](https://git.io/fh5Tr) | OctoPrint web plugin for USB power control |
|
||||
| [USB fan for Raspberry Pi](https://bit.ly/2TRV6sM) | Control USB fan to avoid Raspberry Pi overheating |
|
||||
| [Raspberry Pi Reboot Router](https://bit.ly/3aNbQqs) | Automatically reboot router if internet isn't working |
|
||||
| [Control USB Lamp With Voice](https://bit.ly/2VtW2SX) | Voice Control of USB Lamp using Siri and Raspberry Pi |
|
||||
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
||||
Copyright (C) 2009-2019 Vadim Mikhailov
|
||||
Copyright (C) 2009-2020 Vadim Mikhailov
|
||||
|
||||
This file can be distributed under the terms and conditions of the
|
||||
GNU General Public License version 2.
|
||||
|
||||
77
uhubctl.c
77
uhubctl.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2019 Vadim Mikhailov
|
||||
* Copyright (c) 2009-2020 Vadim Mikhailov
|
||||
*
|
||||
* Utility to turn USB port power on/off
|
||||
* for USB hubs that support per-port power switching.
|
||||
@@ -182,7 +182,7 @@ struct descriptor_strings {
|
||||
char vendor[64];
|
||||
char product[64];
|
||||
char serial[64];
|
||||
char description[256];
|
||||
char description[512];
|
||||
};
|
||||
|
||||
struct hub_info {
|
||||
@@ -408,9 +408,54 @@ static int get_hub_info(struct libusb_device *dev, struct hub_info *info)
|
||||
strcat(info->location, s);
|
||||
}
|
||||
|
||||
/* Get container_id: */
|
||||
bzero(info->container_id, sizeof(info->container_id));
|
||||
struct libusb_bos_descriptor *bos;
|
||||
rc = libusb_get_bos_descriptor(devh, &bos);
|
||||
if (rc == 0) {
|
||||
int cap;
|
||||
#ifdef __FreeBSD__
|
||||
for (cap=0; cap < bos->bNumDeviceCapabilities; cap++) {
|
||||
#else
|
||||
for (cap=0; cap < bos->bNumDeviceCaps; cap++) {
|
||||
#endif
|
||||
if (bos->dev_capability[cap]->bDevCapabilityType == LIBUSB_BT_CONTAINER_ID) {
|
||||
struct libusb_container_id_descriptor *container_id;
|
||||
rc = libusb_get_container_id_descriptor(NULL, bos->dev_capability[cap], &container_id);
|
||||
if (rc == 0) {
|
||||
int i;
|
||||
for (i=0; i<16; i++) {
|
||||
sprintf(info->container_id+i*2, "%02x", container_id->ContainerID[i]);
|
||||
}
|
||||
info->container_id[i*2] = 0;
|
||||
libusb_free_container_id_descriptor(container_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
libusb_free_bos_descriptor(bos);
|
||||
|
||||
/* Raspberry Pi 4 hack for USB3 root hub: */
|
||||
if (strlen(info->container_id)==0 &&
|
||||
strcasecmp(info->vendor, "1d6b:0003")==0 &&
|
||||
info->level==1 &&
|
||||
info->nports==4 &&
|
||||
bcd_usb==USB_SS_BCD)
|
||||
{
|
||||
strcpy(info->container_id, "5cf3ee30d5074925b001802d79434c30");
|
||||
}
|
||||
}
|
||||
|
||||
info->ppps = 0;
|
||||
/* Logical Power Switching Mode */
|
||||
int lpsm = uhd->wHubCharacteristics[0] & HUB_CHAR_LPSM;
|
||||
if (lpsm == HUB_CHAR_COMMON_LPSM && info->nports == 1) {
|
||||
/* For 1 port hubs, ganged power switching is the same as per-port: */
|
||||
lpsm = HUB_CHAR_INDV_PORT_LPSM;
|
||||
}
|
||||
/* Raspberry Pi 4 reports inconsistent descriptors, override: */
|
||||
if (lpsm == HUB_CHAR_COMMON_LPSM && strcasecmp(info->vendor, "2109:3431")==0) {
|
||||
lpsm = HUB_CHAR_INDV_PORT_LPSM;
|
||||
}
|
||||
/* Over-Current Protection Mode */
|
||||
int ocpm = uhd->wHubCharacteristics[0] & HUB_CHAR_OCPM;
|
||||
/* LPSM must be supported per-port, and OCPM per port or ganged */
|
||||
@@ -423,28 +468,6 @@ static int get_hub_info(struct libusb_device *dev, struct hub_info *info)
|
||||
} else {
|
||||
rc = len;
|
||||
}
|
||||
/* Get container_id: */
|
||||
bzero(info->container_id, sizeof(info->container_id));
|
||||
struct libusb_bos_descriptor *bos;
|
||||
rc = libusb_get_bos_descriptor(devh, &bos);
|
||||
if (rc == 0) {
|
||||
int cap;
|
||||
for (cap=0; cap < bos->bNumDeviceCaps; cap++) {
|
||||
if (bos->dev_capability[cap]->bDevCapabilityType == LIBUSB_BT_CONTAINER_ID) {
|
||||
struct libusb_container_id_descriptor *container_id;
|
||||
rc = libusb_get_container_id_descriptor(NULL, bos->dev_capability[cap], &container_id);
|
||||
if (rc == 0) {
|
||||
int i;
|
||||
for (i=0; i<16; i++) {
|
||||
sprintf(info->container_id+i*2, "%02x", container_id->ContainerID[i]);
|
||||
}
|
||||
info->container_id[i*2] = 0;
|
||||
libusb_free_container_id_descriptor(container_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
libusb_free_bos_descriptor(bos);
|
||||
}
|
||||
libusb_close(devh);
|
||||
}
|
||||
return rc;
|
||||
@@ -750,10 +773,6 @@ static int usb_find_hubs()
|
||||
if (hubs[i].nports != hubs[j].nports)
|
||||
continue;
|
||||
|
||||
/* And the same level: */
|
||||
if (hubs[i].level != hubs[j].level)
|
||||
continue;
|
||||
|
||||
/* Finally, we claim a match: */
|
||||
match = j;
|
||||
break;
|
||||
@@ -895,7 +914,7 @@ int main(int argc, char *argv[])
|
||||
opt_location
|
||||
);
|
||||
#ifdef __gnu_linux__
|
||||
if (rc < 0) {
|
||||
if (rc < 0 && geteuid() != 0) {
|
||||
fprintf(stderr,
|
||||
"There were permission problems while accessing USB.\n"
|
||||
"To fix this, run this tool as root using 'sudo uhubctl',\n"
|
||||
|
||||
@@ -2,7 +2,7 @@ DESCRIPTION = "uhubctl - USB hub per-port power control"
|
||||
HOMEPAGE = "https://github.com/mvp/uhubctl"
|
||||
LICENSE = "GPLv2"
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
|
||||
file://LICENSE;md5=7a7d8e0fdffe495ff61f52ceee61b2f7"
|
||||
file://LICENSE;md5=a79e6a142b69522fe7757fe7313895eb"
|
||||
|
||||
DEPENDS = "libusb1"
|
||||
RDEPENDS_${PN} = "libusb1"
|
||||
|
||||
Reference in New Issue
Block a user