Python implementation of the cusb interface for managed USB hubs
Project description
pycusb
A python library for managed USB hubs that are usually operated by a command line tool called cusbi (Linux Intel), cusba (Linux Arm), cusbm (Mac), or CUSBC/CUSBCTL (Windows), e.g., hubs from the companies EXSYS and StarTech.
Usage
Usage as library
from cusb import CUsb
import time
# Example:
path_to_device = "/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_B0036Y2H-if00-port0"
port = 1
with CUsb(path_to_device) as hub:
hub.port_power_on(port, False)
time.sleep(1)
hub.port_power_on(port, True)
Usage as CLI tool
$ pycusb --help
CUSB Hub Control
This CLI tool is able to *set* or *get* the state of the managed USB hub. It
can *save* the current state as the default, so after a power loss, this state
will be restored. The hub can also be *reset*, or a *factory reset* can be
issued, resetting any stored state and/or set password.
If a password is required, it can be provided to all commands as an option. By
default the implementation uses "pass", which is the factory default. The *get*
command does not need the password to succeed.
Usage:
pycusb [options] get <port> PATH
pycusb [options] set <port> (on|off) PATH
pycusb [options] save PATH
pycusb [options] reset PATH
pycusb [options] factory_reset PATH
pycusb -h | --help
Arguments:
PATH Path to serial device file controlling the hub.
Options:
-p --password=<password> Password for the hub [default: pass].
--force Continue despite unknown firmware version. This may
have unknown consequences and could cause damage.
Example: switch off port 1 for 1 second
pycusb set 1 off /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_B0036Y2H-if00-port0
sleep 1
pycusb set 1 on /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_B0036Y2H-if00-port0
Installation
Installation as library
Add pycusb to your pyproject.toml:
[project]
dependencies = [
"pycusb",
]
Installation as CLI tool
Create and activate a virtual environment, then run
pip install pycusb
Development
Clone the repo, create and activate a virtual environment, then install dependencies with:
pip install -e '.[dev]'
Test with
pytest test/test.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycusb-0.3.1.tar.gz.
File metadata
- Download URL: pycusb-0.3.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bb6dfac1b794a0fc2f855f88fb04f9548d1e8e4c3bf80ddde83c371a40301df
|
|
| MD5 |
5ab86cccc5383c90ee1531af2ee502f2
|
|
| BLAKE2b-256 |
6ac887dc6423466a4049be39488ad336187849b32e27c2bd6304fadbc1de47c3
|
Provenance
The following attestation bundles were made for pycusb-0.3.1.tar.gz:
Publisher:
release.yaml on gschwaer/pycusb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycusb-0.3.1.tar.gz -
Subject digest:
4bb6dfac1b794a0fc2f855f88fb04f9548d1e8e4c3bf80ddde83c371a40301df - Sigstore transparency entry: 629785356
- Sigstore integration time:
-
Permalink:
gschwaer/pycusb@ce5c34647f196a487d72e12ffe815d7c1c63a73c -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/gschwaer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@ce5c34647f196a487d72e12ffe815d7c1c63a73c -
Trigger Event:
push
-
Statement type:
File details
Details for the file pycusb-0.3.1-py2.py3-none-any.whl.
File metadata
- Download URL: pycusb-0.3.1-py2.py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99f978fc69b67f84bcf84b323748bf8550ef99c064e890d6a78b8c042732b2c9
|
|
| MD5 |
6b27c7a3c7f9be418e7a80b2bc074a31
|
|
| BLAKE2b-256 |
335aa4955af10cef25f11353e79c0f30781a53548bc34516756bfbabb6e7539d
|
Provenance
The following attestation bundles were made for pycusb-0.3.1-py2.py3-none-any.whl:
Publisher:
release.yaml on gschwaer/pycusb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycusb-0.3.1-py2.py3-none-any.whl -
Subject digest:
99f978fc69b67f84bcf84b323748bf8550ef99c064e890d6a78b8c042732b2c9 - Sigstore transparency entry: 629785365
- Sigstore integration time:
-
Permalink:
gschwaer/pycusb@ce5c34647f196a487d72e12ffe815d7c1c63a73c -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/gschwaer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@ce5c34647f196a487d72e12ffe815d7c1c63a73c -
Trigger Event:
push
-
Statement type: