Skip to main content

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

Example

This examples goes on bus and prints received messages:

from canard import can
from canard.hw import cantact

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

dev.start()
while True:
      print(dev.recv())

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
    make
    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

Example

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")

dev.start()
while True:
    print(dev.recv())

Project details


Download files

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

Source Distribution

CANard-0.1.3.tar.gz (6.8 kB view details)

Uploaded Source

File details

Details for the file CANard-0.1.3.tar.gz.

File metadata

  • Download URL: CANard-0.1.3.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for CANard-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c57a480b80e26fe1bfc0cde30f1578a0cc74a8e3af57c82276ecb29ae40aad5a
MD5 c0c8ba41ac70ae2abf2a172856dd1287
BLAKE2b-256 a7cf7762437e845c61bead56fd7261020086e256dcb96f1a40812db1d36fb6b8

See more details on using hashes here.

Supported by

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