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. 微信-js sdk invalid signature签名错误 问题解决

    如果出现 invalid signature,首先可以确定的是你的签名算法有问题.建议:首先查看微信官方网站给出的解决方案,链接为: http://mp.weixin.qq.com/wiki/7/aa ...

  2. 如何用 js 递归输出树型

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  3. ejs和swig对比问题之二

    上一次用浏览器里面简单的进行了测试,得到的数据是swig是ejs的速度的一倍左右,这次在控制台进行测试,能够得到比较精确的数据,并加入了dot一块儿进行测试. 测试数据是一百万条记录 创建测试数据cr ...

  4. nginx的 CPU參数worker_processes和worker_cpu_affinity使用说明

    Nginx默认没有开启利用多核CPU,我们能够通过添加worker_cpu_affinity配置參数来充分利用多核CPU.CPU是任务处理,计算最关键的资源,CPU核越多.性能就越好. worker_ ...

  5. 浅析JDK中ServiceLoader的源码

    前提 紧接着上一篇<通过源码浅析JDK中的资源加载>,ServiceLoader是SPI(Service Provider Interface)中的服务类加载的核心类,也就是,这篇文章先介 ...

  6. VB 获取默认打印机的状态

    如何获取默认打印机的状态,包括缺纸.卡纸.无连接等状态,还有将某文件打印后,如何得知打印成功? Option ExplicitDeclare Function MapPhysToLin Lib &qu ...

  7. Generator [ˈdʒenəreɪtə(r)] 函数结构

    Generator函数是ES6新增的一种异步编程方案. 说明:Generator函数指的是一种新的语法结构,是一个遍历器对象生成器,它内部可以封装多个状态,非常适合用于异步操作. Generator函 ...

  8. JavaWeb request对象常用操作

      JavaWeb request对象常用操作 CreateTime--2018年6月1日16点47分 Author:Marydon 一.前提 import javax.servlet.http.Ht ...

  9. Java之Undeclared Checked Exception

    之前一直认为在Java里如果每个task是相对独立.并且是可以容忍错误的,那么只需要处理Checked Exception(这个是Java强制的)和主动处理Unchecked Exception(派生 ...

  10. mysql last_insert_id() (转载)

    先来看看官方的说明 The ID that was generated is maintained in the server on a per-connection basis. This mean ...