2

May be not the right place, but ran again that on the RPi platform.

I want to have - say - an output on the RPi. I'm user pi. I'm in gpio group. I say 'echo 26> /sys/class/gpio/export'. Works. I then say 'echo out> /sys/class/gpio/gpio26/direction'. Works, too. I can now set or clear that pin from bash. Okay.

I do 'echo 26> /sys/class/gpio/unexport', then.

Now, I launch that script:

#!/bin/bash
echo 26 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio26/direction

This throws permission denied in line 3, accessing the direction file.

After unexporting the GPIO 26, I patch my script. It now looks like

#!/bin/bash
echo 26 > /sys/class/gpio/export
sleep 1
echo out > /sys/class/gpio/gpio26/direction

That works.

Any known reason?

asked Jan 23, 2019 at 22:01

1 Answer 1

4

It takes a fraction of a second for the kernel to export the GPIO. Adding a short delay lets the action complete before the next command is run.

answered Jan 23, 2019 at 22:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.