NSLU2-Linux
view · edit · print · history

This page is out of date: the format is now:

$ leds [ready|status|disk-1|disk-2] [on|off|slow|fast|panic|blink|flash|user|cpu|cpu-idle]

With the OpenSlug 1.12 beta release there is a simple command leds which sets the LEDs on the NSLU2 to the running state after system boot has complete.

In the following releases leds is enhanced to allow direct setting of all four of the settable LEDs - the two ready/status LEDs (one red, one green) and the disk 1 and disk 2 LEDs. Note that the red and green leds together form the ready/status indicator and hence together control one of the lights on the outside of the slug.
There is no way to control the ethernet LED using this interface.

Access for program writers is as before, and is documented in ProgrammingTheOpenSlugLEDs.

At this time user level access to the buzzer and to the power and reset button output is not available. Program level access is possible, and is documented in the above page.

The OpenSlug boot sequence uses the ready/status LED pair to indicate boot progress, this is described in OpenSlugLEDsDuringBoot. These settings are accomplished using the leds command.

The leds command

In OpenSlug 1.12 leds simply resets all settable LEDs to a state where only the green ready/status LED is on.

In later releases leds puts the LEDs into the same state if given no arguments. With arguments individual control of each LED is supported.

-<leds>
Turns the given LEDs off.
+<leds>
Turns the given LEDs on.
!<leds>
Makes the given LEDs flash.
/<leds>
Makes the LEDs alternate between the state given by the previous options and a state with the LEDs in the / option on. This creates a transition between the two settings.

The LEDs are are identified by one or more characters as follows:

r
The red ready/status LED.
g
The green ready/status LED.
1
The disk 1 LED.
2
The disk 2 LED.
A
All four LEDs.

For example:

leds -A +g1 !r

This sets the state of all LEDs to off (-A) then marks the green ready/status and disk 1 LED to be on (+g1) and the red ready/status LED to flash (!r). Thus the commands sets green on, red flashing, disk 1 on and disk 2 off. Because red and green share the same light pipe the result is that the ready/status LED seems to flash amber/green.

leds +r

This just turns the red ready/status LED on - the other LEDs are not changed in any way.

leds !g

The green ready/status LED starts flashing. Because each LED is controlled by a separate timer the result of setting LEDs to flashing in different leds commands is unpredictable - the synchronisation (or lack thereof) of the flashing depends on the exact delay between the commands.

leds -A +gr /g1

The initial state is set with the disk LEDs off and green and red on (amber). The final state is with green and disk 1 on and (by implication) red and disk 2 off. The LEDs are set to alternate between these two states, so the ready/status LEDs flash amber/green and the disk 1 light flashes (on when the ready/status is green, off when amber.)

leds -A +g /g

There is no change in this transition. The leds command handles this by flashing the LEDs on and off. This is used in the boot process to indicate a state transition between two run states which use the same LED colour.

leds -A +g /r

This is a red/green transition - the ready/status LEDs will flash alternately red/green. Programmers should be aware that this is the only way of invoking the N2_LM_ALT ioctl.

When using a transition it is necessary to specify both the before and after states of the LEDs to be changed, so:

leds +g -r /r

also causes the red/green alternate flashing, but does not change the state of either of the disk LEDs. If the -r were to be omitted the initial state of the red LED would be unknown and so nothing would be done to it - the command would just cause the green LED to flash.

view · edit · print · history · Last edited by Matt Schinckel.
Based on work by eFfeM, tman, jbowler, g2, ByronT, and VoodooZ.
Originally by VoodooZ.
Page last modified on May 04, 2007, at 07:29 AM