打印
[技术问答]

ifconfig can0 up无法启动nuc972的can

[复制链接]
877|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
probedog|  楼主 | 2021-1-8 16:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
自己做的板子,用的can1,管脚是ph14,ph15。
命令行里输入ifconfig can0 up后,打不开can。

  • root@nuc972 /# ifconfig can0 up
  • nuc970-can1 nuc970-can1 can0: bit-timing not yet defined
  • nuc970-can1 nuc970-can1 can0: failed to open can device
  • ifconfig: SIOCSIFFLAGS: Invalid argument


[color=rgb(51, 102, 153) !important]复制代码



使用 ip link set can0 type can bitrate 125000 设置速率,结果也不成功。

  • root@nuc972 /# ip link set can0 type can bitrate 125000
  • ip: either "dev" is duplicate, or "type" is garbage


[color=rgb(51, 102, 153) !important]复制代码



但是ifconfig -a倒是可以看到有can0,不过好奇为什么是can0?我硬件上用的是can1啊?
  • root@nuc972 /# 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:59
  • 。。。


[color=rgb(51, 102, 153) !important]复制代码

[color=rgb(51, 102, 153) !important]


使用特权

评论回复
沙发
cr315| | 2021-3-5 09:56 | 只看该作者
请问您用的是can1,为何用ifconfig can0 up?

使用特权

评论回复
板凳
elephant00| | 2021-3-5 09:57 | 只看该作者
该问题解决了。

执行 ip link set can0 type can bitrate 125000 命令不成功,是因为buildroot默认生成的ip命令不支持配置can。构建root时,勾选iproute2选项,再次编译生成的文件系统里的ip命令就可以执行了。

至于为什么我用的是物理can1,而Linux里显示的是can0,我估计是把第一个can设备当can0吧。

再请教个qt下can的使用问题。看qt5.6的官方can例程,使用QCanDeivce后,需要确定使用哪个can插件。我仿照这个例程写了个简单界面,看搜到的插件有:peakcan, socketcan, tinycan。我该指定哪个插件呢?

使用特权

评论回复
地板
onlycook| | 2021-3-5 10:00 | 只看该作者

你qt5.6移植成功了吗?显示是qml还是widget?

使用特权

评论回复
5
内政奇才| | 2021-3-5 10:04 | 只看该作者

请问你用的是带C后缀的芯片么

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

272

主题

1258

帖子

3

粉丝