CAN driver for Geschwister Schneider USB/CAN devices
Project description
python-can-candle
Full featured CAN driver for Geschwister Schneider USB/CAN devices.
Support Multichannel and CAN FD.
Installation
pip install python-can-candle
Example
Using with python-can
This library implements the plugin interface in python-can, aiming to replace the gs_usb interface within it.
import can
from candle import CandleBus
# Create a CandleBus instance in the python-can API.
with can.Bus(interface='candle', channel=0, ignore_config=True) as bus:
# Bus is an instance of CandleBus.
assert isinstance(bus, CandleBus)
Set ignore_config=True is recommended to prevent potential type casts.
Configurations
You can configure the device by appending the following parameters when creating the can.Bus.
- bitrate: int, defaults to 1000000
- sample_point: float, defaults to 87.5
- data_bitrate: int, defaults to 5000000
- data_sample_point: float, defaults to 87.5
- fd: bool, defaults to False
- loop_back: bool, defaults to False
- listen_only: bool, defaults to False
- triple_sample: bool, defaults to False
- one_shot: bool, defaults to False
- bit_error_reporting: bool, defaults to False
- termination: bool or None, defaults to None
For example, create a canfd device with 1M bitrate and 5M data bitrate.
with can.Bus(interface='candle', channel=0, fd=True, bitrate=1000000, data_bitrate=5000000, ignore_config=True) as bus:
...
Connect multiple devices
When connecting multiple devices at the same time, you can set channel to serial_number:channel to create the specified can.Bus.
with can.Bus(interface='candle', channel='208233AD5003:0', ignore_config=True) as bus:
...
You can also select devices by appending some additional parameters.
- vid: int, vendor ID
- pid: int, product ID
- manufacture: str, manufacture string
- product: str, product string
- serial_number: str, serial number
Device Discovery
Detect all available channels.
channels = can.detect_available_configs('candle')
print(channels)
Open multiple channels of a single device
This driver now supports opening multiple channels from the same device in a single CandleBus instance.
- Pass a list of channel indices belonging to the same device, e.g.
channel=[0, 1]. - For multiple devices, pass
serial_number=SERIALto select the device by serial number. - Configure each channel separately with
channel_configs.
Create a CandleBus instance with multiple channels.
bus = CandleBus(channel=[0, 1], serial_number='208233AD5003', bitrate=1000000)
Create and configure channels with different bitrates.
bus = CandleBus(channel=[0, 1], serial_number='208233AD5003', channel_configs={0: {'bitrate': 500000}, 1: {'bitrate': 1000000})
Send to a specific channel.
msg = can.Message(arbitration_id=0x100, channel=1, data=[0x1, 0x2, 0x3, 0x4])
bus.send(msg)
Send to multiple channels.
msg = can.Message(arbitration_id=0x100, channel=[0, 1], data=[0x1, 0x2, 0x3, 0x4])
bus.send(msg)
Distinguish channels in received messages.
msg = bus.recv()
print(f'Received message on channel {msg.channel}.')
Notes on multi-channel behavior
send()routes frames to the target channel based onmsg.channel(int,"SERIAL:idx", orSequence[int]).recv()returnsMessage.channelset to the source channel number.- When
msg.channelis not set,send()defaults to the first channel.
Performance
The communication layer is implemented based on pybind11 with libusb. You can run the following scripts to evaluate the performance.
For single-channel performance:
python -m candle.stress
For multi-channel performance:
python -m candle.stress_multichannel
Reference
Project details
Release history Release notifications | RSS feed
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 python_can_candle-1.2.4.tar.gz.
File metadata
- Download URL: python_can_candle-1.2.4.tar.gz
- Upload date:
- Size: 29.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5a1d016579045e596931fd5377102816d9f8e891586e07ac19458588f8a80f2
|
|
| MD5 |
54ccc5632eb2eb5600abe7aa6964bc6a
|
|
| BLAKE2b-256 |
c516afc489f64a7128dda1eb880ba245a7eb63c3ff9c336641d5550df7b501eb
|
Provenance
The following attestation bundles were made for python_can_candle-1.2.4.tar.gz:
Publisher:
publish-to-pypi.yml on BIRLab/python-can-candle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_can_candle-1.2.4.tar.gz -
Subject digest:
f5a1d016579045e596931fd5377102816d9f8e891586e07ac19458588f8a80f2 - Sigstore transparency entry: 1004880387
- Sigstore integration time:
-
Permalink:
BIRLab/python-can-candle@1045471694ec70d85bce28be943e27f2e0960373 -
Branch / Tag:
refs/tags/v1.2.4 - Owner: https://github.com/BIRLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@1045471694ec70d85bce28be943e27f2e0960373 -
Trigger Event:
push
-
Statement type:
File details
Details for the file python_can_candle-1.2.4-py3-none-any.whl.
File metadata
- Download URL: python_can_candle-1.2.4-py3-none-any.whl
- Upload date:
- Size: 26.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09cf2942b1e9139c27552788c7a2cea45c37c0ecfd48dbfa03b2d56fe626111b
|
|
| MD5 |
57359f952f3cd4369431dd3e754ab8c4
|
|
| BLAKE2b-256 |
79f48e115593d7e2013e97c88038c3f8fbfd1a8325ce91cc80892d6c7aa9b6f9
|
Provenance
The following attestation bundles were made for python_can_candle-1.2.4-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on BIRLab/python-can-candle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_can_candle-1.2.4-py3-none-any.whl -
Subject digest:
09cf2942b1e9139c27552788c7a2cea45c37c0ecfd48dbfa03b2d56fe626111b - Sigstore transparency entry: 1004880388
- Sigstore integration time:
-
Permalink:
BIRLab/python-can-candle@1045471694ec70d85bce28be943e27f2e0960373 -
Branch / Tag:
refs/tags/v1.2.4 - Owner: https://github.com/BIRLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@1045471694ec70d85bce28be943e27f2e0960373 -
Trigger Event:
push
-
Statement type: