CrossCore XA
Revision: 1.0
Programmers Guide
Date: Jul 1, 10
3.
CAN Communication Interface
The CAN Communication interface enables the caller to receive messages from and send messages
to the CAN interfaces on the CrossCore XA device. The CAN communication is handled over the
SocketCAN interface, which is a method to use standard socket API functions for CAN
communication [4].
3.1.
Configuration of device interface
The device node files for the two CAN interfaces are can0 and can1, which should be shown when
listing all network interfaces with the ifconfig command. The device driver is implemented as
loadable kernel modules, can_dev.ko, xilinx.ko and xilinx_platform.ko. In addition, there are at
least two CAN protocol modules providing access to the CAN protocol interface. A script handles
the loading of the kernel modules upon start-up.
When device has finished its start-up, the CAN driver modules are loaded as a part of the kernel.
This can be checked via terminal access using lsmod command:
# lsmod | egrep “can|xilinx”
can_raw
7552 0
can 23656 1 can_raw
xilinx_platform 2848 0
xilinx 6080 1 xilinx_platform
can_dev 15616 1 xilinx
Since the driver is compiled as modules, unnecessary protocols may be removed or new modules
inserted according to user needs.
The CAN bus itself is not initialized during start-up, it only loads the drivers. Before any
communications can be executed, user must set correct bus speed (as an example 250kbit/s) by
first writing value into bitrate parameter:
# echo 250000 > /sys/class/net/can0/can_bittiming/bitrate
and then setting interface up with ifconfig:
# ifconfig can0 up
After this, ifconfig should show can0 as a network interface:
# ifconfig
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00
UP RUNNING NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:49
Same applies to the second CAN interface by changing can0 to can1.
www.crosscontrol.com
8