linux can总线接收数据串口打包上传_TX2平台下can总线收发功能的实现(一)

因此可以联想到应该有技术文档或者外国文章早已对can总线的通讯已经做过讨论。因此Google搜索:TX2 can bus

22d22ba4f60b582361a0181f56d753b6.png


果然有,只不过是在英伟达官方论坛中,继续深入查找,在网址:https://devtalk.nvidia.com/default/topic/1006762/jetson-tx2/how-can-i-use-can-bus-in-tx2-/3中,有以为英伟达官方人员给出了正确方法

004191db441e5ed0d830192d65fc33e4.png


看看,和之前CSDN中看的英文一模一样,哈哈。
则得出步骤:(1)首先想要使能canbus必须在tegra18_defconfig配置文件中配置CONFIG_MTTCAN = m 之后重新编译内核才能使用。
(2)安装canbus模块(Linux将不常用的模块做成.ko文件,在需要使用时可以将其进行载入内核,降低系统的开销)
modprobe can
modprobe can_raw
modprobe mttcan
(3)配置canbus属性,和串口的波特率设置类似,同驱动编程中的ioctl
ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
ip link set up can0
ip link set can1 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
ip link set up can1
ip link set up can0
ip link set can1 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
ip link set up can1
(4)安装第三方开源app can-utils 测试canbus
sudo apt-get install can-utils
(5)使用应用程序进行测试
发送程序:
cansend <can_interface> <can_frame>
e.g. cansend can0 123#abcdabcd
接收程序:
candump can_interface
e.g. candump can1
检测canbus的状态:
ip -details -statistics link show can0
ip -details -statistics link show can1
OK,那么对TX2平台下的canbus通讯初探完成,但是canbus的API,应用开发函数仍然未知,但是之前官方人员给出的测试程序app:can-utils为开源程序,因此下一步:上GIT看代码!
具体接线图:

346daf547780367d164033aaee6d93b7.png


具体收发详细步骤请看:https://blog.csdn.net/hhlenergystory/article/details/81976069
dbc载入并实现收发源代码及测试:https://blog.csdn.net/hhlenergystory/article/details/81976696

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值