Driver installation

 $ make linux-menuconfig
Networking support  --->
<M> CAN bus subsystem support --->
--- CAN bus subsystem support
<M> Raw CAN Protocol (raw access with CAN-ID filtering)
<M> Broadcast Manager CAN Protocol (with content filtering)
CAN Device Drivers --->
<M> Virtual Local CAN Interface (vcan)
<M> Platform CAN drivers with Netlink support
[*] CAN bit-timing calculation
<M> Microchip 251x series SPI CAN Controller
 $ make linux
$ make
  • Reflash kernel and rootfs

Usage

  • Load all the needed drivers:
# modprobe can
# modprobe can-dev
# modprobe can-raw
APF27 & APF51 APF6
# modprobe mcp251x
# modprobe flexcan
  • Set the bitrate before all operations

Example: Set the bitrate of the can0 interface to 125kbps:

# ip link set can0 up type can bitrate 125000
Note: An error occurs when you try to set the bitrate with an old Linux kernel.
  • If the following error occurs when you do the last instruction :
ip: either "dev" is duplicate, or "type" is garbage

check that this command:

# which ip

return this message:

/sbin/ip

and not this one :

/bin/ip

If the binary is installed in /bin instead of /sbin, the executable file is a link to busybox and the command to set the bitrate doesn't work on busybox, so try the following instructions:

$ make busybox-clean
$ make busybox-dirclean
$ make menuconfig
Package Selection for the target  --->
Networking applications --->
[*] iproute2
$ make

Then, reflash your rootfs.

Quick test

  • Once the driver is installed and the bitrate is set, the CAN interface has to be started like a standard net interface:
 # ifconfig can0 up
  • and can be stopped like that:
 # ifconfig can0 down
  • The socketCAN version can be retrieved this way:
 # cat /proc/net/can/version
  • The socketCAN statistics can be retrieved this way:
 # cat /proc/net/can/stats

Userspace tools

Several tools are provided by socketCAN:

  • candump: dump traffic on a CAN network

The following command shows the received message from the CAN bus

candump can0
  • cansend: simple command line tool to send CAN-frames via CAN_RAW sockets

exemple : The following command sends 3 bytes on the bus (0x1E, 0x10, 0x10) with the identifier 500.

cansend can0 500#1E.10.10

You can send a remote request message

cansend can0 500#R

The information with the identifier 500 will be available on the bus when the device receive the remote request message

  • cangen: CAN frames generator for testing purpose
  • canplayer: send CAN frames from a file to a CAN interface

These tools can be compiled and installed on the target by means of the Buildroot menuconfig:

$ make menuconfig
Package Selection for the target  --->
Networking --->
[*] Socket CAN
$ make

then, reflash your rootfs.

ip: either "dev" is duplicate, or "type" is garbage的更多相关文章

  1. nginx: [warn] duplicate MIME type "text/html"错误

    检查配置文件时提示:nginx: [warn] duplicate MIME type "text/html" in /home/web/nginx/inc/gzip.conf:9 ...

  2. niginx:duplicate MIME type "text/html" in nginx.conf 错误(转载)

    把nginx升级到最新以后,发现用原来的配置启动的时候会提示: duplicate MIME type "text/html" in /usr/local/nginx/conf/n ...

  3. VS2010编译以前版本工程时 ERROR CVT1100:duplicate resource,type:MANIFEST解决办法

    1.将 Resource Files 里面的 *.exe.manifest 文件删除 2.右键选择 *.rc 文件,选择 view code,查找并删除所有引用 *.exe.manifest 文件的代 ...

  4. iproute2交叉编译

    测试zynq+ramdisk平台时发现自带的busybox无法通过ip命令配置can接口,执行can配置命令 ip link set can0 type can bitrate 会出现以下报错: ip ...

  5. Check类之duplicate declaration checking/Class name generation/Type Checking

    1.duplicate declaration checking /** Check that variable does not hide variable with same name in * ...

  6. Neutron 理解(5):Neutron 是如何向 Nova 虚机分配固定IP地址的 (How Neutron Allocates Fixed IPs to Nova Instance)

    学习 Neutron 系列文章: (1)Neutron 所实现的虚拟化网络 (2)Neutron OpenvSwitch + VLAN 虚拟网络 (3)Neutron OpenvSwitch + GR ...

  7. docker学习笔记一:基本安装和设置容器静态ip

    docker是一个lxc升级版的容器类虚拟环境,具有快速部署,灵活,易迁移的虚拟机模式,现在各大公司已经开始广泛使用为了自己方便学习linux,需要多台虚拟机环境,但是vmware开启多台虚拟机时需要 ...

  8. MySQL: ON DUPLICATE KEY UPDATE 用法 避免重复插入数据

    INSERT INTO osc_visit_stats(stat_date,type,id,view_count) VALUES (?,?,?,?) ON DUPLICATEKEY UPDATE vi ...

  9. 动态IP解析

    本文介绍两种方便获取主机动态IP的方式(DDNS,IP报告网页),并给出相应的代码实现. shell脚本获取本机IP,执行上传操作和更新DNS操作.定期执行通过crontab或者systemd等服务. ...

随机推荐

  1. HDU 2897 邂逅明下 (博弈)

    题意: 给你n.p.q,每次操作是令n减小 [p, q]区间中的数,当n < p时必须全部取完了,取完最后一次的人算输,问先手必胜还是必败. 解题思路: 这种非常类似巴什博弈,可以找出必胜区间和 ...

  2. HTTP客户端都应该支持的五个特性

    在我看来,HTTP客户端必须要支持如下五个特性. 缓存 最后修改时间的检查 ETags 压缩 重定向 缓存返回的头如下: Cache-Control: max-age=, public Expires ...

  3. Oracle数据库导入dmp文件报错处理方法

    在向oracle数据库执行导入命令的时候报错,错误如下,大概意思是TNS中找不到服务名 下面说一下解决步骤 1:进入oracle用户,使用cat查看.bash_profile文件,找到ORACLE_H ...

  4. [RSpec] LEVEL 2 CONFIGURATION & MATCHERS

    Installing RSpec In this level we'll start by getting you setup on a regular Ruby project, then move ...

  5. vue - 减少打包后的体积

    打包命令: npm:npm run build yarn:yarn run build 路径:/config/index.js 是否产生map文件,置为false.

  6. 【转帖】ArtisticStyle----很好用的C/C++样式格式化工具

    下载地址:http://srgb.googlecode.com/files/AStyle_2.02_windows.7z 把astyle.exe 复制到 C:\WINDOWS 目录里,省的指定路径VC ...

  7. AP*更新供应商地点

    --更新供应商地点 PROCEDURE update_vendor_site(p_init_msg_list IN VARCHAR2 DEFAULT fnd_api.g_false, x_return ...

  8. 30、Arrays工具类

    1.查询元素 int binarySearch(type[] a,type key):使用二分法查询key元素值在a数组中出现的索引:如果a数组不包含key元素,则返回负数.调用该方法时要求数组中元素 ...

  9. CentOS 6上的redis搭建实战记录(转)

    redis 是一个基于内存的高性能key-value数据库,数据都保存在内存中定期刷新到磁盘,以极高的读写效率而备受关注.他的特点是支持各种数据结构,stirng,hashes, list,set,和 ...

  10. Android异步下载

    概述 实现App常见下载公共 支持通知栏显示 支持 暂停.取消功能,使用Service.AsyncTask实现异步下载.特点简单.实用.方便源码扩展修改 详细 代码下载:http://www.demo ...