CAN功能
3506平台有两路CAN总线接口,CAN 连线方式: CAN 的 H 端子与其它 CAN 设备 H 端连接;CAN的 L 端子与其它 CAN 设备 L 端子连接,GND和GND连接。
查看CAN网络设备
root@3506-buildroot:/# ifconfig -a
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:50
can1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:51
设置CAN0、CAN1设备参数。设置CAN0、CAN1波特率为500000。
root@3506-buildroot:/# ip link set can0 down
root@3506-buildroot:/# ip link set can1 down
root@3506-buildroot:/# ip link set can0 type can bitrate 1000000 sample-point 0.8 dbitrate 2000000 sample-point 0.8 fd on
root@3506-buildroot:/# ip link set can1 type can bitrate 1000000 sample-point 0.8 dbitrate 2000000 sample-point 0.8 fd on
打开CAN0、CAN1
root@3506-buildroot:/# ip link set can0 up
root@3506-buildroot:/# echo 4096 > /sys/class/net/can0/tx_queue_len
root@3506-buildroot:/# ip link set can1 up
root@3506-buildroot:/# echo 4096 > /sys/class/net/can1/tx_queue_len
客户端发送数据服务端接收数据
CAN0设备作为服务端(服务端先执行以下命令)
root@3506-buildroot:/# candump can0 &
CAN1设备作为客户端(客户端发送数据)
root@3506-buildroot:/# cansend can1 1F334455#1122334455667788
can0 1F334455 [8] 11 22 33 44 55 66 77 88
作者:SteveChen 创建时间:2025-04-11 20:20
最后编辑:SteveChen 更新时间:2025-04-11 20:27
最后编辑:SteveChen 更新时间:2025-04-11 20:27