mirror of
https://github.com/mvp/uhubctl.git
synced 2026-05-21 18:36:05 +03:00
Compare commits
18 Commits
quiet-opti
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b2c4c211f | ||
|
|
da8a260538 | ||
|
|
a9cd307a4a | ||
|
|
f45034e0d0 | ||
|
|
74ac3e6bc3 | ||
|
|
1117cc7ce2 | ||
|
|
65e3b74e60 | ||
|
|
ceadf4c13a | ||
|
|
ad94660713 | ||
|
|
ca7610ab01 | ||
|
|
c9edaf3da8 | ||
|
|
9a6e6d3a6d | ||
|
|
1af4949ce8 | ||
|
|
5dda8a874b | ||
|
|
786dcb2277 | ||
|
|
fab805bc12 | ||
|
|
a05a250644 | ||
|
|
b3fa9e7e63 |
33
README.md
33
README.md
@@ -27,6 +27,7 @@ This is list of known compatible USB hubs:
|
||||
| AmazonBasics | U3-7HUB (only works for 1 charge port) | 7 | 3.0 |`2109:2813`| 2020 | |
|
||||
| Anker | AK-68ANHUB-BV7A-0004 ([note](https://git.io/JLnZb)) | 7 | 3.0 |`2109:0812`| 2014 | |
|
||||
| Apple | Mac Mini M4 (2 front ports only) | 2 | 3.2 |`05AC:800B`| 2024 | |
|
||||
| Apple | MacBook Air (Late 2010) | 2 | 2.0 |`1D6B:0002`| 2010 | 2020 |
|
||||
| Apple | Pro Display XDR MWPE2LL/A (internal USB hub) | 4 | 2.0 |`05AC:9139`| 2019 | |
|
||||
| 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 | |
|
||||
@@ -41,11 +42,12 @@ This is list of known compatible USB hubs:
|
||||
| BenQ | PD2700U 4K Monitor (works only in USB2 mode) | 4 | 3.0 |`05E3:0610`| 2018 | |
|
||||
| BenQ | PD3220U | 4 | 3.1 |`05E3:0610`| 2019 | |
|
||||
| Bytecc | BT-UH340 ([warning](https://tinyurl.com/BT-UH340-1)) | 4 | 3.0 |`2109:8110`| 2010 | |
|
||||
| Centech | CT-USB4HUB ReTRY HUB | 4 | 3.0 |`0424:2744`| 2017 | |
|
||||
| Centech | CT-USB4HUB ReTRY HUB ([note](https://github.com/mvp/uhubctl/issues/630)) | 4 | 3.0 |`0424:2744`| 2017 | |
|
||||
| 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 | |
|
||||
| Coolgear | USBG-12U2ML | 12 | 2.0 |`05e3:0607`| 2015 | |
|
||||
| Cypress | CY4608 HX2VL ([note](https://tinyurl.com/CY4608-1)) | 4 | 2.0 |`04B4:6570`| 2012 | |
|
||||
| D-Link | DUB-2332 rev A1 | 3 | 3.0 | | 2022 | |
|
||||
| D-Link | DUB-H4 rev D,E (black). Note: rev A,C,F 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,E (black). Rev B,C,F,G not supported | 7 | 2.0 |`05E3:0608`| 2012 | |
|
||||
@@ -64,6 +66,7 @@ This is list of known compatible USB hubs:
|
||||
| Hawking Technology | UH214 | 4 | 2.0 | | 2003 | 2008 |
|
||||
| Hewlett Packard | USB-C Dock G5 5TW10AA | 5 | 3.0 |`03F0:076B`| 2019 | |
|
||||
| Hewlett Packard | P5Q58UT | 3 | 3.0 | | 2019 | |
|
||||
| IBM | SK-8815 USB Keyboard | 3 | 1.1 |`04B3:301A`| 2004 | |
|
||||
| Inateck | HB2025A ([USB2 only](https://tinyurl.com/HB2025A-1)) | 4 | 3.1 |`2109:2822`| 2021 | |
|
||||
| IOI | U3H415E1 | 4 | 3.0 | | 2012 | |
|
||||
| j5create | JUH377 ([note](https://tinyurl.com/JUH377)) | 7 | 3.0 | | 2016 | |
|
||||
@@ -77,16 +80,17 @@ This is list of known compatible USB hubs:
|
||||
| LG Electronics | 27UK850-W monitor | 2 | 3.0 | | 2018 | |
|
||||
| LG Electronics | 27UN83A-W monitor | 2 | 3.0 |`0451:8142`| 2020 | |
|
||||
| LG Electronics | 38WK95C-W monitor | 4 | 3.0 |`0451:8142`| 2018 | |
|
||||
| Lenovo | ThinkPad Mini Dock Series 3 (433710U) | 6 | 2.0 |`17EF:100A`| 2016 | |
|
||||
| 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 |
|
||||
| Lenovo | ThinkPlus 4-in-1 USB-C hub 4X90W86497 | 3 | 3.0 | | 2021 | |
|
||||
| Lenovo | ThinkVision T24i-10 Monitor | 4 | 2.0 |`17EF:0610`| 2018 | |
|
||||
| Lenovo | USB-C to 4 Port USB-A Hub | 4 | 2.0 |`17EF:103A`| 2020 | |
|
||||
| Lenovo | USB-C to 4 Port USB-A Hub ([USB2 only](https://github.com/mvp/uhubctl/issues/625)) | 4 | 2.0 |`17EF:103A`| 2020 | |
|
||||
| Lindy | USB serial converter 4 port | 4 | 1.1 |`058F:9254`| 2008 | |
|
||||
| Linksys | USB2HUB4 ([note](https://git.io/JYiDZ)) | 4 | 2.0 | | 2004 | 2010 |
|
||||
| Maplin | A08CQ | 7 | 2.0 |`0409:0059`| 2008 | 2011 |
|
||||
| Maplin | A08CQ ([red ports only](https://tinyurl.com/gh635)) | 7 | 2.0 |`0409:0059`| 2008 | 2011 |
|
||||
| Metadot | Das Keyboard 4 | 2 | 3.0 | | 2014 | |
|
||||
| Microchip | EVB9512 | 2 | 2.0 | | 2009 | |
|
||||
| Microchip | EVB-USB2517 | 7 | 2.0 | | 2008 | |
|
||||
@@ -115,14 +119,17 @@ This is list of known compatible USB hubs:
|
||||
| Rosonway | RSH-A37S | 7 | 3.0 |`2109:2822`| 2021 | |
|
||||
| Rosonway | RSH-A104 ([USB2 only](https://tinyurl.com/RSH-A104)) | 4 | 3.1 |`2109:2822`| 2022 | |
|
||||
| Rosonway | RSH-ST07C ([only 4](https://tinyurl.com/4pjnujrn)) | 7 | 3.0 |`2109:2822`| 2023 | |
|
||||
| Rosonway | RSH-ST10C-6 ([note](https://tinyurl.com/428vpa2f)) | 10 | 3.1 | | 2024 | |
|
||||
| Sanwa Supply | USB-HUB14GPH | 4 | 1.1 | | 2001 | 2003 |
|
||||
| Seagate | Backup Plus Hub STEL8000100 | 2 | 3.0 |`0BC2:AB44`| 2016 | |
|
||||
| Seeed Studio | reTerminal CM4104032 | 2 | 2.0 |`0424:2514`| 2021 | |
|
||||
| Sipolar | A-173 | 7 | 3.0 |`0BDA:0411`| 2016 | |
|
||||
| StarTech | DKT30CSDHPD3 USB-C Travel Dock | 3 | 3.0 |`2109:2817`| 2018 | |
|
||||
| StarTech | HB30A4AIB ([warning](https://tinyurl.com/ycxravwk)) | 4 | 3.0 |`2109:2817`| 2018 | |
|
||||
| StarTech | HB31C2A2CB ([note](https://github.com/mvp/uhubctl/issues/601)) | 5 | 3.0 |`14B0:013D`| 2020 | |
|
||||
| Sunix | SHB4200MA | 4 | 2.0 |`0409:0058`| 2006 | 2009 |
|
||||
| System Talks | Sugoi USB2-HUB4X | 4 | 2.0 | | 2007 | |
|
||||
| System Talks | Sugoi USB2-HUB4X ([warning](https://github.com/mvp/uhubctl/issues/636))|4|2.0| | 2007 | |
|
||||
| Targus | ACH155 (port 3 controls all ports) | 4 | 3.0 | | 2022 | |
|
||||
| Targus | PA095UZ | 2 | 2.0 | | 2004 | |
|
||||
| Targus | PAUH212/PAUH212U | 7 | 2.0 | | 2004 | 2009 |
|
||||
| Texas Instruments | TUSB4041PAPEVM | 4 | 2.1 |`0451:8142`| 2015 | |
|
||||
@@ -159,9 +166,15 @@ For Linux and MacOS uhubctl is available in standard package managers
|
||||
and can be installed with following commands:
|
||||
|
||||
* MacOS: `brew install uhubctl` or `sudo port install uhubctl`
|
||||
- :warning: MacOS 26+ requires [fix](https://github.com/libusb/libusb/pull/1700).
|
||||
Until libusb version 1.0.30 with this fix is released, install libusb from master:
|
||||
|
||||
brew uninstall libusb --ignore-dependencies
|
||||
brew install libusb --head
|
||||
* Ubuntu/Debian/Raspbian: `sudo apt install uhubctl`
|
||||
* Redhat/EPEL/Fedora/CentOS: `sudo yum install uhubctl`
|
||||
* OpenSUSE: `sudo zypper install uhubctl`
|
||||
* FreeBSD: `cd /usr/ports/sysutils/uhubctl && sudo make install`
|
||||
|
||||
However, uhubctl installed from standard package manager may not
|
||||
necessarily be latest version, or even severely lag behind current version.
|
||||
@@ -252,23 +265,23 @@ To fix USB permissions, first run `sudo uhubctl` and note all `vid:pid` for hubs
|
||||
Then, add udev rules like below to file `/etc/udev/rules.d/52-usb.rules`
|
||||
(replace `2001` with your hub vendor id, or completely remove `ATTR{idVendor}` filter to allow any USB hub access):
|
||||
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", MODE="0666", ATTR{idVendor}=="2001"
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", MODE="0666", ATTR{idVendor}=="2001"
|
||||
# Linux 6.0 or later (its ok to have this block present for older Linux kernels):
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", \
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", \
|
||||
RUN="/bin/sh -c \"chmod -f 666 $sys$devpath/*port*/disable || true\""
|
||||
|
||||
Note that for USB3 hubs, some hubs use different vendor ID for USB2 vs USB3 components of the same chip,
|
||||
and both need permissions to make uhubctl work properly.
|
||||
E.g. for Raspberry Pi 4B, you need to add these 2 lines (or remove idVendor filter):
|
||||
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", MODE="0666", ATTR{idVendor}=="2109"
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", MODE="0666", ATTR{idVendor}=="1d6b"
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", MODE="0666", ATTR{idVendor}=="2109"
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", MODE="0666", ATTR{idVendor}=="1d6b"
|
||||
|
||||
If you don't like wide open mode `0666`, you can restrict access by group like this:
|
||||
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", MODE="0664", GROUP="dialout"
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", MODE="0664", GROUP="dialout"
|
||||
# Linux 6.0 or later (its ok to have this block present for older Linux kernels):
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", \
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", \
|
||||
RUN+="/bin/sh -c \"chown -f root:dialout $sys$devpath/*port*/disable || true\"" \
|
||||
RUN+="/bin/sh -c \"chmod -f 660 $sys$devpath/*port*/disable || true\""
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
# sudo usermod -a -G dialout $USER
|
||||
|
||||
# This is for Linux before 6.0:
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", MODE="0664", GROUP="dialout"
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", MODE="0664", GROUP="dialout"
|
||||
|
||||
# This is for Linux 6.0 or later (ok to keep this block present for older Linux kernels):
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", \
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", \
|
||||
RUN+="/bin/sh -c \"chown -f root:dialout $sys$devpath/*port*/disable || true\"" \
|
||||
RUN+="/bin/sh -c \"chmod -f 660 $sys$devpath/*port*/disable || true\""
|
||||
|
||||
127
uhubctl.c
127
uhubctl.c
@@ -11,7 +11,6 @@
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -224,7 +223,6 @@ static int opt_level = 0; /* Hub location level (e.g., a-b is level
|
||||
static int opt_ports = ALL_HUB_PORTS; /* Bitmask of ports to operate on */
|
||||
static int opt_action = POWER_KEEP;
|
||||
static double opt_delay = 2;
|
||||
static int opt_quiet = 0; /* quiet operation if set */
|
||||
static int opt_repeat = 1;
|
||||
static int opt_wait = 20; /* wait before repeating in ms */
|
||||
static int opt_exact = 0; /* exact location match - disable USB3 duality handling */
|
||||
@@ -243,7 +241,7 @@ static int is_rpi_4b = 0;
|
||||
static int is_rpi_5 = 0;
|
||||
|
||||
static const char short_options[] =
|
||||
"l:L:n:a:p:d:r:w:s:H:qhvefRN"
|
||||
"l:L:n:a:p:d:r:w:s:H:hvefRN"
|
||||
#if defined(__linux__)
|
||||
"S"
|
||||
#if (LIBUSB_API_VERSION >= 0x01000107) /* 1.0.23 */
|
||||
@@ -265,7 +263,6 @@ static const struct option long_options[] = {
|
||||
{ "wait", required_argument, NULL, 'w' },
|
||||
{ "exact", no_argument, NULL, 'e' },
|
||||
{ "force", no_argument, NULL, 'f' },
|
||||
{ "quiet", no_argument, NULL, 'q' },
|
||||
{ "nodesc", no_argument, NULL, 'N' },
|
||||
#if defined(__linux__)
|
||||
{ "nosysfs", no_argument, NULL, 'S' },
|
||||
@@ -299,7 +296,6 @@ static int print_usage(void)
|
||||
"--repeat, -r - repeat power off count [%d] (some devices need it to turn off).\n"
|
||||
"--exact, -e - exact location (no USB3 duality handling).\n"
|
||||
"--force, -f - force operation even on unsupported hubs.\n"
|
||||
"--quiet, -q - quiet operation, most output is suppressed.\n"
|
||||
"--nodesc, -N - do not query device description (helpful for unresponsive devices).\n"
|
||||
#if defined(__linux__)
|
||||
"--nosysfs, -S - do not use the Linux sysfs port disable interface.\n"
|
||||
@@ -388,20 +384,6 @@ static int ports2bitmap(char* const portlist)
|
||||
return ports;
|
||||
}
|
||||
|
||||
|
||||
/* Standard printf but gated by quiet option */
|
||||
|
||||
int qprintf(const char *format, ...) {
|
||||
int count = 0;
|
||||
if (!opt_quiet) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
count = vprintf(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get model of the computer we are currently running on.
|
||||
* On success return 0 and fill model string (null terminated).
|
||||
@@ -414,15 +396,39 @@ int qprintf(const char *format, ...) {
|
||||
static int get_computer_model(char *model, int len)
|
||||
{
|
||||
int fd = open("/sys/firmware/devicetree/base/model", O_RDONLY);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
if (fd >= 0) {
|
||||
int bytes_read = read(fd, model, len-1);
|
||||
close(fd);
|
||||
if (bytes_read < 0) {
|
||||
return -1;
|
||||
}
|
||||
model[bytes_read] = 0;
|
||||
} else {
|
||||
// devicetree is not available, try parsing /proc/cpuinfo instead.
|
||||
// most Raspberry Pi have /proc/cpuinfo about 1KB, so 4KB buffer should be plenty:
|
||||
char buffer[4096] = {0}; // fill buffer with all zeros
|
||||
fd = open("/proc/cpuinfo", O_RDONLY);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
int bytes_read = read(fd, buffer, sizeof(buffer)-1);
|
||||
close(fd);
|
||||
if (bytes_read < 0) {
|
||||
return -1;
|
||||
}
|
||||
buffer[bytes_read] = 0;
|
||||
char* model_start = strstr(buffer, "Model\t\t: ");
|
||||
if (model_start == NULL) {
|
||||
return -1;
|
||||
}
|
||||
char* model_name = model_start + 9;
|
||||
char* newline_pos = strchr(model_name, '\n');
|
||||
if (newline_pos != NULL) {
|
||||
*newline_pos = 0;
|
||||
}
|
||||
strncpy(model, model_name, len);
|
||||
model[len-1] = 0;
|
||||
}
|
||||
int bytes_read = read(fd, model, len-1);
|
||||
close(fd);
|
||||
if (bytes_read < 0) {
|
||||
return -1;
|
||||
}
|
||||
model[bytes_read] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -848,7 +854,7 @@ static int print_port_status(struct hub_info * hub, int portmask)
|
||||
break;
|
||||
}
|
||||
|
||||
qprintf(" Port %d: %04x", port, port_status);
|
||||
printf(" Port %d: %04x", port, port_status);
|
||||
|
||||
struct descriptor_strings ds;
|
||||
memset(&ds, 0, sizeof(ds));
|
||||
@@ -874,48 +880,48 @@ static int print_port_status(struct hub_info * hub, int portmask)
|
||||
|
||||
if (!hub->super_speed) {
|
||||
if (port_status == 0) {
|
||||
qprintf(" off");
|
||||
printf(" off");
|
||||
} else {
|
||||
if (port_status & USB_PORT_STAT_POWER) qprintf(" power");
|
||||
if (port_status & USB_PORT_STAT_INDICATOR) qprintf(" indicator");
|
||||
if (port_status & USB_PORT_STAT_TEST) qprintf(" test");
|
||||
if (port_status & USB_PORT_STAT_HIGH_SPEED) qprintf(" highspeed");
|
||||
if (port_status & USB_PORT_STAT_LOW_SPEED) qprintf(" lowspeed");
|
||||
if (port_status & USB_PORT_STAT_SUSPEND) qprintf(" suspend");
|
||||
if (port_status & USB_PORT_STAT_POWER) printf(" power");
|
||||
if (port_status & USB_PORT_STAT_INDICATOR) printf(" indicator");
|
||||
if (port_status & USB_PORT_STAT_TEST) printf(" test");
|
||||
if (port_status & USB_PORT_STAT_HIGH_SPEED) printf(" highspeed");
|
||||
if (port_status & USB_PORT_STAT_LOW_SPEED) printf(" lowspeed");
|
||||
if (port_status & USB_PORT_STAT_SUSPEND) printf(" suspend");
|
||||
}
|
||||
} else {
|
||||
if (!(port_status & USB_SS_PORT_STAT_POWER)) {
|
||||
printf(" off");
|
||||
} else {
|
||||
int link_state = port_status & USB_PORT_STAT_LINK_STATE;
|
||||
if (port_status & USB_SS_PORT_STAT_POWER) qprintf(" power");
|
||||
if (port_status & USB_SS_PORT_STAT_POWER) printf(" power");
|
||||
if ((port_status & USB_SS_PORT_STAT_SPEED)
|
||||
== USB_PORT_STAT_SPEED_5GBPS)
|
||||
{
|
||||
printf(" 5gbps");
|
||||
}
|
||||
if (link_state == USB_SS_PORT_LS_U0) qprintf(" U0");
|
||||
if (link_state == USB_SS_PORT_LS_U1) qprintf(" U1");
|
||||
if (link_state == USB_SS_PORT_LS_U2) qprintf(" U2");
|
||||
if (link_state == USB_SS_PORT_LS_U3) qprintf(" U3");
|
||||
if (link_state == USB_SS_PORT_LS_SS_DISABLED) qprintf(" SS.Disabled");
|
||||
if (link_state == USB_SS_PORT_LS_RX_DETECT) qprintf(" Rx.Detect");
|
||||
if (link_state == USB_SS_PORT_LS_SS_INACTIVE) qprintf(" SS.Inactive");
|
||||
if (link_state == USB_SS_PORT_LS_POLLING) qprintf(" Polling");
|
||||
if (link_state == USB_SS_PORT_LS_RECOVERY) qprintf(" Recovery");
|
||||
if (link_state == USB_SS_PORT_LS_HOT_RESET) qprintf(" HotReset");
|
||||
if (link_state == USB_SS_PORT_LS_COMP_MOD) qprintf(" Compliance");
|
||||
if (link_state == USB_SS_PORT_LS_LOOPBACK) qprintf(" Loopback");
|
||||
if (link_state == USB_SS_PORT_LS_U0) printf(" U0");
|
||||
if (link_state == USB_SS_PORT_LS_U1) printf(" U1");
|
||||
if (link_state == USB_SS_PORT_LS_U2) printf(" U2");
|
||||
if (link_state == USB_SS_PORT_LS_U3) printf(" U3");
|
||||
if (link_state == USB_SS_PORT_LS_SS_DISABLED) printf(" SS.Disabled");
|
||||
if (link_state == USB_SS_PORT_LS_RX_DETECT) printf(" Rx.Detect");
|
||||
if (link_state == USB_SS_PORT_LS_SS_INACTIVE) printf(" SS.Inactive");
|
||||
if (link_state == USB_SS_PORT_LS_POLLING) printf(" Polling");
|
||||
if (link_state == USB_SS_PORT_LS_RECOVERY) printf(" Recovery");
|
||||
if (link_state == USB_SS_PORT_LS_HOT_RESET) printf(" HotReset");
|
||||
if (link_state == USB_SS_PORT_LS_COMP_MOD) printf(" Compliance");
|
||||
if (link_state == USB_SS_PORT_LS_LOOPBACK) printf(" Loopback");
|
||||
}
|
||||
}
|
||||
if (port_status & USB_PORT_STAT_RESET) qprintf(" reset");
|
||||
if (port_status & USB_PORT_STAT_OVERCURRENT) qprintf(" oc");
|
||||
if (port_status & USB_PORT_STAT_ENABLE) qprintf(" enable");
|
||||
if (port_status & USB_PORT_STAT_CONNECTION) qprintf(" connect");
|
||||
if (port_status & USB_PORT_STAT_RESET) printf(" reset");
|
||||
if (port_status & USB_PORT_STAT_OVERCURRENT) printf(" oc");
|
||||
if (port_status & USB_PORT_STAT_ENABLE) printf(" enable");
|
||||
if (port_status & USB_PORT_STAT_CONNECTION) printf(" connect");
|
||||
|
||||
if (port_status & USB_PORT_STAT_CONNECTION) qprintf(" [%s]", ds.description);
|
||||
if (port_status & USB_PORT_STAT_CONNECTION) printf(" [%s]", ds.description);
|
||||
|
||||
qprintf("\n");
|
||||
printf("\n");
|
||||
}
|
||||
libusb_close(devh);
|
||||
}
|
||||
@@ -1232,9 +1238,6 @@ int main(int argc, char *argv[])
|
||||
case 'R':
|
||||
opt_reset = 1;
|
||||
break;
|
||||
case 'q':
|
||||
opt_quiet = 1;
|
||||
break;
|
||||
case 'w':
|
||||
opt_wait = atoi(optarg);
|
||||
break;
|
||||
@@ -1344,7 +1347,7 @@ int main(int argc, char *argv[])
|
||||
for (i=0; i<hub_count; i++) {
|
||||
if (hubs[i].actionable == 0)
|
||||
continue;
|
||||
qprintf("Current status for hub %s [%s]\n",
|
||||
printf("Current status for hub %s [%s]\n",
|
||||
hubs[i].location, hubs[i].ds.description
|
||||
);
|
||||
print_port_status(&hubs[i], opt_ports);
|
||||
@@ -1381,19 +1384,19 @@ int main(int argc, char *argv[])
|
||||
/* USB3 hubs need extra delay to actually turn off: */
|
||||
if (k==0 && hubs[i].super_speed)
|
||||
sleep_ms(150);
|
||||
qprintf("Sent power %s request\n", should_be_on ? "on" : "off");
|
||||
qprintf("New status for hub %s [%s]\n",
|
||||
printf("Sent power %s request\n", should_be_on ? "on" : "off");
|
||||
printf("New status for hub %s [%s]\n",
|
||||
hubs[i].location, hubs[i].ds.description
|
||||
);
|
||||
print_port_status(&hubs[i], opt_ports);
|
||||
|
||||
if (k == 1 && opt_reset == 1) {
|
||||
qprintf("Resetting hub...\n");
|
||||
printf("Resetting hub...\n");
|
||||
rc = libusb_reset_device(devh);
|
||||
if (rc < 0) {
|
||||
perror("Reset failed!\n");
|
||||
} else {
|
||||
qprintf("Reset successful!\n");
|
||||
printf("Reset successful!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user