Skip to main content

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

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)

as CLI tool

$ pycusb --help
CUSB Hub Control

Usage:
  pycusb set <port> (on|off) PATH
  pycusb get <port> PATH
  pycusb save PATH
  pycusb reset PATH
  pycusb factory_reset PATH
  pycusb -h | --help

Arguments:
  PATH          Path to serial device file controlling the hub.

Options:
  -h --help     Show this help message.

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

as library

Add pycusb to your pyproject.toml:

[project]
dependencies = [
    "pycusb",
]

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

pycusb-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycusb-0.1.1-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pycusb-0.1.1.tar.gz.

File metadata

  • Download URL: pycusb-0.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pycusb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 352e07be184ed658560a912903a05a6a0f91d87f71f9800df60bf7749911c3d3
MD5 d30a3a37aa53855bc42f12bb91bf97f7
BLAKE2b-256 1ed3ef46d95cfc9f255fa54ef8c1874edb87dc4be52e09ccf70b697d9244b850

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycusb-0.1.1.tar.gz:

Publisher: release.yaml on gschwaer/pycusb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycusb-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pycusb-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pycusb-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 512310b101f451214183d75b06b11d14339c40d5acb02bd6767898d708caaa17
MD5 7cbc9fc0159a4cbec7ed17d6add7b0f2
BLAKE2b-256 9e06df927dd56dadceac1f2c8a243990a4653cb4c93b58c238d96524c3e92549

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycusb-0.1.1-py2.py3-none-any.whl:

Publisher: release.yaml on gschwaer/pycusb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page