Skip to main content

gsusb-canfd (Python)

Part of the gsusb-canfd project. Python implementation of the library: a userspace gs_usb CAN FD driver built directly on pyusb/libusb. It speaks the same wire protocol as the C++ library in this repository, so the two are interchangeable.

It does not depend on the gs_usb / python-can packages. Those assume the candleLight reference endpoints (OUT = 0x02) and only configure classic CAN timing, so they cannot talk to adapters that use different bulk endpoints or CAN FD data-phase timing through GS_USB_BREQ_BT_CONST_EXT / DATA_BITTIMING. This package handles both.

Install

pip install ./python

Requires libusb-1.0 at runtime (brew install libusb, apt install libusb-1.0-0-dev).

Use

from gsusb_canfd import BusConfig, CanFdBus, CanFrame

bus = CanFdBus()
with bus:
    bus.configure(BusConfig(bitrate=1_000_000, sample_point=0.80,
                            data_bitrate=5_000_000, data_sample_point=0.75,
                            fd=True))
    bus.send(CanFrame(id=0x501, data=bytes([0x00, 0x02, 0x50, 0x01]),
                      fd=True, brs=True))
    while True:
        frame = bus.receive(timeout=0.5)
        if frame and not frame.echo and frame.id == 0x481:
            print(frame)

Extended frames: set id > 0x7FF or CanFrame(extended=True).

Async receive (callback on a background thread):

bus.start(lambda frame: print(frame))
...
bus.stop()

Devices

from gsusb_canfd import scan_adapters

for i, adapter in enumerate(scan_adapters()):
    print(i, adapter.name(), f"{adapter.vendor_id:04X}:{adapter.product_id:04X}",
          adapter.serial)

Select one with a DeviceSelector (vid, pid, index, channel, serial, product). By default any gs_usb adapter is auto-discovered (known USB ids plus descriptor heuristics); pass explicit vid/pid to pin one. On devices with several CAN channels, channel selects which one (bus.channel_count() reports the count).

CLI

gsusb-canfd list

gsusb-canfd monitor --bitrate 1000000 --sample-point 0.80 \
                    --data-bitrate 5000000 --data-sample-point 0.75 \
                    --trigger --trigger-id 501 --trigger-data 00025001 \
                    --count 20

gsusb-canfd send --classic 123 1122334455667788

Tests

The protocol logic (bit timing, DLC mapping, frame codec) is pure Python and is covered by unit tests that need no hardware:

pip install -e './python[dev]'
pytest python/tests

Releasing

See PUBLISHING.md; the version lives in src/gsusb_canfd/_version.py.

Metadata

Release files for gsusb-canfd 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gsusb-canfd 0.1.0
File Size Uploaded
gsusb_canfd-0.1.0.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gsusb-canfd 0.1.0
File Interpreter ABI Platform
gsusb_canfd-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.3 kB

Release files / gsusb_canfd-0.1.0.tar.gz

Download URL gsusb_canfd-0.1.0.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2e9c7cb695b21cf0be0e6828c1497d74c8b4e1bbfdbcbab409f87934543e766e
BLAKE2b-256 checksum
How to use checksums
98f922d5d70e8b2887b39d99d3f0b8b98af40f0fec0718df40f910dd47708c41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release files / gsusb_canfd-0.1.0-py3-none-any.whl

Download URL gsusb_canfd-0.1.0-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bce6c2d00150c49a7a6e9bb8d0ff835e0ac61681578f8f72079170017abf71e
BLAKE2b-256 checksum
How to use checksums
cfbc26d3e0e515eaa74f04baa2afc182535d0944869596e25466e745e7fef8ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page