I was wondering if it could be possible to control the power of usb ports in Python, using vendor ids and product ids. It should be controlling powers instead of just enabling and disabling the ports. It would be appreciated if you could provide some examples.
Control the power of a usb port in Python
11.5k views Asked by Anthony AtThere are 2 answers
Orsiris de Jong
On
So far I came to the conclusion that you cannot control the power of a USB port. The 5V USB is always provided, and it's up to the device to use it or not. You can check this with a 5V fan or light. I've tried various methods (disconnect/reconnect/bind/unbind/reset). Best so far are bind/unbind as it forces a cold restart of the device (but no power cycle).
I came up with a solution to reset USB devices, ports and controllers in a python script, which supports all of the above methods. You can find the script at my Github page
Usage:
usb_reset.py -d 8086:1001 --reset-hub
The script uses among others the following solution to reset USB hubs/controllers:
Unbindind a USB port / controller works best via:
echo "myhub" > "/sys/bus/usb/drivers/usb/unbind"
echo "myhub" > "/sys/bus/usb/drivers/usb/bind"
Where myhub is found in /sys/bus/usb/devices/*
Or litteral controllers:
echo "mycontroller" > "/sys/bus/pci/drivers/unbind"
echo "mycontroller" > "/sys/bus/pci/drivers/bind"
Where mycontroller is found in /sys/bus/pci/drivers/[uoex]hci_hcd/*:*
Related Questions in PYTHON
- new thread blocks main thread
- Extracting viewCount & SubscriberCount from YouTube API V3 for a given channel, where channelID does not equal userID
- Display images on Django Template Site
- Difference between list() and dict() with generators
- How can I serialize a numpy array while preserving matrix dimensions?
- Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
- Why is my program adding int as string (4+7 = 47)?
- store numpy array in mysql
- how to omit the less frequent words from a dictionary in python?
- Update a text file with ( new words+ \n ) after the words is appended into a list
- python how to write list of lists to file
- Removing URL features from tokens in NLTK
- Optimizing for Social Leaderboards
- Python : Get size of string in bytes
- What is the code of the sorted function?
Related Questions in USB
- How to disable battery charging during ADB connection?
- USB to Serial, Port Name Changing Unexpectedly
- USB programming, transfer file from iOS device to Embedded os device?
- USB Full Speed polling interval
- Is it possible to limit data traffic in kernel USB drivers?
- communicationg to device using cdc usb protocol in c# windows application
- Shell file that finds a flash drive on my Raspberry Pi and executes a given program
- USB on board switching tools on Android 4.2.2
- Garmin USB driver grmnusb not compatible with chrome USB API on Windows
- STM32 USB HID reports
- Arduino Serial Monitor shows strange ASCII characters
- execute application mac os yosemite 10.10.3 when plugged in usb
- ISO/IEC 7816 commands over CCID
- How to start process on Linux OS in C, C++
- Install Android app on device through wifi - no usb or emulator
Related Questions in PORT
- C# FTP server never receives incoming transfer connection after processing EPRT command
- How to set 3306 port free after uninstalling MySQL?
- List all VM's by their port mirroring settings PowerShell
- How to make Puppet track TCP ports to avoid conflicts?
- Automatically forward ports from clients
- How to find port number of network connected device?
- Tcp Port connection shows incompatible value
- What are the port i can use to send email in java?
- Epson POS printer, ePOS Sdk. What's the default port?
- How to fix Tomcat has failed to start: the port X is already in used?
- Reference web projects from other web projects in solution
- How to run tomcat7 web app through https over port 8443?
- See data that an app is secretly sending to web server in the background
- The requested address is not valid in its context when I try to listen a port
- Send a open port request to router
Related Questions in LIBUSB
- Windows application using libusb: runtime error due to mutex lock
- Persistent error coming from libusb0
- Is it possible to transfer a file to USB device using libusb?
- libusb_open_device_with_vid_pid always return null
- Libusb Error:failed to set Configuration
- Why Does `libusb_bulk_transfer' Return 0?
- Finding the details of the single USB device plugged using java
- on windows 7/8, how to read usb device descriptor from a usb camera, and read picture stream with webcam meanwhile
- Libusb matching USB vendor id/product id with path in linux
- Mapping from locale to USB LANGID
- Transferring data from STM32F407 to libusb through USB CDC class
- libusb: error [op_open] getcap failed in C++ on Linux
- Why is libusb 1.0.9 still a very popular download on SourceForge?
- STM32F4 Discovery USB in HS mode?
- Android L 5.0 & libusb 1.0.9 - no permissions?
Related Questions in PYUSB
- Persistent error coming from libusb0
- What dependencies do I need for USB programing in python with pyUSB?
- Reading data from multiple usbs using threads in python
- PyUSB backend not accessible
- Can't read usb string descriptor with libusb because of permissions
- PyUSB trouble with windows
- Python : PyUSB can't access usb device
- Problems with PyUSB in Python 2.7. Do I need LibUSB driver?
- pyusb: NotImplementedError: Operation not supported or unimplemented on this platform
- Communication via PyUSB to Agilent E4980A
- NotImplementedError using pyusb on Windows10
- Control the power of a usb port in Python
- How to get the capacity of a usb pendrive?
- Trouble reading data from USB device using Python
- Communication with a stepper motor controller through a USB COM?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Look into the subprocess module in the standard library:
What commands you need will depend on the OS.
Windows
For windows you will want to look into devcon
This has been answered in previous posts
Linux
See posts on shell comands