Skip to content

carloop/can-utils

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SocketCAN logo

CAN utilities based on SocketCAN

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.

Prerequisites

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.

Installation

To install, open your terminal and type:

$ sudo apt-get install can-utils

Usage

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.

Step 1

Connect your CAN device to the USB port on your computer.

Step 2

Search for devices connected to a USB port:

ls /dev/ttyACM*

This should list available serial connected USB ports (hopefully just 1):

/dev/ttyACM0
Step 3

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.

Step 4

Bring up the CAN network with:

sudo ifconfig can0 up
Step 5

Sniff all the CAN messages!

cansniffer -cae can0

CAN Bus bitrate speeds

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

Other useful userspace utilities within this repo:

  • 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

Additional Information:

Contributing

Please submit issues or pull requests directly to this repo.

Versioning

Versioning is based on the can-utils debian package: https://packages.debian.org/sid/can-utils

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

README file created by alan707

About

Linux-CAN / SocketCAN user space applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 96.6%
  • Makefile 2.7%
  • Other 0.7%