LED on the Plug

From PlugWiki

Revision as of 14:58, 24 January 2010 by Cemc (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

There are two leds on the SheevaPlug (not counting the leds on the ethernet port, which for some reason are both blinking when there's traffic, at least on my Plug).
One LED is green, it indicates that the Plug is powered. The other one can be programmed to blink to your liking :)

(Note: this was tested with Debian on a SheevaPlug from GlobalScale Technologies)

Contents

Checking for LED support

Log in to your Plug with Debian installed on it. To check if you have support for controlling the LED, go to:

# cd /sys/devices/platform/leds-gpio/leds/plug:green:health

If you don't have this directory at all, you might not have it enabled in the kernel.

LED blinking modes

You should have a couple of files in this directory, but you're interested only in the following ones:

brightness  trigger

The file named trigger sets the LED blinking mode. Let's see what's in it (note: this is on my Plug, you could have other stuff in it):

# cat trigger 
none nand-disk timer [default-on] mmc0 
  • [] indicates the currently selected mode.

The modes are as follows:

none

  • this is the simple one, can be thought of as the manual mode. In this mode you can turn the LED on/off by writing values to the file named brightness:
# echo "1" > brightness
# echo "0" > brightness
  • "1" means turn the LED on, "0" means turn it off (obviously)

nand-disk / mmc0

  • in these modes, the LED will blink when there's activity on the NAND flash or the SD Card (similar to hdd activity LED on desktops/laptops)

default-on

  • this is the default mode on my Plug, in this mode the LED is always turned on.

timer

  • this is my favorite ;) when this mode is activated (see below on how to change modes), two other files appear:
delay_off delay_on

With these two files you control the on/off duration of the LED, by writing duration times (in milliseconds) in the files.
For example if you want the LED to be on for 1 (one) second and off for 2 (two) seconds, you do it like this:

# echo "1000" > delay_on
# echo "2000" > delay_off
  • remember, you see these files only after setting the mode to timer
  • you can reset the timers by writing zeros to both files
  • the files disappear AND the timers are reset to 0 (zero) as soon as you change the mode
  • you shouldn't set delay_off lower than ~30ms otherwise you won't see any blinking (ymmv)

Changing modes

  • you change modes by writing the mode name to the file trigger, like this:
echo "none" > trigger
echo "default-on" > trigger
  • to check the current mode, you just read the file, and see which mode is marked with [ ]:
# cat trigger 
none nand-disk timer [default-on] mmc0