jobin-sun / raspberry-gpio-python

Automatically exported from code.google.com/p/raspberry-gpio-python
MIT License
0 stars 0 forks source link

Allow input(gpio) when GPIO has been set up as OUTPUT #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I've just changed the condition in py_gpio.c:verify_input, line 139 :
[code]
    if ((gpio_direction[*gpio] != INPUT) && (gpio_direction[*gpio] != OUTPUT))
    {
        PyErr_SetString(WrongDirectionException, "The GPIO channel has not been set up");
        return 0;
    }
[/code]

So we can directly the output state using input function :

>>> import RPi.GPIO as g
>>> g.setmode(g.BCM)
>>> g.setup(7, g.OUT)
>>> g.input(7)
False
>>> g.output(7, 1)
>>> g.input(7)
True
>>> g.output(7, 0)
>>> g.input(7)
False

Original issue reported on code.google.com by tro...@trouch.com on 9 Sep 2012 at 4:11

Attachments:

GoogleCodeExporter commented 9 years ago
I see what you mean now when you reported this by email.  I now see why this 
would be very useful for WebIOPi!  I'll see what I can do...

Original comment by btcros...@googlemail.com on 9 Sep 2012 at 4:20

GoogleCodeExporter commented 9 years ago
Thanks, I managed it in WebIOPi, but it will help me and other peoples.

Original comment by tro...@trouch.com on 9 Sep 2012 at 4:32

GoogleCodeExporter commented 9 years ago
Added.  Will be in release 0.4.1a

Original comment by btcros...@googlemail.com on 23 Sep 2012 at 8:46

GoogleCodeExporter commented 9 years ago

Original comment by btcros...@googlemail.com on 23 Sep 2012 at 9:37