NSLU2-Linux
view · edit · print · history

(Note that this applies to Set_Led, a binary available in Unslung. The analogous command to set or toggle LED states in SlugOS is /sbin/leds .)

  • Set_Led - prints available commands.
  • Set_Led turn_on/off1 - controls the Disk 1 indicator.
  • Set_Led usb1_blinking - Blinks the Disk 1 indicator until /proc/hd_conn cannot be accessed.
  • Set_Led turn_on/off2 - controls the Disk 2 indicator.
  • Set_Led usb2_blinking - Blinks the Disk 2 indicator until /proc/usb_conn cannot be accessed.
  • Set_Led beep1 - one short beep. Returns when done.
  • Set_Led beep2 - two short beeps, then waits for 4 seconds. Loops for about a minute or until killed.
  • Set_Led beep3 - Same as beep2, except three beeps. Loops for about a minute or until killed.
  • Set_Led ready - Turns on the green and off the red elements of the ready/status bi-color LED.
  • Set_Led s_error - Turns on the red element only of the ready/status LED. (Green is not affected).
  • Set_Led s_ok - Turns off the red element only of the ready/status LED. (Green is not affected).
  • Set_Led r_blinking - Blinks the green element of the ready/status LED. (Red is not affected).
  • Set_Led s_blinking - Blinks the red element of the ready/status LED. (Green is not affected).
  • Set_Led rs_blinking - Alternates between red and green on the ready/status LED.
  • Set_Led power_off - unconditionally turns power off.

Set_Led does its magic by accessing a few syscalls. I do not know whether this will work with the OpenSlug kernel. The syscalls are as follows.
#define __NR_gpio_high 0x00900101
_syscall1(void, gpio_high, int, bit);
#define __NR_gpio_low 0x00900102
_syscall1(void, gpio_low, int, bit);
#define __NR_beep 0x00900103
_syscall0(void, beep);

The bit arguments referred to above correspond to the information on GPIOConnections. It is not a bitmask, it is the number of the bit to affect.


Some additional comments:

There is a bit of 'magic' going on with some of the commands: The "blinking" commands as well as the "beep2" and "beep3" commands do not return. So to use them in a script and avoid blocking, follow them with an ampersand as in

Set_Led rs_blinking &

A subsequent call of "Set_Led ready" will turn the status LED to green and terminate the blinking or beep processes.

Also when the "r_blinking" command is terminated manually while the LED is off, it will stay off. I do not know of a way to achieve this programmatically though.

Lastly the "power_off" command is intended to be used at the end of the shutdown scripts. A proper shutdown that will also call the shutdown scripts can be triggered with the "halt" command.

 -- gerti

Because I don't want my HDD to run 24/7, I automatically shut down at night (and restart in the morning using the Always-On-wiring). To be warned before shutdown occurs (save data, cancel shutdown, ...), I added the following lines to my /etc/crontab:

 30 22 * * * root Set_Led s_blinking &>/dev/null
 00 23 * * * root Set_Led rs_blinking &>/dev/null
 00 23 * * * root Set_Led beep1 &>/dev/null
 29 23 * * * root Set_Led beep3 &>/dev/null
 30 23 * * * root /usr/sbin/DO_Shutdown &>/dev/null

This way, the Ready-LED starts to blink Green/Orange one hour before shutdown. Half an hour before shutdown, the LED starts to blink Green/Red and a beep is triggered. Finally, one minute before shutdown, a triple beep will demand attention. Feel free to use this as a starting point for your own warning mechanism.

view · edit · print · history · Last edited by Marcelo Vianna.
Based on work by abliss, Sebastian Kraatz, ShaunLeeClarke, gerti, kaste, glum, and rwhitby.
Originally by rwhitby.
Page last modified on August 02, 2008, at 11:42 PM