-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
irled: Use gpio script to read led value #169
Conversation
@@ -33,7 +33,7 @@ case "$mode" in | |||
gpio clear $pin > /dev/null | |||
;; | |||
read) | |||
cat /sys/class/gpio/gpio${pin}/value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the pin you are queryig may be not exported. say a led pin which are defined in the environment but not exported by default. so you will be doing cat from a non-extent file, resulting in an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, new lesson learned. I think this patch should cure the problem, but let me know if you foresee other gotchas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it will work. Merging. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This project is fantastic!
Summary: Add a new value option to the gpio script for retrieving the bare value of a gpio. Use that feature, rather than the /sys/class/gpio tree, to read values in the irled script. Subsequent testing revealed that the gpio directory for the IR LED pin is not available upon boot. The gpio script provides the logic to export the gpio directory. Using the gpio script abstraction allows for reading the gpio without further concern for initialization state. Testing: With the patch, after a reboot, testing irled read: ``` test # irled read 0 test # irled on test # irled read 1 test # ``` After another reboot, testing gpio value option: ``` test # ls /sys/class/gpio/ export gpio57 gpio58 gpio8 gpiochip0 gpiochip32 gpiochip64 unexport test # gpio value 9 0 test # ``` Without the patch, after a reboot, showing prior problem: ``` test # irled read cat: can't open '/sys/class/gpio/gpio9/value': No such file or directory test # irled on test # irled read 1 test # ```
51def59
to
52a7aa6
Compare
Summary: Add a new value option to the gpio script for retrieving the bare value of a gpio. Use that feature, rather than the /sys/class/gpio tree, to read values in the irled script. Subsequent testing revealed that the gpio directory for the IR LED pin is not available upon boot. The gpio script provides the logic to export the gpio directory. Using the gpio script abstraction allows for reading the gpio without further concern for initialization state. Testing: With the patch, after a reboot, testing irled read: ``` test # irled read 0 test # irled on test # irled read 1 test # ``` After another reboot, testing gpio value option: ``` test # ls /sys/class/gpio/ export gpio57 gpio58 gpio8 gpiochip0 gpiochip32 gpiochip64 unexport test # gpio value 9 0 test # ``` Without the patch, after a reboot, showing prior problem: ``` test # irled read cat: can't open '/sys/class/gpio/gpio9/value': No such file or directory test # irled on test # irled read 1 test # ```
Summary:
Add a new value option to the gpio script for retrieving the bare value of a gpio. Use that feature, rather than the /sys/class/gpio tree, to read values in the irled script.
Subsequent testing revealed that the gpio directory for the IR LED pin is not available upon boot. The gpio script provides the logic to export the gpio directory. Using the gpio script abstraction allows for reading the gpio without further concern for initialization state.
Testing:
With the patch, after a reboot, testing irled read:
After another reboot, testing gpio value option:
Without the patch, after a reboot, showing prior problem: