Al 09/05/11 17:14, En/na John Crispin ha escrit: >> >> The next question is, how can I control (some of) the leds from an >> userspace program? >> Opening the /sys/class/leds/<led name>/trigger file and alternatively >> writing "none" or "default-on"? >> Or the same but with the "brightness" file? >> Writing a trigger module? (and how since the trigger comes from user >> space)? >> Open the gpio directly? (again, how?) >> Some other way? >> >> TIA > > Hi luca, > > if it is a gpio > cd /sys/class/gpio > echo 13 > export > echo out > gpio13/direction > echo 0/1 gpio13/brightness > > for a led in userland echo default-on >/sys/class/leds/<led name>/trigger > > or in kernel space use the "default trigger" as shown in this patch > https://lists.openwrt.org/pipermail/openwrt-devel/2008-January/001618.html > > also look at /etc/init.d/led it allows you to setup your leds based on > a uci file > > so ideally you give your leds a default brightness / trigger in the > kernel code and then setup the others in userland via uci depending on > which works best / makes sense for the specific case
Well, none of the above ;-) For almost all the leds there's already a suitable trigger module (be it network activity, usb, heartbeat, etc., so it's just a matter of enabling it like you said above, but there are some leds that I'd like to control from a C application (specifically fxs1, fxs2 and voip), so I'd like to know if there's an api for it, or I just open, e.g., /sys/class/leds/soc:green:fxs1/trigger, and fprintf "default-on" to turn it on and "none" to turn it off (i.e., like the above shell commands but from C). I just wanted to know if is there a more elegant way. Note that those 3 leds are controlled by the ebu driver, and I assigned them to the gpio_led structure, i.e.: static struct gpio_led arv7518pw_leds_gpio[] __initdata = { { .name = "soc:green:power", .gpio = 2, .active_low = 1, }, { .name = "soc:green:adsl", .gpio = 4, .active_low = 1, }, { .name = "soc:green:internet", .gpio = 5, .active_low = 1, }, { .name = "soc:green:wlan", .gpio = 6, .active_low = 1, }, { .name = "soc:red:internet", .gpio = 8, .active_low = 1, }, { .name = "soc:green:usb", .gpio = 19, .active_low = 1, }, { .name = "soc:green:voip", .gpio = 32, .active_low = 1, }, { .name = "soc:green:fxs1", .gpio = 33, .active_low = 1, }, { .name = "soc:green:fxs2", .gpio = 34, .active_low = 1, }, /* no fxo on this board but the led is there, unlabeled */ { .name = "soc:red:fxo", .gpio = 35, .active_low = 1, }, { .name = "soc:yellow:wps", .gpio = 36, .active_low = 1, }, { .name = "soc:red:wps", .gpio = 38, .active_low = 1, }, }; so I'm not sure I can use the /sys/class/gpio method (the "echo xxx > /sys/class/leds/yyy/trigger" method works, that's how it tested from userspace). Bye -- Luca _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel