Skip to main content

python-can-gs-usb-fd

A python-can interface for CAN FD over gs_usb devices: the tricore-debug-machine probe (USB 1d50:606f) and other gs_usb devices that advertise CAN FD.

Installing the package registers the interface gs_usb_fd with python-can (entry point group can.interface). Code only needs import can, and every python-can tool (can.logger, can.viewer, can.player, ...) can use it.

Why not python-can's gs_usb interface? It does classic CAN only: no FD mode, no data-phase bit timing, and a fixed 87.5 % sample point. On a CAN FD network, a controller in classic mode error-frames every FD frame. The probe's firmware runs FDCAN with protocol exception handling off, so it would do exactly that.

Installation

pip install git+https://github.com/1atabey1/gs_usb_fd
# or, in a uv project:
uv add git+https://github.com/1atabey1/gs_usb_fd

Windows

The device needs WinUSB on its gs_usb interface. The probe gets WinUSB automatically through MS OS 2.0 descriptors, so no driver install is needed.

The interface opens only the gs_usb interface it uses, directly through winusb.dll (found by candleLight's DeviceInterfaceGUID {c15b4308-04d3-11e6-b3ea-6057189e6443}). libusb would open the whole composite device instead, and WinUSB gives out one handle per interface, so a CAN program would lock every other program out of the probe's GDB, DAP and trace interfaces. Devices without that GUID (other drivers) fall back to libusb. GS_USB_FD_BACKEND=libusb forces libusb.

libusb-1.0 comes from the libusb-package dependency. Do not install libusb-win32: pyusb would fall back to its libusb0.dll, which cannot see WinUSB devices, and its filter driver can hang Windows device management.

Linux

pyusb and libusb-1.0. The kernel's gs_usb driver binds a probe's interface 0 (can0/can1); opening a bus here detaches it from the interface (until the probe is plugged in again). Your user needs access to the device node (the probe's udev rule).

Configuration

The interface is always "gs_usb_fd". The channel is "SERIAL@N", or just N for the first device found. Channels are 0-based, as the device numbers them. On the probe, 0 is CAN1 (J4) and 1 is CAN2 (J5).

A device can have several gs_usb interfaces. Channels are then counted across them in interface order, so channel numbers do not depend on the layout. The probe has two USB layouts (tdm_dap.py usb-mode):

Layout gs_usb interfaces Channel 0 Channel 1
combined (default) 0 (2 channels) interface 0, channel 0 interface 0, channel 1
split 0 and 4 (1 channel each) interface 0 interface 4

In split two programs can each have one channel. In combined the program that opens the first channel holds both. An interface another program holds cannot be asked for its channel count, so it counts as one channel.

configs = can.detect_available_configs(interfaces=["gs_usb_fd"])
# [{'interface': 'gs_usb_fd', 'channel': '290023001551333034363238@0'},
#  {'interface': 'gs_usb_fd', 'channel': '290023001551333034363238@1'}]

Detection opens each gs_usb interface briefly, so channels on an interface that another process has open are skipped.

Opening a bus

import can

with can.Bus(interface="gs_usb_fd", channel=0, bitrate=1_000_000, data_bitrate=5_000_000) as bus:
    bus.send(can.Message(arbitration_id=0x123, data=bytes(64), is_fd=True, bitrate_switch=True))
    print(bus.recv(timeout=1.0))

Bit timing

bitrate (plus data_bitrate for CAN FD) uses an 80 % sample point; sample_point and data_sample_point change it. For full control, pass timing: a can.BitTimingFd for CAN FD or a can.BitTiming for classic CAN. The probe's CAN clock is 80 MHz. A timing made for another clock is rescaled if it divides evenly, otherwise it is refused.

timing = can.BitTimingFd(f_clock=80_000_000,
                         nom_brp=5, nom_tseg1=12, nom_tseg2=3, nom_sjw=3,   # 1 Mbit/s, 81.25 %
                         data_brp=2, data_tseg1=5, data_tseg2=2, data_sjw=2)  # 5 Mbit/s, 75 %
with can.Bus(interface="gs_usb_fd", channel="290023001551333034363238@0", timing=timing) as bus:
    ...

Without data_bitrate and with a can.BitTiming, the channel runs classic CAN, and sending an FD frame raises CanOperationError.

Modes

Argument Effect
listen_only=True Never drives the bus: no ACK, no error frames, no TX (FDCAN bus monitoring). Safe on a live network.
loopback=True Internal loopback: TX frames come back as RX and the bus is not touched.
one_shot=True No automatic retransmission.
error_frames=True Bus-error reporting on; error frames arrive with is_error_frame, with arbitration_id/data in the SocketCAN error-frame format (linux/can/error.h). Off by default, and error frames are dropped.
receive_own_messages=True The device's TX confirmations are delivered too (is_rx False).
hw_timestamps=False Host receive time instead of the device's microsecond timestamps (default: device time, anchored to the host clock and unwrapped).

Several channels

Both channels of a device can be open at once, in one process. Channels on the same gs_usb interface share one USB connection and one reader thread that routes frames by channel. With the probe in its split layout, each channel can also go to a different process.

with (can.Bus(interface="gs_usb_fd", channel=0, timing=timing) as can1,
      can.Bus(interface="gs_usb_fd", channel=1, timing=timing) as can2):
    ...

Filters, state

can_filters are applied in software (the device has no hardware filters). bus.state reads the controller state: ACTIVE (error-active or warning), PASSIVE or ERROR (bus-off). bus.error_counters() returns (state, rx_errors, tx_errors).

Command line

gs-usb-fd detect
gs-usb-fd listen   --channel 0 --seconds 3     # listen-only dump, never drives the bus
gs-usb-fd loopback --channel 0                 # internal loopback self-test

Both default to 1 Mbit/s / 5 Mbit/s (brp/tseg1/tseg2/sjw 5/12/3/3 and 2/5/2/2 at 80 MHz). Use --bitrate/--data-bitrate or --nom/--data to change it.

Tests

uv run --extra test pytest                                # a fake device, no hardware
GS_USB_FD_HW=1 uv run --extra test pytest -m hardware     # on a probe: loopback and listen-only only

Protocol

The Linux gs_usb host format with CAN FD (drivers/net/can/usb/gs_usb.c, candleLight_fw). The probe's side is sw/Appli/usb/gs_usb.c in the tricore-debug-machine firmware: BT_CONST_EXT, DATA_BITTIMING, frames of a 12-byte header plus 8 or 64 data bytes plus a 32-bit timestamp, and one frame per USB transfer.

Metadata

Release files for python-can-gs-usb-fd 0.2.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 python-can-gs-usb-fd 0.2.0
File Size Uploaded Provenance Actions
python_can_gs_usb_fd-0.2.0.tar.gz 22.3 kB With provenance Details for python_can_gs_usb_fd-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-can-gs-usb-fd 0.2.0
File Interpreter ABI Platform Actions
python_can_gs_usb_fd-0.2.0-py3-none-any.whl Python 3 none any Details for python_can_gs_usb_fd-0.2.0-py3-none-any.whl

Total release size: 47.7 kB

Release files / python_can_gs_usb_fd-0.2.0.tar.gz

Download URL python_can_gs_usb_fd-0.2.0.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
143d0491d809bb5868a92e438f42ccebbbaf8247365a4326dd34551105165598
BLAKE2b-256 checksum
How to use checksums
4b6b09a6e53b1a71524ef8ebd5d66b3d7f8608cf60a18ea284dd22ba070eaa9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / python_can_gs_usb_fd-0.2.0-py3-none-any.whl

Download URL python_can_gs_usb_fd-0.2.0-py3-none-any.whl
Size 25.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55eb93d84e29ce935f7f26c328c014205bf045f783ffcad2bc6a776aac70970c
BLAKE2b-256 checksum
How to use checksums
70da82c3c49d5c4628d98d3a4ae7c781443e615d9a3b743bd52177a4940775ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Security for python-can-gs-usb-fd 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for python_can_gs_usb_fd-0.2.0.tar.gz

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 Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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