
Example C SocketCAN Code
Writing user space C code to talk to CAN devices via the Linux SocketCAN interface is relatively simple and efficient. SocketCAN uses the Berkeley socket API and hence is very similar to communicating with other network socket devices. Below is a simple guide to get you started reading, writing and filtering CAN packets. Official documentation for the SocketCAN interface can be found at: https://www.kernel.org/doc/Documentation/networking/can.txt Complete code for the following examples can be found at the following GitHub repository: https://github.com/craigpeacock/CAN-Examples These examples do not include make files. To build a source file, you can simply use gcc. For example, to build …