Ejemplo n.º 1
0
def input(channel):
    """
    Read the value of a GPIO pin.

    :param channel: the channel based on the numbering system you have specified
        (:py:attr:`GPIO.BOARD`, :py:attr:`GPIO.BCM` or :py:attr:`GPIO.SUNXI`).
    :returns: This will return either :py:attr:`0` / :py:attr:`GPIO.LOW` /
        :py:attr:`False` or :py:attr:`1` / :py:attr:`GPIO.HIGH` / :py:attr:`True`).
    """
    _check_configured(channel)  # Can read from a pin configured for output
    pin = get_gpio_pin(_mode, channel)
    return sysfs.input(pin)
Ejemplo n.º 2
0
def test_input(fs, test_input, expected):
    fs.CreateFile("/sys/class/gpio/gpio0/value")
    with open("/sys/class/gpio/gpio0/value", "w") as fp:
        fp.write("{0}\n".format(test_input))
    assert input(0) == expected