EVO ORIN CAN Usage#

CAN Usage#

CAN DB9 Port Pin Definition

Pin

Signal

1

CAN1_L

2

CAN0_L

7

CAN0_H

8

CAN1_H

3、4、6

GND

Functions and Device Node#

Functions

Device Node

CAN 1

CAN_0

CAN 2

CAN_1

Usage#

  • Use connector 1, connect to PC.

  • Use connector 2, connect to female-female cross connector 3.

  • Use connector 3, connect to the DB9 CAN want to use.

CAN Configuration#

Preparation#

Device

#Load Driver
sudo modprobe can
sudo modprobe can_raw
sudo modprobe mttcan
#Configuration parameters (using can0 as an example)
sudo ip link set can0 up type can bitrate 500000 dbitrate 5000000 sjw 4 restart-ms 1000 berr-reporting on fd on loopback off

PC

#Install
sudo apt-get install can-utils -y
 
#After connecting the USB to CAN (PCAN) device to a PC, execute the command and the output result will be the name of the CAN interface.
ls /sys/class/net/ | grep -E 'can[0-9]+' | sort -V | tail -n 1
 
#Configuration
sudo ip link set can0 up type can bitrate 500000 sjw 4

Receive-Send test#

The device sends data and the PC receives it.

Device

#Execute command to send data.
sudo cansend can0 123#abcdabcd

PC

#Execute command to receive data.
sudo candump can0
#If the following message is printed, it indicates that the data has been successfully sent from the device side.
can0  123   [4]  AB CD AB CD

PC sends data and the device receives it.

PC

#Execute command to send data.
sudo cansend can0 123#abcdabcd

Device

#Execute command to receive data.
sudo candump can0
#If the following message is printed, it indicates that the data has been successfully sent from the PC side.
can0  123   [4]  AB CD AB CD

Troubleshooting Methods#

When you are unable to receive data, experiencing packet loss, or communication interruptions, you can use the following command to view the status information of can0.

ip -d -s link show can0
# Check if 1 is the same as the previously set value.
# Check if 2 and 3 are both 0.
# If 1, 2, and 3 are all fine, check the hardware connection.
# If there are issues and you cannot identify the problem, please contact technical support for further investigation.

Reference#

https://www.kernel.org/doc/html/latest/networking/can.html

linux-can/can-utils