Skip to main content

Controller Area Network interface module for Python

Project description

Latest Version on PyPi Supported Python implementations Downloads on PePy Monthly downloads on PePy This project uses the black formatter.

Documentation Github Actions workflow status Travis CI Server for develop branch Test coverage reports on Codecov.io Mergify Status

The Controller Area Network is a bus standard designed to allow microcontrollers and devices to communicate with each other. It has priority based bus arbitration and reliable deterministic communication. It is used in cars, trucks, boats, wheelchairs and more.

The can package provides controller area network support for Python developers; providing common abstractions to different hardware devices, and a suite of utilities for sending and receiving messages on a can bus.

The library currently supports CPython as well as PyPy and runs on Mac, Linux and Windows.

Library Version

Python

2.x

2.6+, 3.4+

3.x

2.7+, 3.5+

4.x (currently on develop)

3.7+

Features

  • common abstractions for CAN communication

  • support for many different backends (see the docs)

  • receiving, sending, and periodically sending messages

  • normal and extended arbitration IDs

  • CAN FD support

  • many different loggers and readers supporting playback: ASC (CANalyzer format), BLF (Binary Logging Format by Vector), CSV, SQLite and Canutils log

  • efficient in-kernel or in-hardware filtering of messages on supported interfaces

  • bus configuration reading from a file or from environment variables

  • command line tools for working with CAN buses (see the docs)

  • more

Example usage

# import the library
import can

# create a bus instance
# many other interfaces are supported as well (see documentation)
bus = can.Bus(interface='socketcan',
              channel='vcan0',
              receive_own_messages=True)

# send a message
message = can.Message(arbitration_id=123, is_extended_id=True,
                      data=[0x11, 0x22, 0x33])
bus.send(message, timeout=0.2)

# iterate over received messages
for msg in bus:
    print(f"{msg.arbitration_id:X}: {msg.data}")

# or use an asynchronous notifier
notifier = can.Notifier(bus, [can.Logger("recorded.log"), can.Printer()])

You can find more information in the documentation, online at python-can.readthedocs.org.

Discussion

If you run into bugs, you can file them in our issue tracker on GitHub.

There is also a python-can mailing list for development discussion.

Stackoverflow has several questions and answers tagged with python+can.

Wherever we interact, we strive to follow the Python Community Code of Conduct.

Contributing

See doc/development.rst for getting started.

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

python-can-4.0.0.tar.gz (292.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

python_can-4.0.0-py3.9.egg (525.9 kB view details)

Uploaded Egg

python_can-4.0.0-py3.8.egg (526.1 kB view details)

Uploaded Egg

python_can-4.0.0-py3.7.egg (523.2 kB view details)

Uploaded Egg

python_can-4.0.0-py3-none-any.whl (235.8 kB view details)

Uploaded Python 3

File details

Details for the file python-can-4.0.0.tar.gz.

File metadata

  • Download URL: python-can-4.0.0.tar.gz
  • Upload date:
  • Size: 292.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for python-can-4.0.0.tar.gz
Algorithm Hash digest
SHA256 59d92846ffb981e634e9e0f2d14a6b4967a875e3869bd2ba168c92c4db6b8b5d
MD5 c8f91ec0856723eb41be012408870a9e
BLAKE2b-256 1ff7a643cba269d59e108fe4c1854a8e71d5cdadadd4de1b9c8862b190171122

See more details on using hashes here.

File details

Details for the file python_can-4.0.0-py3.9.egg.

File metadata

  • Download URL: python_can-4.0.0-py3.9.egg
  • Upload date:
  • Size: 525.9 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for python_can-4.0.0-py3.9.egg
Algorithm Hash digest
SHA256 60960b715462caabbdcebc3a6a2c573595f2bb58c11d68cd3c3ed402bf2d206d
MD5 893b617d03ec179513eeabfa5b33a642
BLAKE2b-256 a513f4da0c45889fc39c1e0a7d0b2e58c603a64b05cf7c6c40fa64e938d09aaa

See more details on using hashes here.

File details

Details for the file python_can-4.0.0-py3.8.egg.

File metadata

  • Download URL: python_can-4.0.0-py3.8.egg
  • Upload date:
  • Size: 526.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for python_can-4.0.0-py3.8.egg
Algorithm Hash digest
SHA256 6ab63254bdd0e14c8f18b2c55ed3810b3a6395790b28b778dd0112fb0a46e3ce
MD5 89c2b40655fe663cd62c9766c4c776d2
BLAKE2b-256 195cd28b9e275380fc378814080fa0dd2b51fce6cc20507e062d17634c24071e

See more details on using hashes here.

File details

Details for the file python_can-4.0.0-py3.7.egg.

File metadata

  • Download URL: python_can-4.0.0-py3.7.egg
  • Upload date:
  • Size: 523.2 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for python_can-4.0.0-py3.7.egg
Algorithm Hash digest
SHA256 82ed66094cd6d3d6fc0589bc67ca4090af121d7abad58d6754f86abad5e843b1
MD5 70c990007bb77af66548a2e748f62d30
BLAKE2b-256 e9336885c05b0b2aafacaef98a5798b385c524eabb19d8344e57dbf4963963b7

See more details on using hashes here.

File details

Details for the file python_can-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: python_can-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 235.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for python_can-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52ffc4f1bb9a585b9ecf53279451fe8266d934428993c580ccf72f9cb321a2e4
MD5 c577ae76843a055124590beb8283fd8d
BLAKE2b-256 d51fa045d41783476b72fea0f9db53dbd91bea65abf4dc585086ddb51244741f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page