Skip to main content

Controller Area Network interface module for Python

Project description

Latest Version Documentation Status CI Server

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, reliable deterministic communication. It is used in cars, trucks, wheelchairs and more. See wikipedia for more info.

This module provides controller area network support for Python.

Configuration File

In order to use this library a CAN interface needs to be specified. A method to do this is to create a configuration file called can.conf, ~/.canrc or can.ini.

The configuration file sets the default interface and channel:

[default]
interface = <the name of the interface to use>
channel = <the channel to use by default>

Interfaces

The interface available are:

kvaser

Kvaser’s CANLib SDK for Windows (also available on Linux)

socketcan

On linux the socketcan interface is exposed via either:

  • socketcan_ctypes

  • socketcan_native

serial

A text based interface. For example use over bluetooth with /dev/rfcomm0

pcan

Peak-System’s PCAN-Basic API.

Installation

GNU/Linux dependencies

Reasonably modern Linux Kernels (2.6.25 or newer) have an implementation of socketcan. This version of python-can will directly use socketcan if called with Python 3.3 or greater, otherwise that interface is used via ctypes.

Windows dependencies

Kvaser

To install python-can using the Kvaser CANLib SDK as the backend:

  1. Install the latest stable release of Python.

  2. Install Kvaser’s latest Windows CANLib drivers.

  3. Test that Kvaser’s own tools work to ensure the driver is properly installed and that the hardware is working.

PCAN

To use the PCAN-Basic API as the backend (which has only been tested with Python 2.7):

  1. Download the latest version of the PCAN-Basic API.

  2. Extract PCANBasic.dll from the Win32 subfolder of the archive or the x64 subfolder depending on whether you have a 32-bit or 64-bit installation of Python.

  3. Copy PCANBasic.dll into the working directory where you will be running your python script. There is probably a way to install the dll properly, but I’m not certain how to do that.

Note that PCANBasic API timestamps count seconds from system startup. To convert these to epoch times, the uptime library is used. If it is not available, the times are returned as number of seconds from system startup. To install the uptime library, run pip install uptime.

Install python-can

You may need to install pip and setuptools first.

Two options, install normally with:

python setup.py install

Or to do a “development” install of this package to your machine (this allows you to make changes locally or pull updates from the Mercurial repository and use them without having to reinstall):

python setup.py develop

On linux you will need sudo rights.

Documentation

The documentation for python-can has been generated with Sphinx they can be viewed online at python-can.readthedocs.org

Generation

With sphinx installed the documentation can be generated locally with:

python setup.py build_sphinx

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

python-can-1.4.3.tar.gz (62.6 kB view details)

Uploaded Source

Built Distribution

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

python_can-1.4.3-py3-none-any.whl (64.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python-can-1.4.3.tar.gz
  • Upload date:
  • Size: 62.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for python-can-1.4.3.tar.gz
Algorithm Hash digest
SHA256 2dcd32737cc39fbf39f41521146a9685f594942c99c6183bad7e3c404930198b
MD5 b9b556fe6f016c0a3b27cc67790cf821
BLAKE2b-256 29d6b29aa8513fa51e43688d74857047412408c5524c566553fec6e6d6eb23c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_can-1.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 191cc397dad18626270faff872acd4a36d8ca137fee16051f3f4b2af16629503
MD5 c7d4dda4a4aceee1671cbfbbc6dbf597
BLAKE2b-256 74eebce408f6e1ce1c97b379871b053f56333314ea4fedbc353ecaa6c3cf8df5

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