• Stars
    star
    353
  • Rank 119,904 (Top 3 %)
  • Language
    C
  • Created over 10 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Control USB power on a port by port basis on some USB hubs.

hub-ctrl.c

Control USB power on a port by port basis on some USB hubs.

Originally created by NIIBE Yutaka and published to Github by Joel Dare on January 31st, 2013.

This only works on USB hubs that have the hardware necessary to allow software controlled power switching. Most hubs DO NOT include the hardware.

Prerequisites

Before compiling it, you'll need to install libusb-dev (under Ubuntu). I installed that with the following command.

sudo apt-get install libusb-dev

You'll also need the GCC tool chain.

Compiling

To compile the hub-ctrl.c program run the following compile command.

gcc -o hub-ctrl hub-ctrl.c -lusb

That results in an executable binary called hub-ctrl.

Controlling Power

You can control the power on a port using the following command.

sudo ./hub-ctrl -h 3 -P 1 -p 0

That says to control hub 3 (-h 3) port 1 (-P 1) and to turn the power off (-p 0). You can also use ”-p 1” to turn the power back on.

You can also specify the USB device based on the BUS and DEV numbers. Use the following command the list the currently connected devices. It's useful to run this with the device disconnected and then again with the device connected so that you can tell which device is the one you are trying to target (the Targus in my case).

lsusb

Now that we know the BUS and DEV numbers, we can control the power using those numbers as well. Here's the command for that.

sudo ./hub-ctrl -b 001 -d 005 -P 1 -p 0

This time we are controlling the device on BUS 001 (-b 001) device 005 (-d 005) port 1 (-P 1) and turning the power off (-p 0).

Hubs Known to Work

The following is a list of Hubs that are known to have the hardware necessary to allow power switching.

  • D-Link-DUB-H7-High-Speed-7-Port (Tested with old Silver versions (A3, A4 & A5). Also tested with newer Black version C1 although there is one issue reporting that the C1 didn't work).
  • Elecom: U2H-G4S
  • Sanwa Supply: USB-HUB14GPH
  • Targus, Inc.: PAUH212
  • Hawking Technology: UH214
  • B+B SmartWorx (B&B Electronics): UHR204
  • B+B SmartWorx (B&B Electronics): USH304
  • Belkin: F5U701
  • Linksys: USB2HUB4

Original Copyright

Copyright (C) 2006 Free Software Initiative of Japan

Author: NIIBE Yutaka

This file can be distributed under the terms and conditions of the GNU General Public License version 2 (or later).

More Repositories

1

neatcss

Rapidly build efficient sites with Neat, the minimalist css framework.
HTML
604
star
2

nolific

A very simple web based note solution that's designed to serve as my second brain.
PHP
121
star
3

https-basic-auth-go

A template for using HTTP Basic Authentication in Go
Go
96
star
4

http-basic-auth-php

A template that does basic authentication in PHP
PHP
20
star
5

PHP-Pivotal-Tracker-Class

This is a simple class that
PHP
20
star
6

tomark

A Python module that converts a list of dictionaries to a markdown formatted table.
Python
16
star
7

ponder

A fast text scratchpad that saves your thoughts
CSS
8
star
8

hello-alexa

A minimalist "Hello World" skill for Alexa (Amazon Echo) written in PHP.
PHP
7
star
9

neatcss-examples

A set of example pages built using the Neat CSS Framework
HTML
7
star
10

mouse-highlighter

An extension for Google Chrome that highlights the mouse cursor.
JavaScript
5
star
11

git-button

An extension that ads a copy button to Pivotal stories giving you a pasteable git branch command.
JavaScript
4
star
12

random_riff

Randomly generates guitar riffs using standard scales such as the Pentatonic.
JavaScript
4
star
13

Bucketblog

Bucketblog is a simple photoblogging site that pulls it's images from the RSS feed of a Photobucket Album. It's written in PHP and is released under the MIT License.
PHP
3
star
14

mac-app-shell

A minimalist folder structure for a MacOS Application that is just a bash script and icon.
Shell
3
star
15

corkboard

Launch an informational site in minutes, on nearly any platform, and edit the contents with a text editor
JavaScript
3
star
16

x5

Return a list of cities that are within a specific distance based on zip code.
PHP
2
star
17

cgi-lib

A FREE ANSI C library for CGI programming.
C
2
star
18

calories

JavaScript
2
star
19

web-bots

A collection of very simple bots written in JavaScript.
JavaScript
2
star
20

iso

Isometric JavaScript Drawing Library
JavaScript
2
star
21

music_generator

A javascript library for random music generation.
JavaScript
2
star
22

goshell

A very simple app as a basis for an ssh shell (think bash or zsh) written in Go
Go
2
star
23

pwidget

An embeddable widget that displays search results from Pivotal Tracker projects.
PHP
1
star
24

globalprotectswitcher

Automatically start and stop GlobalProtect on a Mac based on your WiFi network
Rich Text Format
1
star
25

mobile_login

A login page with connection detection for turning mobile websites into apps in a web view.
HTML
1
star
26

notes

1
star
27

boiler

A command line tool that outputs common boilerplate templates
Go
1
star
28

sellit

A business sales website that is designed to be as simple as possible but functional enough to setup shop.
JavaScript
1
star
29

color_png

Dynamically returns a 10x10 PNG image using a hex value.
PHP
1
star
30

bbs-dns

A minimalist DNS server written in PHP.
PHP
1
star