Closed felix-ht closed 4 years ago
Another option instead of the sleep, would be to try opening the direction file a couple of times. Similar to how it is solved in
for i in range(GPIO.GPIO_EXPORT_STAT_RETRIES): ...
Thanks for raising this. I'll add code for a retry loop around opening/writing direction, as you mentioned.
I have setup udev rules so that i can run this library without root permissions. Im am using the library to access gpios. In this environment the library throws an error, when i try to acess any gpio:
The cause for this is that after the device is exported it takes a moment until the udev rules get applied. However, this library is trying to change the direction for the GPIO right away. As the new udev defined permissions are not yet set, this fails with the aforementioned error.
To fix there error i monkey patched the
_open
function in the library, by adding a short sleep after the export: