2718.us blog » pulse http://2718.us/blog Miscellaneous Technological Geekery Tue, 18 May 2010 02:42:55 +0000 en hourly 1 http://wordpress.org/?v=3.0.4 Pulsing the Alix LEDs http://2718.us/blog/2008/05/25/pulsing-the-alix-leds/ http://2718.us/blog/2008/05/25/pulsing-the-alix-leds/#comments Mon, 26 May 2008 01:11:07 +0000 2718.us http://2718.us/blog/?p=41 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):

# one-time setup to get 0 and 1 to mean what we expect
  1. gpioctl -q -c 6 out iout
  2. gpioctl -q -c 25 out iout
  3. gpioctl -q -c 27 out iout
  4.  
  5. gpioctl -q 6 [0/1]    # for the left-most LED
  6. gpioctl -q 25 [0/1]   # for the middle LED
  7. 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-outHis 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.

]]>
http://2718.us/blog/2008/05/25/pulsing-the-alix-leds/feed/ 1