Coder Social home page Coder Social logo

canard's Introduction

CANard

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

canard's People

Contributors

ericevenchick avatar freebendy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.