Linux Canbus调试笔记

STM32之CAN---错误管理分析      牛人博客

http://blog.csdn.net/flydream0/article/details/8161418 

 

CAN总线在嵌入式Linux下驱动程序的实现

http://www.21ic.com/app/embed/200911/49216.htm

 

Socke Can设置波特率

找到其中一个方法使用IP命令,BUSYBOX制作的IP好像不支持对socketcan的设置,必须要自己去下载iproute2的源代码自己编译。得到IP命令,拷贝到自己系统的bin目录下。
ip link set can0 type can bitrate 250000
设置CNA0的波特率为250K,在设置前需要先把CAN0关闭了,ip set can0 down
可以结贴了,!!!!!!!!!!!!

 

linux can 总线socket接口测试使用,解释了为什么会从字符设备升级到socket设备

http://blog.chinaunix.net/uid-26119896-id-3452315.html

http://www.cnblogs.com/zym0805/p/4345175.html

 

dmesg | grep can

root@imx_mfgtools_nogpu:~# dmesg | grep can
can-3v3: 3300 mV
flexcan 2090000.can: device registered (reg_base=a0968000, irq=142)
flexcan 2094000.can: device registered (reg_base=a0970000, irq=143)
can: controller area network core (rev 20120528 abi 9)
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
can-3v3: disabling

 

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:142

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:143

 

ip -details link show can0

root@imx_mfgtools_nogpu:~# ip -details link show can0
2: can0: mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can state STOPPED (berr-counter tx 0 rx 0) restart-ms 0
          bitrate 0 sample-point 0.000
          tq 0 prop-seg 0 phase-seg1 0 phase-seg2 0 sjw 0
          flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1
          clock 30000000

ip -details link show can0  // 查看
ifconfig can0 down  // 关闭
ip link set can0 up type can // 打开
 
./candump can0  // 接受数据
./cansend   can0 -e 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88  // 发送数据

你可能感兴趣的:(【CAN】)