Skip to content
The can package provides controller area network support for Python developers
Python Other
  1. Python 99.7%
  2. Other 0.3%
Branch: develop
Clone or download

Latest commit

zariiii9003 and christiansandberg add vector hardware config popup (#774)
Co-authored-by: zariiii9003 <zariiii9003@users.noreply.github.com>
Co-authored-by: Christian Sandberg <christiansandberg@users.noreply.github.com>
Latest commit f4c2cff Mar 28, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
can add vector hardware config popup (#774) Mar 28, 2020
doc Adding plugin support to can.io Reader/Writer (#783) Mar 2, 2020
examples Fix crc_send docstring Jan 29, 2020
scripts
test add vector hardware config popup (#774) Mar 28, 2020
.appveyor.yml Revert "install pywin32 on appveyor CI" Aug 6, 2019
.codecov.yml Change can.Message (#413) Sep 28, 2018
.gitignore add mypy deamon config to gitignore Aug 8, 2019
.pylintrc Enable pylint on Travis CI builds May 19, 2019
.pylintrc-wip fix problem with keyword-arg-before-vararg May 19, 2019
.travis.yml Bump Python 3.8 from dev version in Travis CI (#723) Nov 14, 2019
CHANGELOG.txt fix typo in changlog May 16, 2019
CONTRIBUTORS.txt Add myself to CONTRIBUTORS Jun 8, 2019
LICENSE.txt Use uniform line endings across repository (#419) Sep 21, 2018
MANIFEST.in Include all test scripts in manifest. (#526) Feb 27, 2019
README.rst Fix example usage (#739) Dec 23, 2019
requirements-lint.txt Bump mypy version in lint step to 0.740 Oct 24, 2019
setup.cfg remove universal wheel tag in setup.cfg May 19, 2019
setup.py Exclude all test packages, not just toplevel (#740) Dec 24, 2019
tox.ini Add a basic tox file to the repository (#599) May 19, 2019

README.rst

python-can

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

Documentation Travis CI Server for develop branch AppVeyor CI Server for develop branch Test coverage reports on Codecov.io

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 Python 3.6+ as well as PyPy 3 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.6+

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
  • limited 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 file or environment variables
  • CLI 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 below)
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("{:X}: {}".format(msg.arbitration_id, 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.

You can’t perform that action at this time.