LinuxWorld
Subscribe to this site with RSS

Kernel space: Linux gets CAN support

The rugged communications bus designed for automotive and other high-noise applications now has Linux support, thanks to kernel developers at Volkswagen.

The Controller Area Network (CAN) specification describes a networking stack aimed at a specific environment: embedded, realtime controller networks. At the physical layer, it uses a differential serial technology which is intended to be highly resistant to electrical noise. The higher-level protocols use short datagrams (eight bytes maximum payload) and extensive checksumming to minimize the effect of errors. The protocols are simple in the extreme, placing the smallest possible demand on embedded controllers. CAN will be found in relatively small and hostile environments - inside automobiles, for example. So it makes sense that an automobile manufacturer—not the sort of company known for leading-edge Linux kernel development—is working to get a CAN implementation into the mainline kernel.

There have been CAN implementations on Linux before, though none have made their way into the mainline. Most of them, however, have taken the easy way out: make a CAN controller look more-or-less like a serial port and implement the protocols at the application level. This approach works, but it loses the advantages of having a networking stack around. Any CAN application which wants to take advantage of queueing, quality-of-service controls, the familiar socket API, etc. must implement that functionality itself. All of this may soon change, though, as the PF_CAN protocol family patches posted by Urs Thuermann, Oliver Hartkopp, and several others, matures.

As would be expected, these patches add a new PF_CAN protocol family which can be passed to the socket() system call. From there, sockets can be bound, read from, and written to in all the usual ways. Basic raw sockets can be used to send and receive datagrams on the (broadcast) bus. There is a mechanism for adding filters so that only datagrams of interest are received on a given interface. The PF_CAN implementation also comes with network drivers for a number of CAN interfaces. All told, it looks about as one would expect for a new network protocol family within the kernel. With this code in place, applications using CAN look almost like any other network-based Linux application.

RE: Kernel space: Linux gets CAN support By Karl G on October 18, 2007, 8:41 am Reply | Read entire comment I believe that the CAN code should NOT be integrated into the kernel but should be implemented as a loadable kernel module for those who need/want it. At the rate...

don't worry... By dmarti on October 19, 2007, 2:00 am Reply | Read entire comment Don't worry -- it's already designed to be built as a module (like all new Linux hardware or protocol support). See the patch at: http://svn.berlios.de/svnroot/repos/socketcan/trunk/patch-series/2.6.22/02-can-core.diff (look...

All comments (2)

Note: Register to have your user name appear; otherwise your comment will show up as "Anonymous."

*Anonymous comments will only appear once they are approved by the moderator.

Featured Whitepapers
Newsletter sign-up

Sign up for one of Network World's newsletters compliments of Linux World

Linux & Open Source News Alert
Web Applications Alert
Video and Podcast Alert
Security Alert
Virtualization Alert

Email Address: