CAN bus testing tools and commands
-
Test tools
Canutils is a commonly used CAN communication testing toolkit that includes five independent programs: canconfig, candump, canecho, cansend, and cansequence. The functions of these programs are briefly described as follows:
-
canconfig
The parameters used to configure the CAN bus interface mainly include baud rate and mode. -
candump
Receive data from the CAN bus interface and print it in hexadecimal format to standard output, or output it to a specified file. -
canecho
Resend all data received from the CAN bus interface to the CAN bus interface. -
cansend
Send the specified data to the specified CAN bus interface. -
cansequence
Automatically repeat the increment number to the specified CAN bus interface, or specify the receive mode and verify the received increment number. -
ip
Configuration of CAN baud rate, functions, etc.
Common commands
- Query current network devices:
ifconfig -a
- CAN start:
ip link set can0 down //Close CAN ip link set can0 type can bitrate 500000 //Set bit rate of 500KHz: ip -details -statistics link show can0 //Print can0 information: ip -details -statistics link show can0 //Start CAN:
- CAN sending:
Send (standard frame, data frame, ID: 123, date: DEADBEEF):
cansend can0 123#DEADBEEF
Sending (standard frame, remote frame, ID: 123):
cansend can0 123#R
Send (extended frame, data frame, ID: 0000123, date: DEADBEEF):
cansend can0 00000123#12345678
Sending (extended frame, remote frame, ID: 0000123):
cansend can0 00000123#R
- CAN reception:
Start printing and wait for reception:
candump can0
-