CAN
1 CAN Bus Overview
The CAN bus protocol (Controller Area Network) is a serial communication protocol bus developed by BOSCH (Bosch) of Germany in 1986. The GM-3568JHF development board is equipped with 2 CAN interfaces, implemented based on the integrated CAN controller of the RK3568J processor, providing a reliable communication solution for industrial control, automotive electronics, and device interconnection.
1.1 CAN Bus Technical Features
| Parameter | Specification |
|---|---|
| Protocol Standard | ISO 11898-1 (CAN 2.0A/2.0B) |
| Number of Interfaces | 2 independent CAN interfaces |
| Transmission Medium | Twisted pair |
| Network Topology | Bus type |
| Transmission Distance | Up to 1000 meters (5Kbps) |
| Maximum Number of Nodes | 110 nodes |
| Data Frame Length | 0-8 bytes |
| Arbitration Mechanism | Non-destructive bit arbitration |
1.2 CAN Protocol Features
Technical Advantages
- Multi-master Communication: Supports multiple nodes sending data simultaneously
- Non-destructive Arbitration: High-priority messages are transmitted first
- Error Detection: Powerful error detection and handling mechanism
- Strong Real-time Performance: Deterministic message transmission delay
- High Reliability: Differential signal transmission, strong anti-interference ability
Application Fields
- Automotive Electronics: Engine management, body control, instrumentation systems
- Industrial Automation: PLC control, sensor networks, actuator control
- Medical Equipment: Medical instrument interconnection, monitoring equipment communication
- Marine Systems: Navigation equipment, power system control
- Building Automation: Lighting control, air conditioning systems, security equipment
2 GM-3568JHF CAN Interface Configuration
According to the product specifications, the GM-3568JHF development board provides 2 CAN interfaces to meet a variety of industrial application requirements.
2.1 CAN Hardware Connection
The CAN wiring between the development board and external devices is as follows:
| Development Board | External Device |
|---|---|
| CAN_L | CAN_L |
| CAN_H | CAN_H |

2.2 CAN Communication Test
This test uses a CAN analyzer. Connect the H and L terminals of the two devices

Check the Interface
Check whether the can0 and can1 interfaces are generated on the development board
root@linaro-alip:/# ifconfig -a
can0: flags=128<NOARP> mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 54
can1: flags=128<NOARP> mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 55
···Parameter Settings
Set the baud rate on the development board and perform a test (CAN0 is used as the test sample here)
# 将 CAN0 接口关闭
sudo ip link set can0 down
# 设置比特率为 250000
sudo ip link set can0 type can bitrate 250000
# 将CAN0 接口启用
sudo ip link set can0 up
# 发送(标准帧,数据帧,ID:7ff,date:11223344556677)
cansend can0 -i 0x7ff 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
# 接收
candump can0Test Results
- Development board test result:

- CAN analyzer test result:

3 CAN Network Diagnostics and Debugging
3.1 Using cansniffer for Network Analysis
# 安装 cansniffer
sudo apt-get install can-utils
# 启动网络嗅探
cansniffer can0
# 带过滤的嗅探
cansniffer can0 -c 0x100-0x200
# 保存日志
candump can0 -L > can_log.txt3.2 Network Load Test
# 生成测试流量
cangen can0 -g 10 -I 123 -L 8
# 测试网络带宽
canbusload can0@250000
# 压力测试
for i in {1..1000}; do
cansend can0 123#DEADBEEF
done4 Troubleshooting
4.1 CAN Interface Cannot Start
Inspection Steps:
# 检查内核模块
lsmod | grep can
# 手动加载 CAN 模块
sudo modprobe can
sudo modprobe can-raw
sudo modprobe can-dev
# 检查设备树配置
dmesg | grep can
# 检查硬件连接
cat /proc/interrupts | grep can4.2 Communication Errors or Packet Loss
Diagnostic Methods:
# 检查错误统计
ip -s link show can0
# 查看错误详情
cat /proc/net/can/stats
# 检查总线状态
candump can0 -e
# 调整波特率和时序
sudo ip link set can0 type can bitrate 125000 sample-point 0.754.3 Network Conflict and Arbitration Issues
Solutions:
# 检查网络负载
canbusload can0@250000
# 分析消息冲突
cansniffer can0 -c
# 优化消息优先级
# 使用较低的 CAN ID 获得更高优先级4.4 Hardware Connection Issues
Inspection Points:
- Termination Resistor: Ensure 120Ω termination resistors at both ends of the network
- Cable Quality: Use twisted pair cable, avoid long-distance transmission
- Grounding: Ensure a good signal ground connection
- Power Supply: Check the power supply of the CAN transceiver
# 测试回环模式
sudo ip link set can0 type can bitrate 250000 loopback on
cansend can0 123#DEADBEEF
candump can0