1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00
Files
libgpiod/bindings/python/examples/watch_line_info.py
Vincent Fazio d130ec7666 bindings: python: examples: add type annotations
Add type annotations to help with lint checks.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://patch.msgid.link/20260401001459.19159-6-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-04-03 11:00:36 +02:00

26 lines
713 B
Python
Executable File

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2023 Kent Gibson <warthog618@gmail.com>
"""Minimal example of watching for info changes on particular lines."""
from collections.abc import Iterable
import gpiod
def watch_line_info(chip_path: str, line_offsets: Iterable[int]) -> None:
with gpiod.Chip(chip_path) as chip:
for offset in line_offsets:
chip.watch_line_info(offset)
while True:
print(chip.read_info_event())
if __name__ == "__main__":
try:
watch_line_info("/dev/gpiochip0", [5, 3, 7])
except OSError as ex:
print(ex, "\nCustomise the example configuration to suit your situation")