can-utils
is an extremely versatile collection of CAN utilities to sniff, transmit, record, generate, and replay CAN messages. can-utils
is based on a set of open source CAN drivers and networking stack called SocketCAN, contributed by Volkswagen Research to the Linux Kernel.
For a quick review of CAN, please review Elinux.org CAN Bus Page which provides great background information and will make life easier as you get started.
To use can-utils using simply a Virtual CAN or vcan, you just need:
- computer running linux
To trasnmit and receive CAN messages with a physical CAN devic, you will need:
- computer running linux
- CAN hardware with a USB serial cable
If you are using OSX or Windows, you will need to use a virtual machine (VM) within your computer such as Virtual Box which is free to dowload.
To install, open your terminal and type:
$ sudo apt-get install can-utils
In order to start transmitting or receiving CAN messages, you first need to link the USB serial port on your computer to the target CAN device you are trying to communicate with.
Connect your CAN device to the USB port on your computer.
Search for devices connected to a USB port:
ls /dev/ttyACM*
This should list available serial connected USB ports (hopefully just 1):
/dev/ttyACM0
Use slcand
to link that port to can0
interface from SocketCAN. If your port is /dev/ttyACM0
, you can use:
sudo slcand -o -c -s6 /dev/ttyACM0 can0
otherwise replace the /dev/ttyACM0
with /dev/ttyACM*
and it should work.
Bring up the CAN network with:
sudo ifconfig can0 up
Sniff all the CAN messages!
cansniffer -cae can0
Here's a lit of the CAN bus speed parameters that can be passed to slcand:
-s0
kbit/s-s1
20 kbit/s-s2
50 kbit/s-s3
100 kbit/s-s4
125 kbit/s-s5
250 kbit/s-s6
500 kbit/s-s7
800 kbit/s-s8
1 Mbit/s
- asc2log
- bcmserver
- canbusload
- can-calc-bit-timing
- candump
- canbusload
- canfdtest
- cangen
- cangw
- canlogserver
- canplayer
- cansend
- cansniffer
- isotpdump
- isotprecv
- isotpperf
- isotpsend
- isotpserver
- isotpsniffer
- isotptun
- log2asc
- log2long
- slcan_attach
- slcand
- slcanpty
Please submit issues or pull requests directly to this repo.
Versioning is based on the can-utils debian package: https://packages.debian.org/sid/can-utils
- Oliver Hartkopp - Initial work - hartkopp
- Marc Kleine-Budde - Initial work - marckleinebudde
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
README file created by alan707