| 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 reading the info for a chip.""" |
| 6 | |
| 7 | import gpiod |
| 8 | |
| 9 | |
| 10 | def get_chip_info(chip_path): |
| 11 | with gpiod.Chip(chip_path) as chip: |
| 12 | info = chip.get_info() |
| 13 | print("{} [{}] ({} lines)".format(info.name, info.label, info.num_lines)) |
| 14 | |
| 15 | |
| 16 | if __name__ == "__main__": |
| 17 | try: |
| 18 | get_chip_info("/dev/gpiochip0") |
| 19 | except OSError as ex: |
| 20 | print(ex, "\nCustomise the example configuration to suit your situation") |