CANoe与金溢的obu can连接的环境问题 Cifconfig can0 up 失败 设置波特率失败

今天搭建了CANoe与金溢的obu can连接的环境问题。遇到了一个让人不解的问题。

can0起不来,于是怀疑波特率不匹配,使用调不了。

Linux 设置波特率

ifconfig    can0   down       /*关闭CAN0*/

ip  link set  can0  type  can bitrate  250000    /*设置CAN0   250K波特率*/

ifconfig    can0   up                   /* 开启CAN0*/

---------------------

 sudo ip link set can0 type can bitrate 500000   /*设置CAN0   500K波特率*/

 sudo ip link set can0 up

问题的现象:

[root@genvict ~]# ifconfig can0 up
ifconfig: SIOCSIFFLAGS: Invalid argument
[root@genvict ~]# link can 500000 bitrate type can0 set ip 
-sh: link: command not found
[root@genvict ~]# ip link set can0 type can bitrate 500000
ip: either "dev" is duplicate, or "type" is garbage
[root@genvict ~]# ifconfig can1 up
ifconfig: SIOCSIFFLAGS: Invalid argument
[root@genvict ~]# 500000bitratecantypecan0setlinkipsudo
-sh: 500000bitratecantypecan0setlinkipsudo: command not found
[root@genvict ~]# 
Socket error Event: 32 Error: 10053.
Connection closing...Socket close.

 

问题解决:

后来发现:根目录下有一个 production_test_tools_wbl20b_v1.2可执行文件,运行了这个设备自带的调试工具文件后,发现can起不来的问题解决了。

由于可执行文件是一个二进制文件,不好直接阅读,只能从中读取搜索一些关键字信息。

 

惊不惊喜意不意外?这就解决了?什么垃圾博主!

 

 

 

 

 

 

 

我分析了上面的文件,文件里执行了一句命令,就是设置了波特率

网上很多设置波特率的命令是不生效的:

最后放大招了!!!!!!!!!!!!

用这行命令设置波特率:

canconfig can0 bitrate 500000    /*设置CAN0   500K波特率*/

 

使用obu向Canoe发送消息:

[root@genvict ~]# cansend can0 0x88    #通过can来发送消息

interface = can0, family = 29, type = 3, proto = 1

[root@genvict ~]# cansend can0 -i 0x44  0x8 0x9 0x6 --loop=20   #can0 发送数据,可以传8个十六进制的数

can0          interface=can0发送数据

-i 0x44         消息的ID号为44

 0x8 0x9 0x6    三个数据可以由最多8个字节组成,以空格分隔的列表形式给出

--loop=20      循环发送20

从canoe上看到接收到的发送的消息:

 

 

用法: cansend [<can-interface>] [Options] <can-msg>

<can-msg>可以由最多8个字节组成,以空格分隔的列表形式给出

选项:

interface = can0, family = 29, type = 3, proto = 1

[root@genvict ~]# cansend --help

Usage: cansend [<can-interface>] [Options] <can-msg>

<can-msg> can consist of up to 8 bytes given as a space separated list

Options:

 -i, --identifier=ID        CAN Identifier (default = 1)

 -r  --rtr                send remote request

 -e  --extended        send extended frame

 -f, --family=FAMILY        Protocol family (default PF_CAN = 29)

 -t, --type=TYPE        Socket type, see man 2 socket (default SOCK_RAW = 3)

 -p, --protocol=PROTO        CAN protocol (default CAN_RAW = 1)

 -l                        send message infinite times

       --loop=COUNT        send message COUNT times

 -v, --verbose                be verbose

 -h, --help                this help

      --version                print version information and exit

 

 

    candump #查看can的接

 

[root@genvict ~]# candump --help

Usage: candump [<can-interface>] [Options]

Options:

 -f, --family=FAMILY        protocol family (default PF_CAN = 29)

 -t, --type=TYPE        socket type, see man 2 socket (default SOCK_RAW = 3)

 -p, --protocol=PROTO        CAN protocol (default CAN_RAW = 1)

     --filter=id:mask[:id:mask]...

          apply filter

 -h, --help                this help

 -o <filename>                output into filename

 -d                        daemonize

     --version                print version information and exit

 

接收测试,接收测试软件发送的帧:

# ./candump can0

interface = can0, family = 29, type = 3, proto = 1

<0x00000002> [8] 70 01 02 03 04 05 06 07 

 

[root@genvict ~]# canecho --help

Usage: canecho <can-interface> [<can-interface-out>] [Options]

 

Send all messages received on <can-interface> to <can-interface-out>

If <can-interface-out> is omitted, then <can_interface> is used for sending

 

Options:

 -f, --family=FAMILY   Protocol family (default PF_CAN = 29)

 -t, --type=TYPE       Socket type, see man 2 socket (default SOCK_RAW = 3)

 -p, --protocol=PROTO  CAN protocol (default CAN_RAW = 1)

 -v, --verbose         be verbose

 -h, --help            this help

     --version         print version information and exit

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

aFakeProgramer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值