Now that all my traffic to and from the internet is running happily through my Alix box (and it had no trouble with a few hours of sustained maxing-out of my 6Mbps down/768kbps up DSL line in both directions), and since my first test unslung-NSLU2 “slug” seems to be stably doing its job as a backup DNS/DHCP server, it’s time to do the fun little things, like wonder, “Hey, the Alix has 3 LEDs on the front. What could I do with those?”
Well, first I learned from a mailing list archive post that under OpenBSD, the LEDs are easily controlled with gpioctl (using 0 and 1 for off and on):
-
gpioctl -q -c 6 out iout
-
gpioctl -q -c 25 out iout
-
gpioctl -q -c 27 out iout
-
-
gpioctl -q 6 [0/1] # for the left-most LED
-
gpioctl -q 25 [0/1] # for the middle LED
-
gpioctl -q 27 [0/1] # for the right-most LED
That’s pretty easy, but it’s just on and off (though it does require privileged access to control the GPIO pins). Poking around on the web today, though, I found Jordan Sissel’s blog post on making the Soekris net4501′s LEDs do the Apple-style pulsing fade-in-out. His C program didn’t work straight away on my Alix, perhaps because he was working on FreeBSD and I’m using OpenBSD, but with a little digging in the OpenBSD source code for gpioctl, I was able to cobble together some C code to replace his “led” function that set the state of the LED as well as the device initialization. With a little tweaking to make the code feel more like my own and to make the LED pulse just once (the original code pulsed indefinitely), I arrived at pulse_led2_once.c (which still must be run as root to work, since it uses the GPIO interface).
NOTE: This file is provided “as is” and is not guaranteed to do anything at all, including not guaranteed to be safe to run. It worked for me, YMMV. I’ve posted my modifications having asked Jordan Sissel first; I’d appreciate it if you’d let me know if you wanted to post modifications to my code. AFAIK, my inclusion of OpenBSD source was done in compliance with the copyright notice in their source file, reproduced as requested by the code I used.
Trackbacks & Pingbacks 1
[...] the LEDs is fairly simple. I started on OpenBSD, found a very simple method for controlling them through gpioctl right away and quickly rolled it into this very simple shell script that allows for commands such [...]