Difference between revisions of "CAN bus Linux driver"
From ArmadeusWiki
m (→Usage) |
m (→Quick test) |
||
Line 35: | Line 35: | ||
==Quick test== | ==Quick test== | ||
Once the driver installed, the CAN interface has to be started like a standard net interface | Once the driver installed, the CAN interface has to be started like a standard net interface | ||
− | ifconfig can0 up | + | <pre class="apf"> |
+ | # ifconfig can0 up | ||
+ | </pre> | ||
and can be stopped like that: | and can be stopped like that: | ||
− | ifconfig can0 down | + | <pre class="apf"> |
− | + | # ifconfig can0 down | |
+ | </pre> | ||
The socketCAN version can be retrieved like that: | The socketCAN version can be retrieved like that: | ||
− | cat /proc/net/can/version | + | <pre class="apf"> |
− | + | # cat /proc/net/can/version | |
+ | </pre> | ||
The socketCAN statistics can be retrieved like that: | The socketCAN statistics can be retrieved like that: | ||
− | cat /proc/net/can/stats | + | <pre class="apf"> |
+ | # cat /proc/net/can/stats | ||
+ | </pre> | ||
==Userspace tools== | ==Userspace tools== |
Revision as of 15:16, 23 February 2009
Contents
WORK IN PROGRESS
The current CAN bus driver uses SocketCAN API which is now the official CAN API for Linux.
SocketCAN is based on the Linux socket. Further details can be found on the links at the bottom of this page.
Driver installation
$ make linux26-menuconfig
Device Drivers ---> SPI support ---> <*> Freescale iMX SPI controller Networking ---> <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> Microchip 251x series SPI CAN Controller
Usage
- load all the needed drivers:
modprobe can modprobe candev modprobe can-raw modprobe mcp251x
Quick test
Once the driver installed, 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 like that:
# cat /proc/net/can/version
The socketCAN statistics can be retrieved like that:
# cat /proc/net/can/stats
Userspace tools
- Several tools are provided by socketCAN:
- candump: dump traffic on a CAN network
- cansend: simple command line tool to send CAN-frames via CAN_RAW sockets
- 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:
[armadeus]$ make menuconfig
DevFull Can Bus
- The default baud rate is 250 kbaud.
- The CAN Connector (X2) is wired this way :
- X2.1 = +5Vdc
- X2.2 = CANH
- X2.3 = CANL
- X2.2 = GND
Links
- http://developer.berlios.de/projects/socketcan/ (CAN Linux Driver)
- http://ww1.microchip.com/downloads/en/DeviceDoc/21801e.pdf (MCP2515 datasheet)
- http://www.kvaser.com/can/protocol/index.htm (CAN introduction)