ip && canutils命令
2017-02-22 17:35
169 查看
1、查看是否有can设备
ipaddr
2、关闭can设备
ip link setcan0 down
3、配置波特率
ip link set can0 type can bitrate 250000
设置CNA0的波特率为250K,在设置前需要先把CAN0关闭了
4、打开can设备
ip link setcan0 up
5、查看can设备详细信息
ip -details link show can0
can0: <NOARP,UP,LOWER_UP,ECHO>mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
link/can
can state ERROR-ACTIVE(berr-counter tx 0 rx 0) restart-ms 0
bitrate 500000 sample-point0.875
tq 125 prop-seg 6 phase-seg17 phase-seg2 2 sjw 1
sja1000: tseg1 1..16 tseg21..8 sjw 1..4 brp 1..64 brp-inc 1
clock 16000000
6、发送测试
./cansend can0 -e 0x11 0x22 0x33 0x44 0x550x66 0x77 0x88
interface = can0, family = 29, type = 3,proto = 1
测试软件上能看到接收的帧
7、接收测试,接收测试软件发送的帧:
# ./candump can0
interface = can0, family = 29, type = 3,proto = 1
<0x001> [8] 00 00 00 00 00 00 00 00
<0x002> [8] 01 00 00 00 00 00 00 00
<0x003> [8] 02 00 00 00 00 00 00 00
<0x004> [8] 03 00 00 00 00 00 00 00
8、重启
使用内核文档说的ip link set can0 type can restart-ms 100会报
RTNETLINK answers: Device or resource busy
9、环回测试
ip link set can0 down
ip link set can0 type can bitrate 50000 loopback on/off
ip link set can0 up
candump can0 &
cansend can0 -s 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
10.、将两块板的can接口接起来,CANH对CANH, CANL对CANL,一边发送,另一边接收,测试之前速率要设置好,且can接口已经up.
#candump can0 开发板1执行接收命令
#cansend can0 123#11223344556677 开发板2发送数据
11、关于can工具的使用(cansend等),参考can源码目录下的lib.h文件, 里边讲得很清楚
ipaddr
2、关闭can设备
ip link setcan0 down
3、配置波特率
ip link set can0 type can bitrate 250000
设置CNA0的波特率为250K,在设置前需要先把CAN0关闭了
4、打开can设备
ip link setcan0 up
5、查看can设备详细信息
ip -details link show can0
can0: <NOARP,UP,LOWER_UP,ECHO>mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
link/can
can state ERROR-ACTIVE(berr-counter tx 0 rx 0) restart-ms 0
bitrate 500000 sample-point0.875
tq 125 prop-seg 6 phase-seg17 phase-seg2 2 sjw 1
sja1000: tseg1 1..16 tseg21..8 sjw 1..4 brp 1..64 brp-inc 1
clock 16000000
6、发送测试
./cansend can0 -e 0x11 0x22 0x33 0x44 0x550x66 0x77 0x88
interface = can0, family = 29, type = 3,proto = 1
测试软件上能看到接收的帧
7、接收测试,接收测试软件发送的帧:
# ./candump can0
interface = can0, family = 29, type = 3,proto = 1
<0x001> [8] 00 00 00 00 00 00 00 00
<0x002> [8] 01 00 00 00 00 00 00 00
<0x003> [8] 02 00 00 00 00 00 00 00
<0x004> [8] 03 00 00 00 00 00 00 00
8、重启
使用内核文档说的ip link set can0 type can restart-ms 100会报
RTNETLINK answers: Device or resource busy
9、环回测试
ip link set can0 down
ip link set can0 type can bitrate 50000 loopback on/off
ip link set can0 up
candump can0 &
cansend can0 -s 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
10.、将两块板的can接口接起来,CANH对CANH, CANL对CANL,一边发送,另一边接收,测试之前速率要设置好,且can接口已经up.
#candump can0 开发板1执行接收命令
#cansend can0 123#11223344556677 开发板2发送数据
11、关于can工具的使用(cansend等),参考can源码目录下的lib.h文件, 里边讲得很清楚
相关文章推荐
- TCP/IP详解--ICMP 控制报文和差错报文 && Tracerouter 命令的过程
- 解决:'help、ipconfig' 不是内部或外部命令,也不是可运行的程序或批处理文件
- 【转】解决:'HELP、IPCONFIG' 不是内部或外部命令,也不是可运行的程序或批处理文件
- 用"ntsd"命令杀掉古怪的进程
- Win2000 & WinXP CMD下命令
- dos命令& 批处理命令小结(不断更新中)
- 使用命令查看自己的外网IP地址
- WinXP中自带的netsh命令自动切换IP(zz)
- IP 路由命令详解
- ip命令手册(一)
- 黑客常用的命令和快捷键 & 最全的windows操作系统快捷键
- SMTP&POP命令详解(z)
- 'ls -l'命令输出格式简介
- IP subnet zero 命令的意义
- Windows 开始->运行->命令 集锦
- Windows 开始->运行->命令 集锦
- 国外代理IP地址,随时跟新的,还不错 http://www.ifstar.net/proxy/index.php?act=list&page=1
- 关于icewm的"运行命令"
- 在Jsp页面中调用Ping命令---PingIP.jsp
- SMTP&ESMTP&POP3 简要命令