Apex AD10 CAN Usage#
Instructions for Using CAN Interface#
CAN DB9 Port Pin Definition
Pin |
Signal |
---|---|
2 |
CAN_A_L |
7 |
CAN_A_H |
Function vs Device Node#
Function |
Definition |
Device Node |
---|---|---|
CAN_A |
Orin CAN0 |
can0 |
CAN_B |
Orin CAN1 |
can1 |
CAN_C |
Expanded CAN |
can2 |
CAN_D |
Expanded CAN |
can3 |
CAN_E |
Expanded CAN |
can4 |
Method of Application#
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
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.