-1

https://sourceforge.net/p/raspberry-gpio-python/wiki/Checking%20function%20of%20GPIO%20channels/

says

gpio_function(channel) Shows the function of a GPIO channel. For example:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)
func = GPIO.gpio_function(pin)

will return a value from:

GPIO.IN, GPIO.OUT, GPIO.SPI, GPIO.I2C, GPIO.HARD_PWM, GPIO.SERIAL, GPIO.UNKNOWN

When I try it I get a 1 digit number. Has it ever worked as stated above ?

2
  • I don't use python so I don't have a definitive answer for you, but considering there are < 10 values there, how many digits were you expecting? Put another way, did you try comparing that number to any of those identifiers to see if they are equivalent? An identifier is the name of a variable or constant. If I a call a variable or constant SUPER.GREAT, what kind of value is stored in it? Is it a number? A string? Something else? All caps are commonly used as identifiers for constants in many languages, BTW. A constant has a value that does not change. Like, for example, 3.
    – goldilocks
    Jul 9 '16 at 3:29
  • 1
    +2 for reading the documentation. -1 for not understanding the documentation.
    – joan
    Jul 9 '16 at 7:30
0
print GPIO.IN, GPIO.OUT, GPIO.SPI, GPIO.I2C, GPIO.HARD_PWM, GPIO.SERIAL, GPIO.UNKNOWN

returns

1 0 41 42 43 40 -1

So these are inputs.

1
  • To elaborate: The digit you get returned is the state of the pin where 1=GPIO.IN, 0=GPIO.OUT, 41=GPIO.SPI, etc.
    – 88weighed
    Nov 30 '17 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.