-
Notifications
You must be signed in to change notification settings - Fork 44
Need a sleep/timeout after exporting pin? #5
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
Comments
Thanks for filing the issue. I tested mostly on the BBB and RPi 1 and may have been running as root (I don't recall). My expectation is that the export would be a synchronous operation, but you clearly have some evidence to the contrary. Maybe changing of permissions is handled outside of the kernel by something like udev? I'll have to research a bit more. |
You are right, permissions are changed by udev, the rules are in /lib/udev/rules.d/60-python3-pifacecommon.rules and /lib/udev/rules.d/60-python-pifacecommon.rules files. |
Ok, given that this is udev, I think I will update the example for greater compatibility and add a comment to the code stating that you may need a delay (or to poll for appropriate stat on some file). I don't think a change to the library core to add a delay would be appropriate as many systems would not be setup in the same way. |
I agree that this library should not need to handle delays caused by udev. |
If I run
blinky
example with pi user then I receive error:If I run it with root user, everything is working correctly.
By trial and error I have found that after exporting a pin at least a 80ms sleep is required before exported pin can be manipulated by users in group
gpio
.If I change blink_my_led function in blinky.rs to
then everything runs successfully with a
pi
user.I have found that when pin is exported for short period of time the owner of the exported pin is root:root. Later the owner is changed to root:gpio. During the period when owner is root:root users in gpio group can't operate the pin.
I'm not sure if this issue is specific to my Raspbery Pi / Raspbian version or this is how gpio sysfs works on Raspberry Pi. Maybe it should be documented somewhere that a timeout is required after exporting pin?
Raspberry Pi model 1 B+
The text was updated successfully, but these errors were encountered: