Skip to content

python-CAN Development Guide

python-can is a cross-platform Python library that provides a concise CAN communication interface. KH-UCANFD_Linux SDK is fully compatible with python-can, allowing developers to rapidly develop CAN FD applications using Python.

Features

  • Cross-platform support (Linux, Windows, macOS)
  • Supports multiple CAN interfaces (SocketCAN, Kvaser, PCAN, etc.)
  • Concise API design, easy to get started
  • Rich examples and documentation

Installation

bash
pip install python-can

Quick Start

python
import can

# Create CAN bus interface
bus = can.interface.Bus(channel='can0', bustype='socketcan')

# Send frame
msg = can.Message(arbitration_id=0x123, data=[0x11, 0x22, 0x33, 0x44])
bus.send(msg)

# Receive frame
recv_msg = bus.recv(timeout=1.0)
if recv_msg:
    print(f"Received: {recv_msg}")

📚 Detailed Documentation: python-can Official Documentation

Driving Intelligent Connections, Empowering the Future