Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedded Linux LED-flashing daemon: does it exist?

I've seen embedded boards before that have an LED that flashes like a heartbeat to show that the board is still executing code. I'd like to do something similar on an embedded Linux board I'm working on. Given that it's a fairly trivial bit of code, it seems likely to me that someone has already written a daemon for Linux that does this, but I haven't been able to find any evidence.

Note that OS X Server's heartbeatd and the High-Availability Linux heartbeat daemon are not what I'm looking for-- they both coordinate system availability over IP networks, or something like that.

Assuming what I'm looking for doesn't exist, I'm also interested in advice about how to write a daemon that toggles a pin while minimizing resource usage. At what update rate does cron become a stupid idea?

(I'd also rather not hear gushing about the LED on the sleeping MacBook Pro, if that seems relevant for some reason.)

Thanks.

like image 721
pingswept Avatar asked Oct 25 '25 08:10

pingswept


1 Answers

The LED heartbeat is a built-in kernel function. Assuming you have a device driver for your LED, turning on the heartbeat is done thus:

$ echo "heartbeat" > /sys/class/leds/MyLed/trigger

To see the list of triggers (MMC activity, heartbeat, etc.)

$ cat /sys/class/leds/MyLed/trigger

See drivers/leds/ledtrig-heartbeat.c and http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/LEDs

The interesting thing about the heartbeat is that the pattern is dynamic. The basic pattern is thump-thump-pause, just like a human heartbeat. But the rate of the heartbeat is controlled by the load average! Light loads beat at about 50 beats per minute. Heavier loads cause faster beating until it maxes out at about 180 bpm.

like image 113
Robᵩ Avatar answered Oct 28 '25 03:10

Robᵩ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!