April 10th, 2017, 08:50 PM
how to use leds
What is the correct way to control the LEDs from a C program?
Here is the gist what I am doing now:
Write as needed:
int green_fd = open ("/sys/class/leds/green-led/brightness", O_RDWR);
write (green_fd, "1", 1);
This does work fine and is quite fast.
write (green_fd, "0", 1);
However, running top I noticed a process called systemd-udevd is taking up 100% CPU, even if I stop my program. Using strace I can see it is in a tight loop opening "/sys/devices/soc0/leds.16/leds/green-led/uevent" over and over.
April 10th, 2017, 09:09 PM
Which distribution/board are you running? I'd like to reproduce this here.
April 10th, 2017, 09:26 PM
TS-4900-2048-4096F-Q10S-RTC-E on KIT-8550-4900
root@ts-imx6:~/sbc# uname -a
Linux ts-imx6 3.10.53-1.1.0-technologic+gfc2d17f #1 SMP PREEMPT Mon Dec 21 14:53:23 MST 2015 armv7l GNU/Linux