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.
Warning: Please ensure that you use a recent version of armadeus BSP (kernel version more than 2.6.38 is required) before trying the instructions described on this page! With older kernel versions you may not be able to change the bitrate. |
Driver installation
The Linux driver is developed by means of C Language, which is different form the normal one we use. What we often use is Libc library, which doesn’t exist in the kernel. While the driver is a. This is the Series on Linux Device Driver. The aim of this series is to provide, easy and practical examples so that everybody can understand the concepts in a simple manner. So let’s get into Linux Device Driver Part 1 – Introduction. Before we start with programming, it’s always better to know some basic things about Linux and its drivers.
- Nothing has to be done for the APF51Dev, the APF28Dev, APF6Dev and the OPOS6ULDev.
- For the APF27DevFull:
- Reflash kernel and rootfs
Usage
- Load all the required drivers (not needed on OPOS6UL):
APF27 & APF51 | APF6 |
---|
- Set the bitrate before all operations
Example:Set the bitrate of the can0 interface to 125kbps:
Note: An error occurs when you try to set the bitrate with an old Linux kernel. In that case, echo 125000 > /sys/devices/platform/FlexCAN.0/bitrate was reported to be a good alternative. |
- If the following error occurs when you do the last instruction :
check that this command:
return this message:
and not this one :
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:
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:
- and can be stopped like that:
- The socketCAN version can be retrieved this way:
- The socketCAN statistics can be retrieved this way:
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
- 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.
You can send a remote request message
The information with the identifier 500 will be available on the bus when the device receive the remote request message
Linux Driver Update
- 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:
then, reflash your rootfs.
Automatically launch CAN interface at startup
- Add the following lines to /etc/network/interfaces configuration file:
Linux Driver Md
Links
Linux Driver For Laptop Webcam
- https://www.ridgerun.com/developer/wiki/index.php/How_to_configure_and_use_CAN_bus (How to configure and use CAN bus)
- 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)