Xilinx zynq CAN使用

版权声明:转载请关注我的公众号-青儿创客基地 https://blog.csdn.net/Zhu_Zhu_2009/article/details/82388861

驱动

socketCAN驱动

can4linux

下载地址已经迁移到Gitlab,can4linux

应用

https://blog.csdn.net/sno_guo/article/details/17029295
Linux CAN总线驱动与canutils
can-utils接口测试方法
linux(ubuntu)系统下can调试工具canutils和iproute的编译应用
基于MCP2515的Linux CAN总线驱动程序设计(一)
socket can 编程
AM335X DCAN Driver Guide
canconfig 移植记录

can-utils

下载地址:

canutilsv4.0
libsocketcan

参考can-utils,利用linux的SocketCAN接口,

git clone https://github.com/linux-can/can-utils.git
cd can-utils
./autogen.sh
./configure
make
make install (with root privileges)

使用,

 candump vcan0
 vcan0  123   [4]  01 AA BB 22
 vcan0  123   [4]  01 AA BB 23
 vcan0  123   [4]  01 AA BB 24

iproute2

ip -details link show can0
root@imx_mfgtools_nogpu:~# ip -details link show can0
2: can0: <NOARP,ECHO> 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

配置速度,

ip link set can0 up type can bitrate 800000

CAN总线开启和关闭:ifconfig canx up/ifconfig canx down
设置总线波特率:ip link set canx type can bitrate 250000
设置总线帧参数:ip link set canx type can tq 200 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1
注:ip link set canx type can -help 命令格式中,‘|’含义为只能输入一种,‘[]’含义为可选参数。
查看CAN总线状态:ip -details -statistics show link canx
设置总线的bus-off复位:ip link set canx type can restart-ms 100
帧参数设置的各参数含义:

  • TQ-位单位时间
  • SJW-重新同步跳跃宽度
  • PBS-phase-seg-相位缓冲
  • PTS-prop-seg-传播时间缓冲

网友工具cantool

Linux CAN编程详解
Linux CAN编程详解 文档

猜你喜欢

转载自blog.csdn.net/Zhu_Zhu_2009/article/details/82388861