Skip to content
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

Merged
merged 1 commit into from
Aug 17, 2024

Conversation

DavidPletcher
Copy link
Contributor

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 #

@@ -33,7 +33,7 @@ case "$mode" in
gpio clear $pin > /dev/null
;;
read)
cat /sys/class/gpio/gpio${pin}/value
Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Owner

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.

Copy link
Contributor Author

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 #
```
@themactep themactep merged commit 5e9cbac into themactep:master Aug 17, 2024
1 check passed
@DavidPletcher DavidPletcher deleted the gpio_irled branch August 17, 2024 13:18
jayfan0 pushed a commit to jayfan0/thingino-firmware that referenced this pull request Aug 19, 2024
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 #
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants