You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to read the status of GPIO35 on a Raspberry Pi 2 Model B using the sysfs on Raspbian with a 4.0.8-v7+ kernel. I can access other GPIO pins using /sys/class/gpio but the two leds are already accessable by /sys/class/leds/led[0,1].
My assumption was that putting led1 (the red led) into trigger mode input the state of the led could be read using the brightness attribute. This value does not seem to change and is always on 0.
When using non-sysfs tools I can access the state of GPIO35 without a problem: raspi-gpio get 35 will change its level value from 1 to 0 when an under-voltage occurs. I hope to use one pattern to access all GPIO's by file monitoring using select or poll and not revert to a different solution for the leds.
The reason why I'm monitoring GPIO35 is to see if there are voltage issue and report those to the end user, advising to change the adapter and/or cable.
Does led trigger input does what I think it should do, or could this be a bug?
Could I configure led1 not to be a led but a gpio in sysfs?
The leds-gpio module does not currently implement the brightness get mechanism, but I think it could be made to without too much effort. It has already been modified to get ledtrig-input to work, so making further changes isn't an issue.
Wow, thank you Phil! I will try to test your changes if I can setup a build environment.
One more question: will this enable me to use a select(2) or poll(2) on the brightness attribute? On the gpio sys subsystem this will only work if you enable an edge attribute.
Unfortunately no. The sysfs interface for LEDs is a straight read/write interface, and the structure of the LEDs subsystem insulates the individual LED drivers from the sysfs entries. However, there are some LEDs modules that add their own sysfs entries, so it should be possible.
Activity
pelwell commentedon Jul 15, 2015
The leds-gpio module does not currently implement the brightness get mechanism, but I think it could be made to without too much effort. It has already been modified to get ledtrig-input to work, so making further changes isn't an issue.
leds-gpio: Implement the brightness_get method
leds-gpio: Implement the brightness_get method
pelwell commentedon Jul 15, 2015
That was easy. It will be in the next release.
jvwag commentedon Jul 15, 2015
Wow, thank you Phil! I will try to test your changes if I can setup a build environment.
One more question: will this enable me to use a select(2) or poll(2) on the brightness attribute? On the gpio sys subsystem this will only work if you enable an edge attribute.
pelwell commentedon Jul 16, 2015
Unfortunately no. The sysfs interface for LEDs is a straight read/write interface, and the structure of the LEDs subsystem insulates the individual LED drivers from the sysfs entries. However, there are some LEDs modules that add their own sysfs entries, so it should be possible.
kernel: mfd: Add Raspberry Pi Sense HAT core driver
kernel: mfd: Add Raspberry Pi Sense HAT core driver
leds-gpio: Implement the brightness_get method
leds-gpio: Implement the brightness_get method
leds-gpio: Implement the brightness_get method
leds-gpio: Implement the brightness_get method
leds-gpio: Implement the brightness_get method
leds-gpio: Implement the brightness_get method
271 remaining items
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger
BCM270x_DT: Add pwr_led, and the required "input" trigger