https://github.com/codazoda/hub-ctrl.c Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Customer Stories + White papers, Ebooks, Webinars + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} codazoda / hub-ctrl.c Public * Notifications * Fork 84 * Star 299 Control USB power on a port by port basis on some USB hubs. 299 stars 84 forks Activity Star Notifications * Code * Issues 1 * Pull requests 0 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights codazoda/hub-ctrl.c This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/c] Use Git or checkout with SVN using the web URL. [gh repo clone codazo] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @codazoda codazoda Add a missing word in the readme ... 3ff63e4 Mar 7, 2022 Add a missing word in the readme 3ff63e4 Git stats * 24 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time Makefile Add Makefile October 10, 2017 16:28 README.md Add a missing word in the readme March 7, 2022 16:27 hub-ctrl.c Initial commit. January 31, 2014 07:09 View code hub-ctrl.c Prerequisites Compiling Controlling Power Hubs Known to Work Original Copyright README.md 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). About Control USB power on a port by port basis on some USB hubs. Resources Readme Activity Stars 299 stars Watchers 17 watching Forks 84 forks Report repository Releases No releases published Packages 0 No packages published Contributors 6 * @codazoda * @silum * @alokmenghrajani * @dspinellis * @oligu * @runderwo Languages * C 97.9% * Makefile 2.1% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time.