Beispiel #1
0
 def get_template_vars(self):
     chips = []
     chip: gpiod.Chip
     for chip in gpiod.ChipIter():
         chips.append({'name': chip.name(), 'label': chip.label()})
         chip.close()
     return {'chips': chips}
    def test_iterate_over_chips(self):
        gotA = False
        gotB = False
        gotC = False

        for chip in gpiod.ChipIter():
            if chip.label() == 'gpio-mockup-A':
                gotA = True
            elif chip.label() == 'gpio-mockup-B':
                gotB = True
            elif chip.label() == 'gpio-mockup-C':
                gotC = True

        self.assertTrue(gotA)
        self.assertTrue(gotB)
        self.assertTrue(gotC)
Beispiel #3
0
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1-or-later

#
# This file is part of libgpiod.
#
# Copyright (C) 2017-2018 Bartosz Golaszewski <*****@*****.**>
#

'''Reimplementation of the gpiodetect tool in Python.'''

import gpiod

for chip in gpiod.ChipIter():
    print('{} [{}] ({} lines)'.format(chip.name(),
                                      chip.label(),
                                      chip.num_lines()))