我们使用CAN1和CAN2进行对测。将开发板的 CAN1与CAN2 的H与H相连,L与L相连。板子启动之后,在命令行输入以下命令,对CAN1配置波特率为125000:
root@ELF1:~# ifconfig can0 down //关闭can1
root@ELF1:~# ip link set can0 up type can bitrate 125000 triple-sampling on //设置can1波特率
root@ELF1:~# ifconfig can0 up //开启can1
对CAN2配置波特率为125000:
root@ELF1:~# ifconfig can1 down //关闭can2
root@ELF1:~# ip link set can1 up type can bitrate 125000 triple-sampling on //设置can2波特率
root@ELF1:~# ifconfig can1 up //开启can2
CAN2接收数据:
root@ELF1:~# candump can1 & //can2以后台方式接收数据
[1] 686
CAN1发送数据:
root@ELF1:~# cansend can0 123#1234567891234567 //can1发送数据
can1 123 [8] 12 34 56 78 91 23 45 67 //can2接收到数据