Geschwister Schneider and candleLight

Windows/Linux/Mac CAN driver based on usbfs or WinUSB WCID for Geschwister Schneider USB/CAN devices and candleLight USB CAN interfaces.

Install: pip install "python-can[gs-usb]"

Usage: pass device index or channel (starting from 0) if using automatic device detection:

import can
import usb
dev = usb.core.find(idVendor=0x1D50, idProduct=0x606F)

bus = can.Bus(interface="gs_usb", channel=dev.product, index=0, bitrate=250000)
bus = can.Bus(interface="gs_usb", channel=0, bitrate=250000)  # same

Alternatively, pass bus and address to open a specific device. The parameters can be got by pyusb as shown below:

import usb
import can

dev = usb.core.find(idVendor=0x1D50, idProduct=0x606F)
bus = can.Bus(
    interface="gs_usb",
    channel=dev.product,
    bus=dev.bus,
    address=dev.address,
    bitrate=250000
)

Supported devices

Geschwister Schneider USB/CAN devices and bytewerk.org candleLight USB CAN interfaces such as candleLight, canable, cantact, etc.

Supported platform

Windows, Linux and Mac.

Note

The backend driver depends on pyusb so a pyusb backend driver library such as libusb must be installed.

On Windows, WinUSB and libusbK are both supported. Devices with WCID (Windows Compatible ID) descriptors, such as candleLight firmware, will automatically use WinUSB without any additional driver installation. Alternatively, a tool such as Zadig can be used to set the USB device driver to either WinUSB or libusbK.

Supplementary Info

The firmware implementation for Geschwister Schneider USB/CAN devices and candleLight USB CAN can be found in candle-usb/candleLight_fw. The Linux kernel driver can be found in linux/drivers/net/can/usb/gs_usb.c.

The gs_usb interface in python-can relies on upstream gs_usb package, which can be found in https://pypi.org/project/gs-usb/ or https://github.com/jxltom/gs_usb.

The gs_usb package uses pyusb as backend, which brings better cross-platform compatibility.

Note: The bitrate 10K, 20K, 50K, 83.333K, 100K, 125K, 250K, 500K, 800K and 1M are supported in this interface, as implemented in the upstream gs_usb package’s set_bitrate method.

Warning

Message filtering is not supported in Geschwister Schneider USB/CAN devices and bytewerk.org candleLight USB CAN interfaces.

Bus

class can.interfaces.gs_usb.GsUsbBus(channel, bitrate=500000, index=None, bus=None, address=None, can_filters=None, **kwargs)[source]
Parameters:
  • channel (int | str | Sequence[int]) – usb device name

  • index (int | None) – device number if using automatic scan, starting from 0. If specified, bus/address shall not be provided.

  • bus (int | None) – number of the bus that the device is connected to

  • address (int | None) – address of the device on the bus it is connected to

  • can_filters (Sequence[CanFilter] | None) – not supported

  • bitrate (int) – CAN network bandwidth (bits/s)

  • kwargs (Any)

send(msg, timeout=None)[source]

Transmit a message to the CAN bus.

Parameters:
  • msg (Message) – A message object.

  • timeout (float | None) – timeout is not supported. The function won’t return until message is sent or exception is raised.

Raises:

CanOperationError – if the message could not be sent

Return type:

None

shutdown()[source]

Called to carry out any interface specific cleanup required in shutting down a bus.

This method can be safely called multiple times.