| 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | // SPDX-FileCopyrightText: 2023 Kent Gibson <[email protected]> |
| 3 | |
| 4 | /* Minimal example of reading the info for a chip. */ |
| 5 | |
| 6 | #include <cstdlib> |
| 7 | #include <filesystem> |
| 8 | #include <gpiod.hpp> |
| 9 | #include <iostream> |
| 10 | |
| 11 | namespace { |
| 12 | |
| 13 | /* Example configuration - customize to suit your situation */ |
| 14 | const ::std::filesystem::path chip_path("/dev/gpiochip0"); |
| 15 | |
| 16 | } /* namespace */ |
| 17 | |
| 18 | int main() |
| 19 | { |
| 20 | ::gpiod::chip chip(chip_path); |
| 21 | auto info = chip.get_info(); |
| 22 | |
| 23 | ::std::cout << info.name() << " [" << info.label() << "] (" |
| 24 | << info.num_lines() << " lines)" << ::std::endl; |
| 25 | |
| 26 | return EXIT_SUCCESS; |
| 27 | } |