gpiod


Namegpiod JSON
Version 2.1.1 PyPI version JSON
download
home_pagehttps://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
SummaryPython bindings for libgpiod
upload_time2023-11-03 19:32:45
maintainer
docs_urlNone
authorBartosz Golaszewski
requires_python>=3.9.0
licenseLGPLv2.1
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!-- SPDX-License-Identifier: CC-BY-SA-4.0 -->
<!-- SPDX-FileCopyrightText: 2023 Phil Howard <phil@gadgetoid.com> -->

# gpiod

These are the official Python bindings for [libgpiod](https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/about/).

The gpiod library has been vendored into this package for your convenience and
this version of gpiod is independent from your system package.

Binary wheels are not provided. The source package requires python3-dev.

## Rationale

The new character device interface guarantees all allocated resources are
freed after closing the device file descriptor and adds several new features
that are not present in the obsolete sysfs interface (like event polling,
setting/reading multiple values at once or open-source and open-drain GPIOs).

Unfortunately interacting with the linux device file can no longer be done
using only standard command-line tools. This is the reason for creating a
library encapsulating the cumbersome, ioctl-based kernel-userspace interaction
in a set of convenient functions and opaque data structures.

## Breaking Changes

As of v2.0.2 we have replaced the unofficial, pure-Python "gpiod". The official
gpiod is not backwards compatible.

You should ensure you specify at least v2.0.2 for the official API. Versions
1.5.4 and prior are the deprecated, unofficial, pure-Python bindings.

## Installing

You will need `python3-dev`, on Debian/Ubuntu you can install this with:

```
sudo apt install python3-dev
```

And then install gpiod with:

```
pip install gpiod
```

You can optionally depend upon your system gpiod by installing with:

```
LINK_SYSTEM_LIBGPIOD=1 pip install gpiod
```

If you still need the deprecated pure-Python bindings, install with:

```
pip install gpiod==1.5.4
```

## Examples

Check a GPIO chip character device exists:

```python
import gpiod

gpiod.is_gpiochip_device("/dev/gpiochip0")

```

Get information about a GPIO chip character device:

```python
import gpiod

with gpiod.Chip("/dev/gpiochip0") as chip:
    info = chip.get_info()
    print(f"{info.name} [{info.label}] ({info.num_lines} lines)")
```

Blink an LED, or toggling a GPIO line:

```python
import time

from gpiod.line import Direction, Value

LINE = 5

with gpiod.request_lines(
    "/dev/gpiochip0",
    consumer="blink-example",
    config={
        LINE: gpiod.LineSettings(
            direction=Direction.OUTPUT, output_value=Value.ACTIVE
        )
    },
) as request:
    while True:
        request.set_value(LINE, Value.ACTIVE)
        time.sleep(1)
        request.set_value(LINE, Value.INACTIVE)
        time.sleep(1)
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git",
    "name": "gpiod",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Bartosz Golaszewski",
    "author_email": "brgl@bgdev.pl",
    "download_url": "https://files.pythonhosted.org/packages/d0/7c/332540ce8620e9219a89a16e8141dba308bdb523cd07e1af008d84c226c5/gpiod-2.1.1.tar.gz",
    "platform": "linux",
    "description": "<!-- SPDX-License-Identifier: CC-BY-SA-4.0 -->\n<!-- SPDX-FileCopyrightText: 2023 Phil Howard <phil@gadgetoid.com> -->\n\n# gpiod\n\nThese are the official Python bindings for [libgpiod](https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/about/).\n\nThe gpiod library has been vendored into this package for your convenience and\nthis version of gpiod is independent from your system package.\n\nBinary wheels are not provided. The source package requires python3-dev.\n\n## Rationale\n\nThe new character device interface guarantees all allocated resources are\nfreed after closing the device file descriptor and adds several new features\nthat are not present in the obsolete sysfs interface (like event polling,\nsetting/reading multiple values at once or open-source and open-drain GPIOs).\n\nUnfortunately interacting with the linux device file can no longer be done\nusing only standard command-line tools. This is the reason for creating a\nlibrary encapsulating the cumbersome, ioctl-based kernel-userspace interaction\nin a set of convenient functions and opaque data structures.\n\n## Breaking Changes\n\nAs of v2.0.2 we have replaced the unofficial, pure-Python \"gpiod\". The official\ngpiod is not backwards compatible.\n\nYou should ensure you specify at least v2.0.2 for the official API. Versions\n1.5.4 and prior are the deprecated, unofficial, pure-Python bindings.\n\n## Installing\n\nYou will need `python3-dev`, on Debian/Ubuntu you can install this with:\n\n```\nsudo apt install python3-dev\n```\n\nAnd then install gpiod with:\n\n```\npip install gpiod\n```\n\nYou can optionally depend upon your system gpiod by installing with:\n\n```\nLINK_SYSTEM_LIBGPIOD=1 pip install gpiod\n```\n\nIf you still need the deprecated pure-Python bindings, install with:\n\n```\npip install gpiod==1.5.4\n```\n\n## Examples\n\nCheck a GPIO chip character device exists:\n\n```python\nimport gpiod\n\ngpiod.is_gpiochip_device(\"/dev/gpiochip0\")\n\n```\n\nGet information about a GPIO chip character device:\n\n```python\nimport gpiod\n\nwith gpiod.Chip(\"/dev/gpiochip0\") as chip:\n    info = chip.get_info()\n    print(f\"{info.name} [{info.label}] ({info.num_lines} lines)\")\n```\n\nBlink an LED, or toggling a GPIO line:\n\n```python\nimport time\n\nfrom gpiod.line import Direction, Value\n\nLINE = 5\n\nwith gpiod.request_lines(\n    \"/dev/gpiochip0\",\n    consumer=\"blink-example\",\n    config={\n        LINE: gpiod.LineSettings(\n            direction=Direction.OUTPUT, output_value=Value.ACTIVE\n        )\n    },\n) as request:\n    while True:\n        request.set_value(LINE, Value.ACTIVE)\n        time.sleep(1)\n        request.set_value(LINE, Value.INACTIVE)\n        time.sleep(1)\n```\n\n",
    "bugtrack_url": null,
    "license": "LGPLv2.1",
    "summary": "Python bindings for libgpiod",
    "version": "2.1.1",
    "project_urls": {
        "Homepage": "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d07c332540ce8620e9219a89a16e8141dba308bdb523cd07e1af008d84c226c5",
                "md5": "5f5b4af3ebd757f0a2b8ae639e3cef6d",
                "sha256": "97cae3380f1f47eca19c8b8748bd6f1b9e8bd1dba621258e3183501b07aa644e"
            },
            "downloads": -1,
            "filename": "gpiod-2.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5f5b4af3ebd757f0a2b8ae639e3cef6d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9.0",
            "size": 52334,
            "upload_time": "2023-11-03T19:32:45",
            "upload_time_iso_8601": "2023-11-03T19:32:45.765972Z",
            "url": "https://files.pythonhosted.org/packages/d0/7c/332540ce8620e9219a89a16e8141dba308bdb523cd07e1af008d84c226c5/gpiod-2.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-03 19:32:45",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gpiod"
}
        
Elapsed time: 0.23445s