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.
Download the Peak Linux driver.
Install dependancies:
sudo apt-get install libpopt-dev
Build the driver:
cd peak-linux-driver-x.xx make sudo make install
Enable the driver:
sudo modprobe pcan
Connect a Peak CAN tool, ensure it appears in /proc/pcan. Note the network device name (ie, can0)
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())
Metadata
Release files for CANard 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| CANard-0.2.2.tar.gz | 8.7 kB | Details |
Release files / CANard-0.2.2.tar.gz
| Download URL | CANard-0.2.2.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b7a273aa263d881d1644a6daa644b2bd808bc4b92b2e4a61deb9946930f14a5
|
|
BLAKE2b-256 checksum How to use checksums |
0d2a562900fd636ed226d7ce146f681f51d05f121863a98e069712c1ed49a4fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |