SocketCAN Kernel
Last updated
Last updated
Copyright © 2024 | All Rights Reserved
Intrepid Control Systems introduced an Open Source API called Libicsneo. This can be used with python_ics to integrate Intrepid vehicle networking hardware to any Python application running Linux, Mac or Windows. Please refer to The easy way to program ValueCAN 4 in python using Raspberry Pi (Linux) if you would like to learn how to program your device using Intrepid API.
In this tutorial you will learn how to set up the Intrepid SocketCAN kernel module on your Raspberry Pi 4 to work with any Intrepid tool such as ValueCAN 4 series. Please reference the documentation for a list of supported hardware. We will be using ValueCAN 4–2 that includes two channels of CAN or CAN FD.
Connect ValueCAN 4–2 using DB-9F to OBD-II cable to neoOBD2 Simulator (optional) to receive or transmit CAN or CAN FD messages instead of a car.
Install dkms, the package for Dynamic Kernel Module Support Framework. We need the dkms package for Raspberry Pi because it doesn’t have a kernel header. On Ubuntu, this is accomplished by running:
Go to the module directory by using:
The resulting file will be intrepid.ko. This module depends on can, can_dev, and can_raw. We have a script to help within the makefile, make reload. But If you prefer to run it yourself, you can run using the following command:
Use lsmod
to confirm the module is loaded.
If you wish to have the module auto-load on boot, then please follow the instructions on our GitHub page at https://github.com/intrepidcs/intrepid-socketcan-kernel-module. Once you have the Intrepid Socket Kernel Module setup, then we will need to install icsscand. Intrepid Icsscand is a user-mode SocketCAN daemon for Intrepid devices.
To keep our file system clean, we will move out of the Intrepid SocketCAN Kernel directory by using cd..
command.
To install the dependencies needed we will run
Once you have the dependencies installed, then clone icsscand repository recursively by running
Switch into the cloned directory, cd icsscand
and make a build directory and switch into it, mkdir build && cd build
Daemon should now be available as libicsneo-socketcan-daemon. Daemon allows you to run Intrepid devices in the background. To start the daemon program use
If you’re happy with the results and would like to run in the background, run sudo ./libicsneo-socketcan-daemon -d
to run in daemon mode.
To view your CAN interfaces, use the command, sudo ip link
. They will be labeled can0, can1, and etc. They will have an alias listed which corresponds to the serial number of the device and network on that device. To enable the CAN interface to transmit and receive with sudo ip link set up can0
, replacing can0 with whichever interface you’d like to enable
You can now use any SocketCAN application with this interface. A good package for testing is the can-utils package. You can get this with sudo apt install can-utils
. A good testing tool which comes with this package is candump. Running candump can0
will print a line for every incoming frame.
Install Intrepid SocketCAN Kernel Module
Install and start SocketCAN daemon for Intrepid devices.
View and enable the correct CAN Interface
You can read intrepid-socketcan-kernel-module at https://github.com/intrepidcs/intrepid-socketcan-kernel-module and icsscand https://github.com/intrepidcs/icsscand