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. .NET反编译之manager,base.AutoScaleMode修复

    使用反编译软件导出项目时,出现警告:设计器无法处理第X 行的代码:this.AutoScaleMode = AutoScaleMode.Font;方法"InitializeComponent ...

  2. Python 创建特殊元组tuple

    创建1个元素的tuple  (1,) 创建单元素tupletuple和list一样,可以包含 0 个.1个和任意多个元素.包含多个元素的 tuple,前面我们已经创建过了.包含 0 个元素的 tupl ...

  3. MySQL 工具

    MySQL 客户端工具: 1:mysql       #mysql的功能和Oracle的sqlplus一样,它为用户提供一个命令行接口来管理Mysql服务器. 2:mysqladmin #mysqla ...

  4. 基于Scrapy框架的Python新闻爬虫

    概述 该项目是基于Scrapy框架的Python新闻爬虫,能够爬取网易,搜狐,凤凰和澎湃网站上的新闻,将标题,内容,评论,时间等内容整理并保存到本地 详细 代码下载:http://www.demoda ...

  5. UISearchbar去除背景色的方法,适合iOS5/6/7/8.0beta

    通常使用UISearchbar都须要去除其背景色来与自己的界面风格保持协调,可是UISearchbar的设计随着iOS版本号的升级不断地在发生着变化.以下我们通过分析UISearchbar在各个iOS ...

  6. Column count of mysql.user is wrong. Expected 43, found 42. Created with MySQL 50518, now running 50641. Please use mysql_upgrade to fix this error.

    出现问题: Column count of mysql.user is wrong. Expected 43, found 42. Created with MySQL 50518, now runn ...

  7. iOS开发-应用之间的跳转及通信

    Update 2016-08-12: 在Github的Demo上增加Mac自定义Url Scheme,可以在Safari上输入特定协议头打开应用,并传递参数) 简介 我们接下来将要实现应用程序之间的跳 ...

  8. 【LeetCode】102. Binary Tree Level Order Traversal (2 solutions)

    Binary Tree Level Order Traversal Given a binary tree, return the level order traversal of its nodes ...

  9. css-input与文字的对齐

    前言 目前中文网站上面的文字,就我的个人感觉而言,绝大多数网站的主流文字大小为12px,因为在目前高分辨率显示器屏幕下,11px的汉字,其像素点开始不 规整,文字不如12px来的显示良好.12px大小 ...

  10. Android上怎样使用《贝赛尔曲线》

    首先对于<赛贝尔曲线>不是很了解的童鞋,请自觉白度百科.google. 为了方便偷懒的童鞋,这里给个<贝赛尔曲线>百科地址,以及一段话简述<贝赛尔曲线>: < ...