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. uva 10518 - How Many Calls?(矩阵快速幂)

    题目链接:uva 10518 - How Many Calls? 公式f(n) = 2 * F(n) - 1, F(n)用矩阵快速幂求. #include <stdio.h> #inclu ...

  2. vb.net中将DataGridView与数据源绑定

    在< .net中将DataGridView内的数据导出为Excel表格>中说了如何导出数据到Excel,今天这篇文章将讲述如何绑定数据源,在控件中显示我们需要的信息. 在敲机房收费系统的时 ...

  3. [React] Preventing extra re-rendering with function component by using React.memo and useCallback

    Got the idea form this lesson. Not sure whether it is the ncessary, no othere better way to handle i ...

  4. (剑指Offer)面试题55:字符流中第一个不重复的字符

    题目: 请实现一个函数用来找出字符流中第一个只出现一次的字符.例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g".当从该字符流中读出前 ...

  5. eclipse 发布签名APK图文讲解

    eclipse 发布 签名android 程序 1 在项目上右键 export 2 export android application 3 第一次发布 要创建一个新的keystore 4 填写key ...

  6. bundle中vim相关快捷键的使用

    http://www.cnblogs.com/respawn/archive/2012/08/21/2649483.html http://blog.163.com/liao_ya/blog/stat ...

  7. Linux Samba安装与使用

    一 安装环境: 虚拟机:RedHat  5.4  192.168.75.128 主机环境:WIN7 32bit  192.168.75.1 网络连接方式:NAT 二 安装步骤: 说明: Ø  samb ...

  8. 配置静态监听解决ORA-12514错误的案例

    今天做Linux下DG配置的时候,遇到一个现象.tnsname.ora文件配置都正常,tnsping也正常,监听也正常.可是仍然报ORA-12514错误: SQL> set lin 130 pa ...

  9. Cookie技术

    u  常用的API 创建Cookie对象 Cookie(String name, String value)    ->以指定数据创建Cookie对象 设置Cookie对象 void setMa ...

  10. Linux命令-文件搜索命令:locate

    实际上是在分区表上搜索文件,比find命令速度更快 locate inittab 查找名称包含inittab的所有信息(快速搜索,实际上它是搜索linux资料库,区别于find在某一个磁盘分区或者某一 ...