User manual

6 OnRISC Hardware API
6.5. CAN
SocketCAN provides access to CAN controller on all CAN capable OnRISC devices
49
(refer to
Table 1). SocketCAN
50
is a set of open source CAN drivers and a networking stack contributed
by Volkswagen Research to the Linux kernel. Formerly known as Low Level CAN Framework
(LLCF).
6.5.1. CAN Interface Configuration
Special script /etc/init.d/can_if
51
is provided to setup can0 interface. It is preconfigured to
use can0 at 1000000b/s. These settings are stored in the CAN_IF variable:
CAN_IF="can0@1000000,200"
To start the CAN interface issue:
/etc/init.d/can_if start
to stop CAN interface issue:
/etc/init.d/can_if stop
Further information regarding programming and configuration can be found on the SocketCAN’s
project site.
6.5.2. CAN Usage Examples
To send a CAN frame execute:
cansend can0 123#1234
To receive CAN frames execute:
candump can0
6.5.3. CANopen
It is possible to use CANopen
52
library from CanFestival
53
or any other open source or proprietary
CANopen stack, that has SocketCAN support.
49
The CAN interface and the fourth serial interface on OnRISC Alena are sharing the same connector. The EPLD
must be switched to can before opening the CAN interface.
50
http://elinux.org/CAN_Bus
51
this script is maintained in this git repository: http://gitorious.org/linux-can/can-misc
52
www.can-cia.org
53
www.canfestival.org
May 2014 OnRISC User Manual 46