Difference between revisions of "How to configure and use CAN bus"

From RidgeRun Developer Connection
Jump to: navigation, search
(Setup the networking rules)
Line 17: Line 17:
  
 
== Setup the networking rules==
 
== Setup the networking rules==
Edit your /etc/networking/interfaces on the target filesystem and add the following rules (required to setup the bit-rate of the bus:
+
Edit your /etc/networking/interfaces on the target filesystem and add the following rules (required to setup the bit-rate of the bus):
  
 +
auto can0
 +
iface can0 inet manual
 +
#pre-up ip link set $IFACE type can bitrate 125000 listen-only off
 +
pre-up /ip link set $IFACE type can bitrate 125000 triple-sampling on
 +
up /sbin/ifconfig $IFACE up
 +
down /sbin/ifconfig $IFACE down
  
 
== References==
 
== References==

Revision as of 02:29, 1 June 2010

This article explains how to enable the CAN bus using as example the AM35x EVM, but can be applied to other platforms as well.

Build the SDK with socketcan and ip tools

Working with the CAN buys requires enabling the 'ip' tools from iputils2 package (the 'ip' tool from busybox won't work). The socketcan package is optional and provide you with tools to debug your can bus.

This packages are available from the RidgeRun SDK in the configuration menu.

Enable the kernel driver

In the case of the Category:AM35x platform the configuration is:

Linux Kernel Configuration
     Networking support
        CAN bus subsystem support
           CAN device drivers
               Platform CAN drivers with Netlink support
                 CAN bit-timing calculation
                 TI High End CAN controller (HECC)

Setup the networking rules

Edit your /etc/networking/interfaces on the target filesystem and add the following rules (required to setup the bit-rate of the bus):

auto can0
iface can0 inet manual
	#pre-up ip link set $IFACE type can bitrate 125000 listen-only off
	pre-up /ip link set $IFACE type can bitrate 125000 triple-sampling on
	up /sbin/ifconfig $IFACE up
	down /sbin/ifconfig $IFACE down

References