Debian Codegraph @

bindings/python/examples/watch_line_info.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # SPDX-FileCopyrightText: 2023 Kent Gibson <[email protected]>
4
5 """Minimal example of watching for info changes on particular lines."""
6
7 import gpiod
8
9
10 def watch_line_info(chip_path, line_offsets):
11 with gpiod.Chip(chip_path) as chip:
12 for offset in line_offsets:
13 chip.watch_line_info(offset)
14
15 while True:
16 print(chip.read_info_event())
17
18
19 if __name__ == "__main__":
20 try:
21 watch_line_info("/dev/gpiochip0", [5, 3, 7])
22 except OSError as ex:
23 print(ex, "\nCustomise the example configuration to suit your situation")