Resource busy when trying to run pyGpio example program
I am trying to run the GPIO example programs as well as doing my own GPIO code and keep running into the same errors. I always get a Errno 16 Resource busy at some point or other.
I have tried ˋecho 14 > /sys/class/gpio/unexportˋ to reset the gpio pin, but that didn't help either.
Any ideas what might be wrong?
Ok, so here is code derived from the official GPIO example code (which did not work either):
import onionGpio import time import os print '> Instantiating gpio object' gpio5 = onionGpio.OnionGpio(5) gpio11 = onionGpio.OnionGpio(11) print '' print '> Set direction to output... ' ret = gpio5.setOutputDirection() print ' returned %d'%ret ret = gpio11.setOutputDirection() print ' returned %d'%ret print '> Set gpio 5 value to 0... ' ret = gpio5.setValue(0) print ' returned %d'%ret time.sleep(0.1) print '> Set gpio 11 value to 0... ' ret = gpio11.setValue(0) print ' returned %d'%ret time.sleep(0.1) print '> Set gpio 11 value to 1... ' ret = gpio11.setValue(1) print ' returned %d'%ret time.sleep(0.1) print ''
I hooked up GPIO11 to my Si470x's RST pin, and the GPIO5 (SDA) to the Si470x board's respective i2c SDA pin.
I cross checked with my Pi that exactly this wiring works (it does, using a small i2cinit tool and the C based RdsPi Si470 software).
When running the above software to try and put the Si470x in two wire mode, I still get the resource busy error:
root@Omega-FF87:~# echo 11 > /sys/class/gpio/unexport -ash: write error: Invalid argument root@Omega-FF87:~# echo 5 > /sys/class/gpio/unexport -ash: write error: Invalid argument root@Omega-FF87:~# python onion-si470x.py > Instantiating gpio object > Set direction to output... Traceback (most recent call last): File "onion-si470x.py", line 12, in <module> ret = gpio5.setOutputDirection() File "/usr/lib/python2.7/onionGpio.py", line 168, in setOutputDirection ret = self._setDirection(argument) File "/usr/lib/python2.7/onionGpio.py", line 147, in _setDirection self.setValue(0) File "/usr/lib/python2.7/onionGpio.py", line 85, in setValue status = self._initGpio() File "/usr/lib/python2.7/onionGpio.py", line 46, in _initGpio fd.close() IOError: [Errno 16] Resource busy
I have the feeling that the GPIO libraries on the Omega are totally broken. The only thing I got working was using the gpioctl command line program.
The same stuff seems so much easier on the Pi and much more reliable.
I had the same issue running the sample, I found a bug in the python onionGpio.py library
In the _setDirection function I moved :
# set default for output direction
if direction == _GPIO_OUTPUT_DIRECTION:
so that it followed the :
status = self._freeGpio()
because the setValue call has a __initGpio call in it's code which was being called before the resource had been freed.
I've tried your fix and i'm still getting the same issue. Can you elaborate on the exact syntax you used to fix this issue?