mirror of
https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
synced 2026-10-28 13:55:08 +03:00
Unlike the C++ bindings: we can't expect the python runtime to call the Chip object's destructor when all references are dropped. We need to close each chip explicitly. Either call the close() method directly or use controlled execution in all examples. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
19 lines
457 B
Python
Executable File
19 lines
457 B
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
#
|
|
# This file is part of libgpiod.
|
|
#
|
|
# Copyright (C) 2017-2018 Bartosz Golaszewski <bartekgola@gmail.com>
|
|
#
|
|
|
|
'''Reimplementation of the gpiodetect tool in Python.'''
|
|
|
|
import gpiod
|
|
|
|
for chip in gpiod.ChipIter():
|
|
print('{} [{}] ({} lines)'.format(chip.name(),
|
|
chip.label(),
|
|
chip.num_lines()))
|
|
chip.close()
|