Как использовать libgpiod и C++, как дождаться изменения нескольких строк и получить измененное значение? ⇐ C++
Как использовать libgpiod и C++, как дождаться изменения нескольких строк и получить измененное значение?
Using C++ on a Raspberry Pi 4, I'm building a single routine called monitor to watch my GPIO lines and log changes for all lines. My simple code using libgpiod:
void monitor() { const std::string chipname = "gpiochip0"; const std::vector offsets = {4, 5}; // Lines 4 and 5 for testing try { gpiod::chip chip(chipname); gpiod::line_bulk lines; for (int offset : offsets) { auto line = chip.get_line(offset); line.request({"monitor", gpiod::line_request::EVENT_BOTH_EDGES, 0}); lines.append(line); } while (true) { // Infinite waiting on all lines auto signals = lines.event_wait(std::chrono::nanoseconds(0)); // STUCK HERE - How can I find out which line has changed and get its value and timestamp. } } catch (const std::exception &e) { std::cerr
Источник: https://stackoverflow.com/questions/781 ... the-change
Using C++ on a Raspberry Pi 4, I'm building a single routine called monitor to watch my GPIO lines and log changes for all lines. My simple code using libgpiod:
void monitor() { const std::string chipname = "gpiochip0"; const std::vector offsets = {4, 5}; // Lines 4 and 5 for testing try { gpiod::chip chip(chipname); gpiod::line_bulk lines; for (int offset : offsets) { auto line = chip.get_line(offset); line.request({"monitor", gpiod::line_request::EVENT_BOTH_EDGES, 0}); lines.append(line); } while (true) { // Infinite waiting on all lines auto signals = lines.event_wait(std::chrono::nanoseconds(0)); // STUCK HERE - How can I find out which line has changed and get its value and timestamp. } } catch (const std::exception &e) { std::cerr
Источник: https://stackoverflow.com/questions/781 ... the-change
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение