Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Library for interacting with Controller Area Network (CAN)

Project description

CANard is a library for dealing with Controller Area Network (CAN) data from Python.

Using a CANtact

The CANtact tool is directly supported by CANard. Using it requires pySerial, which can be installed with pip:

pip install pyserial


This examples goes on bus and prints received messages:

from canard import can
from canard.hw import cantact

dev = cantact.CantactDev("/dev/cu.usbmodem14511")

while True:

You will need to set the serial port (/dev/cu.usbmodem14511 in this example) correctly.

Using Peak CAN Tools

Peak CAN tools (also known as GridConnect) are support through SocketCAN. This functionality is only available on Linux

For kernels 3.6 and newer, skip to step 5.

  1. Download the Peak Linux driver.

  2. Install dependancies:

    sudo apt-get install libpopt-dev
  3. Build the driver:

    cd peak-linux-driver-x.xx
    sudo make install
  4. Enable the driver:

    sudo modprobe pcan
  5. Connect a Peak CAN tool, ensure it appears in /proc/pcan. Note the network device name (ie, can0)

  6. Bring the corresponding network up:

    sudo ifconfig can0 up


The device can now be accessed as a SocketCanDev. This examples goes on bus and prints received messages:

from canard import can
from canard.hw import socketcan

dev = socketcan.SocketCanDev("can0")

while True:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for CANard, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size CANard-0.2.2.tar.gz (8.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page