lambdasoup

Go release: go-netlink

Maximilian Hille / Tue, May 5, 2015

To read Maxim iButton temperature sensors in Linux is not a big problem, but needs some work. There is a kernel module / driver for the USB reader adapter. This kernel module can be accessed from user space via a special file ‘rw’ or via a Netlink interface.

The ‘rw’ method is straight forward (with the technical docs from Maxim), but has some drawbacks: The file as it is created is only accessible for root and the location of this file is depending on the unique ID, distribution and maybe even the kernel version.

The Netlink method does not have these drawbacks, but in order to use the Netlink interface, you need to learn a bit about the Linux kernel.

After reading more kernel code that I wanted and learning about how to debug a running kernel (thanks for making Systemtap), I managed to talk to the iButton. You can grab the code at GitHub, it’s license is GPL3+.

The Go packages mirror the Netlink / Connector / One-Wire layer hierarchy within the kernel. Thus, the code can also be interesting for people trying to talk with other branches on those subsystems.

Note that the implementation is not very clean yet. I get some warnings like ALLCAPS for constants. I consider myself still a Go rookie ;-)