CAN,全称为“Controller Area Network”,即控制器局域网,是国际上应用最广泛的现场总线之一。CAN可以多主方式工作;也可以分成不同的优先级,满足不同的实时要求;也可以点对点,一点对多点及全局广播几种传送方式接收数据。TQi.MX6UL开发板平台有2路CAN接口,具体测试方法如下:
1.配置:
i.MX6UL工控板有2路CAN接口,配置使用ip(route2)工具。注意:busybox里也有集成了ip工具,但busybox里的是阉割版本。不支持can的操作。故使用前请先确定ip命令的版本:
# ip -V ip utility, iproute2-ss160314
以下是配置的命令
ifconfig can0 down ip link set can0 type can bitrate 100000 triple-sampling on ip link set can0 up
2.接收:
candump can0
3.发送:
cansend can0 123#DEADBEEF
短接can0与can1的H与L以下是测试过程:
# ifconfig can0 down # ip link set can0 type can bitrate 1000000 triple-sampling on # ifconfig can0 up flexcan 2090000.can can0: writing ctrl=0x012320d4 # ifconfig can1 down # ip link set can1 type can bitrate 1000000 triple-sampling on # ifconfig can1 up flexcan 2094000.can can1: writing ctrl=0x012320d4 # candump can1& #监听can1 # cansend can0 111#1122334455667788 #can0 发送数据 can1 111 [8] 11 22 33 44 55 66 77 88 #can1 接收到的数据